Skip to content

[Renderer] Build virtualized meshlet geometry with automatic LOD and streaming #131

Description

@proggeramlug

Parent: #126
Depends on: #28, #27, #130, and #136

Problem

Traditional per-mesh LOD swaps and CPU submission cannot provide film-scale source geometry with stable frame cost. #28 and #27 establish GPU-visible geometry and visibility shading, but Bloom still needs an offline/runtime virtualized-geometry system to approach Nanite-class density.

Outcome

A Nanite-inspired, not Nanite-identical static-geometry path:

  • imported meshes are partitioned into meshlets/clusters with bounds and error metrics;
  • clusters form a hierarchical LOD DAG/tree produced by the cooker;
  • GPU culling selects clusters by frustum, backface cone, projected error, and Hi-Z occlusion;
  • indirect draws/visibility IDs render selected resident clusters;
  • required pages stream under a fixed memory/IO budget;
  • unsupported, skinned, deforming, translucent, and custom-vertex content stays on a documented compatibility path.

Offline format

The cooker must emit a versioned, endian-defined format containing:

  • cluster vertex/index payloads with bounded size (choose and document limits after GPU/cache experiments);
  • object-space AABB/sphere, normal cone, geometric error, parent/child links, and material ranges;
  • page grouping optimized for locality plus content hashes and dependency records;
  • a coarse always-resident fallback hierarchy;
  • source-to-cooked provenance for deterministic rebuilds.

Do not lock the public API to an internal cluster size.

Runtime architecture

  1. Register virtual meshes and allocate stable mesh/page IDs.
  2. Maintain residency/page table and request queue with per-frame upload/eviction budgets.
  3. Cull instances, then traverse cluster hierarchy on GPU to projected-error targets.
  4. Test selected clusters against previous-frame Hi-Z; preserve conservative behavior for newly revealed content.
  5. Emit indirect commands/visibility IDs consumed by perf ticket 009: GPU-driven rendering — indirect multi-draw + GPU cull #28/perf ticket 008: visibility buffer (Nanite-style) replaces 4-MRT G-buffer #27.
  6. Feed missing-page requests back asynchronously; render the nearest resident ancestor until data arrives.
  7. Expose counters/debug views: selected LOD, rejected reason, page residency, requests, fallback clusters, triangles submitted/rasterized.

Quality behavior

  • LOD error is expressed in pixels and scaled by quality tier/render resolution.
  • Transitions must not crack. Prefer seamless hierarchy topology; use temporal/dither transitions only where necessary and test ghosting.
  • Camera cuts and fast motion may reduce occlusion efficiency but may not make geometry disappear.
  • Material boundaries and UV/tangent continuity must survive cluster construction.

Acceptance criteria

  • Import and render a static stress asset with at least 10 million source triangles under a configurable residency budget.
  • Camera motion produces no holes, cracks, missing-page flashes, or unbounded temporal trails in the fixed motion corpus.
  • Projected geometric error remains at or below the selected pixel threshold in an automated image/geometry test.
  • GPU culling and submission time scale primarily with candidate/visible clusters, not source triangle count; attach uncapped timings and counters.
  • Peak geometry residency respects its configured budget within one page plus explicitly measured staging overhead.
  • Skinned/translucent/deforming content is routed to the compatibility path with correct depth/composition and an inspectable reason.
  • Asset corruption/version mismatch fails with a useful message and never reads arbitrary offsets.
  • Existing immediate-mode and ordinary glTF models still render unchanged.

Likely files

  • tools/bloom-cook/
  • new cooked geometry modules under native/shared/src/
  • native/shared/src/renderer/scene_pass.rs, hiz.rs, graph.rs, shaders
  • native/shared/src/models*.rs and scene data ownership
  • src/models/ and world asset metadata as needed

Verification

Attach cooker determinism hashes, residency/culling statistics, fixed-camera stills, motion-sequence diffs, and before/after GPU captures on at least one discrete and one integrated GPU.

Non-goals

  • Skinned-mesh virtualization.
  • Runtime arbitrary topology editing.
  • Making mesh shaders mandatory; use them only as an optional backend after feature/correctness qualification.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions