Difference between revisions of "Geometry Shader/Defined Inputs"

From OpenGL Wiki
Jump to: navigation, search
(separate page for built-in inputs.)
 
(Formatting.)
Line 10: Line 10:
 
</source>
 
</source>
  
These values don't really mean anything; they're just whatever the prior stage wrote to them.
+
These variables have only the meaning the prior shader stage(s) that passed them gave them.  
  
 
There are some GS input values that are based on primitives, not vertices. These are not aggregated into arrays. These are:
 
There are some GS input values that are based on primitives, not vertices. These are not aggregated into arrays. These are:
Line 19: Line 19:
 
</source>
 
</source>
  
{{code|gl_PrimitiveIDIn}} is the current input primitive's ID, based on the number of primitives processed by the GS since the current rendering command started.
+
; {{code|gl_PrimitiveIDIn}}
 
+
: the current input primitive's ID, based on the number of primitives processed by the GS since the current rendering command started.
{{code|gl_InvocationID}} is the current instance, as defined when [[Geometry Shader#Instancing|instancing geometry shaders]].
+
; {{code|gl_InvocationID}}
 +
: the current instance, as defined when [[Geometry Shader#Instancing|instancing geometry shaders]].

Revision as of 08:49, 26 July 2013

Geometry Shaders provide the following built-in input variables:

in gl_PerVertex
{
  vec4 gl_Position;
  float gl_PointSize;
  float gl_ClipDistance[];
} gl_in[];

These variables have only the meaning the prior shader stage(s) that passed them gave them.

There are some GS input values that are based on primitives, not vertices. These are not aggregated into arrays. These are:

in int gl_PrimitiveIDIn;
in int gl_InvocationID;  //Requires GLSL 4.0 or ARB_gpu_shader5
gl_PrimitiveIDIn
the current input primitive's ID, based on the number of primitives processed by the GS since the current rendering command started.
gl_InvocationID
the current instance, as defined when instancing geometry shaders.