Shadow map rendering incorrectly

I made these changes but it’s still not working. Everything else I’m doing: rendering the first render pass I’m setting the light and model matrix uniforms, then rendering all the meshes. Second pass I’m setting all other uniforms + the depth map texture and the light matrix. And the shader is working other than the small shadow calculation code I’ve showed. Do I need to mulitply the light matrix and the model matrix?

Some things which look out of place:

  glm::mat4 lightView = glm::lookAt(lightPosition, lightDirection, up);

The second parameter should probably be lightPosition + lightDirection. The first parameter is subtracted from the second to get the forward direction.

  glCall(glViewport(0,0,Screen::GetWidth(), Screen::GetHeight()));

This should probably use SHADOW_WIDTH and SHADOW_HEIGHT.

I don’t see any other issues, although I can’t speak for the code you haven’t shown.

I made these changes but it’s still doing the same thing. Other things I’m doing are binding the light matrix uniform for both passes, binding the depth map texture for the render pass, multiplying the light matrix by the vertex positions in the vs, rendering with depth map shader for first pass, then rendering everything into a framebuffer in the second pass. It looks like the shadows are correct but in the wrong place?

Edit: Got shadows working, I was both not putting the shadowmap texture to the correct slot and not multiplying the shadowmap matrix with the vertex positions in the shader.