   Higher contrast in the depth buffer? [DX9]
  Edit: This was previously called Replacing depth stencil surface with a texture, then using that texture but I changed the subject :)I'm writing a program where I need to store the depth of each pixel. At the moment I'm using a pixel shader to write the z value of each pixel into a render target. I was wondering if it's possible to simply replace the depth stencil surface with a texture, and use that? My current method strikes me as wasteful, as the z value is being written to both the depth stencil surface by D3D and my render target by the pixel shader.Am I barking up the wrong tree here?Unfortunately I'm stuck in the past with DirectX 9.Thanks a lot peeps :)[Edited by - The Rug on May 20, 2009 11:05:00 AM]
  In D3D9 it is not possible to use the DepthStencilBuffer as a resource/texture in the shader.One exception would be a certain hack that can be used specifically for shadowmapping and works differently on nvidia and AMD respectively.   ;  Yeah like B_old says, DX9 doesn't expose that sort of functionality.  I really wouldn't worry about it though...rendering out depth to a texture is very cheap.   ;  Cheers, that's a bit of a pain but not too bad.Now my problem is the resolution of my depth texture. Only things really close to the camera are producing enough contrast to be visible. Am I correct in understanding that this is because depth is not stored in a linear fashion? Is there anything I can do about this? I've tried Googling but I'm not really sure what I'm after. Can you guys point me in the right direction?   ;  If you don't want non-linear depth, then don't store non-linear depth. [smile]There's a few good reasons to use linear depth instead.   