Skip to content

An emitter's probability is what the picker used - #156

Merged
yujiaxu-ops merged 1 commit into
mainfrom
light-consistency
Nov 17, 2026
Merged

yujiaxu-ops merged 1 commit into
mainfrom
light-consistency

Conversation

@yujiaxu-ops

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

Copy link
Copy Markdown
Collaborator

An emitter that changed size in place (a movable model or mesh scaled, a skinned one) kept the weight it was loaded with, while the kernel took its probability from formulas that assumed the weight was the triangle's. Scaled three times larger as a scene's main light it read 3 to 8 % dark, three times smaller 12 % bright. A move alone was right. The fault is older than scene step D.

What changes

  • A light candidate is weighed by the density it was drawn with: its pick's probability over the triangle's own area (sample_emitter_ris).
  • A BSDF ray's hit on an emitter takes that same probability from where the picker reads it (emitter_pmf): the light tree's path, or the emitter's entry in the CDF, which its code now names (emitter_codes, written at load and after edits).
  • So a weight that is out of date costs noise, not light.
  • Gone with the formulas: the particles' case apart (a nominal area and the sign that marked it), the cull test at a hit, "MIS by power alone". The kernel no longer reads Params::emit_power.

Checked

  • New test an_emitter_scaled_in_place_is_lit_as_a_build_lights_it: a model and a mesh, three times larger and smaller, with and without a light tree, against a build's picture (0.06 to 0.31 steps; 2.7 to 7.3 before). The readback test also asserts that the entry an emitter's code names is its own.
  • Mutants: a candidate weighed by the stored area fails the new test (2.77 steps); a code that names no entry fails the readback test; a wrong probability at a hit fails six render tests. One mutant survives every picture test: the hit side computed as if the weight were the triangle's now, under a stale weight. In the live picture BSDF rays' emitter hits carry about half a percent, so that case rests on the entry assertion.
  • cargo test 170 passed, test-render 241 pass.
  • Unbiased check: Zero Day 1.0013 / 1.009, Bistro 0.9999 / 1.004, Bistro at 15 s 0.9999 / 1.001 (as before).
  • render-identity against main: 47 of 241 outputs differ in bytes (another float order); offline ones in last bits, live ones with the mean within 5e-5.
  • Live pictures against main, mean luminance over a 4 x 4 grid: Bistro and Tokyo within 0.1 %; the crowd and Zero Day within 1 % (one run each).
  • Trace p50, main -> this, alternated: Bistro 7.147 -> 7.156 ms, the crowd 7.398 -> 7.388, Zero Day 7.696 -> 7.705. Tokyo not timed.
  • Not run: bench-ghosting, test:layer-b, bench-district (no live pass changes).

🤖 Generated with Claude Code


Note

High Risk
Changes direct-light sampling and MIS in the path tracer—correctness-critical rendering logic—with live edit updates to emitter metadata.

Overview
Emitter light sampling and MIS now use the same probability the picker used at draw time, instead of recomputing density from stale CDF weights or “power alone” formulas. That fixes visibly wrong brightness when emitters change size in place (scaled movable models/meshes) while their load-time weights stay fixed.

On the GPU, emitter_sel becomes emitter_pmf, reading the tree path or the CDF entry named by emitter_codes. emit_mis and sample_emitter_ris weigh candidates and BSDF hits by pick probability over the hit triangle’s actual area; separate particle nominal-area handling, hit-side emitter cull, and Params::emit_power usage on the kernel side are removed.

On the CPU, emitter_codes is built at load and refreshed after live edits; the emitter CDF always stores positive triangle area (no negated nominal areas). Docs and tests add the roadmap note, scaled-emitter picture tests, and readback checks that each emitter’s code points at its own CDF entry.

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

An emitter that changed size in place kept the weight it was loaded with while the kernel's formulas assumed the
weight was the triangle's: scaled three times larger as the main light it read 3 to 8 % dark. A candidate is now
weighed by the density it was drawn with, and a BSDF ray's hit takes the same probability from where the picker
reads it (the tree's path, or the emitter's entry in the CDF, named by its code).

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
@yujiaxu-ops
yujiaxu-ops merged commit e37ed6c into main Nov 17, 2026
9 checks passed
@yujiaxu-ops
yujiaxu-ops deleted the light-consistency branch November 17, 2026 18:58
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