As you can see the shadow positions are wrong.
lightSpace = lightSpaceMatrix * model * vec4(position, 1.0);
LightSpace in vertex shader.
vec3 projCoords = fragPosLightSpace.xyz / fragPosLightSpace.w;
projCoords = projCoords * 0.5 + 0.5;
Perspective divide and make sure range is between [0, 1] in fragment shader.
glm::vec3 lightPos(20.0, 20.00, 20.0);
glm::vec3 lightColor(1000.0, 1000.0, 1000.0);
glm::mat4 lightProjection, lightView;
glm::mat4 lightSpaceMatrix;
lightProjection = glm::frustum(-1.0f, 1.0f, -1.0f, 1.0f, 1.0f, 100000.0f);
lightView = glm::lookAt(lightPos, glm::vec3(0.0f), glm::vec3(0.0, 1.0, 0.0));
lightSpaceMatrix = lightProjection * lightView;
Lighting matrix setup in main.
Depth map is 4096 * 4096, I have checked that it is correct, and I have used glViewport to change the render window.
What am I doing wrong here?