Skip to content

A mesh is an instance of its geometry's mesh - #162

Merged
yujiaxu-ops merged 2 commits into
mainfrom
scene-mesh-instances
Nov 18, 2026
Merged

yujiaxu-ops merged 2 commits into
mainfrom
scene-mesh-instances

Conversation

@yujiaxu-ops

@yujiaxu-ops yujiaxu-ops commented Nov 18, 2026 •

Copy link
Copy Markdown
Collaborator

Scene step E, first part: every mesh is an instance. Until now a mesh was one only where scene code asked (dynamicGeometry) or a body drove it; every other mesh was flattened into the still scene's world-space groups, and a movable one was re-transformed on the CPU at each move.

What changes

  • Every shown mesh with a size is an instance of its geometry's mesh: the triangles once in model space, one BLAS, shared by the objects of the same geometry and materials.
  • A mesh of several materials (a geometry group each) is one mesh: its triangles ordered by class, a BLAS geometry a class (scene::own_mesh).
  • A movable mesh's move is its instance's transform: no vertex is written again. Under software traversal it moves in place too.
  • A moved instance whose placement has no size (scene code hides by scaling to 0) stands at a point, hidden, and comes back in place (scene::placed_world, the rule an instanced object's copy had).
  • A material that starts emitting gives each instance of its meshes its emitters in place: the mesh's emitting triangles are numbered again, an instance gets a new run of the light list, the old one stays at no weight (Tables::mesh_mats, add_material_emitters). A material a model or an instanced object has too still rebuilds.
  • Room for edits in place stays where the scene said a mesh is edited or driven.

Still flattened: a mesh built without size, THREERT_INSTANCING=0, a light's card, particles, triangles on the same vertices (flatten_coincident), deforming meshes. Still a rebuild, the second part: hiding a mesh, a still mesh's first move, removing or changing the geometry of one the scene did not say it edits.

Not the common structure

A mesh is shared by geometry and materials, because the material is a triangle's attribute: two objects of one geometry with different materials hold its triangles twice. The common structure has the material on the instance; that is a step of its own after this one.

Tests

  • shadow/glass-groups, -frame, -cutout, -live-exact: a mesh of three materials (glass, cutout, opaque) whose geometry has them in the reverse of the classes' order.

  • A several-material mesh's order and counts (a_mesh_of_several_materials_lies_by_class).

  • A material that starts emitting, against a build: a mesh two objects share (one movable, moved after), a mesh of two materials one of which emitted already, a mesh added in place; a material an instanced object has too rebuilds. The light list's check now reads the instances' records from the GPU.

  • A movable mesh scaled to nothing and back, against a build.

  • Mutants, each failing on the path meant: a movable mesh not marked moving, no class order, the materials' rule, the old run kept, the record or the attributes not written, the mesh's count or the instance's first not kept, the new emitters not moving, the two rules of a mesh or an instanced object added in place; under software traversal, the mesh tree's order. Not run as a mutant: a matrix without size given to the TLAS.

  • 179 unit tests, 262 render tests natively. Under software traversal the branch fails 23, main 24: the same ones with the same values, less wind/pivot-sway-live, which passes now.

Timing

GPU time a frame (median) on twelve live scenes, this branch and main alternated, five runs a side (the first of a batch reads high for either build and is left out):

scene main this
Kabukicho 7.93 – 7.97 ms 8.18 – 8.20 ms +3.1 %
colour 9.48 – 9.53 9.14 – 9.27 −3 to −4 %
refraction 7.28 – 7.35 7.06 – 7.22 −2 to −3.4 %
the other nine within their run-to-run spread

Kabukicho: its emitting triangles with a material function are on instances now, so a function's inputs are placed by the instance (F_IFUNC; #160 read +3.6 % with that code compiled in). The two that got faster are not attributed. The pictures against the offline references are the same on all twelve.

Vulkan (RTX 5090): 179 unit tests pass; render tests natively fail the known five, under software traversal main's list less wind/pivot-sway-live.

🤖 Generated with Claude Code

yujiaxu-ops and others added 2 commits November 18, 2026 19:28
Every shown mesh with a size: of one material or a group's each (triangles ordered by class, a BLAS geometry a
class), still or movable (its move is the instance's transform). A material that starts emitting gives each
instance of its meshes its emitters in place.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…nds hidden at a point

Tests: a mesh of glass, cutout and opaque groups; a several-material mesh's order; a material that starts emitting
against a build; a movable mesh scaled to nothing and back. The light list's check reads the records from the GPU.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
@yujiaxu-ops
yujiaxu-ops merged commit ac4d1d1 into main Nov 18, 2026
9 checks passed
@yujiaxu-ops
yujiaxu-ops deleted the scene-mesh-instances branch November 18, 2026 12:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant