Hi Ian,

You have come across the basic limitation of depth buffers and
transparency - for perfect blending one is required to draw all opaque
objexts then draw each transparent fragement from far to near.
Sorting by fragment isn't possible given how hardware is implemented
save for some custom fragment program, this means that you have to do
the sorting at the application level.

The best the OSG can do in this department is sort by depth of
Geometry objects, as this is the finest grained object that the OSG
draws.  This is rather coarsed grained relative to the idea of
fragment sorted, but usually works well enough for most models that
are well conditioned.

In you case you are setting the opaque objects in the scene to be
rendered as part of the transparent bin and therefore sorted along
with all the genuinely transparent objects, and its not surprisingly
that the draw order become less optimal and what were transparent
blending objects become opaque once they are drawn too early.

The fix is to take care what parts of the scene you set to transparent
and to keep the size of your transparent objects small so that depth
sorting can be relatively fine grained.

Robert.

On 8/21/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
> I have encountered two strange behaviors with alpha blending.  The context:
> I am rendering a set of markers and paths atop a map.  The markers are
> textured quads attached to AutoTransforms which keep them aligned with the
> screen and at a constant size, surrounded by translucent spheres ( 1, 0, 0,
> 0.25 ).  The paths are drawn with GL points and lines, surrounded by
> translucent cylinders ( 0, 0, 1, 0.25 ).  The map is a large textured quad.
> The root level stateset has the BlendFunc( SRC_ALPHA, ONE_MINUS_SRC_ALPHA ),
> the BlendEquation( FUNC_ADD ), and texture unit 0 (the only one in use) has
> TexEnv( REPLACE ).
>
> The first strange behavior is that if I set the root-level stateset's
> rendering hint to TRANSPARENT_BIN, the translucent geometry becomes suddenly
> opaque as its nominal location moves such that its viewing volume
> z-coordinate lies behind that of the map.  At various locations the
> translucent geometry also occludes the GL points and lines without becoming
> opaque with respect to the map.  If the rendering hint is set to OPAQUE_BIN,
> this does not happen and the scene renders with correct blending.  Is this
> expected?
>
> The second strange behavior is that the textured quad markers are completely
> occluded by the transparent geometry, which is instead rendered with a blend
> of the geometry's color and that of the map lying behind the marker.  The
> marker texture image is in .bmp format and has no alpha channel, but the
> quad it is attached to has color ( 1, 1, 1, 1 ), and the OpenGL
> documentation indicates that when GL_REPLACE is in effect the geometry alpha
> is used where the texture does not supply an alpha value.  I can't tell if
> this behavior is caused by odd texture behavior, or by some strange
> interaction of the AutoTransform with blending, or by something else
> entirely.  I would greatly appreciate any suggestions.
>
> - Ian Zeilstra
>  This is an e-mail from General Dynamics Land Systems. It is for the
> intended recipient only and may contain confidential and privileged
> information. No one else may read, print, store, copy, forward or act in
> reliance on it or its attachments. If you are not the intended recipient,
> please return this message to the sender and delete the message and any
> attachments from your computer. Your cooperation is appreciated.
> _______________________________________________
> 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