I'm new to shaders and I'm trying to make a shader for some very simple low poly water. I have created this simple surface shader that changes the vertex heights.
The problem is that it doesn't receive shadows as you can see in the gif and there is a weird behavior on the edges.
What am I doing wrong?
Shader "Ramble/LowPolyWater" {
Properties {
_MainTex ("Texture", 2D) = "white" {}
_Color ("Main Color", Color) = (1,1,1,1)
_Emission ("Emission", Color) = (1,1,1,1)
_ScrollYSpeed("Scroll y speed", Float) = 0.1
}
SubShader {
Tags { "RenderType"="Opaque" }
CGPROGRAM
#pragma surface surf Lambert vertex:vert
struct Input {
float2 uv_MainTex;
};
sampler2D _MainTex;
fixed4 _Color;
fixed4 _Emission;
float _ScrollYSpeed;
void vert (inout appdata_full v)
{
v.vertex.z += frac(sin( dot(v.vertex.xyz ,float3(12.9898,78.233,45.5432) )) * 43758.5453) * sin(_Time.y) * _ScrollYSpeed;
}
void surf (Input IN, inout SurfaceOutput o) {
o.Albedo = (tex2D (_MainTex, IN.uv_MainTex) * _Color).rgb;
o.Emission = _Emission.rgb;
}
ENDCG
}
Fallback "VertexLit"
}
Figured it out!
I just need to add addshadow to this line #pragma surface surf Lambert vertex:vert addshadow