Your company here — click to reach over 10,000 unique daily visitors

gl_FragCoord.3G - Man Page

contains the window-relative coordinates of the current fragment


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 pipeline or language features.

Version Support

OpenGL Shading Language Version
Variable Name1.101.201.301.401.503.304.

See Also


Referenced By

gl_FragDepth.3G(3), gl_FrontFacing.3G(3), gl_PointCoord.3G(3), gl_SampleMask.3G(3), gl_SampleMaskIn.3G(3), gl_SamplePosition.3G(3).