Sign in to follow this  
ehmdjii

drawing transparency correctly

Recommended Posts

ehmdjii    238
ok, say i have a scene containing opaque and transparent objects. what i do is to first draw the opaque objects, then turn the depth-test off and draw the transparent ones. this works good, as long as not two transparent objects overlap. what if my z-order is a transparent object, an opaque object and a transparent one agai? if the depth-test is off this gives incorrect results. on NEHE i read: The correct way is to draw all the transparent (with alpha < 1.0) polys after you have drawn the entire scene, and to draw them in reverse depth order (farthest first). so how do i get the distance of a poly? and how can i change the drawing order dynamically? thanks!

Share this post


Link to post
Share on other sites
Aeluned    196
NeHe's described method will work as long as the transparent polygons don't intersect.

You can use the center point of the object (found using a bounding cube or sphere).

If you have intersecting polygons however this method breaks down.
In this case, the problem becomes a bit more complicated and involves finding intersection points of the polygons and subdividing them and sorting them that way.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this