Transfer Z-Buffer

Started by
7 comments, last by MetaKnight 18 years, 10 months ago
I have two rendertargets, is there any way I can take the zbuffer from the backbuffer and copy it in a another render target?
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...
Yep that's just what I need. But I cannont find the command to lock and copy a z buffer?
It might be called something like "IDirect3DDevice9::GetDepthStencilSurface()".

:)
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.
Sirob Yes.» - status: Work-O-Rama.

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?
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!
Yup that's it.

It indeed does keep the dataintact, and keep functioning, as long as they are the same size.
Sirob Yes.» - status: Work-O-Rama.
Perfect! Thank you guys for all the help

This topic is closed to new replies.

Advertisement