Sign in to follow this  
MZP

Depth map error

Recommended Posts

MZP    124
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
MZP    124
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
MJP    19754
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

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