- Home /
The question is answered, right answer was accepted
Why changing the normal affects the viewDir?
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?
Answer by Piflik · Apr 26, 2012 at 09:39 PM
Well...changing the normals changes the direction a surface is looking at... If it wasn't like that, then for example fresnel shaders with normal maps wouldn't work correctly.
Now that I see the answer I see how lame my question was. Sorry for that and thank you for the answer.