1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
//! Virtualized geometry: a mesh as a hierarchy of small triangle clusters
//! rather than one vertex and index buffer.
//!
//! A mesh is baked once, offline, by [`from_mesh`]. It is split into clusters
//! of at most a couple of hundred triangles, those clusters are grouped,
//! simplified, and re-split until the whole mesh collapses to a handful, and
//! every step is recorded as a level in a hierarchy. Each level records the
//! error its simplification introduced, and that error only grows towards the
//! root, which is the property everything downstream depends on: a cut can be
//! made anywhere the error is small enough to disappear on screen, and the
//! levels either side of that cut agree along their shared boundary because
//! they were simplified with those boundaries locked.
//!
//! What that buys is a triangle count that follows the pixels rather than the
//! model. A mesh may carry millions of triangles and cost a few hundred when it
//! is far away, and an instance may be drawn ten thousand times while its
//! geometry is uploaded once.
//!
//! Vertex data is quantized into bitstreams whose width is chosen per cluster,
//! so positions cost the bits their bounds actually need rather than a fixed
//! three floats. Nothing reads that layout directly: [`gpu_mesh`] uploads every
//! asset into shared streams and rebases each one's offsets to absolute
//! locations, and the shaders address it by index from there.
//!
//! Baking needs `meshlet_processor`, which links METIS and meshopt and is
//! native only. Rendering needs `meshlet`. An asset can therefore be baked on
//! one machine, written with [`asset::MeshletMesh::write`], and loaded by a
//! build that cannot bake.
//!
//! [`from_mesh`]: from_mesh::from_mesh