Sign in to follow this  

DX Alpha Blending and Z test

This topic is 4301 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

I'm trying to render fake shadows below the objects in my 3d world (as quads with an alpha-channeled circular gradient texture on them, you know). So there's a giant mesh that surrounds everything which makes up the floor. Currently the shadows draw, then the objects, then the surrounding mesh (isn't that lovely?) The shadow is preventing the surrounding mesh from drawing beneath it (because it's writing the Z values for the entire quad right?) What I'd like is a way to make it so the surrounding mesh can draw at any time and still blend with the shadow correctly, cuz mainly I'm lazy. Is there like a render state flag or something for this? I can imagine a way that such a feature could be implemented (but yes, it might use more memory and be slower, but maybe it still exists) Thanks for your time!

Share this post


Link to post
Share on other sites
I don't know If I got your point, but maybe tuning off writing to Z-buffer for the shadow quad will do the job.
d3ddevice->SetRenderState(D3DRS_ZENABLE,false);

oh, and do not forget to turn it on again when you finished drawing the quad.

Share this post


Link to post
Share on other sites
Basically, when drawing translucent objects, you'd have to first draw the solid ones, then draw the translucent objects from back to front. I don't really know how it would be possible to draw the solid objects after the translucent ones and still get it to blend correctly...? Because, as you say, the z-buffer will be written for the entire translucent quad. If you don't write the translucent object to the z-buffer, the solid object will overwrite the translucent one completely (when drawing the solid object after the translucent one, that is). If you draw the translucent objects back-to-front after all the solid rendering, you don't have to write to the z-buffer though.

-Trond

Share this post


Link to post
Share on other sites

This topic is 4301 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.

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