Difference between revisions of "Tessellation Control Shader/Defined Inputs"

From OpenGL.org
Jump to: navigation, search
m (typo)
(Formatting.)
 
Line 7: Line 7:
 
</source>
 
</source>
  
{{code|gl_PatchVerticesIn}} is the number of vertices in the input patch. {{code|gl_PrimitiveID}} is the index of the current patch within this rendering command. {{code|gl_InvocationID}} is the index of the TCS invocation within this patch. A TCS invocation writes to per-vertex output variables by using this to index them.
+
; {{code|gl_PatchVerticesIn}}
 +
: the number of vertices in the input patch.
 +
; {{code|gl_PrimitiveID}}
 +
: the index of the current patch within this rendering command.
 +
; {{code|gl_InvocationID}}
 +
: the index of the TCS invocation within this patch. A TCS invocation writes to per-vertex output variables by using this to index them.
  
 
The TCS also takes the built-in variables output by the [[Vertex Shader#Outputs|vertex shader]]:
 
The TCS also takes the built-in variables output by the [[Vertex Shader#Outputs|vertex shader]]:
Line 20: Line 25:
 
</source>
 
</source>
  
Note that just because {{code|gl_in}} is defined to have {{code|gl_MaxPatchVertices}} entries does not mean that you can access beyond {{code|gl_PatchVerticesIn}} and get reasonable values.
+
Note that just because {{code|gl_in}} is defined to have {{code|gl_MaxPatchVertices}} entries does not mean that you can access beyond {{code|gl_PatchVerticesIn}} and get reasonable values. These variables have only the meaning the vertex shader that passed them gave them.
 
 
Note that every TCS invocation for an input patch has access to the same data (except for {{code|gl_InvocationID}}, which will be different for each). So a TCS invocation can look at the input vertex data for the entire input patch
 

Latest revision as of 02:05, 26 July 2013

Tessellation Control Shaders provide the following built-in input variables:

 in int gl_PatchVerticesIn;
 in int gl_PrimitiveID;
 in int gl_InvocationID;
gl_PatchVerticesIn​
the number of vertices in the input patch.
gl_PrimitiveID​
the index of the current patch within this rendering command.
gl_InvocationID​
the index of the TCS invocation within this patch. A TCS invocation writes to per-vertex output variables by using this to index them.

The TCS also takes the built-in variables output by the vertex shader:

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

Note that just because gl_in​ is defined to have gl_MaxPatchVertices​ entries does not mean that you can access beyond gl_PatchVerticesIn​ and get reasonable values. These variables have only the meaning the vertex shader that passed them gave them.