Jump to content
  • Advertisement
Sign in to follow this  
MetaKnight

Transfer Z-Buffer

This topic is 4883 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 have two rendertargets, is there any way I can take the zbuffer from the backbuffer and copy it in a another render target?

Share this post


Link to post
Share on other sites
Advertisement
I think that the zBuffer for a render-target/screen-buffer is nothing more than a Surface of some type - at least that's how it used to be done in D3D. When you specify that a buffer (which is just a surface) should have Z and/or stencil capabilities, I think D3D allocates special surfaces for each of these and links them to your image surface. If this is still true, there will presumably be an API call to get the attached Z-buffer surface. You could then copy the data to another surface with the same format.

Of course there are issues like making sure the Z-surface is readable etc...

Share this post


Link to post
Share on other sites
It might be called something like "IDirect3DDevice9::GetDepthStencilSurface()".

:)

Share this post


Link to post
Share on other sites
I think theres a way to use the same depth buffer on two different render targets without copying it, if you're interested in that.

Share this post


Link to post
Share on other sites

Quote:
Original post by Hinch
It might be called something like "IDirect3DDevice9::GetDepthStencilSurface()".

:)



Oh that's that's just I needed! Thank you

Quote:
Original post by sirob
I think theres a way to use the same depth buffer on two different render targets without copying it, if you're interested in that.


Oh this would make things much better, do you know a key word to do this so I can search it in sdk? Does it involve swap chains?

Share this post


Link to post
Share on other sites
Quote:
Original post by MetaKnight
Quote:
Original post by sirob
I think theres a way to use the same depth buffer on two different render targets without copying it, if you're interested in that.


Oh this would make things much better, do you know a key word to do this so I can search it in sdk? Does it involve swap chains?


SetRenderTarget() and SetDepthStencil() are two separate calls, so AFAICS it will continue to use the same depthstencil surface after you've changed render targets. Just make sure the depthstencil surface satisfies the following conditions for both rendertargets:

* The multisample type must be the same for the render target and the depth stencil surface.
* The formats must be compatible for the render target and the depth stencil surface. See IDirect3D9::CheckDepthStencilMatch.
* The size of the depth stencil surface must be greater than or equal to the size of the render target.

(Nabbed from the DX9 SDK docs for the SetDepthStencil() method)

HTH!

Share this post


Link to post
Share on other sites
Yup that's it.

It indeed does keep the dataintact, and keep functioning, as long as they are the same size.

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!