Members - Reputation: 193
Posted 05 November 2001 - 07:58 AM
Members - Reputation: 122
Posted 06 November 2001 - 07:35 PM
1) Turn on the depth buffer, depth writes and depth testing. (The latter two are enabled by default if the depth buffer is enabled.)
2) Turn of blending and draw all your opaque objects, preferably in front-to-back order but that''s not necessary.
3) Disable depth writes.
4) Turn on bledning and draw all transparent objects in a back-to-front order. Order is very important here!
Now here''s the logic.
Drawing your opaque objects from front-to-back decreases the amount of unnecessarily rendered pixels. If you render a cube in the background, and then another object in the foreground that obscures it, then you wouldn''t need to draw all those cube pixels.
When blending, we don''t want to write to the depth buffer because transparent pixels should not obscure other pixels entirely. We do keep depth testing enabled because we do want transparent pixels to be obscured by opaque pixels.
The rendering in front-to-back order is necessary for proper blending. If a destination pixel is in front of your pixel to be rendered, you''ll need another blending function than when it''s the other way around. This is not possible in OpenGL in a single pass, so it is better to sort your objects to prevent it from happening.
Did that help?
Dirk =[Scarab]= Gerrits