Simulating fog
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 ...
Get OpenGL – Build high performance graphics now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.