getting depth buffer info?

Started by
3 comments, last by RavNaz 18 years, 7 months ago
anyone know how I can get the depth buffer information as RGB, or if not...greyscale??
Advertisement
You usually want to avoid retrieving or generally messing with the contents of the depth buffer for various performance reasons.

This is backed up by the fact that, to perform a regular IDirect3DSurface9::Lock() operation you have to create the depth buffer with a "lockable" format (e.g. D3DFMT_D16_LOCKABLE) - and I've come across a fair few bits of hardware that DONT allow this format [headshake]

You can use various pixel shader tricks to effectively copy the depth buffer (or just simultaneously write the depth information) to a texture and then use that as appropriate.

hth
Jack

<hr align="left" width="25%" />
Jack Hoxley <small>[</small><small> Forum FAQ | Revised FAQ | MVP Profile | Developer Journal ]</small>

mmmm...ok....dont want to write directly to the depth buffer...just want the info in a seperate surface to read from.....can this not be done without shaders?

many thanks
Quote:Original post by RavNaz
just want the info in a seperate surface to read from.....can this not be done without shaders?

I'm not using my development machine at the moment, so I can't check the details - but you can definitely retrieve the depth stencil surface (as a IDirect3DSurface9), so you might (if you're lucky) be able to StretchRect to another (lockable) surface. Without my docs to hand I can't easily check whether the formats/pools match up [oh]

Although, the simplest method I've seen is that used a lot in shadow mapping algorithms - writing the depth to a texture during the initial rendering phase(s). But, as mentioned, you need to be using a shader-based pipeline for this to be useful...

hth
Jack

<hr align="left" width="25%" />
Jack Hoxley <small>[</small><small> Forum FAQ | Revised FAQ | MVP Profile | Developer Journal ]</small>

crap...doesnt sound as though it's going to work then...oh well....thanks anyways

This topic is closed to new replies.

Advertisement