D3D11 how to simulate multiple depth channels
- by Nock
Here's what I'd like to achieve:
Rendering a first pass of objects in my scene, using standard depth comparison
Rendering another pass of objects in the same scene, but with the following rules:
A Pixel of the 2nd pass always override the first pass (no depth compare between them)
Use Depth comparison between pixels written from the second pass.
In English I want depth comparison made inside each pass but I always want the second pass pixels to override the first pass ones.
Some things I've thought:
I tried to think about using stencil to solve this, but I couldn't find a way.
I know I could render into a separate target the second pass then composite the result into the first, but I'd like to avoid that.
I could use two separate Depth Buffer, one dedicated to each pass. (I never tried, but I figure it's possible to switch the depth buffer in a Render Target "on the fly")
Any idea of the best solution?
Thanks