-
Notifications
You must be signed in to change notification settings - Fork 510
DebugEffect
DirectXTK | Effects |
---|
This effect provides a way to visualize normals, tangents, and binormals/bitangents for debugging purposes. This effect also supports GPU instancing.
Related tutorials: Using advanced shaders, Multistream rendering and instancing
classDiagram
class Mode{
<<enumeration>>
Mode_Default
Mode_Normals
Mode_Tangents
Mode_BiTangents
}
class IEffect{
<<Interface>>
+Apply()
+GetVertexShaderBytecode()
}
class IEffectMatrices{
<<Interface>>
+SetWorld()
+SetView()
+SetProjection()
+SetMatrices()
}
class DebugEffect{
+SetMode()
+SetHemisphericalAmbientColor()
+SetAlpha()
+SetVertexColorEnabled()
+SetBiasedVertexNormals()
+SetInstancingEnabled()
}
DebugEffect .. Mode
DebugEffect --|> IEffect
DebugEffect --|> IEffectMatrices
#include <Effects.h>
Construction requires a Direct3D 11 device.
std::unique_ptr<Debugffect> effect;
effect = std::make_unique<DebugEffect>(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
PBREffect supports IEffect and IEffectMatrices.
This effect requires SV_Position
, NORMAL
, and TEXCOORD0
. If per-vertex colors are enabled, it also requires COLOR
.
If instancing is enabled, this effect also requires these vertex elements:
"InstMatrix", 0, DXGI_FORMAT_R32G32B32A32_FLOAT
"InstMatrix", 1, DXGI_FORMAT_R32G32B32A32_FLOAT
"InstMatrix", 2, DXGI_FORMAT_R32G32B32A32_FLOAT
-
SetMode: Sets which debug shader to use. Defaults to
Mode_Default
:
Mode_Default | Hemispherical ambient lighting |
Mode_Normals | RGB normals |
Mode_Tangents | RGB tangents |
Mode_BiTangents | RGB bi-tangents (a.k.a. binormals) |
-
SetAlpha: Sets the alpha (transparency) of the effect. Defaults to 1 (fully opaque).
-
SetHemisphericalAmbientColor: The default mode uses a simple hemispherical ambient lighting so you can see the object with some 3D clues regardless of overall scene lighting. It defaults to using White to Black. This property can set different upper/lower colors.
-
SetVertexColorEnabled: Enables per-vertex color. Defaults to false. Modifying this setting requires recreating associated input layouts, and enabling it requires
COLOR
. -
SetBiasedVertexNormals: Enables support for compressed vertex normals which require
*2 - 1
biasing at runtime such asDXGI_FORMAT_R10G10B10A2_UNORM
. -
SetInstancingEnabled: Enables support for per-vertex instancing by adding a per-vertex
XMFLOAT3X4
transform matrix.
This effect uses Shader Model 4.0 so requires Direct3D hardware feature level 10.0 or greater.
Christian Schüler, "Normal Mapping without Precomputed Tangents", ShaderX 5, Chapter 2.6, pp. 131 – 140 and this blog post
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