I use baked animation example here is shader example Code (CSharp): struct appdata{ float2 uv : TEXCOORD0; float4 pos : POSITION; UNITY_VERTEX_INPUT_INSTANCE_ID }; struct v2f{ float2 uv : TEXCOORD0; float4 vertex : SV_POSITION; UNITY_VERTEX_INPUT_INSTANCE_ID }; CBUFFER_START(UnityPerMaterial) float _AnimLen; sampler2D _MainTex; float4 _MainTex_ST; sampler2D _AnimMap; float4 _AnimMap_TexelSize;//x == 1/width CBUFFER_END float4 ObjectToClipPos (float3 pos){ return mul (UNITY_MATRIX_VP, mul (UNITY_MATRIX_M, float4 (pos,1))); } v2f vert (appdata v, uint vid : SV_VertexID){ UNITY_SETUP_INSTANCE_ID(v); float f = _Time.y / _AnimLen; fmod(f, 1.0); float animMap_x = (vid + 0.5) * _AnimMap_TexelSize.x; float animMap_y = f; float4 pos = tex2Dlod(_AnimMap, float4(animMap_x, animMap_y, 0, 0)); v2f o; o.uv = TRANSFORM_TEX(v.uv, _MainTex); o.vertex = ObjectToClipPos(pos); return o; } float4 frag (v2f i) : SV_Target{ float4 col = tex2D(_MainTex, i.uv); return col; } But the animation only plays one cycle and stops. How to make the cycle permanent?
line 28: fmod(f, 1.0);, that doesn't do anything. Most intrinsic HLSL function don't modify the input variable(s), but rather return a value. So that line should be: f = fmod(f, 1.0); Or, really: f = frac(f); since there's no reason to use the fmod() function when the divisor is 1.0.