Pixel (Z)
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 FogMode enumerated type defines constants that can be used to identify the fog formula you want Microsoft Direct3D to use. The RenderStateManager.FogTableMode property controls the fog mode that Direct3D uses for pixel fog, and the RenderStateManager.FogVertexMode property controls the mode for vertex fog.
When using the linear fog formula, set the starting and ending distances through the RenderStateManager.FogStart and RenderStateManager.FogEnd properties. How the system interprets these values depends on the type of fog—pixel or vertex—an application uses, and when using pixel fog, whether 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 |
Vertex | Camera space |
The RenderStateManager.FogDensity property controls the fog density that is 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.
The color that the system uses for fog blending is controlled through the RenderStateManager.FogColor device property. For more information, see Fog Color and Fog Blending.