Vertex Shader/Defined Inputs
Jump to navigation
Jump to search
Vertex Shaders have the following built-in input variables.
in int gl_VertexID;
in int gl_InstanceID;
in int gl_DrawID; // Requires GLSL 4.60 or ARB_shader_draw_parameters
in int gl_BaseVertex; // Requires GLSL 4.60 or ARB_shader_draw_parameters
in int gl_BaseInstance; // Requires GLSL 4.60 or ARB_shader_draw_parameters
- 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). If you have GLSL 4.60, you may use gl_BaseInstance to compute the proper instance index.
- gl_DrawID
- the index of the drawing command within multi-draw rendering commands (including indirect multi-draw commands). The first draw command has an ID of 0, increasing by one as the renderer passes through drawing commands.
- This value will always be a Dynamically Uniform Expression.
- gl_BaseVertex
- the value of the baseVertex parameter of the rendering command. If the rendering command did not include that parameter, the value of this input will be 0.
- gl_BaseInstance
- the value of the baseInstance parameter of the instanced rendering command. If the rendering command did not include this parameter, the value of this input will be 0.