• Advertisement

Archived

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

Blending and the Z buffer

This topic is 5562 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hello all, anyone know how to draw a transparent quad onto a scene without it being drawn on top of objects between it and the camera? There''s a couple of restrictions, I must draw the quad after most objects would have been drawn. So leaving the z-buffer enabled while drawing it is a must (or ist it?) But while the z-buffer is switched on some funny things can happen, like a square part of the scene (behind a transparent part of the quad) will suddenly disappear... Thanks in advance for any help.

Share this post


Link to post
Share on other sites
Advertisement
If I understand your question correctly:

I render the whole scene with zBuffer read/write enabled, but only rendering totally opaque quads. Afterwards, disable zBuffer write and render the (semi)transparent quads.

I don''t know if this answers your question.

Share this post


Link to post
Share on other sites
Thanks for the prompt response, but using that method I find that the transparent quad just gets rendered over everything else, even when it should be hidden behind an opaque object. I need a method of rendering a semi-transparent object onto the scene without having to render it before or after all opaque objects are drawn.

Share this post


Link to post
Share on other sites
quote:
Thanks for the prompt response, but using that method I find that the transparent quad just gets rendered over everything else, even when it should be hidden behind an opaque object. I need a method of rendering a semi-transparent object onto the scene without having to render it before or after all opaque objects are drawn.


I think you misunderstood a subtlety in what Carrot said. When rendering the alpha stuff you leave ZTEST on. e.g.:


D3DRS_ZENABLE = TRUE
D3DRS_ZWRITEENABLE = TRUE
Render_all_opaque_stuff();
...
D3DRS_ZENABLE = TRUE
D3DRS_ZWRITEENABLE = FALSE
Render_alpha_object();


The only "issue" with doing that is alpha polys will simply draw on top of any other alpha polys regardless of depth since no alpha polys exist in the Z buffer. For those you need to manually Z sort the objects and sometimes polygons into Z order so that the rendering takes place in the correct order.



--
Simon O''Connor
Creative Asylum Ltd
www.creative-asylum.com

Share this post


Link to post
Share on other sites

  • Advertisement