Ben Discoe
2008-05-15 02:35:24 UTC
There's something i'm not understanding about osgShadow, and it's probably a basic behavior of OSG.
So, the simple question first:
The default node mask for all nodes is 0xffffffff.
It i set the mask to 0, then the node (and its children) is not drawn.
If i set the mask to some other value, then it seems to be drawn also. So what is OSG testing for, mask!=0? The NodeVisitor code seem to deal with bit masks. So is there some specific bit (high bit, perhaps?) in the node mask which says "draw me"?
This relates to osgShadow's CastsShadowTraversalMask.
Let's say it's set to 1.
In the simple case (like example osgshadow) of a ShadowedScene with some children, it's clear how it will behave: nodes with the 0x1 bit set in their mask will cast shadows.
But, what if there is a large complex scene graph?
Nodes A and B are far apart in the graph. The ShadowedScene node is up at the top of the graph. If we want A to shadow B, then we need to set the appropriate bits in the node mask of A and B, and un-set them for everything else. But, will the node traversal (of the ShadowTechnique) ever reach A and B, to test if they have CastsShadowTraversalMask set? Or does every parent along the nodepath need the flag set also?
If that's true, then for this to be useful, we'd need some iteration code (NodeVisitors, presumably) to set up the scene graph, clearing the mask bits everywhere, and then starting with the ShadowCasting nodes, walking upwards setting the CastsShadowTraversalMask bits along the way, until it reaches ShadowedScene?
If anyone can answer these, i am happy to add an explanation the osgShadow wiki docs.
Thanks,
Ben
So, the simple question first:
The default node mask for all nodes is 0xffffffff.
It i set the mask to 0, then the node (and its children) is not drawn.
If i set the mask to some other value, then it seems to be drawn also. So what is OSG testing for, mask!=0? The NodeVisitor code seem to deal with bit masks. So is there some specific bit (high bit, perhaps?) in the node mask which says "draw me"?
This relates to osgShadow's CastsShadowTraversalMask.
Let's say it's set to 1.
In the simple case (like example osgshadow) of a ShadowedScene with some children, it's clear how it will behave: nodes with the 0x1 bit set in their mask will cast shadows.
But, what if there is a large complex scene graph?
Nodes A and B are far apart in the graph. The ShadowedScene node is up at the top of the graph. If we want A to shadow B, then we need to set the appropriate bits in the node mask of A and B, and un-set them for everything else. But, will the node traversal (of the ShadowTechnique) ever reach A and B, to test if they have CastsShadowTraversalMask set? Or does every parent along the nodepath need the flag set also?
If that's true, then for this to be useful, we'd need some iteration code (NodeVisitors, presumably) to set up the scene graph, clearing the mask bits everywhere, and then starting with the ShadowCasting nodes, walking upwards setting the CastsShadowTraversalMask bits along the way, until it reaches ShadowedScene?
If anyone can answer these, i am happy to add an explanation the osgShadow wiki docs.
Thanks,
Ben