Shadow Mapping UV coordinates

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.

it should be:
biasMatrix * LightProjMatrix * lightViewMatrix * viewMatrixInverse * modelViewMatrix * gl_Vertex
or
biasMatrix * LightProjMatrix * lightViewMatrix * modelMatrix * gl_Vertex

Thanks for your answer Nowhere :slight_smile:

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 !