Mayrel and Dactylos, you were absolutely right that I made an error in disabling the Z-buffer when drawing the blended polygons. The rest was correct however. Here is what the final correct procedure should be (AFAIK):
1) Enable Z-buffer and Z-buffer writes. (The latter is on by default.)
2) Draw all 100% opaque polygons. (Preferably front-to-back for speed, but they don't _have_ to be sorted.)
3) Keep the Z-buffer enabled but disable Z-buffer writes.
4) Draw all <100% opaque polygons.
What happens now is that we ARE discarding blended pixels that are behind opaque pixels, but we AREN'T discarding blended pixels that are behind other blended pixels.
Cheers.
EDIT: typo + addition
Edited by - Scarab0 on October 24, 2001 2:27:32 PM
Z Buffer
Guys, you''re missing something obvious... just set it to greater than or equal to... and draw your translucent polygons last. That way, it will draw over the old ones since it''s equal to in the zbuffer (you can even disable writes for this part too), and it will be covered by anything that is in front of it, and it will cover anything behind it (or partially cover depending on it''s alpha).
Billy
BillyB@mrsnj.com
Billy
BillyB@mrsnj.com
quote:Original post by Anonymous Poster
Guys, you''re missing something obvious... just set it to greater than or equal to... and draw your translucent polygons last. That way, it will draw over the old ones since it''s equal to in the zbuffer (you can even disable writes for this part too), and it will be covered by anything that is in front of it, and it will cover anything behind it (or partially cover depending on it''s alpha).
Billy
BillyB@mrsnj.com
Exactly.
The point we were making was that the translucent primitives should be drawn in back-to front order, since the blending might not work as expected otherwise.
The order you draw opaque primitives in won''t matter, but drawing them in front-to-back order is an easy-to-implement optimization for spatially sorted primitive-sets (like a BSP-tree).
I really don''t get "drawing front to back"
I''m doing something with planets right now, how can I know if the moon is in front of the earth of behind it? I mean i draw the earth first and then the moon and let the DEPTH_TEST do the work.
I got the same problem, I have a second - transparent- non moving moon to fix it starting position, but this happens:
When I turn on blending AND depth testing, the transparent moon gets weird zigzagged lines on it.
When I turn on blending only, the tranparent moon is always drawn in front of the earth.
So how can I know when the transparent moon is really in front or not.
(btw you may ask why worry if it is in a fixed position, well you can rotate the camera around the earth...)
plz help!
thx
I''m doing something with planets right now, how can I know if the moon is in front of the earth of behind it? I mean i draw the earth first and then the moon and let the DEPTH_TEST do the work.
I got the same problem, I have a second - transparent- non moving moon to fix it starting position, but this happens:
When I turn on blending AND depth testing, the transparent moon gets weird zigzagged lines on it.
When I turn on blending only, the tranparent moon is always drawn in front of the earth.
So how can I know when the transparent moon is really in front or not.
(btw you may ask why worry if it is in a fixed position, well you can rotate the camera around the earth...)
plz help!
thx
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement