Jump to content
  • Advertisement
Sign in to follow this  
elurahu

XNA: Depthbuffer reuse

This topic is 3559 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 implement an effect which involves reusing the depthstencilbuffer from a previous rendertarget. What I want to happen: 1) I render a bunch of geometry to the backbuffer using the default depthstencilbuffer. 2) I set a new active rendertarget where I render some stuff I need depth tested against when SHOULD be in the default depthstencilbuffer. The problem is step 2 doesn't get depthtested against the default depthstencilbuffer. I've tried so many things now I'm at roads end. Anyone have an input on how to do this in XNA? Alternative are welcome! Regards

Share this post


Link to post
Share on other sites
Advertisement
This is a particularly painful consequence of maintaining compatibility with the Xbox 360. You see on the 360 the depth buffer lives in the eDRAM along with the render target. When you're done with render target, it gets "resolved" which means it's dumped back out to main memory so it can be used as a texture. Unfortunately when this happens, your depth buffer goes with it. On the PC this is actually emulated by the XNA runtime by clearing the depth buffer.

To get around this, you can try restoring the depth buffer. Unfortunately this requires rendering depth yourself to a texture (either via MRT or with a second pass), then using a full-screen pass to sample the texture and write out the depth. Catalin Zima has a sample you could look at.

Share this post


Link to post
Share on other sites
Thanks a bunch MJP. Yes on the Xbox I would normally have left the depth values in the eDRAM and then just reused them. Right - Good think I havn't been going mental the last 4 hours. Damn XNA :)

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!