@naanouff/w3dts-path-tracer 0.0.0-stage → 0.1.18

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (95) hide show
  1. package/README.md +44 -3
  2. package/dist/PathTracer2Project.d.ts +17 -0
  3. package/dist/PathTracer2Project.d.ts.map +1 -0
  4. package/dist/PathTracerFrameUploadController.d.ts +186 -0
  5. package/dist/PathTracerFrameUploadController.d.ts.map +1 -0
  6. package/dist/PathTracerProject.d.ts +19 -0
  7. package/dist/PathTracerProject.d.ts.map +1 -0
  8. package/dist/SceneToRayData.d.ts +72 -0
  9. package/dist/SceneToRayData.d.ts.map +1 -0
  10. package/dist/bloomSubgraph.d.ts +14 -0
  11. package/dist/bloomSubgraph.d.ts.map +1 -0
  12. package/dist/buildPathTracerBvh.d.ts +34 -0
  13. package/dist/buildPathTracerBvh.d.ts.map +1 -0
  14. package/dist/buildPathTracerTwoLevel.d.ts +66 -0
  15. package/dist/buildPathTracerTwoLevel.d.ts.map +1 -0
  16. package/dist/emissiveTriangles.d.ts +28 -0
  17. package/dist/emissiveTriangles.d.ts.map +1 -0
  18. package/dist/fsr1EasuConstants.d.ts +7 -0
  19. package/dist/fsr1EasuConstants.d.ts.map +1 -0
  20. package/dist/hybridAtrous.d.ts +25 -0
  21. package/dist/hybridAtrous.d.ts.map +1 -0
  22. package/dist/hybridOidn.d.ts +15 -0
  23. package/dist/hybridOidn.d.ts.map +1 -0
  24. package/dist/hybridTemporal.d.ts +59 -0
  25. package/dist/hybridTemporal.d.ts.map +1 -0
  26. package/dist/index.d.ts +32 -0
  27. package/dist/index.d.ts.map +1 -0
  28. package/dist/khronosPathTraceReference.d.ts +143 -0
  29. package/dist/khronosPathTraceReference.d.ts.map +1 -0
  30. package/dist/pathTracerBackplate.d.ts +29 -0
  31. package/dist/pathTracerBackplate.d.ts.map +1 -0
  32. package/dist/pathTracerBaselineMetrics.d.ts +98 -0
  33. package/dist/pathTracerBaselineMetrics.d.ts.map +1 -0
  34. package/dist/pathTracerBounceBudget.d.ts +32 -0
  35. package/dist/pathTracerBounceBudget.d.ts.map +1 -0
  36. package/dist/pathTracerCameraLens.d.ts +12 -0
  37. package/dist/pathTracerCameraLens.d.ts.map +1 -0
  38. package/dist/pathTracerConstants.d.ts +165 -0
  39. package/dist/pathTracerConstants.d.ts.map +1 -0
  40. package/dist/pathTracerDielectric.d.ts +30 -0
  41. package/dist/pathTracerDielectric.d.ts.map +1 -0
  42. package/dist/pathTracerEnvMap.d.ts +83 -0
  43. package/dist/pathTracerEnvMap.d.ts.map +1 -0
  44. package/dist/pathTracerGraphDefinition.d.ts +11 -0
  45. package/dist/pathTracerGraphDefinition.d.ts.map +1 -0
  46. package/dist/pathTracerInteractionEpoch.d.ts +11 -0
  47. package/dist/pathTracerInteractionEpoch.d.ts.map +1 -0
  48. package/dist/pathTracerInterleave.d.ts +74 -0
  49. package/dist/pathTracerInterleave.d.ts.map +1 -0
  50. package/dist/pathTracerLightFingerprint.d.ts +26 -0
  51. package/dist/pathTracerLightFingerprint.d.ts.map +1 -0
  52. package/dist/pathTracerMaterialTable.d.ts +63 -0
  53. package/dist/pathTracerMaterialTable.d.ts.map +1 -0
  54. package/dist/pathTracerMaterialTextureArrays.d.ts +58 -0
  55. package/dist/pathTracerMaterialTextureArrays.d.ts.map +1 -0
  56. package/dist/pathTracerOidnDenoiser.d.ts +43 -0
  57. package/dist/pathTracerOidnDenoiser.d.ts.map +1 -0
  58. package/dist/pathTracerPost.d.ts +137 -0
  59. package/dist/pathTracerPost.d.ts.map +1 -0
  60. package/dist/pathTracerRuntimeConfig.d.ts +6 -0
  61. package/dist/pathTracerRuntimeConfig.d.ts.map +1 -0
  62. package/dist/pathTracerSceneCache.d.ts +32 -0
  63. package/dist/pathTracerSceneCache.d.ts.map +1 -0
  64. package/dist/pathTracerSceneSettings.d.ts +43 -0
  65. package/dist/pathTracerSceneSettings.d.ts.map +1 -0
  66. package/dist/progressiveRenderState.d.ts +34 -0
  67. package/dist/progressiveRenderState.d.ts.map +1 -0
  68. package/dist/w3dts-path-tracer.es.js +4555 -0
  69. package/dist/w3dts-path-tracer.umd.js +46 -0
  70. package/package.json +55 -3
  71. package/shaders/clear_composite.compute.wgsl +20 -0
  72. package/shaders/clear_composite_layers.compute.wgsl +32 -0
  73. package/shaders/clear_path_trace_tile.compute.wgsl +30 -0
  74. package/shaders/copy_accum.compute.wgsl +15 -0
  75. package/shaders/denoise.compute.wgsl +88 -0
  76. package/shaders/denoise_atrous.compute.wgsl +104 -0
  77. package/shaders/display_grade.wgsl +74 -0
  78. package/shaders/fsr1_easu_path.compute.wgsl +240 -0
  79. package/shaders/fsr1_rcas_path.compute.wgsl +84 -0
  80. package/shaders/hole_fill.compute.wgsl +57 -0
  81. package/shaders/hybrid_atrous.compute.wgsl +239 -0
  82. package/shaders/hybrid_copy_aov.compute.wgsl +24 -0
  83. package/shaders/hybrid_gbuffer.wgsl +150 -0
  84. package/shaders/hybrid_history_copy.compute.wgsl +35 -0
  85. package/shaders/hybrid_primary_aov.compute.wgsl +784 -0
  86. package/shaders/hybrid_taa.compute.wgsl +131 -0
  87. package/shaders/hybrid_temporal.compute.wgsl +507 -0
  88. package/shaders/path_trace.compute.wgsl +923 -0
  89. package/shaders/path_trace_common.wgsl +1738 -0
  90. package/shaders/pt_bloom.compute.wgsl +91 -0
  91. package/shaders/pt_bloom_down.compute.wgsl +88 -0
  92. package/shaders/pt_bloom_up.compute.wgsl +76 -0
  93. package/shaders/pt_display.frag.wgsl +29 -0
  94. package/shaders/tile_composite.compute.wgsl +22 -0
  95. package/shaders/tile_composite_layers.compute.wgsl +86 -0
@@ -0,0 +1,30 @@
1
+ /**
2
+ * @file pathTracerDielectric.ts
3
+ * @description TypeScript mirror of the dielectric helpers in `path_trace.compute.wgsl`
4
+ * (`fresnel_dielectric`, `refract`, `beer_lambert`, `dispersive_ior`, `spectral_rgb_weight`).
5
+ * Keep both in sync; the WGSL source test guards the function names.
6
+ */
7
+ export type Vec3 = [number, number, number];
8
+ /** Hero wavelength range (nm) sampled uniformly at the first dispersive refraction. */
9
+ export declare const PATH_TRACER_SPECTRAL_MIN_NM = 400;
10
+ export declare const PATH_TRACER_SPECTRAL_MAX_NM = 700;
11
+ /**
12
+ * Exact unpolarized Fresnel reflectance; `eta = n_incident / n_transmitted`.
13
+ * Returns 1 on total internal reflection.
14
+ */
15
+ export declare function fresnelDielectric(cosI: number, eta: number): number;
16
+ /** WGSL `refract(i, n, eta)`: zero vector on total internal reflection. */
17
+ export declare function refract(i: Vec3, n: Vec3, eta: number): Vec3;
18
+ /** Beer–Lambert transmittance over `distance`; `attenuationDistance` 0 = no absorption (KHR volume). */
19
+ export declare function beerLambert(attenuationColor: Vec3, attenuationDistance: number, distance: number): Vec3;
20
+ /**
21
+ * Cauchy IOR `n(λ) = A + B / λ²` fitted to `n_d` at 587.6 nm and the Abbe number from KHR
22
+ * `dispersion = 20 / V` (so `n_F − n_C = (n_d − 1) / V`).
23
+ */
24
+ export declare function dispersiveIor(nd: number, dispersion: number, lambdaNm: number): number;
25
+ /**
26
+ * RGB weight of a hero wavelength sampled uniformly in [400, 700] nm. Hat functions form a
27
+ * partition of unity whose mean over the range is 1/3 each, so `3 · hat` averages to white.
28
+ */
29
+ export declare function spectralRgbWeight(lambdaNm: number): Vec3;
30
+ //# sourceMappingURL=pathTracerDielectric.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pathTracerDielectric.d.ts","sourceRoot":"","sources":["../src/pathTracerDielectric.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,MAAM,MAAM,IAAI,GAAG,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;AAE5C,uFAAuF;AACvF,eAAO,MAAM,2BAA2B,MAAM,CAAC;AAC/C,eAAO,MAAM,2BAA2B,MAAM,CAAC;AAO/C;;;GAGG;AACH,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,MAAM,CAQnE;AAED,2EAA2E;AAC3E,wBAAgB,OAAO,CAAC,CAAC,EAAE,IAAI,EAAE,CAAC,EAAE,IAAI,EAAE,GAAG,EAAE,MAAM,GAAG,IAAI,CAM3D;AAED,wGAAwG;AACxG,wBAAgB,WAAW,CACzB,gBAAgB,EAAE,IAAI,EACtB,mBAAmB,EAAE,MAAM,EAC3B,QAAQ,EAAE,MAAM,GACf,IAAI,CAMN;AAED;;;GAGG;AACH,wBAAgB,aAAa,CAAC,EAAE,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,CAOtF;AAED;;;GAGG;AACH,wBAAgB,iBAAiB,CAAC,QAAQ,EAAE,MAAM,GAAG,IAAI,CAKxD"}
@@ -0,0 +1,83 @@
1
+ /**
2
+ * @file pathTracerEnvMap.ts
3
+ * @description Equirect environment: ACEScg → linear sRGB, importance CDF, softbox packing.
4
+ * Buffer layout matches `pathTracerEnv` in `path_trace.compute.wgsl` (binding 6).
5
+ */
6
+ export declare const PATH_TRACER_ENV_MAX_LIGHTS = 4;
7
+ export declare function acescgToLinearSrgb(r: number, g: number, b: number): [number, number, number];
8
+ /** Rec.709 luminance of a linear sRGB radiance. */
9
+ export declare function envLuminance(r: number, g: number, b: number): number;
10
+ /**
11
+ * Direction of a Light Tracer environment light, in glTF Y-up.
12
+ * `AngleX` / `AngleY` are radians in Light Tracer's Z-up frame (same frame as
13
+ * the camera extras). `Ry(angleY) * Rx(-angleX) * +Z`, then `(x, z, −y)`.
14
+ * The pitch sign is the one that puts the bench's first softbox inside its
15
+ * cone of the bench camera.
16
+ */
17
+ export declare function environmentLightDirection(angleX: number, angleY: number): [number, number, number];
18
+ /** Solid angle of a cone whose full opening is `fullAngle` radians. */
19
+ export declare function coneSolidAngle(fullAngle: number): number;
20
+ /**
21
+ * Radiance inside the cone. `LightPower` is that radiance: dividing by Ω left
22
+ * a face-on diamond near 1, under the glare threshold 4.5, while the bench
23
+ * capture blows those stones out. A zero opening emits nothing.
24
+ */
25
+ export declare function softboxRadiance(power: number, fullAngle: number): number;
26
+ /**
27
+ * Emission mask of a softbox. `angularDist` / `phi` are measured from the axis.
28
+ * `halfAngle` is the bounding cone. `sides` < 3 is a disk. `falloff` is the
29
+ * fraction of the radius used to fade out (0 = hard edge).
30
+ */
31
+ export declare function softboxWeight(angularDist: number, phi: number, halfAngle: number, sides: number, falloff: number): number;
32
+ /**
33
+ * Radiance of one softbox along `dir` (from the surface toward the light).
34
+ * A specular miss sees this value. Opaque NEE integrates the same radiance
35
+ * over the cone, so the two estimators must not both run on one event.
36
+ */
37
+ export declare function softboxEmissionAlong(dir: readonly [number, number, number], axis: readonly [number, number, number], radiance: number, color: readonly [number, number, number], halfAngle: number, sides: number, falloff: number): [number, number, number];
38
+ export interface EnvImportance {
39
+ width: number;
40
+ height: number;
41
+ /** Inclusive CDF over rows, length `height`. */
42
+ marginal: Float32Array;
43
+ /** Inclusive CDF inside each row, row-major `height * width`. */
44
+ conditional: Float32Array;
45
+ /** Σ luminance · sin(θ). */
46
+ sumWeight: number;
47
+ }
48
+ /** Builds a luminance · sin(θ) CDF. `rgb` is tightly packed linear radiance. */
49
+ export declare function buildEnvImportance(rgb: Float32Array, width: number, height: number): EnvImportance;
50
+ /** Solid-angle pdf of the pixel that contains `lum` (the sin(θ) terms cancel). */
51
+ export declare function envSolidAnglePdf(lum: number, width: number, height: number, sumWeight: number): number;
52
+ /**
53
+ * Lookup direction for a panorama rotated by `rot` (radians, XYZ = PanoAngles).
54
+ * `R = Ry · Rx · Rz`; the map is sampled with `Rᵀ · worldDir`.
55
+ */
56
+ export declare function mapDirectionForLookup(dir: readonly [number, number, number], rot: readonly [number, number, number]): [number, number, number];
57
+ export interface PathTracerEnvLight {
58
+ direction: readonly [number, number, number];
59
+ color: readonly [number, number, number];
60
+ power: number;
61
+ /** Full angular size, radians. */
62
+ angleSize: number;
63
+ sides: number;
64
+ falloff: number;
65
+ /** Environment slot this light is linked to (gem softboxes use 1). */
66
+ slot: number;
67
+ enabled: boolean;
68
+ }
69
+ export interface PathTracerEnvLayer {
70
+ /** Linear sRGB radiance, RGB, `PATH_TRACER_ENV_WIDTH * HEIGHT * 3`. */
71
+ rgb: Float32Array;
72
+ rotation: readonly [number, number, number];
73
+ lights: readonly PathTracerEnvLight[];
74
+ }
75
+ /** Resamples an RGBA equirect to the path-tracer resolution and applies color + power. */
76
+ export declare function equirectToEnvRgb(rgba: Float32Array, width: number, height: number, options: {
77
+ acescg: boolean;
78
+ powerScale: number;
79
+ }): Float32Array;
80
+ export declare function emptyEnvLayer(): PathTracerEnvLayer;
81
+ /** Packs up to two layers. A null slot before the last used one becomes black. */
82
+ export declare function packPathTracerEnvironments(layers: readonly (PathTracerEnvLayer | null)[]): Float32Array;
83
+ //# sourceMappingURL=pathTracerEnvMap.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pathTracerEnvMap.d.ts","sourceRoot":"","sources":["../src/pathTracerEnvMap.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAmBH,eAAO,MAAM,0BAA0B,IAAI,CAAC;AAK5C,wBAAgB,kBAAkB,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAO5F;AAED,mDAAmD;AACnD,wBAAgB,YAAY,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,CAEpE;AAED;;;;;;GAMG;AACH,wBAAgB,yBAAyB,CACvC,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,MAAM,GACb,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAU1B;AAED,uEAAuE;AACvE,wBAAgB,cAAc,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,CAGxD;AAED;;;;GAIG;AACH,wBAAgB,eAAe,CAAC,KA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,SAAS,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,GACrC,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAgB1B;AAED,MAAM,WAAW,kBAAkB;IACjC,SAAS,EAAE,SAAS,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;IAC7C,KAAK,EAAE,SAAS,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;IACzC,KAAK,EAAE,MAAM,CAAC;IACd,kCAAkC;IAClC,SAAS,EAAE,MAAM,CAAC;IAClB,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,CAAC;IAChB,sEAAsE;IACtE,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,OAAO,CAAC;CAClB;AAED,MAAM,WAAW,kBAAkB;IACjC,uEAAuE;IACvE,GAAG,EAAE,YAAY,CAAC;IAClB,QAAQ,EAAE,SAAS,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;IAC5C,MAAM,EAAE,SAAS,kBAAkB,EAAE,CAAC;CACvC;AAgCD,0FAA0F;AAC1F,wBAAgB,gBAAgB,CAC9B,IAAI,EAAE,YAAY,EAClB,KAAK,EAAE,MAAM,EACb,MAAM,EAAE,MAAM,EACd,OAAO,EAAE;IAAE,MAAM,EAAE,OAAO,CAAC;IAAC,UAAU,EAAE,MAAM,CAAA;CAAE,GAC/C,YAAY,CAmCd;AAED,wBAAgB,aAAa,IAAI,kBAAkB,CAMlD;AAED,kFAAkF;AAClF,wBAAgB,0BAA0B,CACxC,MAAM,EAAE,SAAS,CAAC,kBAAkB,GAAG,IAAI,CAAC,EAAE,GAC7C,YAAY,CA6Dd"}
@@ -0,0 +1,11 @@
1
+ import { GraphDefinitionFile } from '../../core/src/index.ts';
2
+ export declare function createPathTracerGraphDefinition(tileSizePx: number): GraphDefinitionFile;
3
+ export declare const pathTracerGraphDefinition: GraphDefinitionFile;
4
+ /**
5
+ * Scene buffers plus the two accumulated AOVs. No tile composite, FSR, bloom, or screen blit.
6
+ * `tileSizePx` is ignored: the trace is full frame.
7
+ */
8
+ export declare function createHybridAovSubgraph(tileSizePx: number): GraphDefinitionFile;
9
+ /** @deprecated The hybrid graph uses {@link createHybridAovSubgraph}. */
10
+ export declare function createPathTracerSubgraphForHybrid(tileSizePx: number): GraphDefinitionFile;
11
+ //# sourceMappingURL=pathTracerGraphDefinition.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pathTracerGraphDefinition.d.ts","sourceRoot":"","sources":["../src/pathTracerGraphDefinition.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAC;AA4DhE,wBAAgB,+BAA+B,CAAC,UAAU,EAAE,MAAM,GAAG,mBAAmB,CA2kBvF;AAED,eAAO,MAAM,yBAAyB,qBAAyD,CAAC;AAkFhG;;;GAGG;AACH,wBAAgB,uBAAuB,CAAC,UAAU,EAAE,MAAM,GAAG,mBAAmB,CAuR/E;AAED,yEAAyE;AACzE,wBAAgB,iCAAiC,CAAC,UAAU,EAAE,MAAM,GAAG,mBAAmB,CAEzF"}
@@ -0,0 +1,11 @@
1
+ /**
2
+ * @file pathTracerInteractionEpoch.ts
3
+ * @description Monotonic counter bumped on every path-trace accumulation reset (camera / scene).
4
+ * Async consumers (final OIDN denoise, export) capture it before starting and drop their result
5
+ * if it changed, so a slow denoise never overwrites the beauty of a newer view.
6
+ */
7
+ /** Current interaction epoch (0 before the first reset). */
8
+ export declare function getPathTracerInteractionEpoch(): number;
9
+ /** Marks a camera / scene interaction; invalidates in-flight async results. */
10
+ export declare function bumpPathTracerInteractionEpoch(): void;
11
+ //# sourceMappingURL=pathTracerInteractionEpoch.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pathTracerInteractionEpoch.d.ts","sourceRoot":"","sources":["../src/pathTracerInteractionEpoch.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AASH,4DAA4D;AAC5D,wBAAgB,6BAA6B,IAAI,MAAM,CAEtD;AAED,+EAA+E;AAC/E,wBAAgB,8BAA8B,IAAI,IAAI,CAIrD"}
@@ -0,0 +1,74 @@
1
+ /**
2
+ * @file pathTracerInterleave.ts
3
+ * @description Phase 2: Bayer spatial interleave + GPU-budget controller (stride instead of frame skip).
4
+ */
5
+ /**
6
+ * Returns the (offsetX, offsetY) for a given interleave phase and spatial stride.
7
+ * After `stride²` phases, every pixel in the grid has been visited once.
8
+ */
9
+ export declare function bayerOffsetForPhase(stride: number, phase: number): {
10
+ ox: number;
11
+ oy: number;
12
+ };
13
+ /** Dispatch dimensions for a full-frame interleaved pass. */
14
+ export declare function interleaveDispatchSize(fullW: number, fullH: number, stride: number): {
15
+ dispatchW: number;
16
+ dispatchH: number;
17
+ };
18
+ /**
19
+ * Workgroups for a PathTrace dispatch that covers only the Bayer sublattice
20
+ * (`ceil(pixelCount / stride)` threads, grouped by `threadsPerGroup`).
21
+ */
22
+ export declare function interleaveWorkgroupCount(fullW: number, fullH: number, stride: number, threadsPerGroup?: number): [number, number, number];
23
+ /**
24
+ * Adds the fraction of a full-frame sample covered by one Bayer pass.
25
+ * Stride 1 adds 1, stride 2 adds 1/4. Uses this pass's stride only:
26
+ * re-dividing the whole history by the current stride made the HUD jump
27
+ * to 100% when stride dropped, then fall back when it rose.
28
+ */
29
+ export declare function accumulateSpatialSpp(spp: number, stride: number): number;
30
+ /** True once `phase` has covered a full Bayer cell (every pixel got ≥1 sample this round). */
31
+ export declare function interleaveRoundComplete(stride: number, phase: number): boolean;
32
+ /**
33
+ * Adjusts spatial interleave stride from measured frame time (EWMA).
34
+ * Replaces temporal `progressiveFrameStride` skipping for progressive mode.
35
+ */
36
+ export declare class SpatialBudgetController {
37
+ private ewmaMs;
38
+ private stride;
39
+ private readonly alpha;
40
+ constructor(initialStride?: number);
41
+ getStride(): number;
42
+ setStride(stride: number): void;
43
+ /** Ingest frame delta (ms) and return the updated stride. */
44
+ tick(frameDeltaMs: number): number;
45
+ reset(): void;
46
+ }
47
+ /**
48
+ * Extended `pathTracerTileInfo` layout (16 × u32) for Phase 2 interleave.
49
+ * Indices 0–7: legacy tile fields; 8–11: stride / offset / mode.
50
+ */
51
+ export declare const PATH_TRACER_TILE_INFO_U32S = 16;
52
+ export declare const PATH_TRACER_TILE_INFO_BUFFER_BYTES_V2: number;
53
+ export declare const TILE_INFO_STRIDE = 8;
54
+ export declare const TILE_INFO_OFFSET_X = 9;
55
+ export declare const TILE_INFO_OFFSET_Y = 10;
56
+ /** 1 = full-frame spatial interleave (Phase 2). */
57
+ export declare const TILE_INFO_PROGRESSIVE_MODE = 11;
58
+ /**
59
+ * Phase 5 AOV debug (written into beauty composite for display):
60
+ * 0=beauty, 1=albedo, 2=normal, 3=depth, 4=objectId.
61
+ */
62
+ export declare const TILE_INFO_AOV_DEBUG = 12;
63
+ /** 1 = freeze beauty composite (OIDN final result); skip TileComposite beauty writes. */
64
+ export declare const TILE_INFO_FREEZE_BEAUTY = 13;
65
+ /**
66
+ * f32 bits: hybrid reflection roughness ceiling. 0 = shader default 0.5.
67
+ * Read by `hybrid_primary_aov.compute.wgsl`.
68
+ */
69
+ export declare const TILE_INFO_HYBRID_REFL_ROUGH = 14;
70
+ /** f32 bits: hybrid firefly clamp on luminance. 0 = shader default 20. */
71
+ export declare const TILE_INFO_HYBRID_CLAMP = 15;
72
+ export type PathTracerAovDebugView = 'off' | 'albedo' | 'normal' | 'depth' | 'objectId';
73
+ export declare function pathTracerAovDebugMode(view: PathTracerAovDebugView | undefined): number;
74
+ //# sourceMappingURL=pathTracerInterleave.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pathTracerInterleave.d.ts","sourceRoot":"","sources":["../src/pathTracerInterleave.ts"],"names":[],"mappings":"AAAA;;;GAGG;AA6BH;;;GAGG;AACH,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG;IAAE,EA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7C;;;GAGG;AACH,eAAO,MAAM,mBAAmB,KAAK,CAAC;AACtC,yFAAyF;AACzF,eAAO,MAAM,uBAAuB,KAAK,CAAC;AAC1C;;;GAGG;AACH,eAAO,MAAM,2BAA2B,KAAK,CAAC;AAC9C,0EAA0E;AAC1E,eAAO,MAAM,sBAAsB,KAAK,CAAC;AAEzC,MAAM,MAAM,sBAAsB,GAAG,KAAK,GAAG,QAAQ,GAAG,QAAQ,GAAG,OAAO,GAAG,UAAU,CAAC;AAExF,wBAAgB,sBAAsB,CAAC,IAAI,EAAE,sBAAsB,GAAG,SAAS,GAAG,MAAM,CAavF"}
@@ -0,0 +1,26 @@
1
+ import { World } from '../../core/src/index.ts';
2
+ /** One light, already resolved to world space. */
3
+ export interface PathTracerLightSample {
4
+ id: number;
5
+ /** 0 directional, 1 point, 2 spot, 3 area. */
6
+ type: number;
7
+ /** World matrix, 16 floats. */
8
+ transform: ArrayLike<number>;
9
+ color: ArrayLike<number>;
10
+ intensity: number;
11
+ range: number;
12
+ inner: number;
13
+ outer: number;
14
+ /** 1 when the light casts a shadow. */
15
+ shadows: number;
16
+ /** Area shape code, 0 otherwise. */
17
+ shape: number;
18
+ }
19
+ /**
20
+ * Stable fingerprint. Floats are quantized to 1e-4 so noise does not reset the accumulation.
21
+ * Order follows entity id, then light type.
22
+ */
23
+ export declare function hashPathTracerLights(lights: readonly PathTracerLightSample[]): number;
24
+ /** Reads directional, point, spot and area lights. Missing transform uses the identity. */
25
+ export declare function collectPathTracerLights(world: World): PathTracerLightSample[];
26
+ //# sourceMappingURL=pathTracerLightFingerprint.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pathTracerLightFingerprint.d.ts","sourceRoot":"","sources":["../src/pathTracerLightFingerprint.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAOL,KAAK,KAAK,EACX,MAAM,sBAAsB,CAAC;AAE9B,kDAAkD;AAClD,MAAM,WAAW,qBAAqB;IACpC,EAAE,EAAE,MAAM,CAAC;IACX,8CAA8C;IAC9C,IAAI,EAAE,MAAM,CAAC;IACb,+BAA+B;IAC/B,SAAS,EAAE,SAAS,CAAC,MAAM,CAAC,CAAC;IAC7B,KAAK,EAAE,SAAS,CAAC,MAAM,CAAC,CAAC;IACzB,SAAS,EAAE,MAAM,CAAC;IAClB,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;IACd,uCAAuC;IACvC,OAAO,EAAE,MAAM,CAAC;IAChB,oCAAoC;IACpC,KAAK,EAAE,MAAM,CAAC;CACf;AAYD;;;GAGG;AACH,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,SAAS,qBAAqB,EAAE,GAAG,MAAM,CAmBrF;AA8BD,2FAA2F;AAC3F,wBAAgB,uBAAuB,CAAC,KAAK,EAAE,KAAK,GAAG,qBAAqB,EAAE,CAiF7E"}
@@ -0,0 +1,63 @@
1
+ /**
2
+ * @file pathTracerMaterialTable.ts
3
+ * @description Per-material GPU table (`pathTracerMaterials`), independent of texture slots: every
4
+ * material keeps its transmission / IOR / volume / BSDF kind even without textures.
5
+ * Triangles store the table index; the texture slot is read from the record.
6
+ */
7
+ /** Floats per record; must match WGSL `PathTracerMaterial` (5 × vec4<f32>). */
8
+ export declare const PATH_TRACER_MATERIAL_FLOATS = 20;
9
+ /** Record capacity; index 0 is the default material (draws without a material id or past the cap). */
10
+ export declare const PATH_TRACER_MAX_MATERIALS = 4096;
11
+ export declare const PATH_TRACER_MATERIALS_BUFFER_BYTES: number;
12
+ /** Float offsets inside one record (WGSL: a, spec, trans, atten, extra). */
13
+ export declare const PATH_TRACER_MATERIAL_FIELD: {
14
+ readonly texSlot: 0;
15
+ readonly bsdfKind: 1;
16
+ readonly envSlot: 2;
17
+ /** header.w: 0 opaque, >0 MASK cutoff, <0 BLEND (stochastic coverage). */
18
+ readonly alphaMode: 3;
19
+ readonly specularFactor: 4;
20
+ readonly specularColor: 5;
21
+ readonly transmission: 8;
22
+ readonly opacity: 9;
23
+ readonly ior: 10;
24
+ readonly dispersion: 11;
25
+ readonly attenuationColor: 12;
26
+ readonly attenuationDistance: 15;
27
+ readonly clearcoat: 16;
28
+ readonly clearcoatRoughness: 17;
29
+ readonly catcherReflect: 18;
30
+ readonly shadowCatcherCutoff: 19;
31
+ };
32
+ export declare const PATH_TRACER_BSDF_SHADOW_CATCHER = 2;
33
+ export declare const PATH_TRACER_BSDF_UNLIT = 3;
34
+ export type PathTracerMaterialLike = {
35
+ id?: number;
36
+ shadingModel?: string;
37
+ alphaMode?: string;
38
+ alphaCutoff?: number;
39
+ shaderGraph?: unknown;
40
+ properties?: Map<string, unknown>;
41
+ };
42
+ /**
43
+ * True when a material uses `KHR_materials_unlit` / `UnlitMasterNode` (`shadingModel === 'unlit'`,
44
+ * `bsdfKind === 3`, or a shader graph containing `UnlitMasterNode`).
45
+ */
46
+ export declare function isUnlitMaterialLike(m: PathTracerMaterialLike | undefined | null): boolean;
47
+ /** Built once per scene triangle build; upload the first {@link count} records. */
48
+ export declare class PathTracerMaterialTable {
49
+ readonly data: Float32Array<ArrayBuffer>;
50
+ private readonly indexById;
51
+ private nextIndex;
52
+ private transmissive;
53
+ constructor();
54
+ /** Drops all records but the default one (pooled reuse across scene builds). */
55
+ reset(): void;
56
+ /** At least one recorded material has transmission > 0. */
57
+ get hasTransmission(): boolean;
58
+ get count(): number;
59
+ /** Byte length of the used records. */
60
+ get byteLength(): number;
61
+ getIndex(material: PathTracerMaterialLike, texSlot: number): number;
62
+ }
63
+ //# sourceMappingURL=pathTracerMaterialTable.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pathTracerMaterialTable.d.ts","sourceRoot":"","sources":["../src/pathTracerMaterialTable.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAIH,+EAA+E;AAC/E,eAAO,MAAM,2BAA2B,KAAK,CAAC;AAE9C,sGAAsG;AACtG,eAAO,MAAM,yBAAyB,OAAO,CAAC;AAE9C,eAAO,MAAM,kCAAkC,QACc,CAAC;AAE9D,4EAA4E;AAC5E,eAAO,MAAM,0BAA0B;;;;IAIrC,0EAA0E;;;;;;;;;;;;;;CAclE,CAAC;AAIX,eAAO,MAAM,+BAA+B,IAAI,CAAC;AACjD,eAAO,MAAM,sBAAsB,IAAI,CAAC;AAExC,MAAM,MAAM,sBAAsB,GAAG;IACnC,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,UAAU,CAAC,EAAE,GAAG,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACnC,CAAC;AAEF;;;GAGG;AACH,wBAAgB,mBAAmB,CAAC,CAAC,EAAE,sBAAsB,GAAG,SAAS,GAAG,IAAI,GAAG,OAAO,CAMzF;AAsGD,mFAAmF;AACnF,qBAAa,uBAAuB;IAClC,QAAQ,CAAC,IAAI,4BAA6E;IAC1F,OAAO,CAAC,QAAQ,CAAC,SAAS,CAA6B;IACvD,OAAO,CAAC,SAAS,CAAK;IACtB,OAAO,CAAC,YAAY,CAAS;;IAM7B,gFAAgF;IAChF,KAAK,IAAI,IAAI;IAMb,2DAA2D;IAC3D,IAAI,eAAe,IAAI,OAAO,CAE7B;IAED,IAAI,KAAK,IAAI,MAAM,CAElB;IAED,uCAAuC;IACvC,IAAI,UAAU,IAAI,MAAM,CAEvB;IAED,QAAQ,CAAC,QAAQ,EAAE,sBAAsB,EAAE,OAAO,EAAE,MAAM,GAAG,MAAM;CAsBpE"}
@@ -0,0 +1,58 @@
1
+ import { PathTracerTextureSlot } from './SceneToRayData';
2
+ export interface MaterialBlitSourceStrategy {
3
+ targetFormat: 'rgba8unorm' | 'rgba8unorm-srgb';
4
+ sourceViewFormat?: GPUTextureFormat;
5
+ decodeSrgbInShader: boolean;
6
+ }
7
+ /**
8
+ * Resolves how a material texture channel is blitted into its packed array layer:
9
+ * - Color channels (`albedo` = 0, `emissive` = 3) pack into `'rgba8unorm-srgb'` so WebGPU hardware
10
+ * decodes sRGB -> linear with linear texel filtering on every ray sample (`glTF 2.0 §3.9`).
11
+ * - Data channels (`orm` = 1, `normal` = 2) stay strictly `'rgba8unorm'` linear.
12
+ */
13
+ export declare function resolveMaterialBlitSourceStrategy(srcFormat: string | undefined, supportsSrgbView: boolean, isColorChannel: boolean): MaterialBlitSourceStrategy;
14
+ type ArrayBindTarget = {
15
+ setOutput(handle: string, texture: GPUTexture): void;
16
+ };
17
+ export interface MaterialTextureArrayDimensions {
18
+ /** Total active slot count (`maxSlot + 1`, or `0` if no textured slot is used). */
19
+ totalSlots: number;
20
+ /** Per-channel `[albedo, orm, normal, emissive]` layer counts (each `>= 1` when `totalSlots > 0`). */
21
+ channelLayers: [number, number, number, number];
22
+ /** Per-channel `[albedo, orm, normal, emissive]` square edge in texels (`1` when channel is unused). */
23
+ channelEdges: [number, number, number, number];
24
+ /** Combined RGBA8 byte footprint across the 4 arrays. */
25
+ totalBytes: number;
26
+ }
27
+ /**
28
+ * Computes independent `[edge, edge, layers]` dimensions for each of the four material texture arrays
29
+ * (`albedo`, `orm`, `normal`, `emissive`), keeping unused channels at `1×1×1` (4 B) and scaling down
30
+ * the largest channel edges if total RGBA8 memory exceeds `maxVramBytes`.
31
+ */
32
+ export declare function computeMaterialTextureArrayDimensions(slots: readonly PathTracerTextureSlot[], flags: Uint32Array, maxEdge?: number, maxVramBytes?: number): MaterialTextureArrayDimensions;
33
+ /**
34
+ * Builds and reuses the four material arrays. Call {@link sync} when the scene slots change,
35
+ * then {@link bind} on each render graph that runs PathTrace.
36
+ */
37
+ export declare class PathTracerMaterialTextureArrays {
38
+ private device;
39
+ private pipelineLinear;
40
+ private pipelineSrgbLinearSrc;
41
+ private pipelineSrgbDecodeSrc;
42
+ private sampler;
43
+ private bindGroupLayout;
44
+ private albedo;
45
+ private orm;
46
+ private normal;
47
+ private emissive;
48
+ private sources;
49
+ private channelEdges;
50
+ private channelLayers;
51
+ private warned;
52
+ sync(device: GPUDevice, slots: PathTracerTextureSlot[], flags: Uint32Array): void;
53
+ bind(graph: ArrayBindTarget): void;
54
+ private ensurePipeline;
55
+ private rebuild;
56
+ }
57
+ export {};
58
+ //# sourceMappingURL=pathTracerMaterialTextureArrays.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pathTracerMaterialTextureArrays.d.ts","sourceRoot":"","sources":["../src/pathTracerMaterialTextureArrays.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAOH,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,kBAAkB,CAAC;AAgD9D,MAAM,WAAW,0BAA0B;IACzC,YAAY,EAAE,YAAY,GAAG,iBAAiB,CAAC;IAC/C,gBAAgB,CAAC,EAAE,gBAAgB,CAAC;IACpC,kBAAkB,EAAE,OAAO,CAAC;CAC7B;AAED;;;;;GAKG;AACH,wBAAgB,iCAAiC,CAC/C,SAAS,EAAE,MAAM,GAAG,SAAS,EAC7B,gBAAgB,EAAE,OAAO,EACzB,cAAc,EAAE,OAAO,GACtB,0BAA0B,CAiC5B;AAKD,KAAK,eAAe,GAAG;IACrB,SAAS,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,UAAU,GAAG,IAAI,CAAC;CACtD,CAAC;AAEF,MAAM,WAAW,8BAA8B;IAC7C,mFAAmF;IACnF,UAAU,EAAE,MAAM,CAAC;IACnB,sGAAsG;IACtG,aAAa,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;IAChD,wGAAwG;IACxG,YAAY,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;IAC/C,yDAAyD;IACzD,UAAU,EAAE,MAAM,CAAC;CACpB;AAED;;;;GAIG;AACH,wBAAgB,qCAAqC,CACnD,KAAK,EAAE,SAAS,qBAAqB,EAAE,EACvC,KAAK,EAAE,WAAW,EAClB,OAAO,SAAiC,EACxC,YAAY,SAAuC,GAClD,8BAA8B,CAsFhC;AAED;;;GAGG;AACH,qBAAa,+BAA+B;IAC1C,OAAO,CAAC,MAAM,CAA0B;IACxC,OAAO,CAAC,cAAc,CAAkC;IACxD,OAAO,CAAC,qBAAqB,CAAkC;IAC/D,OAAO,CAAC,qBAAqB,CAAkC;IAC/D,OAAO,CAAC,OAAO,CAA2B;IAC1C,OAAO,CAAC,eAAe,CAAmC;IAC1D,OAAO,CAAC,MAAM,CAA2B;IACzC,OAAO,CAAC,GAAG,CAA2B;IACtC,OAAO,CAAC,MAAM,CAA2B;IACzC,OAAO,CAAC,QAAQ,CAA2B;IAC3C,OAAO,CAAC,OAAO,CAA6B;IAC5C,OAAO,CAAC,YAAY,CAAkD;IACtE,OAAO,CAAC,aAAa,CAAkD;IACvE,OAAO,CAAC,MAAM,CAAS;IAEvB,IAAI,CAAC,MAAM,EAAE,SAAS,EAAE,KAAK,EAAE,qBAAqB,EAAE,EAAE,KAAK,EAAE,WAAW,GAAG,IAAI;IAqCjF,IAAI,CAAC,KAAK,EAAE,eAAe,GAAG,IAAI;IAQlC,OAAO,CAAC,cAAc;IAwEtB,OAAO,CAAC,OAAO;CAuHhB"}
@@ -0,0 +1,43 @@
1
+ /**
2
+ * @file pathTracerOidnDenoiser.ts
3
+ * @description Phase 6b: final OIDN-style denoise via dynamic `oidn-web` (WebGPU U-Net).
4
+ * Weights are not bundled; set `__W3DTS_PATH_TRACER_CONFIG.oidnWeightsUrl`.
5
+ */
6
+ export type OidnDenoiseBuffers = {
7
+ width: number;
8
+ height: number;
9
+ /** HDR RGBA float32, length width*height*4. */
10
+ color: Float32Array;
11
+ /** Albedo RGBA float32 (rgb used). */
12
+ albedo: Float32Array;
13
+ /** Normal RGBA float32 (xyz in [0,1] or world; oidn-web expects aux layout). */
14
+ normal: Float32Array;
15
+ };
16
+ export type OidnDenoiseResult = {
17
+ color: Float32Array;
18
+ width: number;
19
+ height: number;
20
+ };
21
+ /**
22
+ * Lazy wrapper around `oidn-web`. Safe when the package is not installed:
23
+ * {@link ensureModel} returns false and callers keep the A-trous preview.
24
+ */
25
+ export declare class PathTracerOidnDenoiser {
26
+ private unet;
27
+ private loading;
28
+ private abortFn;
29
+ private weightsUrl;
30
+ isReady(): boolean;
31
+ abort(): void;
32
+ dispose(): void;
33
+ /**
34
+ * Dynamically imports `oidn-web` and loads TZA weights from `weightsUrl`.
35
+ * Returns false if the dependency is missing or load fails.
36
+ */
37
+ ensureModel(weightsUrl: string): Promise<boolean>;
38
+ /**
39
+ * Runs a CPU/TypedArray denoise (HDR + albedo + normal). Resolves null if aborted or unavailable.
40
+ */
41
+ denoise(buffers: OidnDenoiseBuffers): Promise<OidnDenoiseResult | null>;
42
+ }
43
+ //# sourceMappingURL=pathTracerOidnDenoiser.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pathTracerOidnDenoiser.d.ts","sourceRoot":"","sources":["../src/pathTracerOidnDenoiser.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,MAAM,MAAM,kBAAkB,GAAG;IAC/B,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,+CAA+C;IAC/C,KAAK,EAAE,YAAY,CAAC;IACpB,sCAAsC;IACtC,MAAM,EAAE,YAAY,CAAC;IACrB,gFAAgF;IAChF,MAAM,EAAE,YAAY,CAAC;CACtB,CAAC;AAEF,MAAM,MAAM,iBAAiB,GAAG;IAC9B,KAAK,EAAE,YAAY,CAAC;IACpB,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;CAChB,CAAC;AAgBF;;;GAGG;AACH,qBAAa,sBAAsB;IACjC,OAAO,CAAC,IAAI,CAAyB;IACrC,OAAO,CAAC,OAAO,CAAiC;IAChD,OAAO,CAAC,OAAO,CAAiC;IAChD,OAAO,CAAC,UAAU,CAAuB;IAEzC,OAAO,IAAI,OAAO;IAIlB,KAAK,IAAI,IAAI;IAOb,OAAO,IAAI,IAAI;IAQf;;;OAGG;IACH,WAAW,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAoCjD;;OAEG;IACH,OAAO,CAAC,OAAO,EAAE,kBAAkB,GAAG,OAAO,CAAC,iBAAiB,GAAG,IAAI,CAAC;CAyBxE"}
@@ -0,0 +1,137 @@
1
+ import { ProgressiveRenderPhase } from './progressiveRenderState';
2
+ import { PathTracerBloomSettings, PathTracerSceneRenderSettings } from './pathTracerSceneSettings';
3
+ export declare const PATH_TRACER_POST_PARAMS_FLOATS = 16;
4
+ /** Floats 0–11 match the display uniform. 12 mode, 13 intensity, 14 levels. */
5
+ export declare const PATH_TRACER_BLOOM_MODE_PYRAMID = 1;
6
+ export declare const PATH_TRACER_POST_PARAMS_BUFFER_BYTES: number;
7
+ export declare const PATH_TRACER_BLOOM_STEPS = 16;
8
+ export declare const PATH_TRACER_BLOOM_FALLOFF = 3;
9
+ /** Extra scale on the shared 16-tap falloff. The bench stars stayed too bright at 1. */
10
+ export declare const PATH_TRACER_BLOOM_WEIGHT_SCALE = 0.25;
11
+ export declare const PATH_TRACER_BLOOM_RAY_CAP = 8;
12
+ /** Mode 2 pre-scale. `scripts/lt-tonemap-fit.mjs` picked it over plain ACES on the bench background. */
13
+ export declare const PATH_TRACER_MODE2_PRESCALE = 0.6;
14
+ export interface PathTracerPostResolved {
15
+ exposureEv: number;
16
+ contrast: number;
17
+ saturation: number;
18
+ /** 0 clamp, 1 Reinhard, 2 ACES fitted × 0.6, 3 Khronos PBR Neutral. */
19
+ colorBalanceMode: number;
20
+ /** 1 only in Converged / Denoised when the scene asked for bloom. */
21
+ bloomMix: number;
22
+ bloom: PathTracerBloomSettings;
23
+ }
24
+ /** `2^exposure`. Exposure 0 (the bench) is ×1. */
25
+ export declare function exposureMultiplier(exposureEv: number): number;
26
+ /** sRGB OETF, one channel, as a display byte. Matches `linear_to_srgb` in `pt_display.frag.wgsl`. */
27
+ export declare function linearToSrgbByte(x: number): number;
28
+ /**
29
+ * Soft-knee excess. Knee width k = 0.5 τ.
30
+ * Below τ + k the response is max(0, Y − τ + k)² / (4k). At and above τ + k it is Y − τ.
31
+ */
32
+ export declare function bloomSoftExcess(luminance: number, threshold: number): number;
33
+ /** 13-tap downsample weights. They sum to 1. */
34
+ export declare const BLOOM_DOWNSAMPLE_WEIGHTS: readonly [0.125, 0.125, 0.125, 0.125, 0.125, 0.0625, 0.0625, 0.0625, 0.0625, 0.03125, 0.03125, 0.03125, 0.03125];
35
+ /**
36
+ * First bloom downsample (`pt_bloom_down`, PREFILTER): each tap is weighted by
37
+ * w / (1 + Y), then normalized. Taps are prefiltered luminances.
38
+ */
39
+ export declare function bloomKarisPrefilter(luminances: readonly number[]): number;
40
+ /** Pyramid composite gain: each level adds the prefiltered energy once. */
41
+ export declare function bloomCompositeGain(intensity: number, levels: number): number;
42
+ /** True when the swap chain stores the shader output as-is (`bgra8unorm`, not `*-srgb`). */
43
+ export declare function canvasFormatNeedsSrgbEncode(canvasFormat: string | undefined): boolean;
44
+ /** ACES fitted, one channel. Coefficients match `pt_display.frag.wgsl`. */
45
+ export declare function acesFittedChannel(x: number): number;
46
+ export declare function rec709Luminance(r: number, g: number, b: number): number;
47
+ export interface PathTracerHdrClassStats {
48
+ count: number;
49
+ maxLuma: number;
50
+ p95Luma: number;
51
+ maxChannel: number;
52
+ aboveLumaThreshold: number;
53
+ aboveMaxChannel: number;
54
+ }
55
+ export interface PathTracerHdrHighlightSummary {
56
+ width: number;
57
+ height: number;
58
+ threshold: number;
59
+ maxLuma: number;
60
+ aboveLumaThreshold: number;
61
+ aboveMaxChannel: number;
62
+ green: PathTracerHdrClassStats;
63
+ blue: PathTracerHdrClassStats;
64
+ neutral: PathTracerHdrClassStats;
65
+ }
66
+ /**
67
+ * Straight-HDR stats for the glare threshold.
68
+ * Green and blue are the dominant channel, clearly above the other two.
69
+ * Neutral is a low-chroma pixel brighter than the backplate (the band stones).
70
+ * `aboveLumaThreshold` is Rec.709. `aboveMaxChannel` is max(r, g, b). Exposure is not applied.
71
+ */
72
+ export declare function summarizePathTracerHdrHighlights(hdr: Float32Array, width: number, height: number, threshold: number): PathTracerHdrHighlightSummary;
73
+ /** Strict: a pixel at the threshold does not bloom. */
74
+ export declare function bloomExceedsThreshold(luminance: number, threshold: number): boolean;
75
+ /** Angle of ray `index` (radians). Ray 0 is +X, then π/numRays. */
76
+ export declare function glareRayAngle(index: number, numRays: number, rotation: number): number;
77
+ /**
78
+ * Grade used when the loaded GLB has no Light Tracer `RenderSettingsLT`
79
+ * (Damaged Helmet, Rolex, glTF studio scenes). Mode 3 is Khronos PBR Neutral with
80
+ * neutral exposure/contrast (0 / 0) matching the raster Lit display curve 1:1.
81
+ * Mode 2 remains the jewelry bench ACES × 0.6 curve when requested by `RenderSettingsLT`.
82
+ */
83
+ export declare const PATH_TRACER_DEFAULT_DISPLAY_GRADE: {
84
+ readonly exposure: 0;
85
+ readonly contrast: 0;
86
+ readonly saturation: 1;
87
+ readonly colorBalanceMode: 3;
88
+ };
89
+ export declare const PATH_TRACER_EXPOSURE_MIN_EV = -12;
90
+ export declare const PATH_TRACER_EXPOSURE_MAX_EV = 6;
91
+ export declare function clampPathTracerExposureEv(n: number): number;
92
+ export interface PathTracerDisplayGrade {
93
+ exposure: number;
94
+ contrast: number;
95
+ saturation: number;
96
+ /** 0 clamp, 1 Reinhard, 2 ACES fitted × {@link PATH_TRACER_MODE2_PRESCALE}, 3 Khronos PBR Neutral. */
97
+ colorBalanceMode: number;
98
+ }
99
+ /**
100
+ * Scene fields win when they are numbers (a Light Tracer GLB keeps its grade).
101
+ * Missing fields, and a scene with no render settings, use the Preferences grade.
102
+ */
103
+ export declare function resolvePathTracerDisplayPost(settings: PathTracerSceneRenderSettings | null | undefined, phase: ProgressiveRenderPhase | undefined, grade?: PathTracerDisplayGrade): PathTracerPostResolved;
104
+ export declare function resolvePathTracerPost(settings: PathTracerSceneRenderSettings | null | undefined, phase: ProgressiveRenderPhase | undefined): PathTracerPostResolved;
105
+ /**
106
+ * Tonemap then contrast then saturation.
107
+ * `rgb` is straight scene HDR, before exposure. Glare is added by the caller in that same space.
108
+ */
109
+ export declare function applyPathTracerDisplayGrade(rgb: readonly [number, number, number], post: Pick<PathTracerPostResolved, 'exposureEv' | 'contrast' | 'saturation' | 'colorBalanceMode'>): [number, number, number];
110
+ /**
111
+ * Pack the uniform / storage layout consumed by `pt_display` and `pt_bloom`.
112
+ * Float 10 is `encode_srgb`: 1 when the swap chain does not encode.
113
+ */
114
+ export declare function writePathTracerPostParams(out: Float32Array, post: PathTracerPostResolved, encodeSrgb?: boolean): void;
115
+ /**
116
+ * Straight-HDR glare added on top of the beauty. `hdr` is premultiplied RGBA, same as the composite.
117
+ * Returns RGB, length `width * height * 3`.
118
+ */
119
+ export declare function accumulateGlare(hdr: Float32Array, width: number, height: number, bloom: PathTracerBloomSettings): Float32Array;
120
+ /**
121
+ * Computes camera exposure in stops (`[-12, +6] EV`) from log-average straight HDR luminance
122
+ * over covered pixels (`a > 1e-4`), mapping geometric-mean scene luminance to `targetMidGray` (`0.18`).
123
+ */
124
+ export declare function computeAutoExposureEvFromHdr(hdrRgba: Float32Array, width: number, height: number, targetMidGray?: number): number;
125
+ export interface PunctualPhotometricSample {
126
+ kind: 'directional' | 'point' | 'spot' | 'area';
127
+ intensity: number;
128
+ color: ArrayLike<number>;
129
+ area?: number;
130
+ }
131
+ /**
132
+ * Estimates initial EV compensation when an imported GLB has no `RenderSettingsLT` grade
133
+ * and carries physical SI `KHR_lights_punctual` intensities (candela / lux, e.g. Blender `500..5000 cd`).
134
+ * Returns `null` when reference irradiance stays in normalized engine range (`<= 8`), preserving `0 EV`.
135
+ */
136
+ export declare function estimateInitialExposureEvForPunctualLights(lights: readonly PunctualPhotometricSample[], sceneDiagonal: number): number | null;
137
+ //# sourceMappingURL=pathTracerPost.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":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,EACb,MAAM,EAAE,MAAM,EACd,KAAK,EAAE,uBAAuB,GAC7B,YAAY,CAuCd;AAED;;;GAGG;AACH,wBAAgB,4BAA4B,CAC1C,OAAO,EAAE,YAAY,EACrB,KAAK,EAAE,MAAM,EACb,MAAM,EAAE,MAAM,EACd,aAAa,SAAO,GACnB,MAAM,CAuBR;AAED,MAAM,WAAW,yBAAyB;IACxC,IAAI,EAAE,aAAa,GAAG,OAAO,GAAG,MAAM,GAAG,MAAM,CAAC;IAChD,SAAS,EAAE,MAAM,CAAC;IAClB,KAAK,EAAE,SAAS,CAAC,MAAM,CAAC,CAAC;IACzB,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED;;;;GAIG;AACH,wBAAgB,0CAA0C,CACxD,MAAM,EAAE,SAAS,yBAAyB,EAAE,EAC5C,aAAa,EAAE,MAAM,GACpB,MAAM,GAAG,IAAI,CA0Bf"}
@@ -0,0 +1,6 @@
1
+ /**
2
+ * @file pathTracerRuntimeConfig.ts
3
+ * @description Reads path tracer options from `globalThis.__W3DTS_PATH_TRACER_CONFIG` (viewer sync).
4
+ */
5
+ export declare function getPathTracerTileSizeFromGlobal(): number;
6
+ //# sourceMappingURL=pathTracerRuntimeConfig.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pathTracerRuntimeConfig.d.ts","sourceRoot":"","sources":["../src/pathTracerRuntimeConfig.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,wBAAgB,+BAA+B,IAAI,MAAM,CAUxD"}
@@ -0,0 +1,32 @@
1
+ import { InstanceBatch, RenderCommand } from '../../core/src/index.ts';
2
+ import { SceneTriangleData } from './SceneToRayData';
3
+ /**
4
+ * Lightweight fingerprint of geometry + transforms + material factors for the path-tracer scene.
5
+ * Cheaper than FNV over the full triangle soup (Phase 0 / pre-1a behavior).
6
+ */
7
+ export declare function computePathTracerSceneFingerprint(renderQueue: RenderCommand[], instanceBatches: InstanceBatch[] | undefined, maxTriangles: number): number;
8
+ export interface PathTracerSceneCacheStats {
9
+ /** Total `buildOrReuse` calls. */
10
+ buildsRequested: number;
11
+ /** Times a full rebuild ran. */
12
+ rebuilds: number;
13
+ /** Times the cached {@link SceneTriangleData} was returned. */
14
+ cacheHits: number;
15
+ /** Last fingerprint. */
16
+ lastFingerprint: number;
17
+ }
18
+ /**
19
+ * Caches the last {@link SceneTriangleData} keyed by {@link computePathTracerSceneFingerprint}.
20
+ */
21
+ export declare class PathTracerSceneCache {
22
+ private cached;
23
+ private cachedFingerprint;
24
+ private readonly stats;
25
+ getStats(): PathTracerSceneCacheStats;
26
+ clear(): void;
27
+ /**
28
+ * Return cached triangles+BVH when the scene fingerprint matches; otherwise rebuild.
29
+ */
30
+ buildOrReuse(renderQueue: RenderCommand[], instanceBatches: InstanceBatch[] | undefined, maxTriangles: number): SceneTriangleData;
31
+ }
32
+ //# sourceMappingURL=pathTracerSceneCache.d.ts.map