Skip to content

OpenPBR: stochastic coat / transmission weight blend (default stays threshold) - #129

Open
DennisSmolek wants to merge 1 commit into
mainfrom
openpbr-weight-blend
Open

DennisSmolek wants to merge 1 commit into
mainfrom
openpbr-weight-blend

Conversation

@DennisSmolek

Copy link
Copy Markdown
Member

Part of #55 (materials) / #52 (maps).

What

The OpenPBR-mode adapter cut a fractional coatWeight and transmissionWeight at 0.5 (found by PR #122, its V576): a coat of 0.3 rendered as no coat, 0.7 as a full one. OpenPBR mixes linearly.

  • New PtMaterialOptions.weightBlend: 'threshold' | 'stochastic' (bench: pt_weight_blend=stochastic). 'stochastic' draws two numbers per shading point from their own sampler pair (ptWeightPair, 2^30 + vertex: x transmission, y coat) and takes the layer with probability = weight, so the expectation is the linear mix; weights 0 and 1 stay exact. Same model as the metalness mix pick: a fixed function of the vertex's numbers, so NEE and MIS see the same lobe set as the BSDF sample.
  • Default stays threshold: all 355 existing kernels of node bench/size-snapshot.ts are byte-identical (6 new *wblend* files; +0.23 KB on the all-features megakernel).
  • Both schedulers. ReSTIR and materialLod: 'secondary' refuse it (clear error): the reservoir target / reduced adapter would need the same pick. The legacy adapter (no openpbr material) has no per-vertex random number and is unchanged, as is its metalness threshold.
  • Thin film follows the picks. ptMaterialFeatures(table, { weightBlend }) compiles lobes for any weight > 0.
  • DIVERGES V610-V614, TASKS P2.23c, one CLAUDE.md trap. PR P1.4c5: glTF extension texture maps (transmission, clearcoat, specular, sheen) #122's ext-map scenes are not on main, so the fractional-weight map rendering is not shown (open).

Verified (M5 Pro, load 37-53, correctness only)

  • --page weight-blend-check (spp 128): coat sphere (diffuse and metal) at w 0.25/0.5/0.75 vs (1-w)A(0) + wA(1) per mu_o bin: max abs 0.0007-0.0015 (threshold 0.024-0.099). Thin sheet w 0.25..1 vs w T' L: max abs 1.6e-4 (threshold 0.23). Megakernel vs wavefront per pixel: max rel 5.5e-7.
  • --page openpbr-check: stochastic adapter WGSL vs TS twin, 140 cases (5 new fractional materials), 0 mismatches; default mode still 0.
  • 13 unit tests (weight-blend.test.ts) + the touched bsdf / integrator / wavefront / restir / exporter tests pass. pnpm typecheck: only the known @pmndrs/vdb errors.
  • Vs references (new scenes wblend-coat / -glass / -sheet; exporters write pbrt mix and Mitsuba blendbsdf; refs 4096 spp, ours 1024 spp), relBias vs Mitsuba / pbrt:
scene stochastic threshold
coat 0.3 +0.04% / +0.16% +3.7% / +3.8%
glass 0.6 +0.04% / -0.01% +55.7% / +55.6%
thin sheet 0.4 (expected 0.36923) +0.01% / +0.29% (0.36928) -100% / -100%

Wavefront vs megakernel per pixel (pt-wavefront-agreement.ts): max rel 2e-6 / 3e-6 / 0.

A/B for the maintainer (default flip)

node bench/adapters/matrix.ts --renderers pt-megakernel --scenes wblend-coat,wblend-glass,wblend-sheet --spp 1024 --snapshots 16,64,256 --name a --extra pt_weight_blend=stochastic
node bench/adapters/matrix.ts --renderers pt-megakernel --scenes wblend-coat,wblend-glass,wblend-sheet --spp 1024 --snapshots 16,64,256 --name b
node bench/adapters/pt-agreement.ts --report a ; node bench/adapters/pt-agreement.ts --report b

Read relBias and relMSE vs the references; the cost is variance from a binary pick per vertex. No timing claims (0.08 ms/spp on the sheet in both modes, loaded machine).

Open

ReSTIR / reduced adapter with the pick stored; a weight-map scene once #122 lands; spec-form coat scaling (V613). V614 notes a knife edge at exactly 0.5 in the default mode (f64 features vs the unorm16 record).

🤖 Generated with Claude Code

…-V614), default stays threshold

PtMaterialOptions.weightBlend 'stochastic' takes a fractional coatWeight / transmissionWeight layer with
probability = weight from its own sampler pair, so the expectation is OpenPBR's linear mix. Both schedulers;
ReSTIR and materialLod 'secondary' refuse it. Default kernels byte-identical. Checks: weight-blend-check page,
openpbr-check adapter twin, unit tests, wblend-* scenes vs pbrt mix / Mitsuba blendbsdf.

Part of #55.

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