Here is the function I use to map the depthbuffer values into a range
between the near and far planes accounting for the mapping:

  double reverseComputeZ(double depthBufferZ) {
    // compute the world space distance taking into account perspective
    // projection interpolation
    return near / (1.0 - ((depthBufferZ * (far - near)) / far));
  }

I found it in Tomas Mueller's Real Time Rendering book.  I can't speak to
its portability on other platforms or APIs, but it works perfectly on Win2k
with OpenGL and Nvidia hardware.

-Pedro


----- Original Message -----
From: "Anthony Ashbrook" <
[EMAIL PROTECTED]>
To: <
[EMAIL PROTECTED]>
Sent: Thursday, May 24, 2001 8:13 AM
Subject: [JAVA3D] Interpretation of depth buffer values


> I have an application in which I need to interpret values
> in the depth buffer as distances relative to the camera or
> the image plane.
>
> I have been able to obtain the depth data using the
> DepthComponentFloat object but I am unsure of the
> mapping from these float values to distances. I am
> also concerned that this mapping might be dependant
> on the graphics hardware being used.
>
> Does anyone have any suggestions or comments on
> this subject.
>
> Regards.
>
> Anthony.
>
>
===========================================================================
> To unsubscribe, send email to
[EMAIL PROTECTED] and include in the
body
> of the message "signoff JAVA3D-INTEREST".  For general help, send email to
>
[EMAIL PROTECTED] and include in the body of the message "help".
>

Reply via email to