In this shader, the blinnPhong function is exactly the same as the one used in The Blinn-Phong reflection model recipe. The part of this shader that deals with the fog effect lies within the main function.
The uniform variable Fog contains the parameters that define the extent and color of the fog. The MinDist field is the distance from the eye to the fog's starting point, and MaxDist is the distance to the point where the fog is maximal. The Color field is the color of the fog.
The dist variable is used to store the distance from the surface point to the eye position. The z coordinate of the position is used as an estimate of the actual distance. The fogFactor variable is computed using the preceding equation. Since dist ...