Loading and using GLSL shaders
Shader programs must be compiled before use. Fortunately, OpenGL offers an interface to load shader programs in text form. The shader source code uses a syntax similar to the C code with several limitations. For instance, you can't perform recursive function calls. After compilation, you can check whether there were any errors in the process.
Shaders can use input values from your application. These input values are called uniforms. You can use these values in any part of the rendering pipeline, which consists of several shader program stages:
- Vertex shader: This performs operations on vertex attributes: vertex color, position, normal vector and many others
- Tessellation control shader: This controls tessellation amount on polygons
- Tessellation evaluation shader: This computes the interpolated vertex positions after tessellation
- Geometry shader: This performs per vertex operations on polygons
- Fragment shader: This operates on fragments after the rasterization...