Skip to content

Scene step D, fourth part: emitters on instances, a model's - #154

Merged
yujiaxu-ops merged 6 commits into
mainfrom
emitters-models
Nov 17, 2026
Merged

yujiaxu-ops merged 6 commits into
mainfrom
emitters-models

Conversation

@yujiaxu-ops

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

Copy link
Copy Markdown
Collaborator

Scene step D, fourth part: emitters on instances, for a model. Follows #152.

What

A model's triangles that only emit were flattened at every placement (world space, for light sampling: the reason #147 took away), and a movable or posed model re-transformed them on the CPU every frame. They stay in the model's mesh now, as real-time engines have them.

  • Static placements: the emitting triangles are in the mesh's BLAS with the rest; each placement's are a run of the light list (InstMesh::emitters, numbered among the mesh's triangles by number_emitters).
  • Movable models and a rigid posed model's moving nodes: the instance moves; fill_moved has the fill pass take their runs again (move_instances, repose_rigid).
  • Still flattened: glass and material functions; a mesh that deforms (a shared pose, a skinned model); and one case of emitters: a triangle that emits with a cutout on exactly its vertices goes with the cutout (below).
  • A model with emitters added in place still rebuilds, as before.

Flattened a placement (the build's log): Tokyo 1,800,744 -> 0 triangles, Bistro 20,638 -> 0, Zero Day 10,105 -> 4, the crowd's Bistro's moving nodes 18,400 -> 0.

Timing (Metal, 1280x720 at scale 0.75, trace p50, alternating runs on a quiet machine)

scene main this
Bistro crowd 7.38 ms 7.37 ms commit 4.46 -> 3.61 ms (-19 %), frame interval 13.2 -> 13.0
Bistro 7.20 7.13 -1.0 %
Zero Day 7.68 7.71 pairs +0.00 to +0.06
Tokyo 4.47 4.60 +2.9 %

Tokyo's cost is known and taken (the user's decision): it is the emitting triangles' being instanced. With every model flattened (THREERT_INSTANCING=0) both builds read 4.44 to 4.48; instancing the other 21.3 M triangles costs nothing. The mechanism is not established. Ruled out, each by a build: the instance record's reads, the attributes' order, the light list's order, emit_mis's tree descents (main pays them too), the shadow rays' ends; it grows with the paths' depth. The mesh whole in its instance is the standard structure and what direct-light resampling and moving a still model in place need. The way back, if wanted, is merging still geometry whole, as its own measured step.

Kabukichō's data is unchanged (its emitters are not in instanced models).

A regression found and fixed on the way

Zero Day read 4.3 % dark in a region: a masked decal on exactly the vertices of an emitting quad. A cutout hit that lets a ray through steps the ray past it, and past the emitter at the same distance once both are in one BLAS. The existing rule (a pool triangle on a flattened one's vertices is flattened with it) is extended to this pair. The guard is the unbiased check on Zero Day: PASS with the rule (worst region 1.009), FAIL without (0.969). A small render test for it could not be made to discriminate (in a small mesh the opaque quad is always met first) and was dropped.

From review (Bugbot): the rule was in the still placement's branch only. It is one function now (flatten_coincident), used by a rigid model's moving nodes too, with a structural test (a_cutout_on_an_emitter_is_flattened_with_it, tests/render/data/panel-decal.glb); a mutant without the rule in either branch fails it. No picture changes (241 outputs: 221 byte-identical, 20 within their spread), and Zero Day, Bistro and the crowd flatten what they did.

Checked

  • cargo test 169 passed, test-render 241 pass; under software traversal the same 25 tests fail as before.
  • Unbiased check (hardware offline render against the software-BVH referee): Zero Day mean 1.0013, worst region 1.009; Bistro 0.9999 / 1.004; Bistro at 15 s 0.9999 / 1.001. Main's render against the same referees reads the same.
  • Live pictures against main: Bistro, Zero Day, Kabukichō: mean luminance over a 4 x 4 grid within 0.7 %; Tokyo and the crowd inside their own run-to-run range.
  • New: geometry/emitter-model (a model's emitters, analytic; tests/render/data/panel.glb: a grey quad, an emitting quad, a clip); the readback test with a model still, movable (moved) and posed by a clip (its node moved), and which emitters carry the moving flag. Four mutants, each caught.
  • render-identity against main, 241 outputs: 219 byte-identical, 21 within their own spread; the one that differs is the new test (2.6e-7: its model's emitters are flattened on main). No other test of the suite has a model that emits.
  • Vulkan (RTX 5090; at 4272ec4, before the review fix, which is in the scene build on the CPU), against main: natively 217 byte-identical, 19 within their spread, the new test 2.5e-7; under software traversal 220 byte-identical, 17 within (one of them, a volume test without a model, has two outcomes from run to run on one build: run alone, four times a side). cargo test 168 passed; test-render natively fails the five that fail there on main, under software traversal the same 25 as main, value for value.

🤖 Generated with Claude Code


Note

Medium Risk
Changes scene build, light-list layout, and live emitter updates for instanced models; touches traversal/light sampling with documented Tokyo trace cost (+2.9%) accepted.

Overview
Keeps a glTF model's pure emissive triangles in its instanced mesh instead of flattening them per placement. Each instance gets a contiguous run in the light list (InstMesh::emitters, number_emitters on emitting materials only), matching typical engine behavior and avoiding per-frame CPU re-transform/upload for movable models.

Still flattens glass and material-function triangles per placement; deforming meshes (skinned/shared pose) still flatten emitters. Introduces mesh_class (replaces own_mesh_class) so emit-only materials stay in the pool as opaque/cutout, and flatten_coincident so a cutout on the same vertices as an emitter is flattened together (fixes Zero Day decal/emitter interaction in one BLAS).

Live path: fill_moved centralizes GPU refills of emitter runs when instances move (movable models, rigid animated nodes). Moving-instance tracking includes rigid model node instances.

Adds geometry/emitter-model render test, extended inplace light-list tests for still/movable/posed models, and a_cutout_on_an_emitter_is_flattened_with_it.

Reviewed by Cursor Bugbot for commit fde6f22. Bugbot is set up for automated code reviews on this repo. Configure here.

yujiaxu-ops and others added 5 commits November 17, 2026 19:44
…t stay in its mesh

Static placements and a rigid model's moving nodes; a deforming mesh's are
still flattened. Numbered among the mesh's; a rigid model's moved nodes fill
their runs. Tests: geometry/emitter-model (analytic), the readback test with a
model still / movable / posed (tests/render/data/panel.glb).

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…ertices is flattened with it; which emitters move, asserted

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…ion part is what is flattened)

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

Reviewed by Cursor Bugbot for commit e0856a9. Configure here.

Comment thread renderer/src/scene.rs
}
let count = (classed[0].len() + classed[1].len()) as u32;
meshes.push(InstMesh { first: first_pool, count, opaque: classed[0].len() as u32, rest_first: 0, rest_count: 0, lo, hi, deforms: false, emitters: 0 });
meshes.push(InstMesh { first: first_pool, count, opaque: classed[0].len() as u32, rest_first: 0, rest_count: 0, lo, hi, deforms: false, emitters });

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rigid nodes skip emitter-cutout flatten

Medium Severity

A rigid posed node's emitting triangles now stay in its mesh BLAS with cutouts, but the coincident-vertex flatten added for static models is not applied here. A cutout that lets a ray through still steps past an emitter at the same t, so a masked decal on an emitting quad of a moving node goes dark the way Zero Day did before that rule.

Additional Locations (1)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit e0856a9. Configure here.

…el's moving node too

The rule was in the still placement's branch only (review of #154). One function, flatten_coincident, for both
branches; a structural test on tests/render/data/panel-decal.glb (panel.glb with a masked quad on the emitting one).

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
@yujiaxu-ops
yujiaxu-ops merged commit 00ae78a into main Nov 17, 2026
9 checks passed
@yujiaxu-ops
yujiaxu-ops deleted the emitters-models branch November 17, 2026 15:04
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