Geometry Shader Inputs

The input to the geometry shader is fed by the output of the vertex shader, or if tessellation is active, the output of the tessellation evaluation shader.3 As the geometry shader runs once per input primitive, outputs from the previous stage (vertex shader or tessellation evaluation shader) become arrays in the geometry shader. This includes all user-defined inputs and the special built-in input variable, gl_in, which is array containing the built-in outputs that are available in the previous stage. The gl_in input is implicitly declared as an interface block. The definition of gl_in is shown in Example 10.3.

3. Tessellation shaders are covered in detail in Chapter 9.

Example 10.3. Implicit Declaration of gl_in[]

Get OpenGL Programming Guide: The Official Guide to Learning OpenGL, Version 4.3, Eighth Edition now with the O’Reilly learning platform.

O’Reilly members experience live online training, plus books, videos, and digital content from nearly 200 publishers.