Good post! Thanks for the info, Robert.

Where I always get confused is when the world of render bins and the world
of camera ordering collide. For example, let's say I have a Group node with
several Camera children. How would I control their order? Does it make sense
to do that with a different bin number on each Camera? I suspect that
wouldn't work, but haven't tried it. From experience, it appears that the
order of the Camera children determines their processing order.

Paul Martz
Skew Matrix Software LLC
http://www.skew-matrix.com
+1 303 859 9466

-----Original Message-----
From: [email protected]
[mailto:[email protected]] On Behalf Of Robert
Osfield
Sent: Saturday, May 09, 2009 12:55 AM
To: OpenSceneGraph Users
Subject: Re: [osg-users] Rendering a series of nodes in precise order...

Hi Nathan,

To control draw order in the OSG you have use a combination of RenderStage
and RenderBin's that are built in the rendering backend.
The scene graph interface that tell how one builds these are the Camera and
StateSet classes.

Camera's tend to get used from rendering whole stages in the pipeline (hence
are typically implement with RenderStage in the rendering
backend.)    A RenderStage is a specialised RenderBin that adds a
depth/colour/stencil buffer clear at the begining of the RenderStage, and an
optional copy buffer at the end of the RenderStage.

StateSet's tend to used to control whether associated geometry is dropped
into an opaque bin or transparent bin using the convinience method
StateSet::setRenderingHint, the actually just sets the more capable
StateSet::setRenderBinDetails(..) method which tells the rendering which
bins to create and how to number them.  The bins are renderered in accending
order from negative bin number to postitive.
So bin 0 gets drawn before bin 10.  The bins also can have different sorting
of the geometry that is dropped in them - the default RenderBin will be
state sorted, while the DepthSortedBin will sort from back to front.

In your case it's like StateSet::setRenderBinDetails(..) is all that you'll
need.  See the osgreflect example.

Robert.

On Fri, May 8, 2009 at 10:29 PM, Monteleone, Nathan
<[email protected]> wrote:
> Here’s the deal: I’m implementing a stencil buffer trick that looks 
> like
> this:
>
>
>
> for each object:
>
>             render some stuff into the stencil buffer
>
>             render a bounding box to draw in the places carved out by 
> the stencil, clearing stencil as I go
>
>
>
> The unusual thing is that it has to happen in exactly that order – I 
> can’t, for example, do the stencil pass for all objects, then do the 
> bounding box pass.
>
>
>
> I can easily write both render steps as geometry with StateSets, i.e. 
> I don’t need to develop a custom Drawable to do this stuff.
>
>
>
> Obviously I could control this with render bin numbers:
>
>
>
> binNumber = 1
>
> For each object:
>             render stencil in binNumber++
>
>             render bounding box in binNumber++
>
>
>
> That seems a little awkward though, mostly because it makes the 
> ordering of my other render bins more confusing.  Is there a more
straightforward way?
>
>
>
> Thanks,
>
> Nathan
>
> _______________________________________________
> osg-users mailing list
> [email protected]
> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.
> org
>
>
_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply via email to