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

Thread: Relationship between gl_FragDepth and fixed function depth test?

  1. #1
    Newbie Newbie
    Join Date
    Sep 2017
    Posts
    1

    Question Relationship between gl_FragDepth and fixed function depth test?

    I came across this scenario recently and after looking through both the GLSL and OpenGL specs, I have not been able to confirm or refute the following:

    Is the use of gl_FragDepth independent of the fixed function depth test? That is, can gl_FragDepth write to the depth buffer even when the depth test and/or depth write mask are disabled?

    I can reason why enabling the depth test is required for the depth write mask to be honored in the fixed function computation: fragments that pass the depth test use the depth write mask to determine what exactly to write. However, as I understand it, gl_FragDepth is not directly related to the depth fixed function test (it has implications for the early Z optimization, sure, but nothing beyond that).

    Does anyone how the answer to this question and, if so, can point me to their source?

    Thanks!

  2. #2
    Senior Member OpenGL Guru Dark Photon's Avatar
    Join Date
    Oct 2004
    Location
    Druidia
    Posts
    4,123
    Quote Originally Posted by re9012 View Post
    Is the use of gl_FragDepth independent of the fixed function depth test?
    They're dependent in that the latter (and depth writes) makes use of the former, if written.
    They're independent in the sense that depth tests and writes can be disabled whether or not you're writing gl_FragDepth.

    That is, can gl_FragDepth write to the depth buffer even when the depth test and/or depth write mask are disabled?
    No. Not through the normal depth buffer write-out by the fragment pipeline.

    Does anyone how the answer to this question and, if so, can point me to their source?
    Just read the spec language that talks about "fragment depth", "fragdepth", and "DEPTH_TEST". The gl_FragDepth mentions in the GL spec and the GLSL spec make it pretty clear if/when gl_FragDepth overrides the fixed-function computed fragment depth. And the DEPTH_TEST language is pretty blatant about when that resulting fragment depth is actually used and how.
    Last edited by Dark Photon; 09-16-2017 at 05:10 PM.

Posting Permissions

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