Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 6 of 6

Thread: Extracting z coordinate from z buffer

  1. #1
    Junior Member Newbie
    Join Date
    Feb 2000
    Location
    Florianopolis - SC - Brazil
    Posts
    5

    Extracting z coordinate from z buffer

    Is it possible to extract the z coordinate of a fragment from the information stored in the z buffer?

    If yes, is this solution portable amongst desktop graphics accelerators and hi-end workstations?

    Cheers,

    camelo
    Marcelo A. Camelo

  2. #2
    Senior Member OpenGL Guru Relic's Avatar
    Join Date
    Apr 2000
    Posts
    2,527

    Re: Extracting z coordinate from z buffer

    1.) Yes, glReadPixels with GL_DEPTH_COMPONENT.
    2.) Yes, this is a standard OpenGL method. The performance may vary among implementations.

  3. #3
    Junior Member Newbie
    Join Date
    Feb 2000
    Location
    Florianopolis - SC - Brazil
    Posts
    5

    Re: Extracting z coordinate from z buffer

    Ok. So far so good. Now I need to convert the z information extracted from the z buffer back to camera space. How can I do that?

    Thaks,

    --camelo
    Marcelo A. Camelo

  4. #4
    Junior Member Newbie
    Join Date
    Feb 2000
    Location
    Florianopolis - SC - Brazil
    Posts
    5

    Re: Extracting z coordinate from z buffer

    Found it...

    gluUnProject

    Thanks anyway.
    Marcelo A. Camelo

  5. #5
    Intern Contributor
    Join Date
    Mar 2003
    Location
    Suffolk, United Kingdom
    Posts
    98

    Re: Extracting z coordinate from z buffer

    Does gluUnproject() do what you want?

    Or have I missed the point....

  6. #6
    Member Regular Contributor
    Join Date
    Jun 2002
    Posts
    371

    Re: Extracting z coordinate from z buffer

    Originally posted by camelo:
    Now I need to convert the z information extracted from the z buffer back to camera space.
    Haven't tried that myself, but I've heard people say that even though the data in the z-buffer are depth values it might not be that easy to map them back to camera space.To my knowledge OpenGL doesn't specify what format the depth values are stored in, it is implementation specific.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •