[osg-users] strange ShadowMap behavior

Jean-Sébastien Guay jean-sebastien.guay at cm-labs.com
Mon Sep 22 13:25:54 PDT 2008

Hello Ben,

> 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:


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,

Jean-Sebastien Guay    jean-sebastien.guay at cm-labs.com

More information about the osg-users mailing list