[osg-users] Depth test and RenderBin details

431 views
Skip to first unread message

Bob Slobodan

unread,
Jun 8, 2012, 8:49:57 AM6/8/12
to osg-...@lists.openscenegraph.org
Hi guys,

I've been implementing my own dragger (from scratch, I didn't use the osg draggers for specific reasons) and I have some problem with the render order. Basically my dragger is composed of four sub-draggers :
- 3 axis dragger (each one composed of a line and a cone)
- 1 sphere dragger
The 3 axis dragger and the sphere have the same origin.

The thing is that I want my whole dragger (the 3 axis and the sphere) to always be rendered on top of the rest of the scene.

But when I deactivate the depth test and set the RenderBinDetails on my main dragger (node that contains the four sub-draggers), the sphere (which is the last node to be added to my main dragger) always appears on top of the axis.

Is there a way to render my dragger with the depth test between the axis and the sphere, and then to display the whole dragger on top of the rest of the scene ?

Thank you!

Cheers,
Bob

------------------
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=48138#48138





_______________________________________________
osg-users mailing list
osg-...@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Sergey Polischuk

unread,
Jun 9, 2012, 6:00:01 AM6/9/12
to osg-...@lists.openscenegraph.org
Hi

You may set different render bins to sphere and axis

Cheers

08.06.2012, 16:49, "Bob Slobodan" <qgal...@msn.com>:

Riccardo Corsi

unread,
Jun 10, 2012, 7:32:59 AM6/10/12
to OpenSceneGraph Users
Hi,

you can also use the "TraversalOrderBin" which renders children node in the order they are visited,
and place in the correct order the different dragger primitives in your subgraph.
Ricky

Bob Slobodan

unread,
Jun 11, 2012, 4:15:12 AM6/11/12
to osg-...@lists.openscenegraph.org
Hi guys,
First of all, thank you for the answers. Unfortunately, I couldn't solve my problem. I already tried the first solution that consisted in giving different render bin to the axis and the sphere, but then I either have the sphere always on top of the axis, or the axis always on top of the sphere.

This image illustrates my problem :

[Image: http://img15.hostingpics.net/pics/490598Sanstitre4.png ] (http://www.hostingpics.net/viewer.php?id=490598Sanstitre4.png)

The image 1 illustrates what i have when the sphere has a lower render bin than the axis. The images 2 and 3 illustrates the opposite.
The image 4 illustrates a shading problem that I have in both situation.

So what I want is a mix between the image 2 and 5. This is basically what I have when I don't deactivate the depth test and don't use render bin details. But then, if I have anything (like a plane for example) between my dragger and the camera, I won't see it anymore.

Thank you so much for helping me.

Cheers,
Bob

------------------
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=48156#48156

Gianluca Natale

unread,
Jun 11, 2012, 6:31:24 AM6/11/12
to osg-...@lists.openscenegraph.org
What I would do in standard OpenGL is this:
1) Draw your whole model first (with depth test enabled);
2) Clean the depth buffer only (glClear(GL_DEPTH_BUFFER_BIT););
3) Draw the dragger (with depth test enabled).
In this way the dragger would always appear on top of the model, no matter its position in the world.

How can you achieve this in a scene graph using OSG?
1) I would set the rendering bin for the whole model to the lowest value, to force it to be drawn first. Keeping depth test enabled during drawing.
2) I would define a CleanDrawable, derived from osg::drawable, whose drawImplementation is just a glClear(GL_DEPTH_BUFFER_BIT). And assign the rendering bin for such drawable to a value
greater than the one assign to the whole model. Then, I would attach a geode containing such drawable somewhere in your scenegraph.
3) I would set for the dragger a rendering bin even greater than that assigned to the CleanDrawable. Keeping the depth test enabled in this case also.

I did do it in my application and it seems to work. But I don't know if there is a better and more elegant solution.
Just my 2 cents.

-----Messaggio originale-----
Da: osg-user...@lists.openscenegraph.org [mailto:osg-user...@lists.openscenegraph.org] Per conto di Bob Slobodan
Inviato: lunedì 11 giugno 2012 10:15
A: osg-...@lists.openscenegraph.org
Oggetto: Re: [osg-users] Depth test and RenderBin details

Tim Moore

unread,
Jun 11, 2012, 7:08:50 AM6/11/12
to OpenSceneGraph Users
On Mon, Jun 11, 2012 at 12:31 PM, Gianluca Natale
<nat...@europe.altair.com> wrote:
> What I would do in standard OpenGL is this:
> 1) Draw your whole model first (with depth test enabled);
> 2) Clean the depth buffer only (glClear(GL_DEPTH_BUFFER_BIT););
> 3) Draw the dragger (with depth test enabled).
> In this way the dragger would always appear on top of the model, no matter its position in the world.
Yes
>
> How can you achieve this in a scene graph using OSG?
> 1) I would set the rendering bin for the whole model to the lowest value, to force it to be drawn first. Keeping depth test enabled during drawing.
...
A less intrusive way to do this is with slave cameras. The main scene
is drawn in a slave. Another slave camera draws your dragger by having
it as its child. Its clear mask is set to GL_DEPTH_BUFFER_BIT.

Tim
Reply all
Reply to author
Forward
0 new messages