Fog Parameters (Direct3D 9)
Fog parameters are controlled through device render states. Both pixel and vertex fog types support all the fog formulas introduced in Fog Formulas (Direct3D 9). The D3DFOGMODE enumerated type defines constants that you can use to identify the fog formula you want Microsoft Direct3D to use. The D3DRS_FOGTABLEMODE render state controls the fog mode that Direct3D uses for pixel fog, and the D3DRS_FOGVERTEXMODE render state controls the mode for vertex fog.
When using the linear fog formula, you set the starting and ending distances through the D3DRS_FOGSTART and D3DRS_FOGEND render states. How the system interprets 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. The following table summarizes fog types and their start and end units.
|Fog type||Fog start/end units|
|Pixel (Z)||Device space [0.0,1.0]|
|Pixel (W)||Camera space|
The D3DRS_FOGDENSITY render state controls the fog density applied when an exponential fog formula is enabled. Fog density is essentially a weighting factor, ranging from 0.0 to 1.0 (inclusive), that scales the distance value in the exponent.