Scroll to navigation

GL_FRAGCOORD(3G) [FIXME: manual] GL_FRAGCOORD(3G)

NAME

gl_FragCoord - contains the window-relative coordinates of the current fragment

DECLARATION

in vec4 gl_FragCoord ;.SH "DESCRIPTION"

Available only in the fragment language, gl_FragCoord is an input variable that contains the window relative coordinate (x, y, z, 1/w) values for the fragment. If multi-sampling, this value can be for any location within the pixel, or one of the fragment samples. This value is the result of fixed functionality that interpolates primitives after vertex processing to generate fragments. The z component is the depth value that would be used for the fragment's depth if no shader contained any writes to gl_FragDepth().

gl_FragCoord may be redeclared with the additional layout qualifier identifiers origin_upper_left or pixel_center_integer. By default, gl_FragCoord assumes a lower-left origin for window coordinates and assumes pixel centers are located at half-pixel centers. For example, the (x, y) location (0.5, 0.5) is returned for the lower-left-most pixel in a window. The origin of gl_FragCoord may be changed by redeclaring gl_FragCoord with the origin_upper_left identifier. The values returned can also be shifted by half a pixel in both x and y by pixel_center_integer so it appears the pixels are centered at whole number pixel offsets. This moves the (x, y) value returned by gl_FragCoord of (0.5, 0.5) by default to (0.0, 0.0) with pixel_center_integer.

If gl_FragCoord is redeclared in any fragment shader in a program, it must be redeclared in all fragment shaders in that program that have static use of gl_FragCoord. Redeclaring gl_FragCoord with any accepted qualifier affects only gl_FragCoord.x and gl_FragCoord.y. It has no affect on rasterization, transformation or any other part of the OpenGL pipline or language features.

VERSION SUPPORT

OpenGL Shading Language Version
Variable Name 1.10 1.20 1.30 1.40 1.50 3.30 4.00 4.10 4.20 4.30 4.40 4.50
gl_FragCoord

SEE ALSO

gl_FragCoord()

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

Copyright © 2011-2014 Khronos Group

04/12/2021 [FIXME: source]