Solved

How does opengl Store the depth values?

Posted on 2004-10-06
5
339 Views
Last Modified: 2013-12-06
Hi,
I would like to know how the depth buffer precision varies depending on the
near/far ratio given a depth buffer of 24bits depth per pixel.
( Mathematical relation between the near/far, original co-ordinates and depth precision bits)
0
Comment
Question by:gizmo_thunder
5 Comments
 
LVL 17

Accepted Solution

by:
davebytes earned 50 total points
ID: 12253624
If using standard Z buffer, Near->Far Z values are normalized to 0.0-1.0, and stored as such.  However, since the standard transformation is logarithmic Z, the 'precision' drops off quickly as you get deeper into the scene -- that is, transformed Z isn't linear.

If using a W buffering approach, W >is< stored linear, so you get more consistant visuals across the entire scene depth -- however, at the loss of high precision (say, object intersections) for objects nearer to the camera.

Since Z values are translated from floating point into an integer representation, obviously the less bits of Z buffer, the less delta-Z that can be represented -- and again, since Z isn't linear, the less bits of Z, the more pixels may end up with EQUAL z values in 'z buffer space' even though their actual floating-point Z values may have been different.

Did that help?

(And, this isn't actually OpenGL, it's 3D cards in general -- though some 3D cards do tricky things with the Z buffer under the covers..)

-d
0
 

Author Comment

by:gizmo_thunder
ID: 12256088
Hmm actually i know about this logarithmic thing and all but what i want to know is
exact relation ship between the bit representation and the depth value retrieved using
glReadPixels.
I found the following information useful.. just in case anybody else requires it..
http://www.opengl.org/resources/faq/technical/depthbuffer.htm
just found it yesterday so.. :)
0
 

Assisted Solution

by:davidmaxwaterman
davidmaxwaterman earned 50 total points
ID: 12357393
The exact relationship is not defined by OpenGL. It is dependant on your graphics hardware. The way graphics hardware handles it varies considerably, even when from the same manufacturer.

However, if you're interested in the 'z' values, then you can translate each of the values using the glu function gluUnProject() :

http://www.opengl.org/resources/faq/technical/glu.htm#0070

This should take account of the specifc hardware involded.

Hope this helps.

Max.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

What is RenderMan: RenderMan is a not any particular piece of software. RenderMan is an industry standard, defining set of rules that any rendering software should use, to be RenderMan-compliant. Pixar's RenderMan is a flagship implementation of …
Recently, in one of the tech-blogs I usually read, I saw a post about the best-selling video games through history. The first place in the list is for the classic, extremely addictive Tetris. Well, a long time ago, in a galaxy far far away, I was…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
Hi friends,  in this video  I'll show you how new windows 10 user can learn the using of windows 10. Thank you.

910 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now