|
楼主 |
发表于 2011-1-5 17:28:04
|
显示全部楼层
我在osg-users找到一段回复。
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,
请问他所说的two passes是什么?如何实现? |
|