Rendering depth map without pixel shaders

Started by
10 comments, last by Nik02 17 years, 1 month ago
I'd like to know, is there any way to render scene depth to the RTT without pixel shaders?
Advertisement
If you have a lockable depth buffer (E.g. D3DFMT_D16_LOCKABLE), then you could lock the depth buffer, read the values, and then render them however you like.

Why do you need to do this though?
But what can I do if depth buffer is not lockable (for example D24X8)?
Nothing (Someone correct me if I'm wrong). The depth buffer could be in any format, cards are free to optimize it how they want (E.g. having sperate depth and stencil buffers, using some compressed format internally, etc), which is why you can't access it directly from D3D.

You might be able to do some sort of basic stuff with the stencil buffer, by setting the stencil op to increment when the Z test fails (D3DRS_STENCILZFAIL), but I wouldn't expect much from it.

Again - what exactly are you trying to do? There might be another way to go about it.
I'm working on the water effect, and I need to render water with fog effect. But now I'm rendering underwater scene without fog, so I'm creating depth map and then use it for calculate color of water.
Anyway, thanks for the answer.
cant you just render to a texture with all geometry as pure white, and render it with fog as black, starting from the camera and ending at your max view distance. Wouldnt this make everything in the foreground white and everything in the background black? Or am I missing the question?
Quote:Original post by Anonymous Poster
cant you just render to a texture with all geometry as pure white, and render it with fog as black, starting from the camera and ending at your max view distance. Wouldnt this make everything in the foreground white and everything in the background black? Or am I missing the question?


This is a very good technique for the purposes of the original poster.

By modulating the depth factor with the scene color and the water color, it is very easy to apply the desired effect.

As a side note, I would render black geometry with white fog so as to establish that the brighter the resulting pixels are, the deeper distances they represent. This would make the subsequent color manipulation a bit more intuitive without the need to invert the effective depth values.

Niko Suni

It's a good idea, i think. I'll try it. Thanks a lot!
Quote:cant you just render to a texture with all geometry as pure white

How would you do that? Is there a global DirectX setting you can apply (like fill mode or cull mode) or do you just need to have a really clever rendering engine?
Quote:Original post by jaafit
Quote:cant you just render to a texture with all geometry as pure white

How would you do that? Is there a global DirectX setting you can apply (like fill mode or cull mode) or do you just need to have a really clever rendering engine?
Not setting any textures, disabling lighting and setting the ambient light level to 0xffffffff should do it.

This topic is closed to new replies.

Advertisement