Skip to content

IEffectFog

Chuck Walbourn edited this page Apr 26, 2022 · 9 revisions
DirectXTK Effects

This abstract interface controls distance fog settings. This interface is implemented by BasicEffect, AlphaTestEffect, DualTextureEffect, EnvironmentMapEffect, NormalMapEffect, and SkinnedEffect if created with EffectFlags::Fog.

Related tutorial: Rendering a model

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(device, EffectFlags::Fog, pd);

...

effect->SetFogStart(6);
effect->SetFogEnd(8);
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, DualTextureEffect, and/or SkinnedEffect), use Run-Time Type Information (RTTI) to obtain the interface.

std::shared_ptr<BasicEffect> effect(device, EffectFlags::Fog, pd);

...

auto ifog = dynamic_cast<IEffectFog*>( effect.get() );
if ( ifog )
{
    ifog->SetFogStart(6);
    ifog->SetFogEnd(8);
    ifog->SetFogColor( Colors::CornflowerBlue );
}

Fog

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, NormalMapEffect, SkinnedEffect

These implement a simple linear fog which is inexpensive on all feature levels.

For Use

  • Universal Windows Platform apps
  • Windows desktop apps
  • Windows 11
  • Windows 10
  • Xbox One
  • Xbox Series X|S

For Development

  • Visual Studio 2022
  • Visual Studio 2019 (16.11)
  • clang/LLVM v12 - v18
  • MinGW 12.2, 13.2
  • CMake 3.20

Related Projects

DirectX Tool Kit for DirectX 11

DirectXMesh

DirectXTex

DirectXMath

Tools

Test Suite

Model Viewer

Content Exporter

DxCapsViewer

See also

DirectX Landing Page

Clone this wiki locally