Fog Color

Fog color for both pixel and vertex fog is set through the RenderStateManager.FogColor property. The render state values can be any RGB color, specified as an RGBA color. The alpha component is ignored.

The following C# code example sets the fog color to white.

          [C#]
          

// For this example, device is a valid Device object.
    
// Get the device's render states object.
RenderStates rs = device.RenderState;

rs.FogColor = System.Color.White;

Fog is applied differently by the fixed-function pipeline and the programmable pipeline.

  1. If the driver supports MiscCaps.SupportsFogAndSpecularAlpha:
    • If the fixed-function pipeline is used and RenderStateManager.FogColor is set, v1.w (in the pixel shader) equals the value set in the fog render state.
    • If the programmable pipeline is used, v1.w (in the pixel shader) equals 0, even if oD1.w is explicitly written in a vertex shader.
  2. If the driver does not support MiscCaps.SupportsFogAndSpecularAlpha:
    • If the fixed-function pipeline is used and RenderStateManager.FogColor is set, v1.w (in the pixel shader) equals the value set in the fog render state.
    • If oFog is explicitly written in a vertex shader, v1.w (in the pixel shader) equals oFog, clamped between 0 and 1.
    • If neither of the above two cases applies, v1.w (in the pixel shader) equals 0, even if oD1.w is explicitly written in a vertex shader.

For more information, see MiscCaps.