JolifantoBambla / trichi

Generates triangle cluster hierarchies for per-cluster LOD selection & rendering
https://jolifantobambla.github.io/trichi/
MIT License
3 stars 0 forks source link
graphics graphics-programming level-of-detail lod mesh-processing meshlets triangle-mesh

Tri Chi: Triangle Cluster Hierarchy

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 :)

Getting Started

CPM

CPMAddPackage("gh:JolifantoBambla/trichi#v0.1.0")

target_link_libraries(${YOUR_TARGET} trichi)

CMake options

Usage

#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(),
  });

Dependencies

Caveats

No faceted meshes supported yet

The 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.

Related Projects

Further Reading