So, here’s what I’m doing:

Set projection matrix to light’s gluPerspective

Set modelview matrix to light’s gluLookAt

Render the scene geometry into a depth-only FBO

Set projection matrix to players’s gluPerspective

Set modelview matrix to players’s gluLookAt

Make texture matrix using:

(bias matrix) * (light’s projection) * (light’s modelview) * (camera’s modelview inverse)

Render scene properly using the following shadow coordinates specified in the vert shader:

shadowCoord = gl_TextureMatrix[3] * gl_ModelViewMatrix * gl_Vertex + vec4(0.0,0.0,-0.004,0.0);

the offset is there to prevent z-fighting.

What is supposed to happen is the camera’s modelview inverse in the texture matrix should cancel out the camera transformation in the gl_ModelViewMatrix in the vert shader leaving only the object transformation (I think).

This is what happens:

However, if I place the gluLookAt for both the light and scene camera into the projection matrix, shadows are rendered correctly (but lighting breaks):

Am I missing out on a step? The drawing of the geometry includes calling glLightfv with GL_POSITION, but taking it out didn’t help.

I’m not sure what other details might be requried, but here’s the main bits.

Note: I also posted this on GameDev last week.

Thanks.