Jump to content
  • Advertisement
Sign in to follow this  
Alex-R

Rendering depth map without pixel shaders

This topic is 4142 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I'd like to know, is there any way to render scene depth to the RTT without pixel shaders?

Share this post


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

Share this post


Link to post
Share on other sites
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
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
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
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
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
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
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!