Reputation: 38
Spurious artifacts in case of creation of shadows through shadow mapping.
I can't understand why many shadows are drawn, and from where they originate? example: example
Upvotes: 0
Views: 194
Reputation:
It looks like your shadow map is covering only a fraction of the scene, and is being tiled (repeated) to cover the rest. Change the wrapping mode for the shadow map to GL_CLAMP_TO_BORDER
:
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_BORDER);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_BORDER);
And set your border color to 1.0f
or 0.0f
, depending on whether you want things outside the shadow map to be lit or unlit:
GLfloat borderColor[] = { 1.0f, 1.0f, 1.0f, 1.0f };
glTexParameterfv(GL_TEXTURE_2D, GL_TEXTURE_BORDER_COLOR, borderColor);
Upvotes: 2
Reputation: 398
I think you mean shadow acne. when you are rendering a litten surface, you calculate the surface point's distance from the light, and compare it with the distance read from the shadow map. Now ideally these should be equal if the surface is lit, but due to float precision errors there may be slight inaccuracies resulting in shadows where there shouldnt be any.
Solution is to apply an offset, so add a small number like 0.001 to the distance you read from the shadow map. The actual offset should be dependant on the world's scale.
Upvotes: 0