I’m getting two errors from my shader saying I’ve got missing semantics on line 103 and 118. What does this error mean? Here’s what the error messages say.
'vert': function return value missing semantics at line 103
'frag': input parameter 'i' missing semantics at line 118
I believe the lines that the error message are pointing to are incorrect. I think I’ve found the correct lines below marked with // Missing Semantics. What exactly is wrong with the code and how do I fix it?
v2f vert (a2v v) // Missing Semantics
{
v2f o;
//Create a rotation matrix for tangent space
TANGENT_SPACE_ROTATION;
//Store the light's direction in tangent space
o.lightDirection = mul(rotation, ObjSpaceLightDir(v.vertex));
//Transform the vertex to projection space
o.pos = mul( UNITY_MATRIX_MVP, v.vertex);
//Get the UV coordinates
o.uv = TRANSFORM_TEX (v.texcoord, _MainTex);
o.uv2 = TRANSFORM_TEX (v.texcoord, _Bump);
return o;
}
float4 frag(v2f i) : COLOR // Missing Semantics
{
//Get the color of the pixel from the texture
float4 c = tex2D (_MainTex, i.uv);
//Merge the colours
c.rgb = (floor(c.rgb*_ColorMerge)/_ColorMerge);
//Get the normal from the bump map
float3 n = UnpackNormal(tex2D (_Bump, i.uv2));
//Based on the ambient light
float3 lightColor = UNITY_LIGHTMODEL_AMBIENT.xyz;
//Work out this distance of the light
float lengthSq = dot(i.lightDirection, i.lightDirection);
//Fix the attenuation based on the distance
float atten = 1.0 / (1.0 + lengthSq);
//Angle to the light
float diff = saturate (dot (n, normalize(i.lightDirection)));
//Perform our toon light mapping
diff = tex2D(_Ramp, float2(diff, 0.5));
//Update the colour
lightColor += _LightColor0.rgb * (diff * atten);
//Product the final color
c.rgb = lightColor * c.rgb * 2;
return c;
}