Note: Loading a vertex shader turns off parts of the OpenGL pipeline (vertex shaders fully replace the "Texturing & Lighting unit")
Vertex shaders operate on each vertex, the vertex shader is executed for every vertex related OpenGL call (e.g. glVertex* or glDrawArrays).
* gl_Position is an special output variable for the transformed vertex coordinate
Common tasks for a vertex shader include:
* Vertex position transformation
* Per vertex lighting
The vertex shader runs from start to end for each and every vertex that's passed into the graphics card - the fragment process does the same thing at the pixel level. In most scenes there are a heck of a lot more pixel fragments than there are vertices - so the performance of the fragment shader is vastly more important and any work we can do in the vertex shader, we probably should.
A minum vertex shader example may
look like this: