I am currently trying to implement per pixel lighting in my app (OpenGL Descent 2 modification).
The shader is the usual simple affair for vanilla pp-lighting, but it just didn’t work, until I changed
normal = normalize (gl_NormalMatrix * gl_Normal)
to
normal = normalize (vec3 (gl_ModelViewMatrix * vec4 (gl_Normal, 1.0)))
Why the heck is that?
I double and triple and quadruple and … checked to make sure the normals set with glNormal are correct, so I have no idea why gl_NormalMatrix doesn’t do what I expect it to (transform the normal properly).
Do I have to explicitly set it, like the model view matrix? I thought it was derived from the model view matrix?
Any ideas? Please enlighten me, maybe I am making some fundamental mistake I am not aware of?