Jump to content
  • Advertisement
Sign in to follow this  
MZP

Depth map error

This topic is 3178 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

Hello, I'm trying to render the depth buffer to a texture and while it is working I get some strange results. The problem is that the depth value is mostly white. It's only until I get extremely close that it darkens, and even then it never gets specially dark. In my application I have a water plane where I am currently rendering the depth of the underlying terrain, that's why the attached image might look a bit weird. I realize I haven't provided much info, but I don't even know where to begin. Camera range goes from 1 to 1000. The code that sets up the render target was more or less copied from Frank D Luna's DirectX book. http://img21.imageshack.us/img21/9341/depthmaperror.png

Share this post


Link to post
Share on other sites
Advertisement
I see, thanks.

I increased the distance to the near clip plane
and got somewhat better results. The weird thing
is that the sample code I use for reference (Frank
D Luna's code) has a much closer near clip plane
and yet his depth map look a lot better.
(http://www.d3dcoder.net/Images/Book3/chap13.jpg)

Can I 'linearize' it somehow?

Share this post


Link to post
Share on other sites
Quote:
Original post by MZP
Can I 'linearize' it somehow?


Look at the equation in the section 'The Resolution of Z' in the link I posted. Rearrange the equation to find 'd'.

Share this post


Link to post
Share on other sites
If you want to store linear depth, you can just store something other than post-projection z/w. For instance you could take the z component of the view-space pixel position and divide it by the distance to your far-clip plane.

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!