View Full Version : Shadow Mapping UV coordinates

12-23-2013, 09:06 AM
Hello everyone,

I'm trying to implement spot light shadow mapping in my opengl program (so perspective projection matrix), the issue i'm facing seems to be that i'm not getting the correct shadow map UV coordinates from my vertex transformation (biasMatrix * LightProjMatrix * lightViewMatrix * modelViewMatrix * gl_Vertex). Is this calculation wrong ?

I tried setting my spot light the same direction and position as my camera, so if i'm right the matrices to use would be the regular ones for UV calculation (biasMatrix * cameraProjMatrix * cameraViewMatrix * modelViewMatrix * gl_Vertex). Still getting wrong results.

My shadow map is correctly rendered.

Thanks for your time, regards.

12-23-2013, 10:07 AM
it should be:
biasMatrix * LightProjMatrix * lightViewMatrix * viewMatrixInverse * modelViewMatrix * gl_Vertex
biasMatrix * LightProjMatrix * lightViewMatrix * modelMatrix * gl_Vertex

12-24-2013, 04:05 PM
Thanks for your answer Nowhere :)

Actually the coordinates calculation was right, i was just dividing these coordinates by W too early in the shader. It's now fixed. and i'm very happy^^. Merry christmas !