I get the following error
syntax error unexpected token vertex
I am still learning shaders so I can't really understand the reason for this error. How can I make this shader work?
enter Shader "Custom/VertAnimShader"
{
Properties
{
_MainTex("Texture", 2D) = "white" {}
_PosTex("Position texture", 2D) = "black" {}
_NmlTex("Normal texture", 2D) = "white" {}
_Length("Animator lengh", float) = 1
_DT("Delta time", float) = 0
}
SubShader{
Pass{
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
#pragma debug
#include "UnityCG.cginc"
#define ts _PosTex_TexelSize
struct appdata
{
float2 uv : TEXTCOORD0;
};
struct v2f {
float2 uv : TEXTCOORD0;
float3 normal: TEXTCOORD1;
float4 vertex : SV_POSITION;
};
sampler2D _MainTex, _PosTex, _NmlTex;
float4 _PosTex_TexelSize;
float _Length, _DT;
v2f vert(appdata v, uint vid: SV_VertexID)
{
float t = (_Time.y - _DT) / _Length;
t = fmod(t, 1.0);
float x = (vid + 0.5) * ts.x;
float y = t;
float4 pos = tex2Dlod(_PosTex, float4(x, y, 0, 0));
float4 normal = tex2Dlod(_NmlTex, float4(x, y, 0, 0));
v2f o;
o.vertex = UnityObjectToClipPos(pos);
o.normal = UnityObjectToWorldNormal(normal);
o.uv = v.uv;
return o;
}
half4 frag(v2f i) : SV_TARGET
{
half diff = dot(i.normal, float3(0,1,0))*0.5 + 0.5;
half4 col = tex2D(_MainTex, i.uv);
return diff * col;
}
ENDCG
}
}
}