Hi Roger,

I would like to render a scene that has some nodes in it that should not receive a shadow, and also some nodes that should neither cast nor receive a shadow but still be rendered.

Not that I want to curb your enthusiasm to fix a percieved problem, but there are ways to achieve what you want without changing the shadow technique code.

(Note that I will only speak from experience with osgShadow::ShadowMap and the new ViewDependentShadow techniques - the others I know less about but it might be similar)

First of all, ShadowMap and the new ViewDependentShadow classes (LightSpacePerspectiveShadowMap being the one you probably want) will honor the castsShadow traversal mask. So if you flag a node like so:

unsigned int castsShadow = shadowedScene->getCastsShadowTraversalMask();
node->setNodeMask(node->getNodeMask() & ~castsShadow);

it will not cast shadows (and its volume will not be considered when calculating the shadow casting volume, which is good for reducing shadow aliasing in the case of ShadowMap).

Second, no shadow technique right now honors the receivesShadow traversal mask. But you can work around this by putting the node you don't want to receive shadows outside the shadowedScene in your scene graph. So for example, your actual scene root would be an ordinary osg::Group, which would have as children all the nodes you don't want to receive shadows, and also the ShadowedScene under which all nodes will receive shadows.

You can also add control for receiving shadows in your shadow shader. Both ShadowMap and LightSpacePerspectiveShadowMap allow you to replace the shaders by ones you would write yourself. In my case, I have a single shader pair (vertex + fragment) for the whole scene, where I have a uniform that controls if the object is shadowed (so if this uniform is false, no shadow map lookup will be performed for the current vertex/fragment). Then I just set that uniform to the desired value on the nodes. This might slow down your rendering a bit, but it gives you better control over shadow application in your scene.

So with those suggestions I think you can get the result you want. If not, perhaps I've misunderstood what you were trying to accomplish.

Hope this helps,

J-S
--
______________________________________________________
Jean-Sebastien Guay    [EMAIL PROTECTED]
                               http://www.cm-labs.com/
                        http://whitestar02.webhop.org/
_______________________________________________
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply via email to