Discussion:
strange ShadowMap behavior
Ben Axelrod
2008-09-22 20:05:29 UTC
Permalink
I am seeing strange shadow artifacts on my model when I use a ShadowMap. The artifacts get worse as I increase the size of my ground plane. You can see the artifacts get progressively worse in these images:

Loading Image...
Loading Image...
Loading Image...
Loading Image... <- this is the desired size of ground plane
Loading Image...

You can see strange gradients on the humanoid's hands and feet. And the shadow gets more and more pixilated.

I am using OSG 2.6 on Debian Etch with a NVidia 7300 LE graphics card.

This is how I configure the ShadowMap:

shadowmap->setTextureSize(osg::Vec2s(1024, 1024));
shadowmap->setPolygonOffset(osg::Vec2(1.1f, 4.0f));

Do I need to tune these parameters? If so, how? Are there more parameters I need? And what do these parameters control exactly?

Thanks,
-Ben
Jean-Sébastien Guay
2008-09-22 20:25:54 UTC
Permalink
Hello Ben,
Post by Ben Axelrod
I am seeing strange shadow artifacts on my model when I use a ShadowMap.
These are not strange, they're quite expected when using a straight
shadow mapping algorithm. It's simply shadow map aliasing. See this page:

http://www.openscenegraph.org/projects/osg/wiki/Support/ProgrammingGuide/osgShadow

for some details. In a nutshell, since osgShadow::ShadowMap uses the
whole scene bounds and fits that to the shadow map texture, as your
scene becomes bigger your shadows will become more and more pixelated,
and will match the geometry less. Classic workarounds are:
* increasing the shadow texture resolution (most cards today can render
to 2048x2048 or 4096x4096 without too much trouble) but this is
limited as even with the highest resolution your card supports, you
can make a terrain that will make shadows very pixelated...
* marking your terrain so that it does not cast shadows, which means
that it won't be used in the shadow texture, and so the bounding
volume that the texture must fit will (probably) be smaller. This also
breaks down if
1) you want your terrain to cast shadows (not a problem for a plane,
but for mountains, you might want to see their shadow too)
2) you have other objects everywhere in your scene (and not in a very
localized area)

A new technique called Light-Space Perspective Shadow Maps (LiSPSM) will
soon be integrated into OSG. This is a view-dependent shadow technique,
so the shadow map texture will fit the intersection of the scene volume
and the viewing volume, so you aren't wasting resolution in parts of the
scene where you don't even see if there are shadows or not... This
massively improves the situation, and will be a great tool for people
who want to integrate shadows to their applications.

Hope this helps,

J-S
--
______________________________________________________
Jean-Sebastien Guay jean-sebastien.guay-***@public.gmane.org
http://www.cm-labs.com/
http://whitestar02.webhop.org/
Loading...