Getting vertex data from lighting function in shaders.

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.
alt text

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.)

The current normal is the vertex normal, interpolated between vertices. By writing to the Normal, you’re writing over the per-pixel normal, before lighting takes it into account.

I don’t think it’s possible to get non-interpolated Vertex normals, because that just doesn’t make sense, since you’re working with pixels.

So I assume you want interpolated vertex normals PRIOR to applying your tangent-space normal map? Apparently if you write to o.Normal, the normals and lighting is all calculated in Tangent-Space, meaning that the default vertex normal would just be (0,0,1). That’s all you should need to do your calculation I think.

Sorry I don’t have time to do the code and check it for you. But this should tell you enough to figure it out. Hope this helped!