\( \newcommand{\P}[]{\unicode{xB6}} \newcommand{\AA}[]{\unicode{x212B}} \newcommand{\empty}[]{\emptyset} \newcommand{\O}[]{\emptyset} \newcommand{\Alpha}[]{Α} \newcommand{\Beta}[]{Β} \newcommand{\Epsilon}[]{Ε} \newcommand{\Iota}[]{Ι} \newcommand{\Kappa}[]{Κ} \newcommand{\Rho}[]{Ρ} \newcommand{\Tau}[]{Τ} \newcommand{\Zeta}[]{Ζ} \newcommand{\Mu}[]{\unicode{x039C}} \newcommand{\Chi}[]{Χ} \newcommand{\Eta}[]{\unicode{x0397}} \newcommand{\Nu}[]{\unicode{x039D}} \newcommand{\Omicron}[]{\unicode{x039F}} \DeclareMathOperator{\sgn}{sgn} \def\oiint{\mathop{\vcenter{\mathchoice{\huge\unicode{x222F}\,}{\unicode{x222F}}{\unicode{x222F}}{\unicode{x222F}}}\,}\nolimits} \def\oiiint{\mathop{\vcenter{\mathchoice{\huge\unicode{x2230}\,}{\unicode{x2230}}{\unicode{x2230}}{\unicode{x2230}}}\,}\nolimits} \)

OpenGL Shading Language (GLSL) is the shader language used in OpenGL and WebGL.

Usage

Pipeline

Vertex Shader

In the vertex shader, your inputs are a model matrix, view matrix, and projection matrix uniforms as well as one vertex position in local coordinates.
There may also be attributes which are per-vertex values such as UVs.

Your vertex shader program is run once per each vertex of a mesh.
The goal of the vertex shader is to output a position in screen coordinates.
Typically this is done by multiplying with the model matrix to get world coordinates, then the view matrix to get camera coordinates, and finally the projection matrix to get screen coordinates.

You can also do any other per-vertex calculations in this stages.
These values can be passed to the following stages as varying's.
varying's are linearly interpolated using barycentric coordinates.

Geometry Shader

Tesselation Shader

Fragment Shader