First, I would like to let clear that this shader makes no sense. It’s just the problem of my real shader isolated.
Shader "Test" {
SubShader
{
CGPROGRAM
#pragma surface surf Lambert
struct Input
{
float3 viewDir;
};
void surf (Input IN, inout SurfaceOutput o)
{
o.Albedo = IN.viewDir;
//o.Normal = half3(0, 0, 0);
}
ENDCG
}
FallBack "Mobile/Diffuse"
}
Apply this shader to an object and move the camera/view port around. You will see the object changing color. This happen because the RGB is mapped to the relative camera/view port position. That’s fine.
Uncomment the commented line and the colors will change. Of course we would expect a lighting change, but what happens is a hue change, what makes no sense for me.
So, why changing the normal affects the viewDir?