• Advertisement
Sign in to follow this  

Any way to save and restore the Z-buffer?

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

Hi, I was wondering if there's a way to save and restore the Z-buffer. What I want to do is pretty much to create a G-buffer, save the Z-buffer, do stuff, including creating shadow maps etc. Then restore the Z-buffer before rendering the forward pass with particles and other translucent surfaces. Is there any sane way to do this?

 

I'm using XNA with the intention of moving on to MonoGame in the near-ish future.

Share this post


Link to post
Share on other sites
Advertisement

You might try RenderTargetUsage.PreserveContents, although that means you'll be using the same render target - so it's not an option if you'll be sampling from the same one you used when creating Z-buffer. I'm also not sure if that's supported in MonoGame. 

 

The depth buffer is tightly-coupled with the render target in XNA.

 

Another option (this is what I do), is to render depth values to a render target during your G-buffer pass, and then use that render target to render to the z-buffer during your forward pass (by outputting DEPTH from your pixel shader, and using a BlendState that disables color writes).

Share this post


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

  • Advertisement