Jump to content
  • Advertisement
Sign in to follow this  
Tree Penguin

Render-to-texture and depth buffers...

This topic is 4976 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
Advertisement
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
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!