Sign in to follow this  

Render-to-texture and depth buffers...

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

Hi, what is the right way to get the original depth value out of a depth buffer that's rendered to a texture? Is it value*(farplane-nearplane)+nearplane? I guess not as i get strange results, the values i get are far too high, like the values start at 0.7 or so. Has anyone got the right formula? Thanks

Share this post


Link to post
Share on other sites
find out how Z values get mapped from world space to clipspace and reverse run it backwards [grin]

btw, you'll probably never get the value back completely, there probably wont be enuff precission in texture to map a 0.0f=>1.0f range back into the near=>far range precisely

Share this post


Link to post
Share on other sites
As _the_phanton_ said :D

as place where this formula is explicitly stated and with a few counting examples are on http://www.opengl.org/resources/faq/technical/depthbuffer.htm

Go check out question "12.050 Why is my depth buffer precision so poor?" it contains all the formulas you need to reverse the process.

Share this post


Link to post
Share on other sites
>>I guess not as i get strange results, the values i get are far too high, like the values start at 0.7 or so. Has anyone got the right formula?<<

check the math to see why most values are in the range 0.9->1.0 and not say 0.5

Share this post


Link to post
Share on other sites

This topic is 4763 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.

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