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.
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.
It recommends not using glPolygonOffset but tweaking the projection matrix instead.
I’m not clear either on the parameters to glPolygonOffset. http://lists.apple.com/archives/mac-opengl/2006/Jul/msg00026.html
…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