0
\$\begingroup\$

I almost have point light shadows working but the corner of the samplerCube that I use for the shadow map has corners that get darker depending on the main camera. Is this something to do with a transform into a different space somewhere? I followed learn-opengls tutorial on this and they don't seem to have this issue or it just didn't come up in their simple example.

Here a YouTube video of the problem because it is kinda hard to explain... https://youtu.be/FXpwgyJh1ZA

That shows the depth map sampler not the shadows by the way.

This also happens when the radius is almost 0 and the cube map is completely white.

float PointLightShadow(
    vec3 NegL, // FragWorldPos - pointLights[i].Position
    float R)   // radius of light
{
    if (mat_hasShadowMap2 == 0) {
        return 1.0f;
    }

    float closestDepth = texture(mat_shadowMap2, NegL).r;
    float currentDepth = length(NegL);

    float bias = 0.05;
    float shadow = R * closestDepth > currentDepth - bias ? 1.0 : 0.0;

    return closestDepth; // for this example
}

Sending light position to shader

...
m_lightData.PointLights[i].Position = lights[i]->Position(); // setting in world space
...

and for the FragWorldPos

...
out vec3 FragWorldPos;
...
vec4 worldPos = model * vec4(vert, 1);
FragWorldPos  = worldPos.xyz;
...

and then the fragment shader has a matching in variable.

I think like 99% of this is working, I just don't understand why the cube map seems to have these dark corners. They change aspect by changing the screen also suggesting that they are in some type of camera space, but I don't see where that would happen. Let me know if you need more context for the code snippets, these are the only important parts I think though.

\$\endgroup\$
0

1 Answer 1

1
\$\begingroup\$

For anyone with this problem in future: I never thought to check the mipmaps which were generated as fully black originally. Fix was to regenerate them after the light was updated.

\$\endgroup\$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .