[osg-users] Draw two translucent geometries in specific order

Kristofer Krus kristofer.krus at liu.se
Mon May 21 02:34:31 PDT 2018

Hi again robertosfield, I took a look at the code you posted at this thread (http://forum.openscenegraph.org/viewtopic.php?t=17289), and it gave me some further questions.

According to this code, there seems like there are six default rendering bins, and I don't see that any numbers are associated with them. However, the article (http://www.bricoworks.com/articles/stategraph/stategraph.html) I linked to claims there are two default rendering bins, numbered 0 and 10. Why does that article claim that, if the code seems to imply something very different? Also, why would it say that the numbers used for those bins are 0 and 10? That seems kind of arbitrary to me and doesn't make much sense.

robertosfield wrote:
> subgraphA->getOrCrreateStateSet()->setRenderinBinDetails("RenderBin", 5); // or "DepthSortedBin" if you have mulitple transparent objects that need sorting
> subgraphB->getOrCrreateStateSet()->setRenderinBinDetails("RenderBin", 6);

There is no method called setRenderinBinDetails, but there is a method called setRenderBinDetails. And the order of the arguments for this method is the reversed compared to what you write, i.e. setRenderBinDetails(5, "RenderBin") and setRenderBinDetails(6, "RenderBin").

Also, what do the arguments do? When I use the code you suggested, A is now always rendered after B, i.e. in the wrong order, no matter if I use the numbers 5 and 6 or if I swap them so that I use the numbers 6 and 5. (This seems to be independent of the direction I view the scene from, which is a good thing, though.) I had the impression that render bins with higher numbers would always be rendered later, and that the number we provide as an argument to setRenderBinDetails is the number of the bin we want to put the subgraph in, but this doesn't seem to be the case.

Read this topic online here:

More information about the osg-users mailing list