This project has moved and is read-only. For the latest updates, please go here.
NEWS: This project is now hosted on GitHub This site is being maintained for now, but please move to using GitHub

This abstract interface controls distance fog settings typically communicated to the shader via a dynamic constant buffer. Settings for this interface can influence the choice of shader permtuation. This interface is implemented by BasicEffect, AlphaTestEffect, DualTextureEffect, EnvironmentMapEffect, and SkinnedEffect.

Obtaining the interface

There are two methods used in DirectX Tool Kit. For simple cases, just maintain a reference directly to the desired effect class:

std::shared_ptr<BasicEffect> effect;


effect->SetFogColor( Colors::CornflowerBlue );

For more general cases where a number of effect classes can be in use (such as Model which uses a mix of BasicEffect, SkinnedEffect, and/or DGSLEffect), use RTTI to obtain the interface.

std::shared_ptr<IEffect> effect;


auto ifog = dynamic_cast<IEffectFog*>( part->effect.get() );
if ( ifog )
    ifog->SetFogColor( Colors::CornflowerBlue );


The fog effects work for both right-handed and left-handed coordinate systems, but the distance settings should be negated for left-handed coordinates.

Built-in Effect Notes

BasicEffect, AlphaTestEffect, DualTextureEffect, EnvironmentMapEffect, SkinnedEffect
These implement a simple linear fog which is inexpensive on all feature levels.

Fog settings are encoded in the choice of DGSL pixel shader, if supported, and these shaders do not expose settings to control such effects. Therefore, this built-in effect does not support this interface. The default materials (Unlit, Lambert, and Phong) have no fog effects.

Last edited Jul 28, 2015 at 8:08 PM by walbourn, version 2