I am trying a VERY basic diffused shader based on the Normal-Diffuse.shader from the built in shaders source code pack. However when I call a couple functions from the AutoLight.cginc, they cause errors in the console:
Cg in program 'frag': error C1010: expression left of ."_LightCoord" is not a struct or array at line 37
Cg in program 'frag': error C1010: expression left of ."_ShadowCoord" is not a struct or array at line 37
Cg in program 'frag': error C1010: expression left of ."_ShadowFade" is not a struct or array at line 37
Cg in program 'frag': error C1010: expression left of ."_LightCoord" is not a struct or array at line 45
Cg in program 'frag': error C1010: expression left of ."_ShadowCoord" is not a struct or array at line 45
Cg in program 'frag': error C1010: expression left of ."_ShadowFade" is not a struct or array at line 45
And here is my basic non-functional shader:
Shader "Experimental/BasicTest" {
Properties {
_Color ("Main Color", Color) = (1,1,1,1)
_MainTex ("Base (RGB)", 2D) = "white" {}
}
SubShader {
Pass {
Tags { "LightMode" = "Pixel" }
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
#pragma multi_compile_builtin
#pragma fragmentoption ARB_fog_exp2
#pragma fragmentoption ARB_precision_hint_fastest
#include "UnityCG.cginc"
#include "AutoLight.cginc"
float4 _Color;
struct v2f {
V2F_POS_FOG;
float2 uv;
float3 normal;
float3 lightDir;
};
v2f vert (appdata_base v) {
v2f o;
PositionFog( v.vertex, o.pos, o.fog );
o.normal = v.normal;
o.uv = TRANSFORM_TEX(v.texcoord, _MainTex);
o.lightDir = ObjSpaceLightDir( v.vertex );
TRANSFER_VERTEX_TO_FRAGMENT(o);
return o;
}
uniform sampler2D _MainTex;
float4 frag (v2f i) : COLOR {
half4 texcol = tex2D(_MainTex, i.uv);
return DiffuseLight(i.lightDir, i.normal, texcol, LIGHT_ATTENUATION(i));
}
ENDCG
}
}
}
Ultimately I want to replace these AutoLight.cginc calls with the actual algorithm used to create the diffuse effect for the purpose of better understanding the math behind it and using it as a jumping off point for more abstract shaders based on lighting angle.