Solved

How does opengl Store the depth values?

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

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

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 …
Artificial Intelligence comes in many forms, and for game developers, Path-Finding is an important ability for making an NPC (Non-Playable Character) maneuver through terrain.  A* is a particularly easy way to approach it.  I’ll start with the algor…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…

758 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

19 Experts available now in Live!

Get 1:1 Help Now