Sign in to follow this  
Alex-R

Rendering depth map without pixel shaders

Recommended Posts

Evil Steve    2017
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?

Share this post


Link to post
Share on other sites
Evil Steve    2017
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.

Share this post


Link to post
Share on other sites
Alex-R    126
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.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster   
Guest 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?

Share this post


Link to post
Share on other sites
Nik02    4348
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.

Share this post


Link to post
Share on other sites
jaafit    116
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?

Share this post


Link to post
Share on other sites
Evil Steve    2017
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.

Share this post


Link to post
Share on other sites
Nik02    4348
Quote:
Original post by jaafit
But if lighting is disabled, ambient light doesn't have an effect. :S


This can be corrected by leaving the lighting state on. If both the ambient light and the materials' ambient color are white, this will wash out other colors.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this