Skip to content

S8a: point and spot lights from KHR_lights_punctual - #111

Open
DennisSmolek wants to merge 2 commits into
mainfrom
issue-52-punctual-lights
Open

DennisSmolek wants to merge 2 commits into
mainfrom
issue-52-punctual-lights

Conversation

@DennisSmolek

Copy link
Copy Markdown
Member

Part of #52 (S8: point and spot lights; S8 keeps basisu / Draco / meshopt, occlusion slots, exact browser PNG decode, instancing).

What changed

  • Light kinds: point and spot (KHR_lights_punctual) in the scene copy light table (after the environment), SceneCopyInput.punctualLights, SCENE_FLAG.punctual, SceneCopy.punctual. Delta lights: NEE only, delta = true, pdf 1, no MIS, never hit by a ray. Power 4 pi Y(I) (point) and Y(I) times the integral of the falloff (spot, closed form); selection treats them as bounded lights (V527).
  • Spot falloff exactly as the extension: saturate(cos * scale + offset)^2, scale = 1 / max(0.001, cos inner - cos outer). range ignored (V526).
  • Kernels: integrator.punctual (megakernel and wavefront share ptShadingModulesWgsl), set by ptSceneOptions from the scene copy; setScene throws on a mismatch. ReSTIR refuses it with a message. +470 B on the plain megakernel when on.
  • Loader: loadGltf returns punctualLights (world position, -Z axis for spots, candela as W/sr); bench LightDesc gets point / spot; pbrt point / spot, Mitsuba point / spot, glTF exporter write them.
  • Docs: docs/concepts/lights.mdx, loading-gltf.mdx; DIVERGES V525-V527; TASKS S8a (split); one CLAUDE.md trap.

Verified

  • Default kernels byte-identical: node bench/size-snapshot.ts before / after, diff -rq over 355 files, empty.
  • Scenes punctual-point, punctual-spot, punctual-spot-ramp (256 spp, load-wait 0, correctness only): closed form albedo/pi * I * atten * cos / r^2, mean rel dev 5.6e-7 / -6.6e-7 / -3.4e-6, zero leak outside the cones. Wavefront = megakernel: max per-pixel difference 0.
  • pbrt-v4 and Mitsuba (1024 spp) against ours on punctual-point and punctual-spot: mean 0.000%, max 0.07% (pbrt) / 0.00% (Mitsuba): I is W/sr 1:1 in both. The spot ring (about one pixel) is masked: their smoothstep differs from glTF's ramp (V525).
  • Unit tests: punctual.test.ts (both packages), loader fixtures in load.test.ts and gltf-scene.test.ts. pnpm typecheck clean apart from the known @pmndrs/vdb errors.

Check yourself

node bench/adapters/matrix.ts --renderers pt-megakernel,pt-wavefront --scenes punctual-point,punctual-spot,punctual-spot-ramp --spp 256 --name r then node bench/adapters/punctual-check.ts --report r --pair --refs (the refs need node bench/references/render.ts --scenes punctual-point,punctual-spot --spp 1024).

Left

ReSTIR with punctual lights; NEE through media / equiangular with punctual lights (generic li.delta path, not run); Khronos LightsPunctualLamp is not in the MANIFEST (a hand-built glTF is the fixture).

🤖 Generated with Claude Code

DennisSmolek and others added 2 commits December 2, 2026 03:05
… light sampler (gated)

Part of #52

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…py, both schedulers, pbrt / Mitsuba / glTF exporters, closed-form + reference check)

Part of #52

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>

This branch has not been deployed

No deployments
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