# Normal Mapping issue

The first image shows a spotlight shining correctly on the floor. The second image shows the same spotlight but rotated 180 degrees.

The first is correct, the second is not.

The third image shows the light "half if and half out"

Can anyone understand what is happening here?

Normal mapping code:

vec3 CalcBumpedNormal()
{
vec3 Normal = normalize(normal0);
vec3 Tangent = normalize(tangent0);
Tangent = normalize(Tangent - dot(Tangent, Normal) * Normal);
vec3 Bitangent = cross(Tangent, Normal);
mat3 TBN = mat3(Tangent, Bitangent, Normal);

return normalize(TBN * (255.0/128.0 * texture2D(normalMap, texCoord0.xy).xyz - 1 ));
}


• When you say the spotlight is "rotated 180 degrees", what exactly do you mean? Rotated around what axis? The lower picture looks like it might be getting some bit of spill from the spotlight. Maybe you could debug it by slooowly rotating the spotlight, to see at what point what you expect deviates from what you see... – david van brink Jan 19 '15 at 18:37
• Hi thanks for the reply. I am rotating the light using a Quaternion on the axis (0,1,0) by 180 (converted to radians). I will add another image that shows the light half in and half out (if you get what I mean). – Nick Jan 19 '15 at 18:38
• Image added to main post. – Nick Jan 19 '15 at 18:42
• I don't have the experience with opengl that I do with DirectX, but why are you calculating the tangent and bitangent? I believe that's where the problem is. Can't you just use the tangent0 and bitangent0 semantics? – Peethor Jan 20 '15 at 6:15
• Thanks for the info, however I have worked out what was wrong and will post it as an answer. – Nick Jan 20 '15 at 9:09