meshoptimizer is a C/C++ library of algorithms that make triangle meshes smaller and faster to render on a GPU. When a GPU processes vertex and index data, the efficiency of each pipeline stage depends heavily on how that data is organized; meshoptimizer provides algorithms to reorder and compress mesh data for those stages, plus algorithms to reduce triangle count and overall storage overhead. The library exposes a C-compatible header (meshoptimizer.h) with C++ source files, and is also usable from Rust via the meshopt crate or from JavaScript via the meshoptimizer.js npm package.
meshopt_optimizeVertexCache reorders triangles for GPU post-vertex-shader cache locality, with meshopt_optimizeVertexCacheFifo as a roughly 2x faster alternative tuned for fixed-size FIFO caches.meshopt_simplify reduces triangle count while tracking a normalized deviation error against a target, and meshopt_simplifySloppy collapses topology-independent detail for more aggressive LODs.meshopt_buildMeshlets, meshopt_buildMeshletsSpatial, and cluster partitioning build GPU mesh-shader-ready clusters for both rasterization and ray tracing, including NVIDIA cluster acceleration structures.meshopt_encodeVertexBuffer / meshopt_encodeIndexBuffer codecs shrink buffers for storage or transmission, and are the basis of the glTF EXT_meshopt_compression extension.meshopt_spatialClusterPoints splits point clouds into fixed-size spatial clusters for parallel processing or mesh/compute shader rendering.meshoptimizer is applied as a pipeline where order matters: indexing (deduplicating vertices into a vertex and index buffer), vertex cache optimization, optional overdraw optimization, vertex fetch optimization, vertex quantization, index filtering to drop degenerate or duplicate triangles, and optional shadow indexing for depth-only passes. Simplification and meshlet generation typically run after this core pipeline, on already-indexed data. Every function operates on plain vertex/index buffers, so the library has no dependency on any particular renderer or math library.
The library is distributed as src/meshoptimizer.h plus src/*.cpp, buildable with CMake or by adding the source files directly to an existing build system; only the algorithms you call need to be compiled in. It ships as a package for ArchLinux, Debian, FreeBSD, Nix, and Ubuntu, and is available through vcpkg and Conan. The companion gltfpack command-line tool automatically optimizes glTF files and is distributed as a prebuilt binary or npm package, while clusterlod.h provides a single-header implementation of continuous level of detail using clustered simplification.