Vertex Shader/Defined Inputs: Difference between revisions

From OpenGL Wiki
Jump to navigation Jump to search
Page for built-in vertex shader inputs.
 
Formatting.
Line 6: Line 6:
</source>
</source>


{{code|gl_VertexID}} is the index of the vertex currently being processed. When using non-indexed rendering, it is the effective index of the current vertex (the number of vertices processed + the {{param|first}} value). For indexed rendering, it is the index used to fetch this vertex from the buffer.
; {{code|gl_VertexID}}
 
: the index of the vertex currently being processed. When using non-indexed rendering, it is the effective index of the current vertex (the number of vertices processed + the {{param|first}} value). For indexed rendering, it is the index used to fetch this vertex from the buffer.
{{note|{{code|gl_VertexID}} will have the [[Vertex_Rendering#Base_Index|base vertex]] applied to it.}}
{{note|{{code|gl_VertexID}} will have the [[Vertex_Rendering#Base_Index|base vertex]] applied to it.}}
 
; {{code|gl_InstanceID}}
{{code|gl_InstanceID}} is the index of the current instance when doing some form of [[Vertex_Rendering#Instancing|instanced rendering]]. The instance count ''always'' starts at 0, even when using base instance calls. When not using instanced rendering, this value will be 0.
: the index of the current instance when doing some form of [[Vertex_Rendering#Instancing|instanced rendering]]. The instance count ''always'' starts at 0, even when using base instance calls. When not using instanced rendering, this value will be 0.

Revision as of 07:00, 26 July 2013

Vertex Shaders have the following built-in input variables.

in int gl_VertexID;
in int gl_InstanceID;
gl_VertexID
the index of the vertex currently being processed. When using non-indexed rendering, it is the effective index of the current vertex (the number of vertices processed + the first​ value). For indexed rendering, it is the index used to fetch this vertex from the buffer.
Note: gl_VertexID will have the base vertex applied to it.
gl_InstanceID
the index of the current instance when doing some form of instanced rendering. The instance count always starts at 0, even when using base instance calls. When not using instanced rendering, this value will be 0.