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

Reply via email to