[osg-users] ShadowMap problem...

Jean-Sébastien Guay jean-sebastien.guay at cm-labs.com
Tue Nov 10 13:07:41 PST 2009

Hi Wyatt,

> Just have to ask, if you try with only one object and a ground plane (a 
> really simple scene) do you get the same results?

I just tested, and your code seems to work. I've attached a source file 
which is the osgshadow example, with the main() commented out and your 
code in its place. Have a look, the only changes were to put the 
ModelThree scene as child of your m_World group and to make sure I had a 
manipulator, and make everything compile...

You seem to be using a skydome (based on a variable called SKYDOME_RANGE 
in the code). You did set your skydome's node mask to ~cast right? 
Otherwise what you're seeing is probably your skydome's shadow being 
cast over everything... That's one thing about using osgShadow, you need 
to make sure things that you don't want to cast shadows don't have the 
cast shadow bit in their node mask. Also HUDs should be set that way. 
Keep an iron grip on your node masks or you'll have unpleasant 
surprises... :-)

The receive shadow node mask is not used for ShadowMap classes, but you 
can implement a node that doesn't receive shadows by adding a case in 
your shader (a test on a boolean uniform that skips the shadow test) and 
set that uniform to true at your scene's root and false for each node 
that you don't want to receive shadows.

And btw, osgShadow::ShadowMap is not really designed for positional 
lights, because they're omnidirectional and would need 6 full-scene RTT 
passes (like a cube map) to be totally accurate. I think (IIRC) 
osgShadow::ShadowMap and the ViewDependentShadow classes try to 
approximate a directional in that case, but the approximation breaks 
down if the light source is positioned inside the bounding box of the 
scene... You're better off either approximating the sun with a 
directional, or using a spot light for an interior scene.

Hope this helps,

Jean-Sebastien Guay    jean-sebastien.guay at cm-labs.com
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: osgshadow.cpp
URL: <http://lists.openscenegraph.org/pipermail/osg-users-openscenegraph.org/attachments/20091110/6757ece5/attachment.asc>

More information about the osg-users mailing list