Hi,
I am trying to understand how to include and use unity autolight macros in my shader.
I tried exactly the code described here :
http://docs.unity3d.ru/Components/SL-Attenuation.html
But I am getting unxepected result: it doesn’t matter how I try to modify the output color variable, it seems that a perfect lambert which interacts with unity lights overwrites all my edits.
Just for example, I modified this:
// Vertex program
v2f vert (appdata_base v)
{
v2f o;
PositionFog( v.vertex, o.pos, o.fog );
// compute a simple diffuse per-vertex
float3 ldir = normalize( ObjSpaceLightDir( v.vertex ) );
float diffuse = dot( v.normal, ldir );
o.color = diffuse * _ModelLightColor0;
// compute&pass data for attenuation/shadows
TRANSFER_VERTEX_TO_FRAGMENT(o);
return o;
}
into this:
v2f vert (appdata_base v)
{
v2f o;
PositionFog( v.vertex, o.pos, o.fog );
o.color = float4(0.5, 0.5, 0.5, 0.5);
// compute&pass data for attenuation/shadows
TRANSFER_VERTEX_TO_FRAGMENT(o);
return o;
}
It seems that adding "LIGHTING_COORDS " to the vert struct is enough to enable this strange behaviour
The only thing I can suppose, is that the shader goes to the line ‘Fallback “VertexLit”’, but I don’t know why this should happpen.
Help !