Re: Depth Buffer

New Message Reply Date view Thread view Subject view Author view

Steve Baker (sbaker++at++link.com)
Thu, 25 Sep 1997 12:38:55 -0500 (CDT)


On Thu, 25 Sep 1997, Paul Berridge wrote:

> Can anyone tell me how to calculate depth from the value stored in the
> depth buffer?
>
> I guessed that it would be something like:
>
> depth = nearClip*farClip/((1-dBuffVal)*farClip+dBuffVal*nearClip),
>
> which gives depth values between the near and far clip ranges, but the
> results aren't quite right.
>
> Alternatively, is there a Performer function I can call to calculate it
> for me?

This comes up about every 6 months....here is the stock reply...

  The 'official' SGI solution to this is...

    z = value in z buffer after rendering (input)
    range = distance to pixel in database units (output)

    np = distance to near clipping plane
    fp = distance far clipping plane
                           (as read from pfGetChanNearFar)

    nz = near-clip z value
    fz = far-clip z value
                           (as passed to lsetdepth for IrisGL,
                            as read from glGetIntegerv ( GL_DEPTH_RANGE,...) for OpenGL)

    For each Z-buffer value:

                     fp*np(fz-nz)
                     ------------
                        fp-np
    - range = --------------------------
                  (fp+np)(fz-nz) fz+nz
              z - -------------- - -----
                     2(fp-np) 2

I hope this helps...

Steve Baker 817-619-8776 (Vox/Vox-Mail)
Hughes Training Inc. 817-619-4028 (Fax)
2200 Arlington Downs Road SBaker++at++link.com (eMail)
Arlington, Texas. TX 76005-6171 SJBaker1++at++airmail.net (Personal eMail)
http://www.hti.com http://web2.airmail.net/sjbaker1 (personal)

** Beware of Geeks bearing GIF's. **

=======================================================================
List Archives, FAQ, FTP: http://www.sgi.com/Technology/Performer/
            Submissions: info-performer++at++sgi.com
        Admin. requests: info-performer-request++at++sgi.com


New Message Reply Date view Thread view Subject view Author view

This archive was generated by hypermail 2.0b2 on Mon Aug 10 1998 - 17:56:00 PDT

This message has been cleansed for anti-spam protection. Replace '++at++' in any mail addresses with the '@' symbol.