Solved

How does opengl Store the depth values?

Posted on 2004-10-06
5
348 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Want Experts Exchange at your fingertips?

With Experts Exchange’s latest app release, you can now experience our most recent features, updates, and the same community interface while on-the-go. Download our latest app release at the Android or Apple stores today!

Question has a verified solution.

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

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…
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.
There are cases when e.g. an IT administrator wants to have full access and view into selected mailboxes on Exchange server, directly from his own email account in Outlook or Outlook Web Access. This proves useful when for example administrator want…
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…

632 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