Share via


Fog Formulas

C++ applications can control how fog affects the color of objects in a scene by changing how Microsoft® Direct3D® computes fog effects over distance. The D3DFOGMODE enumerated type contains members that identify the three fog formulas. All formulas calculate a fog factor as a function of distance, given parameters that your application sets. How distance is computed depends on the projection matrix or whether range-based fog is enabled. For more information, see Eye-Relative vs. Z-Based Depth and Range-Based Fog.

D3DFOG_LINEAR

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.

When Direct3D calculates fog effects, it uses the fog factor from the preceding equations in the blending formula, shown here.

This formula effectively scales the color of the current polygon Ci by the fog factor f, and adds the product to the fog color Cf, scaled by the bitwise inverse of the fog factor. The resulting color value is a blend of the fog color and the original color, as a factor of distance.

See Also

Fog

 Last updated on Thursday, April 08, 2004

© 1992-2003 Microsoft Corporation. All rights reserved.