How to use a depth target surface as a texture

Started by
0 comments, last by SimmerD 18 years, 10 months ago
I’m trying to optimize my implementation of deferred shading by avoiding doing multiple pass for render normals and position information. So I like to render the normals to the color target and instead of doing another pass to render the position into another color target. I’m trying to get the depth information stored in the depth target so I be able to compute the screen space position of the pixel. To do that I created a depth-stencil surface and I had used it as a depth render target when rendering normals. Now in a second pass, I need to use that depth surface as a texture; but I can’t figure it out how. I had already tried D3DXLoadSurfaceFromSurface but it only seems to support color surfaces. Any idea? Btw: MTR is not an option since only the latest hardware supports it!
God is Real unless is declared Integer
Advertisement
Nope, the dx api does not allow using depth stencil surfaces for anything officially.

Nvidia has overloaded depth stencil surface fetching to indicate a shadow map lookup.

There is no way to get the depth from the depth buffer directly, and even if you could, the contents of this buffer are not guaranteed to be the same thing spit out of your projection matrix after the divide by w.

For instance, at least one IHV supported only 1- floating point z format for z buffers.

So, you want to render your own depth into a texture - probably just w, another name for viewspace z.

This topic is closed to new replies.

Advertisement