PDA

View Full Version : Yet another Shadow Map. question.(artifact/bug?)



UT666
11-06-2007, 07:35 AM
Hi,

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.

SCENE: http://www.avondo.com/shadowmap1.jpg
CLOSEUP: http://www.avondo.com/shadowmap2.jpg

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,

ut.

ZbuffeR
11-06-2007, 08:25 AM
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.

UT666
11-06-2007, 10:20 AM
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?

thanks,

ut.

knackered
11-06-2007, 12:41 PM
google glpolygonoffset.

pudman
11-06-2007, 02:44 PM
I googled and found:
http://www.gamedev.net/community/forums/topic.asp?topic_id=335012&whichpage=1&#2178508

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.

Simon Arbon
11-06-2007, 10:41 PM
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

azcoder
11-07-2007, 05:39 AM
"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:

http://www.cs.cmu.edu/afs/cs/academic/class/15462/web.06s/asst/project3/shadowmap/


Hope it helps...