GL_FRAGDEPTH(3G)
π GL_FRAGDEPTH (3G) π
ok so bestie, welcome to the 3G manual page for gl_FragDepth β yes it's a lowercase-gl_ situation, yes that's normal, no we don't ask questions β¨
π NAME π
gl_FragDepth β the variable that literally sets the depth value for the current fragment. main character energy fr fr π
πΈ DECLARATION πΈ
out float gl_FragDepth ;
that's it. that's the whole declaration. she's simple, she's a float, she's an out variable. obsessed π«Ά
β¨ DESCRIPTION β¨
okay so here's the tea, and this part is only available in the fragment language β no vertex shader, no geometry shader, don't even try it π
gl_FragDepth is an output variable that you use to establish the depth value for the current fragment. simple as that.
now for the β¨ nuance β¨ (iykyk):
- if depth buffering is enabled and no shader writes to
gl_FragDepth, then the fixed function value for depth will be used β that value is contained in the z component ofgl_FragCoord() - otherwise, the value written to
gl_FragDepthis used
and now the part where you gotta pay attention bestie, because this is the π gotcha π:
If a shader statically assigns togl_FragDepth, then the value of the fragment's depth may be undefined for executions of the shader that take that path. that is, if the set of linked fragment shaders statically contain a write togl_FragDepth, then it is responsible for always writing it.
translation: you touched it, it's yours now. you commit to writing that depth on every path, or you get undefined behavior. no halfsies, no take-backs. periodt π
π VERSION SUPPORT π
vibe check on which OpenGL Shading Language versions have gl_FragDepth β she's been an icon in every single one of these, no cap:
1.10β β yup1.20β β yup1.30β β yup1.40β β yup1.50β β yup3.30β β yup4.00β β yup4.10β β yup4.20β β yup4.30β β yup4.40β β yup4.50β β yup
so yeah, the variable gl_FragDepth is checked off across the entire board π§ it ate and left no crumbs
π¦ SEE ALSO π¦
gl_FragCoord()β go read that one too, bestie, they're literally siblings π«Ά
π₯ COPYRIGHT π₯
Copyright Β© 2011-2014 Khronos Group. This material may be distributed subject to the terms and conditions set forth in the Open Publication License, v 1.0, 8 June 1999. http://opencontent.org/openpub/.
Copyright Β© 2011-2014 Khronos Group
π and that's the whole page!! source:[FIXME: source], dated08/09/2021, pageGL_FRAGDEPTH(3G)β mwah, slay, go write your depth values responsibly πβ¨πΈ
π¦ where this page comes from
- centos-stream 9: gl-manpages 1.1-24.20190306.el9 Β· MIT and Open Publication
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms