[osg-users] transparent object sorting and back face culling
Paul Speed
pspeed at progeeks.com
Thu Aug 13 23:58:44 PDT 2009
P.S.: I don't pretend to understand any of this. Render bins and render
bin details are one of the more confusing parts of OSG... I generally
just keep monkeying with them until something sticks.
I will point out that in my understanding, the render bin number and the
render bin details are not tightly related like one might think. It's
not like there's a fixed array of bins somewhere. As I recall, bin
number controls rendering order locally to that part of the scene graph.
Render bin details define how to sort/render things within that local
bin. So if child 1 is render bin 1 it will be rendered before child 2
at render bin 2. The parent node might be render bin 25 and it's
irrelevant. I think.
Though as soon as I pretend I understand that I've had it bite me. So I
could be somewhat wrong somewhere.
-Paul
Paul Speed wrote:
> Even within the transparent bin you can enforce specific ordering with
> the bin number. Lower numbers get rendered before higher numbers.
>
> I'd have to dig to find any of my own example code but I hoped perhaps
> the hint would be enough in short time.
>
> We did this all the time to render double-side transparent geometry.
> Draw the inner faces in a lower bin number than the outer faces. Even
> with different bin numbers you can still depth sort them.
>
> We had semi-transparent glass boxes with text on the sides. I think we
> ultimately had three different bin numbers we used for that associated
> with the inner, outer, and text geometries.
>
> -Paul
>
> Jason Daly wrote:
>> Rabbi Robinson wrote:
>>> Hi,
>>>
>>> Is there anyway that I can enforce drawing the objects inside first
>>> before drawing the outside membrane?
>>>
>>
>> Sure, just use setRenderBinDetails() to set a render bin for the
>> membrane that has a higher number than the render bin used by the
>> interior objects. For the other parameter, you can set either
>> "DefaultBin" for a state-sorted bin, or "DepthSortedBin" for a
>> depth-sorted bin.
>>
>> interiorStateSet->setRenderBinDetails(0, "DefaultBin");
>> membraneStateSet->setRenderBinDetails(10, "DepthSortedBin");
>>
>>
>> However, this is equivalent to this code:
>>
>> interiorStateSet->setRenderingHint(StateSet::OPAQUE_BIN);
>> membraneStateSet->setRenderingHint(StateSet::TRANSPARENT_BIN);
>>
>>
>> Which is probably close to what you're already doing. The problem is
>> that the transparent geometry still has to obey the depth (z-buffer)
>> test, even if it's drawn last. You can try disabling the depth test,
>> but this is likely to cause other problems (if you ever have anything
>> move in front of the membrane, for example):
>>
>> depth = new Depth();
>> depth->setFunction(Depth::ALWAYS);
>> membraneStateSet->setAttributeAndModes(depth, StateAttribute::ON);
>>
>>
>> This is the main reason why the alpha to coverage method is sometimes
>> used, even though it's a bit expensive in draw time.
>>
>> --"J"
>>
>> _______________________________________________
>> osg-users mailing list
>> osg-users at lists.openscenegraph.org
>> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
>
> _______________________________________________
> osg-users mailing list
> osg-users at lists.openscenegraph.org
> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
More information about the osg-users
mailing list