View Full Version : Yet another Shadow Map. question.(artifact/bug?)
11-06-2007, 06:35 AM
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,
11-06-2007, 07: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.
11-06-2007, 09: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?
11-06-2007, 11:41 AM
11-06-2007, 01:44 PM
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.
11-06-2007, 09: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
11-07-2007, 04: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"
Hope it helps...
Powered by vBulletin® Version 4.2.3 Copyright © 2017 vBulletin Solutions, Inc. All rights reserved.