• Advertisement
Sign in to follow this  

Reading stencil/depth-buffers

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

Hello, I created my device with AutoDepthStencilFormat = D3DFMT_D24S8. Once I write to the stencil/depth buffers, is there a way I can find out exactly what the values of each 32-bits for each pixel in this buffer? Thanks. -amtri

Share this post


Link to post
Share on other sites
Advertisement
Quote:
Original post by amtri
Once I write to the stencil/depth buffers, is there a way I can find out exactly what the values of each 32-bits for each pixel in this buffer?

Unless you use the D3DFMT_D[16/32]_LOCKABLE format, you won't be able to lock the surface directly. You won't be able to use any APIs to copy it to a lockable surface, either (such as StretchRect()). If you need to get the values from a z-buffer, it is more practical to use multiple render targets and just write the depth out to a R32F surface.

Share this post


Link to post
Share on other sites
circlesoft: the problem with using multiple render targets is the overhead. Won't this slow things down tremendously?

I usually don't know when exactly I will need to query for the z buffer contents. My feeling is that this is going to be a rare occurrence, so I'd rather use a method that, although less efficient in this one time call, will be more efficient overall since I won't need to render to multiple targets all the time.

-amtri

Share this post


Link to post
Share on other sites
One option is to set up two different shaders, one that renders to multiple targets and one that doesn't, and switch to the MRT one whenever you need the depth information. You can eliminate dependencies by calling one shader from the other (or putting common code in a function). The only hassle is that you'd need to write special shaders for each one that needs MRT support.

Share this post


Link to post
Share on other sites
Depending on what you need the depth info for, an easier way is to use a floating point ARGB texture (like A32R32G32B32F) for the main render target and always output the depth value to the alpha channel..(this does create some problems when you need to do alpha blending..alpha testing can be handled by using the clip() function )..

Share this post


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

  • Advertisement