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

From OpenGL Wiki
Jump to: navigation, search
(Formatting.)
(Updating info with data from bug.)
Line 15: Line 15:
 
: the index of the current patch in the series of patches being processed for this draw call.
 
: the index of the current patch in the series of patches being processed for this draw call.
  
{{note|The [[Tessellation#Tessellation primitive generator|tessellation primitive generator]] will cull patches that have a zero for one of the outer tessellation levels. It is not clear from the OpenGL specification whether {{code|gl_PrimitiveID}} will be affected by this.}}
+
{{note|The [[Tessellation#Tessellation primitive generator|tessellation primitive generator]] will cull patches that have a zero for one of the outer tessellation levels. [[http://www.khronos.org/bugzilla/show_bug.cgi?id=754 The intent of the specification]] is that {{code|gl_PrimitiveID}} will still be incremented for culled patches. So the primitive ID for the TCS is the same as for the TES. But this is not entirely clear from the spec itself.}}
  
 
The TES also has access to the tessellation levels provided for the patch by the TCS or by OpenGL:
 
The TES also has access to the tessellation levels provided for the patch by the TCS or by OpenGL:

Revision as of 09:46, 10 August 2013

Tessellation Evaluation Shaders have the following built-in inputs.

in vec3 gl_TessCoord;
in int gl_PatchVerticesIn;
in int gl_PrimitiveID;
gl_TessCoord
the location within the tessellated abstract patch for this particular vertex. Every input parameter other than this one will be identical for all TES invocations within a patch.
Which components of this vec3 that have valid values depends on the abstract patch type. For isolines and quads, only the XY components have valid values. For triangles, all three components have valid values. All valid values are normalized floats (on the range [0, 1]).
gl_PatchVerticesIn
the vertex count for the patch being processed. This is either the output vertex count specified by the TCS, or the patch vertex size specified by glPatchParameter if no TCS is active. Attempts to index per-vertex inputs by a value greater than or equal to gl_PatchVerticesIn results in undefined behavior.
gl_PrimitiveID
the index of the current patch in the series of patches being processed for this draw call.
Note: The tessellation primitive generator will cull patches that have a zero for one of the outer tessellation levels. [The intent of the specification] is that gl_PrimitiveID will still be incremented for culled patches. So the primitive ID for the TCS is the same as for the TES. But this is not entirely clear from the spec itself.

The TES also has access to the tessellation levels provided for the patch by the TCS or by OpenGL:

patch in float gl_TessLevelOuter[4];
patch in float gl_TessLevelInner[2];

Only the outer and inner levels actually used by the abstract patch are valid. For example, if this TES uses isolines, only gl_TessLevelOuter[0] and gl_TessLevelOuter[1] will have valid values.

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

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.