Hello Dominique,

This is a very simple piece of code and I don't understand why I having some 
artifacts.
I am trying to show a transparent box around the loaded model.

This is a classic problem. In real-time graphics to get correct transparency the transparent geometry needs to be sorted back to front and rendered after opaque geometry. However, to keep real-time, we generally won't sort all the polygons individually, we'll approximate by sorting on the Drawable level. This, in general, gives the correct results, as long as no drawable intersects or is inside a transparent one. You can see where I'm going with this.

Your box is around the other object, hence this object is inside the box that you want to make transparent. So depending on your view point, the box will be sorted before or after the other object, and you will get artifacts. There are workarounds though, but they involve tradeoffs in performance. In your case since it's just one box you might not notice the difference.

You could render the translucent box in two passes, one for the back faces, and one for the front faces. You'll need to turn depth test (or is it depth writes, can't remember, look it up on the web) off for this to work.

Or you could split the box into 6 drawables, each having one rectangle in it. That way the sorting on the Drawable level would work correctly.

Or you could investigate more advanced techniques, such as depth peeling and order-independent transparency. Where the first two options were specific to your case (a box surrounding another object) this one is general and will work for all transparent objects, but will probably be more difficult to implement and might cost more in terms of performance.

You can search the web and the archives for more details, as this has been discussed in the past. And there are examples in the OSG sources that can help as well.

Hope this helps,

J-S
--
______________________________________________________
Jean-Sebastien Guay    [email protected]
                               http://www.cm-labs.com/
                        http://whitestar02.webhop.org/
_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply via email to