[osg-users] Nested transparent objects

2009-09-03 Thread Ben Axelrod
I am trying to view transparent objects inside of other transparent objects.  
My objects are simple ShapeDrawables with some color and alpha transparency.  I 
am seeing strange behavior where the inner object is sometimes completely 
hidden by the outer object depending on camera angle.  Also, some of the object 
edges that should be visible are not. (Again, depending on camera angle).

In the attached images: badalpha.png there is a small red cube partially 
inside of a larger green cube.  they both have some transparency and you should 
be able to see through both objects.  however, some edges of the green cube are 
completely hidden by the red cube.  The desired behavior can be seen in 
badalphamodbyhand.png in which I modified to show what should be shown.

This must be a common problem, but I searched the archives and it did not turn 
up much.

my GL_DEPTH_TEST attribute is on as well as GL_BLEND.  I am using OSG 2.6.0 
with an NVidia series 7 graphics card.

Is there some way to improve the transparency visualization?

Thanks,
-Ben

attachment: badalpha.PNGattachment: badalphamodbyhand.png___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] Nested transparent objects

2009-09-03 Thread Thrall, Bryan
Ben Axelrod wrote on Thursday, September 03, 2009 4:25 PM:

 I am trying to view transparent objects inside of other transparent
objects. 
 My objects are simple ShapeDrawables with some color and alpha
transparency. 
 I am seeing strange behavior where the inner object is sometimes
completely
 hidden by the outer object depending on camera angle.  Also, some of
the
 object edges that should be visible are not. (Again, depending on
camera
 angle). 
 
 In the attached images: badalpha.png there is a small red cube
partially
 inside of a larger green cube.  they both have some transparency and
you
 should be able to see through both objects.  however, some edges of
the green
 cube are completely hidden by the red cube.  The desired behavior can
be seen
 in badalphamodbyhand.png in which I modified to show what should be
shown. 
 
 This must be a common problem, but I searched the archives and it did
not
 turn up much. 
 
 my GL_DEPTH_TEST attribute is on as well as GL_BLEND.  I am using OSG
2.6.0
 with an NVidia series 7 graphics card. 
 
 Is there some way to improve the transparency visualization?

This is a common problem: OSG sorts at the granularity of Drawables and
according to the bounding sphere's center, so it can get the rendering
order wrong from certain points of view (for proper blending, distant
transparent objects need to be rendered before nearer objects). For
intersecting Drawables, there is no correct order, which is what you're
seeing.

To get correct behavior, you'd have to split your objects into separate
Drawables so that they can be sorted, which may require splitting
polygons (and for dynamic objects, splitting the polygons every time the
objects move or change shape).

HTH,
-- 
Bryan Thrall
FlightSafety International
bryan.thr...@flightsafety.com
___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org