A simple fog effect can be achieved by mixing the color of each fragment with a constant fog color. The amount of influence of the fog color is determined by the distance from the camera. We could use either a linear relationship between the distance and the amount of fog color, or we could use a non-linear relationship such as an exponential one.
The following figure shows four teapots rendered with a fog effect produced by mixing the fog color in a linear relationship with distance.
To define this linear relationship we can use the following equation:
In the preceding equation, dmin is the distance from the eye where the fog is minimal ...