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

Robert Osfield robert.osfield at gmail.com
Fri May 18 07:21:09 PDT 2018

Hi Kristofer,

On 18 May 2018 at 14:42, Kristofer Krus <kristofer.krus at liu.se> wrote:
> I have two geometries, A and B, that are both translucent, of which A should always be rendered before B because it is farther from the camera fragment-wise. However, OpenSceneGraph sometimes renders A first and sometimes renders B first, depending on the viewing angle, which, when B is rendered first, causes A to disappear at the fragments where A and B overlap.
> How can I make sure A is always rendered first and then B?

There a several ways to achieve it.  The most common way is assign the
two geometries to two different RenderBins

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

Or put them both into a traversal order bin:

  Group* group = new osg::Group;
  group->getOrCreateStateSet()->setRenderinBinDetails("TraversalOrderBin", 5);

Performance wise the later might be a little faster, but won't be a
huge difference.


More information about the osg-users mailing list