- Home /
Question by
ThatPolygon · Dec 07, 2017 at 09:29 AM ·
shadowshader programmingsurface shadervertex shader
Surface Shader vertex displacement, shadows not moving
I've got a surface shader where the vertices are slightly moving over time but somehow the shadows aren't changing correctly according to the new vertex positions. I thought about a custom shadow pass where i also displace the vertices but how would i do that with a surface shader?
Shader "Custom/leaf" {
Properties{
_Color("Color", Color) = (1,1,1,1)
_MainTex("Albedo (RGB)", 2D) = "white" {}
_Glossiness("Smoothness", Range(0,1)) = 0.5
_Metallic("Metallic", Range(0,1)) = 0.0
}
SubShader {
Tags { "Queue" = "Transparent" "RenderType" = "Transparent" }
LOD 200
//Blend SrcAlpha OneMinusSrcAlpha
CGPROGRAM
// Physically based Standard lighting model, and enable shadows on all light types
#pragma surface surf Standard vertex:vert alpha:fade
// Use shader model 3.0 target, to get nicer looking lighting
#pragma target 3.0
void vert(inout appdata_full v) {
float3 worldPos = mul(unity_ObjectToWorld, v.vertex).xyz;
float m = sin(_Time.z * 2 + worldPos.x + worldPos.y + worldPos.z);
v.vertex.y += m * v.texcoord.x*0.02;
v.vertex.xz += m * worldPos.y*0.001;
}
sampler2D _MainTex;
half _Glossiness;
half _Metallic;
fixed4 _Color;
struct Input {
float2 uv_MainTex;
};
void surf(Input IN, inout SurfaceOutputStandard o) {
fixed4 c = tex2D(_MainTex, IN.uv_MainTex) * _Color;
o.Albedo = c.rgb;
o.Metallic = _Metallic;
o.Smoothness = _Glossiness;
o.Alpha = c.a;
}
ENDCG
}
Fallback "Transparent/Cutout/Diffuse"
}
Comment
Answer by wikmanyo · Mar 16, 2020 at 02:44 AM
any answer for this?
alpha:fade seems to stop vertex displacement working