Platform SDK: DirectX

Fog Blending

[C++]

Fog blending refers to the application of the fog factor to the fog and object colors to produce the final color that appears in a scene, as discussed in Fog Formulas. The D3DRENDERSTATE_FOGENABLE render state controls fog blending. Set this render state to TRUE to enable fog blending (the default is FALSE), as in the following example code.

//
// For this example, g_lpDevice is a valid pointer
// to an IDirect3DDevice7 interface.
HRESULT hr;
hr = g_lpDevice->SetRenderState(
                     D3DRENDERSTATE_FOGENABLE,
                     TRUE);
if FAILED(hr)
    return hr;

You must enable fog blending for both pixel fog and vertex fog. For information about using these types of fog, see Pixel Fog and Vertex Fog.

[Visual Basic]

Fog blending refers to the application of the fog factor to the fog and object colors to produce the final color that appears in a scene, as discussed in Fog Formulas. The D3DRENDERSTATE_FOGENABLE render state controls fog blending. Set this render state to True to enable fog blending (the default is False), as in the following example code.

'
' For this example, g_d3dDevice contains a valid
' reference to an Direct3DDevice7 object.
'
On Local Error Resume Next

Call g_d3dDevice.SetRenderState( _
                     D3DRENDERSTATE_FOGENABLE, _
                     True)
                     
If Err.Number <> DD_OK Then
    ' Code to handle error goes here.
End If

You must enable fog blending for both pixel fog and vertex fog. For information about using these types of fog, see Pixel Fog and Vertex Fog.