okay, the title might sound confusing, but basically I've been following LearnOpenGL to get pointlight shadows to work. I've gotten spotlight and directional shadows to work, but I messed up point light. I've narrowed it down to something on the mathematical side of things in C++, 90% sure it isn't the shaders, framebuffer, cubemap etc., but I could be wrong. I've added some photos about what I am describing. I'm only going to provide my code if requested (shaders specifically) but here is the main math part of it. Also rendering to the framebuffer cubemap is correct. ```void OpenGLRenderer::SetupPointLightMatrix() {
float aspect = (float)2048 / (float)2048; //resolution of the shadow map, adjust as needed
float near = 0.1f;
float far = 25.0f;
glm::mat4 shadowProj = glm::perspective(glm::radians(90.0f), aspect, near, far);
shadowTransforms.clear();
shadowTransforms.push_back(shadowProj * glm::lookAt(lightPos, lightPos + glm::vec3(1, 0, 0), glm::vec3(0, -1, 0))); // +X
shadowTransforms.push_back(shadowProj * glm::lookAt(lightPos, lightPos + glm::vec3(-1, 0, 0), glm::vec3(0, -1, 0))); // -X
shadowTransforms.push_back(shadowProj * glm::lookAt(lightPos, lightPos + glm::vec3(0, 1, 0), glm::vec3(0, 0, 1))); // +Y
shadowTransforms.push_back(shadowProj * glm::lookAt(lightPos, lightPos + glm::vec3(0, -1, 0), glm::vec3(0, 0, -1))); // -Y
shadowTransforms.push_back(shadowProj * glm::lookAt(lightPos, lightPos + glm::vec3(0, 0, 1), glm::vec3(0, -1, 0))); // +Z
shadowTransforms.push_back(shadowProj * glm::lookAt(lightPos, lightPos + glm::vec3(0, 0, -1), glm::vec3(0, -1, 0))); // -Z
}
that and potentially shader issues is the only thing I can think of. Also here is the main shadow point light calculation float PointShadowCalc(vec3 fragPos, samplerCube map)
{
// get vector between fragment position and light position
vec3 fragToLight = fragPos - lightPos;
// use the light to fragment vector to sample from the depth map
closestDepth = texture(map, fragToLight).r;
// it is currently in linear range between [0,1]. Re-transform back to original value
closestDepth *= light_far_plane;
// now get current linear depth as the length between the fragment and light position
float currentDepth = length(fragToLight);
// now test for shadows
float bias = 0.01 + 0.05 * (currentDepth / light_far_plane);
float shadow = currentDepth - bias > closestDepth ? 1.0 : 0.0;
return shadow;
} ```