When I assign SurfaceOutput.Normal, dot(viewDir, lightDir) is giving an unexpected result in my custom lighting function. It doesnt matter what I assign Normal to, the output is always the same. The expected result happens when Normal is not assigned. Here is the shader I used to test:
Shader "Custom/SkyboxDebug" {
SubShader {
Tags { "RenderType"="Opaque" }
LOD 200
CGPROGRAM
#pragma surface surf TestDirs nolightmap noambient alpha
#pragma target 3.0
#pragma debug
struct Input {
float2 uv_Cloud1Tex;
float4 color : COLOR;
};
half4 LightingTestDirs (SurfaceOutput s, half3 lightDir, half3 viewDir, half atten) {
half4 light4 = half4(0,0,0, s.Alpha);
half sun = saturate(dot(viewDir, lightDir) * -1);
light4.rgb = pow(sun, 10).rrr;
return light4;
}
void surf (Input IN, inout SurfaceOutput o) {
o.Albedo = half3(0,0,0);
o.Normal = half3(0,0,1);
o.Alpha = 1;
}
ENDCG
}
FallBack "Diffuse"
}
I tested with a large sphere that has normals facing inwards and a single directional light
When I assign o.Normal in surf, it gives the result on the right, when I comment out that line, it gives the result on the left