-
Notifications
You must be signed in to change notification settings - Fork 152
ComputeCullData
Computes culling data for input meshlets, typically generated by ComputeMeshlets.
HRESULT ComputeCullData(
const XMFLOAT3* positions, size_t nVerts,
const Meshlet* meshlets, size_t nMeshlets,
const uint16_t* uniqueVertexIndices, size_t nVertIndices,
const MeshletTriangle* primitiveIndices, size_t nPrimIndices,
CullData* cullData,
MESHLET_FLAGS flags = MESHLET_DEFAULT);
HRESULT ComputeCullData(
const XMFLOAT3* positions, size_t nVerts,
const Meshlet* meshlets, size_t nMeshlets,
const uint32_t* uniqueVertexIndices, size_t nVertIndices,
const MeshletTriangle* primitiveIndices, size_t nPrimIndices,
CullData* cullData,
MESHLET_FLAGS flags = MESHLET_DEFAULT);
The meshlets to compute culling data for are provided in meshlets, uniqueVertexIndices, and primitiveIndices. The array sizes are nMeshlets, nVertIndices, and nPrimIndices.
The result is written into the _cullData__
array which must be of length nMeshlets.
The flags can be MESHLET_DEFAULT
or MESHLET_WIND_CW
. By default, it assumes the vertices are counter-clockwise for back facing.
The CullData
structure is defined with the following members:
- BoundingSphere which is a bounding sphere for the meshlet geometry in the local space
-
NormalCone contains a 4-vector of 0..255 quantized data encoding the normal cone in xyz and w is the
-cos(a + 90)
. -
ApexOffset contains a float value for the
center - axis * offset
auto mesh = std::make_unique<WaveFrontReader<uint16_t>>();
if ( FAILED( mesh->Load( L"test.obj" ) ) )
// Error
size_t nFaces = mesh->indices.size() / 3;
size_t nVerts = mesh->vertices.size();
std::unique_ptr<XMFLOAT3[]> pos( new XMFLOAT3[ nVerts ] );
for( size_t j = 0; j < nVerts; ++j )
pos[ j ] = mesh->vertices[ j ].position;
std::vector<Meshlet> meshlets;
std::vector<uint8_t> uniqueVertexIB;
std::vector<MeshletTriangle> primitiveIndices;
if ( FAILED( ComputeMeshlets( mesh->indices.data(), nFaces,
pos.get(), nVerts,
nullptr,
meshlets, uniqueVertexIB, primitiveIndices) )
// Error
auto uniqueVertexIndices = reinterpret_cast<const uint16_t*>(uniqueVertexIB.data());
size_t vertIndices = uniqueVertexIB.size() / sizeof(uint16_t);
CullData cull = {};
if ( FAILED( ComputeCullData(g_fmCubeVerts, 24,
meshlets.data(), meshlets.size(),
uniqueVertexIndices, vertIndices,
primitiveIndices.data(), primitiveIndices.size(), &cull) )
// Error
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 opencode@microsoft.com with any additional questions or comments.
- Universal Windows Platform apps
- Windows desktop apps
- Windows 11
- Windows 10
- Windows 8.1
- Xbox One
- Xbox Series X|S
- Windows Subsystem for Linux
- x86
- x64
- ARM64
- Visual Studio 2022
- Visual Studio 2019 (16.11)
- clang/LLVM v12 - v18
- GCC 10.5, 11.4, 12.3
- MinGW 12.2, 13.2
- CMake 3.20
DirectX Tool Kit for DirectX 11