In some of the preceding chapters (Chapter 5, Skeletal Animations; Chapter 7, Static Lighting; and Chapter 8, Dynamic Lighting), we used shader programs. There, we mostly focused on vertex shaders, but fragment shaders can also be extremely useful.
The essential difference between these two types of shaders is that the vertex shader will determine the actual location where a vertex will be drawn in the world space through translations and similar actions. This is quite different from the fragment shader, which—as the name suggests—handles the resulting fragments, or faces, after the vertex shader and the graphic hardware's vertex pipeline are done with them.
What a fragment shader can do is change the properties of the face, including the color and gamma value. It can generate gradients as well as more complex patterns and apply them to a face.
Shaders for OpenGL are written in GLSL, the OpenGL Shader Language. This is a C-like language which you use to write programs that...