Fog

Adding fog to a 3-D scene can enhance realism, provide ambiance or set a mood, and obscure artifacts sometimes caused when distant geometry comes into view. Essentially, fog is implemented by blending the color of objects in a scene with a chosen fog color based on the depth of an object in a scene or its distance from the viewpoint. As objects grow more distant, their original color blends more and more with the chosen fog color, creating the illusion that the object is being increasingly obscured by tiny particles floating in the scene.

Fog Formulas

There are three fog modes: Linear, Exp, Exp2.

In this linear formula, start is the distance at which fog effects begin, end is the distance at which fog effects no longer increase, and d represents depth, or distance from the viewpoint, in a scene. Values for d increase as objects become more distant.

   Note  Linear mode will not supported if runs on a 3D accelerator without eye-relative fog ( w-based fog ) support.

 

In these two exponential formulas, e is the base of natural logarithms (approximately 2.71828), density is an arbitrary fog density that can range from 0.0 to 1.0, and d is depth, or distance from the viewpoint, in a scene.