# 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.

## 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 on other sites
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 on other sites
Quote:
 Original post by MZPCan 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 on other sites
Right, that was lazy of me :) Thank you for your help!

##### 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.

1. 1
Rutin
26
2. 2
3. 3
JoeJ
20
4. 4
5. 5

• 10
• 10
• 9
• 9
• 10
• ### Forum Statistics

• Total Topics
631751
• Total Posts
3002087
×