Hello there,
I recently started programming my own shaders, and decided to start looking into the custom lighting functions. I currently want to solve the issue of having parts of the unlit side of a mesh be lit due to their normal maps.
In order to solve the issue, i figured it would be as simple as both taking the current normal’s (after applying the normal map) dot product with the lighting angle, as well as the vertex’s normals (without the normal map) into consideration when applying lighting.
So, i want to do the following (semi-pseudocode):
if((dot (s.Normal, lightDir))>0.2&&dot(vertex.Normal,lightDir)>-0.1)
c.rgb=//blah
else
c.rgb=float3(0,0,0);
However, i have no idea how to actually get the normal of the current vertex from the lighting function, which is what i would like help with.
Entire lighting function below:
half4 LightingChoppedLambert (SurfaceOutput s, half3 lightDir, half atten) {
half NdotL = dot (s.Normal, lightDir);
half diff = (NdotL);
half4 c;
if(NdotL>0.2/*&&(*something*)*/)
c.rgb = (s.Albedo) * (_LightColor0.rgb) * ((diff) * atten *2);
else
c.rgb=float3(0,0,0);
c.a = _LightColor0.a ;
return c;
}
(Yes, the lighting model is supposed to have steep colour changes based on the lighting, “else c.rgb=float3(0,0,0);” is completely intentional.)