-
Notifications
You must be signed in to change notification settings - Fork 513
VertexTypes
DirectXTK |
---|
The VertexTypes.h header defines these commonly used vertex data structures:
Structure | Stride |
---|---|
VertexPosition | 12 bytes |
VertexPositionColor | 28 bytes |
VertexPositionTexture | 20 bytes |
VertexPositionDualTexture | 28 bytes |
VertexPositionNormal | 24 bytes |
VertexPositionColorTexture | 36 bytes |
VertexPositionNormalColor | 40 bytes |
VertexPositionNormalTexture | 32 bytes |
VertexPositionNormalColorTexture | 48 bytes |
VertexPositionNormalTangentColorTexture | 52 bytes |
VertexPositionNormalTangentColorTextureSkinning | 60 bytes |
#include <VertexTypes.h>
Each type also provides a D3D11_INPUT_ELEMENT_DESC
array which can be used to create a matching input layout, for example:
Microsoft::WRL::ComPtr<ID3D11InputLayout> inputLayout;
device->CreateInputLayout(
VertexPositionColorTexture::InputElements,
VertexPositionColorTexture::InputElementCount,
vertexShaderCode, vertexShaderCodeSize,
inputLayout.GetAddressOf());
Position (which uses the semantic "SV_Position") is required for all rendering. This is XMFLOAT3 (DXGI_FORMAT_R32G32B32_FLOAT
).
Normal is required for any effect that supports lighting computations. This is XMFLOAT3 (DXGI_FORMAT_R32G32B32_FLOAT
).
Color is for per-vertex coloring used by some effects. Color is typically XMFLOAT4(DXGI_FORMAT_R32G32B32A32_FLOAT
).
Texture coordinates (which uses the semantic "TEXCOORD0") are XMFLOAT2 (DXGI_FORMAT_R32G32_FLOAT
).
DualTexture coordinates (which uses the semantic "TEXCOORD0" and "TEXCOORD1") are XMFLOAT2 (DXGI_FORMAT_R32G32_FLOAT
).
See DirectXMesh for more information.
VertexPositionNormalTangentColorTexture contains the vertex elements needed for using Visual Studio Shader Designer (DGSL) shaders via DGSLEffect (which requires position, normal, tangent, color, and texture coordinates) and is used when loading .CMO
file models. It defines Color as a uint32_t
(DXGI_FORMAT_R8G8B8A8_UNORM
)
VertexPositionNormalTangentColorTextureSkinning extends VertexPositionNormalTangentColorTexture with blend weights and indices for skinning using Visual Studio Shader Designer (DGSL) shaders via DGSLEffect and is used when loading .CMO
file skinned models. It defines the blend indices as uint32_t
(DXGI_FORMAT_R8G8B8A8_UINT
) and the blend weights as uint32_t
(DXGI_FORMAT_R8G8B8A8_UNORM
).
The .SDKMESH
format describes input layouts as Direct3D 9 style vertex decls. There is therefore no specific vertex structure for .SDKMESH
data and such input layouts are built on-the-fly. The Model loader attempts to create input layouts that match the needs of the standard Effects, so it can end up ignoring some of the vertex layout content if the critical content is found first.
-
DirectX Tool Kit for DX12 does not support CMO, so it does not have
VertexPositionNormalTangentColorTexture
orVertexPositionNormalTangentColorTextureSkinning
. -
DirectX Tool Kit built-in Effects that require a tangent-space compute the tangent/bi-tangent in the shader from the normal and texture coordinates to simplify usage.
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
- 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