Yet another Shadow Map. question.(artifact/bug?)


I have attempted to implement a shadow mapping algorithm.
However I get the following artifact, on any surface that is “too” perpendicular to the light direction.


I don’t understand why I get the artifact present in the rendering. Could someone please help me understand what is going on.

I can post code to show my approach in more detail if needed.
thanks in advance,


That the problem with shadow maps, you need to shift by a small offset so that these glitches disappear.
It looks like you render backfaces only on the depthmap buffer, right ?
So push the Z values a bit away from the light.

yeah, i only render the back faces of my scene when computing the depthmap.

“push the z values back”, how do I do this? PolygonOffset? Seems to do something, but how do I compute the values to plug in?



google glpolygonoffset.

I googled and found:

It recommends not using glPolygonOffset but tweaking the projection matrix instead.

I’m not clear either on the parameters to glPolygonOffset.
…provides a derivation and poses a question (specific to apple’s software implementation). Then he goes on to ignore the problem and implement the projection matrix solution.

It looks like the problem is limited to fragments facing away from the light.
Fragments that face away from the light are always in shadow, so do you check the sign of dot( FragmentNormal, LightDirection ) and always render as shadowed if this is negative ?

ie. when rendering the visible fragments, only show as illuminated by the light if it is BOTH closer to the light than the depth in the shadow map AND it is facing the light; dot(FragmentNormal, LightDirection) >0

“Push what’s being drawn back a bit so avoid z-fighting (see below) by calling glPolygonOffset (0, 1) and enabling GL_POLYGON_OFFSET_FILL”

Taken from:

Hope it helps…