Hi, I've just finished a normal mapping shader for the first time so I'll try and help you out!
Perhaps the "gl_NormalMatrix" variable is incorrect. I would recommend implementing it just as a basic diffuse lighting shader for the time being, and seeing if that works correctly? Once you get the diffuse lighting sorted, just then use the same matrix that you multiply the incoming normal by, to the tangent and binormal vectors.
"gl_NormalMatrix" should be the object matrix you're applying to the object being rendered. For example:
//frame startglViewport(0, 0, icg::mainWindow->Width(), icg::mainWindow->Height());glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);glClearColor(0.0f, 0.0f, 0.0f, 1.0f);//camera setupglMatrixMode(GL_PROJECTION); glLoadIdentity();gluPerspective(m_fieldOfView, aspectRatio, m_nearClip, m_farClip);glMatrixMode(GL_MODELVIEW);glLoadIdentity();gluLookAt(cam_pos[X],cam_pos[Y], cam_pos[Z], cam_pos[X]+cam_fwd[X], cam_pos[Y]+cam_fwd[Y], cam_pos[Z]+cam_fwd[Z], cam_up[X], cam_up[Y], cam_up[Z]);//render objectglPushMatrix(); glMultMatrixf( m_objectMatrix ); model->Render();glPopMatrix();//End frame
For my solution i used the matrix "m_objectMatrix" to make it work correctly.
For your reference, here's my post.
http://www.gamedev.net/community/forums/topic.asp?topic_id=455035
** edit ** NOT the inverse! Just realised I had some redundant, misleading code.
[Edited by - Striken on July 11, 2007 5:54:25 PM]
- Teach a programmer an answer, he can code for a day. Show a programmer the documentation, he can code for a lifetime.