Solved

How does opengl Store the depth values?

Posted on 2004-10-06
5
340 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

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

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

Suggested Solutions

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 …
Performance in games development is paramount: every microsecond counts to be able to do everything in less than 33ms (aiming at 16ms). C# foreach statement is one of the worst performance killers, and here I explain why.
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…

773 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