OpenGL Vertex Shader Inputs

From GPWiki
Jump to: navigation, search

A OpenGL Shading Language (GLSL) vertex shader does not receive inputs through its main function. Instead, it gets input through predefined variables that it can access as though they were global variables

Special Output Variables

These variables are read and writeable.

  • vec4 gl_Position - The vertex shader must write to this variable.
  • float gl_PointSize - GL_VERTEX_PROGRAM_POINT_SIZE must be enabled to get this variable.
  • vec4 gl_ClipVertex

Attribute Inputs

These variables are read only.

  • vec4 gl_Vertex - The input vertex.
  • vec4 gl_Normal - The input normal.
  • vec4 gl_Color - The input color.
  • vec4 gl_SecondaryColor - The secondary input color.
  • vec4 gl_MultiTexCoord0 - The first texturing coordinate group.
  • vec4 gl_MultiTexCoord1 - The second texturing coordinate group.
  • vec4 gl_MultiTexCoord2 - The third texturing coordinate group.
  • vec4 gl_MultiTexCoord3 - The fourth texturing coordinate group.
  • vec4 gl_MultiTexCoord4 - The fifth texturing coordinate group.
  • vec4 gl_MultiTexCoord5 - The sixth texturing coordinate group.
  • vec4 gl_MultiTexCoord6 - The seventh texturing coordinate group.
  • vec4 gl_MultiTexCoord7 - The eighth texturing coordinate group.
  • float gl_FogCoord - The fog coordinate.

Varying Outputs

These variables will be interpolated and fed into the fragment shader. These variables are read and writable.

  • vec4 gl_FrontColor - The front color.
  • vec4 gl_BackColor - GL_VERTEX_PROGRAM_TWO_SIDE must be enabled.
  • vec4 gl_FrontSecondaryColor - The Secondary front color.
  • vec4 gl_BackSecondaryColor - The secondary back color.
  • vec4 gl_TexCoord[] - An array with maximum size = gl_MaxTextureCoords.
  • float gl_FogFragCoord - The fog fragment coordinate.