[osg-users] rendering order

Gianluca Natale natale at europe.altair.com
Mon Oct 23 10:08:09 PDT 2017


Hi all, I have an issue with order of rendering.
I do know that OSG has rendering bins to provide the order of rendering, and that, inside a rendering bin, it optimizes drawing by sorting objects to render WRT the state sets.
That's fine. But now I have an use case that I don't know how to implement.
My graphic object is made by a 2D rectangular box with a text on top, as shown in the picture a).
Well, I do have many of them, which can overlap. I do disable depth test when I render them, because I want the last one to cover completely the others, when overlapping.
The visualization that I want to achieve is that shown in picture b).
In order to do that, my scenegraph is made by these nodes:

              Main root node
                  |                     |
           Transf1         Transf2
             |       |             |       |
      Box1      |        Box2    |
                      |                      |
                 Text1             Text2

Transf1 sets the position of Object1
Trasnf2 sets the position of Object2.
Box1 is a geode that contains a drawable that render the rectangular box for Object1.
Text1 is a text drawable for the text on top of the box1.
Box2 is a geode that contains a drawable that render the rectangular box for Object2.
Text2 is a text drawable for the text on top of the box2.

So, my objects should be rendered in this order, to draw what I want:
Box1, Text1, Box2, Text2, ...
I do have hundreds of graphic objects like those.
So, how can I do this?
I cannot set the same rendering bin for all Boxes, and a different rendering bin for all Texts, because OSG would render first all the boxes, and then all texts, which would overlap each other, like in picture c). Orrible!!!
So, I thought that I have to assign the same rendering bin to all Transf, in order to make it render all my objects in the same bin, but I have to specify somehow that it has to render Box and Text in that order for each sub-graph,
instead of optimizing rendering by state set order, which breaks my requirement.
I would need to set some "offset" in rendering bins for Boxes and Texts (1 and 2 respectively), to force OSG to render the Box and Text in that order, for each subgraph connected to Transf.
It seems an easy thing to do, and mine seems a silly question, but I cannot do that.
Any help is appreciated.

Thanks,
Gianluca

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openscenegraph.org/pipermail/osg-users-openscenegraph.org/attachments/20171023/05e508f0/attachment-0001.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: TextsInBoxes.png
Type: image/png
Size: 26097 bytes
Desc: TextsInBoxes.png
URL: <http://lists.openscenegraph.org/pipermail/osg-users-openscenegraph.org/attachments/20171023/05e508f0/attachment-0001.png>


More information about the osg-users mailing list