Difference between revisions of "Vertex Shader/Defined Inputs"

From OpenGL Wiki
Jump to navigation Jump to search
m (Bot: Updating section links to use redirects.)
m (Bot: Updating section links to use redirects.)
Line 11: Line 11:
 
; {{code|gl_InstanceID}}
 
; {{code|gl_InstanceID}}
 
: the index of the current instance when doing some form of [[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 [[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.
{{warning|This value '''''does not''''' follow the [[Vertex Rendering#Instancing|{{param|baseinstance}} provided by some instanced rendering functions]]. {{code|gl_InstanceID}} always falls on the half-open range [0, {{param|instancecount}}).}}
+
{{warning|This value '''''does not''''' follow the [[Instancing|{{param|baseinstance}} provided by some instanced rendering functions]]. {{code|gl_InstanceID}} always falls on the half-open range [0, {{param|instancecount}}).}}

Revision as of 16:38, 6 May 2015

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.
Warning: This value does not follow the baseinstance​ provided by some instanced rendering functions. gl_InstanceID always falls on the half-open range [0, instancecount​).