Archived

This topic is now archived and is closed to further replies.

Ulfie

Drawing multiple transparent objects

Recommended Posts

Ulfie    122
I want to draw multiple transparent (or rather semi- transparent in order to see anything...)objects at once in OpenGL and one way to do this properly is to depth sort the polygons drawing the farthest ones first. But consider a more complex object, for example a torus, or a lot of them. Would the best thing to do be to depth sort every single polygon in every single object? Surely this could be optimized using bounding volumes for the objects, but it still seems like a lot of work on the CPU. Is there any OpenGL specific method that could be of use? Does anybody have anything to contribute in the area of efficient dept sorting or similar on this subject? ----------Hard Problem--------------- And finally, a pretty hard problem (I think): Consider 3 polygons, A, B and C A overlaps B, B overlaps C and C overlaps A no matter in which order they''re drawn, if they are transparent, the overlaps will not be rendered properly! How would you render them? ------------------------------------- Happy for reply!

Share this post


Link to post
Share on other sites
noisecrime    817
In reply to your ''Hard Problem'' you can''t. Its the classic flaw with the ''painters algorithm''. although its possible that using an alpha test instead of blending might work in some cases I guess (see below)

However the general approach to such a problem is to split intersected traingles so as to remove any render order ambiguities. BSP trees are very good at doing that, and also give you a perfect front to back (or vice versa) draw order.

Of course BSP trees may not be practical, in which case the best fall back plan is to make sure you split up the geometry when its being model.

In the case of doing say vegatation or trees the usual approach is to use alpha testing (and still read/write into the zbuffer) it will give textures aliased edges though, but you can work around that i believe by layer several of the same texture and using different alpha thresholds or something.

Share this post


Link to post
Share on other sites
Drath    138
There is a way to do this perfectly though it involves a lot of messing around...

It requires 4 draws to off screen targets with different cull directions and depth comparings. It finally combines them to the main target. The example comes with ATI''s RenderMonkey and is tailored to DX though I see no reason why it should not translate fine.

Alternatively you could do one ordinary render to a seperate target and combine it with the scene using your alpha value.

Here only one ''layer'' will be shown, only the normally rendered part of the model will be scene. With the other method you can render out nice glass effects, or a teapot in the RenderMonkey Example.

Share this post


Link to post
Share on other sites