I'm trying to make my first shader and wanted to make a simple wave shader using cos on the vertices. Im following this tutorial: The problem is when this shader is placed on a material on a quad it doesn't move at all. Im aware 4 vertices isnt what i want but there should still be some movement right? Anyway im not sure what to do so i would appreciate help. Code (CSharp): Shader "Custom/Waves" { Properties { _Color("Color", Color) = (1, 1, 1, 1) _WaveHeight("Height", Range(0,2)) = 1.0 _Speed("Speed", Range(0,200)) = 100 } SubShader{ Tags{ "RenderType" = "Opaque" } Pass { CGPROGRAM #pragma vertex VertexFunc #pragma fragment fragmentFunc float4 _Color; float _Height; float _Speed; struct vertexInput { float4 vertex : POSITION; }; struct vertexOutput { float4 pos : SV_POSITION; }; vertexOutput VertexFunc(vertexInput IN) { vertexOutput o; float4 worldPos = mul(unity_ObjectToWorld, IN.vertex); float displacement = (cos(worldPos.y) + cos(worldPos.x + (_Speed * _Time))); worldPos.y = worldPos.y + (displacement * _Height); o.pos = mul(UNITY_MATRIX_VP, worldPos); return o; } float4 fragmentFunc(vertexOutput IN) : COLOR { return _Color; } ENDCG } } }
_Time is a float4 value. If you use a float4 value with float values, as you're doing above, then only the .x component is used. _Time.x is equivalent to Time.timeSinceLevelLoad / 20f in the game view when in play mode. That might be slow enough you're simply not seeing it move. Otherwise when not in play mode the game view does not (or infrequently) updates _Time. You want to use _Time.y in most case, as that's the actual unmodified time. If you're in the scene view, _Time has values unique to the scene view, and you need to have the Animated Materials option enabled for, well, materials to animate. Otherwise the _Time value the shader gets in the scene view is not updated.
I dont have the option to enable animated materials in that dropdown. Also im using the 3D template not URP if that makes any difference. Even using time.y nothing happens to during play mode.