Hello friends,

I am trying to improve the way that we utilize node masks. Right now, the cull 
mask for our Viewer's master camera is set to 0xffffffff (all bits on). So, a 
node will always be drawn if _any_ of its node mask bits are set.

Right now, we're essentially using the node mask for three things:

1) To indicate whether the node should be drawn or is hidden
2) To indicate if the node should be a shadow caster
3) To indicate if the node should be a shadow receiver

To this end, we have three basic masks that we bitwise OR together:

visibleNodeMask 0x1
castsShadowsMask 0x2
receivesShadowsMask 0x4

So, a visible object that casts shadows, but does not receive them, would have 
a mask of 0x1 | 0x2 = 0x3. I'm sure you get the idea, as this seem pretty 
common.

But the problem is, since our camera's cull mask is set to 0xffffffff, the 
visibility bit doesn't actually matter. If we want to hide an object, we have 
to set its node mask to zero. If we want to show an object that was previously 
hidden, we have to reconstruct its node mask, and that means we have to store 
its shadow state separately.

This is all very silly, so I decided to try and set our camera's cull mask to 
0x1. That way, the only bit that matters, as far as whether objects draw or 
not, is the visibility bit that we've already designated, and showing or hiding 
an object is a matter of simple, straightforward bitwise math.

So I did this:


Code:
m_viewer->getCamera()->setCullMask(visibleNodeMask);



And this seems to work fine, as far as determining which objects should be 
hidden and which objects should be shown, however now my shadows are messed up. 
I have a scene with one shadow caster, and the shadow appears as a full square 
below the caster. To me, it looks as though the camera that renders the shadow 
map is correctly identifying which object should be rendered, and adjusting its 
frustum to match the bounding box of this object. However, after the shadow map 
is rendered, the resulting shadow map is filled with depth values of zero (or 
nearly zero) -- almost as if it didn't actually render the caster into the 
shadow map.

Just in case, I took a look at my scene graph in the debugger, just to see what 
the nodes' masks looked like. They all seemed to be what I expected.

I know that you guys couldn't possibly tell me exactly what is causing my 
problem, because you have no idea what my code or scene graph looks like. 
However, I was hoping that perhaps this is a common-enough problem that has a 
well-known solution. Just a stab in the dark.

I was reading elsewhere that, when setting the cull mask of the camera, one 
should also set the inheritance mask like so:


Code:
osg::Node::NodeMask inheritanceMask = 
m_viewer->getCamera()->getInheritanceMask();
inheritanceMask |= ~(osg::CullSettings::CULL_MASK);
m_viewer->getCamera()->setInheritanceMask(inheritanceMask);



I have no idea what this does. I tried it, but it didn't seem to help.

Thanks,
Frank[/code]

------------------
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=30939#30939





_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply via email to