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 3 of 3

Thread: gl_FragCoord question

  1. #1
    Intern Contributor
    Join Date
    Sep 2012
    Posts
    76

    gl_FragCoord question

    Greetings:
    Question: What is the range of gl_FragCoord.z (frag depth) and which end is closest/farthest from the eye?
    Thanks,
    Sam

  2. #2
    Intern Contributor uwi2k2's Avatar
    Join Date
    Mar 2011
    Posts
    98
    hi sam,

    the fragCoord is a strange vec3.
    in the x and y it holds the window coords and in the z it holds the depth information from 0 to 1
    where 1 is the most distance point in the szene and 0 is just the camera lens surface.

    cu
    uwi
    uwi2k2 - OpenGL Trainer: www.opengl-trainer.com
    ---------------------------------------------------------
    Free Programming Helpline: www.programming-hotline.com
    ---------------------------------------------------------
    A Friday Night Programmer: www.uwiworld.net

  3. #3
    Member Regular Contributor
    Join Date
    Jun 2013
    Posts
    495
    Quote Originally Posted by sam_thedancer View Post
    Question: What is the range of gl_FragCoord.z (frag depth) and which end is closest/farthest from the eye?
    The limits are as set by glDepthRange(). In the initial state (equivalent to glDepthRange(0,1)), the range is 0 to 1 with 0 at the near plane and 1 at the far plane. glDepthRange() clamps its inputs to the range [0,1], so you will never encounter values outside of that range. However, there's no requirement that the near-plane value is less than the far-plane value; it is possible to reverse them.

    gl_FragCoord.z is the value which is written to the depth buffer (after conversion to fixed point where applicable) if the fragment shader doesn't write to gl_FragDepth.

Posting Permissions

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