OpenGL Programming/Shaders reference

From Wikibooks, open books for an open world
Jump to navigation Jump to search

Vertex shader1[edit | edit source]

Input variables[edit | edit source]

Output variables[edit | edit source]

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

Fragment shader[edit | edit source]

Input variables[edit | edit source]

  • 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 variables[edit | edit source]

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


References[edit | edit source]

  • "OpenGL ES Shading Language 1.0.17 Specification" (PDF). Khronos.org. 2009-05-12. Retrieved 2011-09-25.

< OpenGL Programming

Browse & download complete code