A library for generating triangle cluster hierarchies for per-surface-patch LOD selection & rendering.
Note that this library only preprocesses triangle meshes but provides no rendering solution. Check out the WebGPU demo (takes its sweet time to load!) to see what a very naive renderer for such cluster hierarchies could look like.
This library is still in development. The API is not yet stable and the implementation is neither optimized for runtime performance nor quality, nor does it handle all edge cases. If you want to help change that, you are more than welcome to submit a PR :)
CPMAddPackage("gh:JolifantoBambla/trichi#v0.1.0")
target_link_libraries(${YOUR_TARGET} trichi)
TRICHI_PARALLEL
: build multithreaded version#include "trichi.hpp"
const std::vector<uint32_t> indices = /* triangle indices */
const std::vector<float> vertices = /* the first three floats of a vertex should be its 3d position */
const auto clusterHierarchy = trichi::buildClusterHierarchy(
indices,
vertices,
vertexStrideInBytes,
trichi::Params {
.maxVerticesPerCluster: 64,
.maxTrianglesPerCluster: 128,
.clusterConeWeight: 0.0,
.targetClustersPerGroup: 4,
.maxHierarchyDepth: 25,
.threadPoolSize: std::thread::hardware_concurrency(),
});
TRICHI_PARALLEL
option): used for parallelizing some dag construction steps, MIT licensedThe algorithm builds on the assumption that the input mesh is contiguous. It is currently the user's responsibility to ensure that this condition is satisfied, e.g., by welding similar vertices beforehand.