Download

Retrieve depth buffer for UTextureRenderTarget?

Hi, I was wondering if anyone had some pointers for how I might obtain the depth buffer for a UTextureRenderTarget? I’m interested in doing some post-processing on it in C and would like to grab both the color buffer and depth buffer.

RenderTargets have a very handy ReadPixels() interface for grabbing the color buffer but it appears the depth buffer is tossed after the texture is done rendering. Is there a way to keep it around, or is there something I can modify in the engine to force it to be kept around?

As a workaround I was thinking I could render the texture twice, the second time through with a full-screen post process effect that sets the color buffer to the depth buffer, but this seems like a waste since it’s already got the depth buffer when it rips the texture the first time.

Any ideas? Thanks!