Skip to content

IEffect

Chuck Walbourn edited this page Aug 15, 2022 · 8 revisions
DirectXTK Effects

This is the abstract interface implemented by all effects in DirectX Tool Kit, and is typically used as the 'base' reference.

classDiagram
class IEffect{
    <<Interface>>
    +Apply()
}
class IEffectMatrices{
    <<Interface>>
    +SetWorld()
    +SetView()
    +SetProjection()
    +SetMatrices()
}
class IEffectLights{
    <<Interface>>
    +SetAmbientLightColor()
    +SetLightEnabled()
    +SetLightDirection()
    +SetLightDiffuseColor()
    +SetLightSpecularColor()
    +EnableDefaultLighting()
}
class IEffectFog{
    <<Interface>>
    +SetFogStart()
    +SetFogEnd()
    +SetFogColor()
}
class IEffectSkinning{
    <<Interface>>
    +SetBoneTransforms()
    +ResetBoneTransforms()
}
IEffect .. IEffectMatrices
IEffect .. IEffectLights
IEffect .. IEffectFog
IEffect .. IEffectSkinning
Loading

Drawing

The Apply method is used to set the Pipeline State Object (PSO) and root signature for drawing with the effect. This includes updating and setting the required constants consumed by these shaders.

The caller must ensure that the bound vertex and index buffer and primitive topology match the PSO in the effect.

Texturing effects require the GPU handle to the descriptor for the texture, and the caller must ensure the proper descriptor heap is active before applying the effect.

effect->Apply( commandList );

commandList->IASetVertexBuffers(0, 1, &vertexBufferView);
commandList->IASetIndexBuffer(&indexBufferView);
commandList->IASetPrimitiveTopology(D3D_PRIMITIVE_TOPOLOGY_TRIANGLELIST);

commandList->DrawIndexedInstanced(indexCount, 1, 0, 0, 0);

Input Layouts

Direct3D 12 Pipeline State Objects (PSO) include the specific input layout provided as a D3D12_INPUT_LAYOUT_DESC at creation time. If a different input layout is required, the caller must create a new effect to match that input layout.

Built-in Effect Notes

All built-in effects require the SV_Position semantic.

AlphaTestEffect

This effect requires TEXCOORD0, and COLOR if per-vertex colors are enabled.

BasicEffect

This effect requires NORMAL if lighting is enabled, COLOR if per-vertex colors are enabled, and TEXCOORD0 if texturing is enabled.

DualTextureEffect

This effect requires TEXCOORD0 and TEXCOORD1.

EnvironmentMapEffect

This effect requires NORMAL and TEXCOORD0.

NormalMapEffect

This effect requires NORMAL , TEXCOORD0 and TANGENT. If per-vertex colors are enabled, it also requires COLOR.

SkinnedEffect

This effect requires NORMAL, TEXCOORD0, BLENDINDICES and BLENDWEIGHT.

For Use

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

Architecture

  • x86
  • x64
  • ARM64

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