Skip to content

Path Tracer Light Cut Trees and Alias table#1081

Draft
karimsayedre wants to merge 58 commits into
masterfrom
pt-light-cut-tree
Draft

Path Tracer Light Cut Trees and Alias table#1081
karimsayedre wants to merge 58 commits into
masterfrom
pt-light-cut-tree

Conversation

@karimsayedre
Copy link
Copy Markdown
Contributor

Description

Adds many-light next-event estimation to the path tracer: lights are picked either by stochastic lightcuts-style tree or a flat alias table, with MIS-exact probabilitiesn both directions, and the chosen light's solid angle is then sampled with theamplers from #1058 (new-sampler-concepts) and builds upon it. Also adds the GUI and camera work that makeshe path tracer usable and navigatable.

Light tree (sampling/stochastic_lightcut_tree.hlsl)

  • 4-ary heap (children at 4i+1..4i+4, leaves padded to power-of-4) with a canonical 32 B CWBVH-4 packed wide node: fp32 origin, fp16 parent power, one shared biased exponent, 4-bit leaf mask, and per-child 4-bit quantized bboxes (floored min / ceiled max, so decoded boxes always contain the true ones) + 8-bit relative power. One encode/decode contract shared by the CPU builder (CLightTree.cpp) and the GPU accessor.
  • Receiver-adaptive descent with compile-time weight modes (0: full geometric, 1: power-only, 2: uniform, 3: power × orientation, the default; distance importance belongs in the RIS target, not the proposal denominator). Fully-facing clusters take a transcendental-free fast path for the cosine cone bound. MAX_RATIO early stop (Estevez-Kulla "no clear winner"): descent hands the remaining pick to a per-subtree power-weighted alias table in O(1), via the SubtreeAliasAccessor concept. Fix included: the old default τ=0.2 was unsatisfiable (max of 4 non-negative weights ≥ wSum/4), so the stop never fired; default is now 0.5 and the >¼ feasibility bound is documented.

Alias table (sampling/alias_table.hlsl)

  • Used both as the flat NEE selector and for the tree's per-subtree tables. Packed layout A (4 B word + separate pdf[], 8 B/sample).

Renderer (ex40)

  • NEE selector switchable between light tree and flat alias table; beauty shader has three MIS modes (NEE_ONLY, BxDF_ONLY, BOTH) for unbiased A/B anchoring.
  • NEE_PROPOSAL_PROBE debug mode visualizes first-bounce contributing samples;
  • Very experimental debug shader shows the quantized cluster AABBs.

Testing

  • examples_tests 37: CPU builder tests (8 weight distributions), GPU correctness testers for alias/CDF/tree (forward/backward pdf + weight consistency), and the discrete-sampler benchmark sweep (N = 2 → 33.5M, ps/sample via GPU timestamps using the framework from Add structured stats/IRs to pipeline executable info #1070(IBenchmark)), with serialized-RNG loops to prevent unrealistic compiler unrolling/pipelining.
  • ex40 benchmark reports per-row details including Beauty images, usable for bias and FLIP checks; fixed the spp-cap bug that produced no-op frames in cheap rows.

karimsayedre and others added 30 commits December 3, 2025 23:29
# Conflicts:
#	examples_tests
…ation arguments, also used promote instead of _static_cast(not sure if this is fine), also updated examples submodule
# Conflicts:
#	examples_tests
#	include/nbl/ext/FullScreenTriangle/FullScreenTriangle.h
# Conflicts:
#	examples_tests
# Conflicts:
#	examples_tests
#	include/nbl/ext/FullScreenTriangle/FullScreenTriangle.h
#	src/nbl/ext/FullScreenTriangle/CFullScreenTriangle.cpp
…gle Sampler global like its Triangle counterpart, we need to keep the basis around
…local coordinate system) already given and fixed.

This way we can share computation between Solid Angle and Projected Solid Angle calculations

Also apply the `abs` fix from the triangle
devshgraphicsprogramming and others added 27 commits April 17, 2026 03:39
…actical Warps are broken wrong weight was getting returned and MIS weights were inconsistent.

They're broken now, NaN returned as the backwardWeight
always move the scalar multiplication of a vector in a dot product outside the dot product
…ramming/Nabla into solid-angle-vis

# Conflicts:
#	examples_tests
# Conflicts:
#	examples_tests
Add structured stats/IRs to pipeline executable info
# Conflicts:
#	examples_tests
#	include/nbl/builtin/hlsl/sampling/spherical_rectangle.hlsl
…ges, obb silhouettte doesn't need the shading point, added HLSL macros
# Conflicts:
#	examples_tests
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.

3 participants