-
Notifications
You must be signed in to change notification settings - Fork 511
DualTextureEffect
DirectXTK | Effects |
---|
This is a native Direct3D 11 implementation of the built-in DualTextureEffect from XNA Game Studio 4 (Microsoft.Xna.Framework.Graphics.DualTextureEffect
) which supports two layer multi-texturing (for light maps or detail textures), vertex color, and fogging.
classDiagram
class IEffect{
<<Interface>>
+Apply()
+GetVertexShaderBytecode()
}
class IEffectMatrices{
<<Interface>>
+SetWorld()
+SetView()
+SetProjection()
+SetMatrices()
}
class IEffectFog{
<<Interface>>
+SetFogEnabled()
+SetFogStart()
+SetFogEnd()
+SetFogColor()
}
class DualTextureEffect{
+SetDiffuseColor()
+SetAlpha()
+SetColorAndAlpha()
+SetTexture()
+SetTexture2()
+SetVertexColorEnabled()
}
DualTextureEffect --|> IEffect
DualTextureEffect --|> IEffectMatrices
DualTextureEffect --|> IEffectFog
#include <Effects.h>
Construction requires a Direct3D 11 device.
std::unique_ptr<DualTextureEffect> effect;
effect = std::make_unique<DualTextureEffect>(device);
For exception safety, it is recommended you make use of the C++ RAII pattern and use a std::unique_ptr
or std::shared_ptr
DualTextureEffect supports IEffect, IEffectMatrices, and IEffectFog
Does not support lighting as it is assumed to be 'baked' into one of the two textures.
This effect requires SV_Position
, TEXCOORD0
, and TEXCOORD1
. It requires COLOR
if per-vertex colors are enabled.
-
SetDiffuseColor: Sets the diffuse color of the effect. Defaults to white (1,1,1). Alpha channel (.w component) is ignored.
-
SetAlpha: Sets the alpha (transparency) of the effect. Defaults to 1 (fully opaque). This value is also used for binning opaque vs. transparent geometry.
-
SetColorAndAlpha: Sets the diffuse color of the effect and the alpha (transparency).
-
SetVertexColorEnabled: Enables per-vertex color. Defaults to false. Modifying this setting requires recreating associated input layouts, and enabling it requires
COLOR
. -
SetTexture: Associates a texture shader resource view with the effect. Can be set to nullptr to remove a reference. This uses the sampler in slot 0. Can optionally include an alpha channel as well.
-
SetTexture2: Associates a texture shader resource view with the effect. Can be set to nullptr to remove a reference. This uses the sampler in slot 1.
This effect requires a texture sampler in both slots 0 and 1. GeometricPrimitive and SpriteBatch only set a texture sampler in slot 0 by default, Model sets a sampler in slots 0 and 1.
GeometricPrimitive, Model loaded from VBO
or CMO
, and SpriteBatch only define a single set of texture coordinates in their vertex buffers so they can't be used with DualTextureEffect.
Diffuse map | Light map |
All content and source code for this package are subject to the terms of the MIT License.
This project has adopted the Microsoft Open Source Code of Conduct. For more information see the Code of Conduct FAQ or contact [email protected] with any additional questions or comments.
- Universal Windows Platform apps
- Windows desktop apps
- Windows 11
- Windows 10
- Windows 8.1
- Windows 7 Service Pack 1
- Xbox One
- x86
- x64
- ARM64
- Visual Studio 2022
- Visual Studio 2019 (16.11)
- clang/LLVM v12 - v18
- MinGW 12.2, 13.2
- CMake 3.20