microZEUS
The whole stack, hand-drawn.

◄ Wiki / Graphics

gl_PrimitiveID / gl_Layer

A pair of shader built-ins: one identifies the current primitive, the other picks which render-target layer to write to.

gl_PrimitiveID gives each primitive a running index so shaders can vary behavior per triangle, while gl_Layer selects a slice of a layered framebuffer to render into. Together they often appear in layered-rendering techniques where a single pass draws many primitives across many render-target layers. They are complementary handles: one about 'which primitive,' the other about 'which destination.'

See also

  • gl_PrimitiveIDgl_PrimitiveID is a shader built-in giving the index number of the primitive currently being processed.
  • gl_Layergl_Layer is a shader built-in variable that selects which layer of a layered render target to draw into.
  • geometry shaderA geometry shader is a programmable GPU stage that can take a primitive and emit new primitives from it.

Referenced by

gl_PrimitiveID