How to controll write to zbuffer dynamically RRS feed

  • Question

  • In D3D9 you could control write to depth buffer via flick of render state with:


    this was needed for particle effects.

    I looked into it with D3D11 and the method I am seeing look much more involved.  Is there a simple way to dynamically enable/disable depth buffer updates in D3D11 like there was in D3D9?


    Saturday, May 19, 2012 4:13 PM

All replies

  • This was the path I was looing at, but I found a simpler method (or at least I think it is simpler).

    At startup create a depth stencil state using device->CreateDepthStencilState()

    make sure that in the D3D11_DEPTH_STENCIL_DESC the DepthWriteMask is set to D3D11_DEPTH_WRITE_MASK_ZERO

    Now, in the render loop, just before you draw the particles, call:

    context->OMSetDepthStencilState() and pass in the struct from above.

    At the top of the render loop you need to make sure it is set to default by calling OMSetDepthStencilState() and passing in a null which sets to default.

    This makes it easy.  This bit of code is pretty much a must-have for particle effects.


    Monday, May 21, 2012 5:21 PM