Jump to content
  • Advertisement
Sign in to follow this  
Ender1618

Drawing only the the z-buffer

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

What I am trying to do is for certain objects draw only to the z-buffer. This way that object can occlude others without actually being visible. What i used to do is this:
    if(m_bRenderToZBufOnly)
        pd3dDevice->SetRenderState(D3DRS_COLORWRITEENABLE,0x00000000);

    RenderObj(pd3dDevice);

    if(m_bRenderToZBufOnly)
        pd3dDevice->SetRenderState(D3DRS_COLORWRITEENABLE,0x0000000f);
This used to seem to work, but now it doesn't (yes my hardware supports COLORWRITEENABLE). Is there any other state that could be set that would effect how this works. I do notice that some objects do seem to be occluded by the z-buf only objects, but most arent. Is there some sort of drawing order problem with this technique? Is there some sort of early z-buffer rejection optimization that would effect this?

Share this post


Link to post
Share on other sites
Advertisement
You need to draw those occluding objects first, before drawing what is behind them. If objects behind them are drawn first, then they will not be covered later since color writes are disabled, and their image in the color buffer will still be present even though the z-buffer is overwritten by a closer object.

Share this post


Link to post
Share on other sites
You don't need to sort objects per-se, just to separate your color pass in two separate passes (1st render all z-only models, then render all models) like you would do for a depth pre-pass. Within each pass, objects noeed no particular sorting

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!