Built-in Variables

gl_NumWorkGroups, gl_WorkGroupID, gl_LocalInvocationID, gl_GlobalInvocationID, gl_LocalInvocationIndex, gl_WorkGroupSize (constant).

11.1 Vertex shader

index of the current vertex (gl_VertexIndex in Vulkan) instance index for instanced draws (gl_InstanceIndex in Vulkan) draw index in multi-draw (4.60) gl_BaseVertex, gl_BaseInstance clip-space position (must write) size of rendered points (enable GL_PROGRAM_POINT_SIZE) user clip planes

11.2 Fragment shader

window coordinates (x, y pixel center at.5, z depth, w = 1/w_clip) whether the primitive faces the camera coordinates within a point sprite (0..1)

gl_SampleID, gl_SamplePosition, gl_SampleMaskIn[] gl_Layer, gl_ViewportIndex helper invocation for derivatives override depth (disables early-Z) gl_FragColor, gl_FragData[] legacy outputs (ES 1.00 / ≤ 1.20)

11.3 Compute shader

gl_NumWorkGroups, gl_WorkGroupID, gl_LocalInvocationID, gl_GlobalInvocationID, gl_LocalInvocationIndex, gl_WorkGroupSize (constant).

11.4 Geometry/tessellation

gl_in[] (per-vertex inputs: gl_Position, ...), gl_PrimitiveIDIn, gl_InvocationID, gl_TessLevelOuter[4], gl_TessLevelInner[2], gl_TessCoord, gl_PatchVerticesIn, gl_Layer.

11.5 Built-in constants

gl_MaxVertexAttribs, gl_MaxTextureImageUnits, gl_MaxDrawBuffers, gl_MaxComputeWorkGroupSize, gl_MaxClipDistances, etc. (query actual limits from the host with glGetIntegerv).