Zezba

I am trying to find a way to sample from a DepthStencilSurface in the pixel shader.

I have tryed using StretchRect to copy the DepthStencilSurface to a Surface(The Surface was part of a Texture created in the D3DPOOL_DEFAULT memory) and then sampling from the Texture the Surface was part of.

But that doesn't work, probably because of the difference in the D3DFMT_ of the two Surfaces.
Surface_Format = D3DFMT_A8R8G8B8.
DepthStencilSurface_Format = D3DFMT_D16.

Anyone know how to accomplish this


Re: Game Technologies: DirectX 101 sample from a DepthStencilSurface

BLANC Guillaume

Have you try to use a depth stencil surface created with the Device::CreateTexture function and D3DUSAGE_DEPTHSTENCIL usage I don't know which format to use, but I think it could allow to directly sample that surface from a pixel shader.




Re: Game Technologies: DirectX 101 sample from a DepthStencilSurface

Ralf Kornmann

The usage of depth stencil formats for textures is not a common feature of Direct3D 9 hardware. It is supported by nvidia chips but the do something called PCF if you read from them in the pixel shader. Therefore you caní»t get the real depth value.

The normally used solution for this problem is an additional render pass that render your depth values in a float16 or float32 texture.






Re: Game Technologies: DirectX 101 sample from a DepthStencilSurface

Zezba

If thats the only way to do it then I guess it will have to do. I just was trying to find a way around that so I wouldn't have to render to 2 targets. Thanks for the help.