Open main menu

Wikibooks β

OpenGL Programming/Shaders reference

< OpenGL Programming


Vertex shaderEdit

Input variablesEdit

Output variablesEdit

  • vec4 gl_Position : vertex homegeneous coordinates in projection space
  • float gl_PointSize : using rendering points, size of the point

Fragment shaderEdit

Input variablesEdit

  • vec4 gl_FragCoord : pixel coordinates (x,y) + fragment depth (z)
  • bool gl_FrontFacing : is pixel facing the camera or the opposite direction? (used in two-sided lighting)
  • vec2 gl_PointCoord : when using Point Sprites, position within the point

Output variablesEdit

  • vec4 gl_FragColor : RGBA color to use
  • vec4 gl_FragData[gl_MaxDrawBuffers] : alternative to gl_FragColor when drawing to multiple buffers