The use of fog in the scene not only improves realism, but also optimizes performance in specific situations. In particular, when the object is far enough away from the camera, the fog is strong enough to see only the fog and not see the object, it is not necessary to the object coloring detailed calculation, which can greatly improve rendering efficiency.
There are many mathematical models of fog
Linear Model:
F=max (min (end-dist)/(End-start), 1.0), 0.0)
- F is the atomization factor, the value range is 0.0~1.0 (0 means the fog is very thick, only see fog)
- The dist is the distance from the camera that the slice element is currently being drawn.
- End represents a specific distance value, and the atomization factor is 0 when the distance from the camera exceeds end
- Start represents a specific distance value, and the atomization factor is 1 when the distance between the element and the camera is less than start
Nonlinear Calculation formula:
F=1.0-smoothstep (Start,end,dist)
OpenGL ES 2.0 Fog