DirectX SDK

Fog Parameters

[C++]

Fog parameters are controlled through device render states. Both pixel and vertex fog types support all of the fog formulas introduced in Fog Formulas. The D3DFOGMODE enumerated type defines constants that you can use to identify the fog formula you want Direct3D to use. The D3DRENDERSTATE_FOGTABLEMODE render state controls the fog mode that Direct3D will use for pixel fog, and the D3DRENDERSTATE_FOGVERTEXMODE render state controls the mode for vertex fog.

When using the linear fog formula, you set the starting and ending distances through the D3DRENDERSTATE_FOGSTART and D3DRENDERSTATE_FOGEND render states. How the system inteprets these values depends on the type of fog your application uses—pixel or vertex fog—and, when using pixel fog, if z-based or w-based depth is being used. (For information z- and w-based pixel fog, see Eye Relative vs. Z-based Depth.) The following table summarizes:

Fog Type Fog Start/End Units
Pixel (Z) Device space [0.0,1.0]
Pixel (W) Camera space
Vertex Camera space

The D3DRENDERSTATE_FOGDENSITY render state controls the fog density applied when an exponential fog formula is enabled. Fog density is a essentially weighting factor, ranging from 0.0 to 1.0 (inclusive), that scales the distance value in the exponent.

The color that the system uses for fog blending is controlled through the D3DRENDERSTATE_FOGCOLOR device render state. For more information, see Fog Color and Fog Blending.

[Visual Basic]

Fog parameters are controlled through device render states. Both pixel and vertex fog types support all of the fog formulas introduced in Fog Formulas. The CONST_D3DFOGMODE enumeration defines constants that you can use to identify the fog formula you want Direct3D to use. The D3DRENDERSTATE_FOGTABLEMODE render state controls the fog mode that Direct3D will use for pixel fog, and the D3DRENDERSTATE_FOGVERTEXMODE render state controls the mode for vertex fog.

When using the linear fog formula, you set the starting and ending distances through the D3DRENDERSTATE_FOGSTART and D3DRENDERSTATE_FOGEND render states. How the system inteprets these values depends on the type of fog your application uses—pixel or vertex fog—and, when using pixel fog, if z-based or w-based depth is being used. (For information z- and w-based pixel fog, see Eye Relative vs. Z-based Depth.) The following table summarizes:

Fog Type Fog Start/End Units
Pixel (Z) Device space [0.0,1.0]
Pixel (W) Camera space
Vertex Camera space

The D3DRENDERSTATE_FOGDENSITY render state controls the fog density applied when an exponential fog formula is enabled. Fog density is a essentially weighting factor, ranging from 0.0 to 1.0 (inclusive), that scales the distance value in the exponent.

The color that the system uses for fog blending is controlled through the D3DRENDERSTATE_FOGCOLOR device render state. Use the DirectX7.CreateColorRGB method to generate valid color values for this render state. For more information, see Fog Color and Fog Blending.