three-realtime-rt 0.4.2 → 0.6.0

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.
package/src/index.d.ts CHANGED
@@ -161,12 +161,62 @@ export interface RealtimeRaytracerOptions {
161
161
  * matters most to each pixel. Cost is flat in light count.
162
162
  */
163
163
  restir?: boolean;
164
- /** Index of refraction used for transmissive surfaces. */
164
+ /**
165
+ * EXPERIMENTAL — ReSTIR GI (v1, temporal-only): per-pixel reservoirs reuse the
166
+ * 1-bounce global-illumination sample across frames (at the reprojected
167
+ * same-surface point; no spatial reuse). When on, the lighting pass skips its
168
+ * inline GI trace and the reservoir's resolved GI is added at the denoise
169
+ * stage — so it only takes effect when `gi` and `denoise` are also on. Its
170
+ * mean matches the inline GI path; convergence character differs. Default
171
+ * `false`. Live-toggleable.
172
+ */
173
+ restirGI?: boolean;
174
+ /** EXPERIMENTAL — temporal M-cap for the ReSTIR GI reservoir (default 20). */
175
+ restirGIMCap?: number;
176
+ /**
177
+ * EXPERIMENTAL — ReSTIR GI (v2) spatial-reuse taps per frame, taken after the
178
+ * temporal merge from the previous frame's reservoirs (reconnection-Jacobian
179
+ * reweighted, with a final visibility ray to prevent leaks). Clamped to 0..4;
180
+ * `0` reproduces v1 temporal-only behaviour. Default 2.
181
+ */
182
+ restirGISpatialTaps?: number;
183
+ /**
184
+ * EXPERIMENTAL — ReSTIR GI reservoir-sample validation period. Every frame a
185
+ * rotating 1-in-N subset of pixels re-aims its single candidate ray at the
186
+ * reservoir's stored hit (instead of a fresh cosine bounce) and re-shades it;
187
+ * the reservoir is killed when the geometry moved or the re-shaded target
188
+ * collapsed to near-black (a light switched off), and left untouched otherwise.
189
+ * Reuses the existing candidate trace (no extra bounce rays); fixes stale bounce
190
+ * light (a switched-off light stops haunting the reservoir) without drifting a
191
+ * static scene. `0` disables it (byte-identical to before the feature). Default 8.
192
+ */
193
+ restirGIValidate?: number;
194
+ /**
195
+ * Global fallback index of refraction for transmissive surfaces. A
196
+ * `MeshPhysicalMaterial.ior` overrides this per material for fully-transmissive
197
+ * glass (encoded in the G-buffer, supported range [1.0, 1.98]); `material.ior`
198
+ * wins when present. This value applies to partial-transmission glass and as
199
+ * the default when no per-material ior is carried.
200
+ */
165
201
  ior?: number;
202
+ /**
203
+ * Chromatic dispersion strength for glass, `0..0.5` (clamped), default `0`
204
+ * (off). Splits refracted white light into a spectrum via stochastic spectral
205
+ * sampling — each frame every glass pixel estimates one colour channel through
206
+ * a channel-shifted ior, and temporal accumulation blends the three into a
207
+ * rainbow (no extra rays). Needs accumulation to converge, so it shimmers
208
+ * slightly in motion. Global control only (no per-material dispersion).
209
+ */
210
+ dispersion?: number;
166
211
  /** History length cap: higher = smoother but slower to react. */
167
212
  maxHistory?: number;
168
213
  /** Clamp on indirect luminance to suppress fireflies. 0 disables. */
169
214
  fireflyClamp?: number;
215
+ /**
216
+ * BVH-cost heatmap scale for the mode-7 debug view: shadow-ray node-visit
217
+ * count is multiplied by this before the palette (default 1/96).
218
+ */
219
+ costScale?: number;
170
220
  /** Reproject accumulated lighting through camera motion. */
171
221
  temporalReprojection?: boolean;
172
222
  /**
@@ -176,6 +226,12 @@ export interface RealtimeRaytracerOptions {
176
226
  taa?: boolean;
177
227
  /** Fresh-sample weight in the TAA blend (lower = smoother/more AA, more lag). */
178
228
  taaBlend?: number;
229
+ /**
230
+ * Scales the TAA sub-pixel jitter amplitude. Set to your canvas scale when
231
+ * rendering a reduced drawing buffer CSS-stretched to the screen, so jitter
232
+ * stays constant in screen pixels (no visible wobble at low quality). Default 1.
233
+ */
234
+ taaJitterScale?: number;
179
235
  /** Edge-aware à-trous denoise on the irradiance buffer. */
180
236
  denoise?: boolean;
181
237
  /**
@@ -235,6 +291,16 @@ export interface CompileSceneOptions {
235
291
  * normal attribute current (e.g. call `geometry.computeVertexNormals()` after
236
292
  * deforming). The live vertex count is fixed at compile time — changing it
237
293
  * throws; call `compileScene()` again after a topology change.
294
+ *
295
+ * A **`SkinnedMesh` is auto-detected** (no flag needed) and CPU-skinned into the
296
+ * dynamic BVH every frame from its live skeleton pose, so an animated character
297
+ * casts a moving traced shadow and rasterizes in its animated pose (the G-buffer
298
+ * skins via three's standard skinning chunks). Pose the skeleton *before*
299
+ * `updateDynamic()` — `mixer.update(dt)` then `characterRoot.updateMatrixWorld(true)`
300
+ * — since the skinning reads each bone's `matrixWorld`. Cost is O(source verts ×
301
+ * 4 bones); secondary-ray normals are per-face (recomputed from the skinned
302
+ * triangles), while primary visibility keeps smooth skinned normals from the
303
+ * raster path. Budget ~10–20k skinned source verts for a sub-2 ms frame.
238
304
  */
239
305
  dynamicMeshes?: Object3D[];
240
306
  }
@@ -248,11 +314,19 @@ export class CompiledScene {
248
314
  triangleCount: number;
249
315
  /** Number of lights scanned into the compiled light tables. */
250
316
  lightCount: number;
251
- /** Number of emissive triangles registered as NEE area lights. */
317
+ /** Number of emissive triangles registered as NEE area lights (static + dynamic). */
252
318
  emissiveTriCount: number;
253
319
  /** World-space diagonal of the static level (used to auto-scale ray epsilon). */
254
320
  sceneDiagonal: number;
255
- /** Re-bake moving meshes' current world transforms and refit the dynamic BVH. */
321
+ /** True when any dynamic emitter contributes NEE rows refreshed each frame. */
322
+ hasDynamicEmissive: boolean;
323
+ /** CPU cost (ms) of the most recent dynamic-emissive refresh (0 if none). */
324
+ lastEmissiveRefreshMs: number;
325
+ /**
326
+ * Re-bake moving meshes' current world transforms and refit the dynamic BVH.
327
+ * Also refreshes any dynamic emitters' NEE area-light rows + power CDF from the
328
+ * freshly baked world positions.
329
+ */
256
330
  updateDynamic(): void;
257
331
  /** Release GPU resources held by this compiled scene. */
258
332
  dispose(): void;
@@ -298,8 +372,14 @@ export class RealtimeRaytracer {
298
372
  compiled: CompiledScene | null;
299
373
  /** Accumulated frame counter. */
300
374
  frame: number;
301
- /** Debug view: 0 composite, 1 albedo, 2 normal, 3 irradiance, 4 worldPos, 5 emissive, 6 specular. */
375
+ /** Debug view: 0 composite, 1 albedo, 2 normal, 3 irradiance, 4 worldPos, 5 emissive, 6 specular, 7 bvh cost. */
302
376
  outputMode: number;
377
+ /**
378
+ * BVH-cost heatmap scale (outputMode 7): the per-pixel shadow-ray node-visit
379
+ * count is multiplied by this before the palette (default 1/96 — ~96 visits
380
+ * saturate to white). Live-tunable.
381
+ */
382
+ costScale: number;
303
383
 
304
384
  /** Resolution scale for the ray traced lighting; assigning reallocates targets. */
305
385
  get renderScale(): number;
@@ -338,8 +418,17 @@ export class RealtimeRaytracer {
338
418
  refraction: boolean;
339
419
  /** Alpha-blended transparency: composite `transparent` meshes over the geometry behind them. */
340
420
  transparency: boolean;
341
- /** Index of refraction used for transmissive surfaces. */
421
+ /**
422
+ * Global fallback index of refraction. `MeshPhysicalMaterial.ior` overrides it
423
+ * per material for fully-transmissive glass (range [1.0, 1.98]).
424
+ */
342
425
  ior: number;
426
+ /**
427
+ * Chromatic dispersion strength for glass, `0..0.5` (clamped on upload),
428
+ * default `0`. Stochastic spectral sampling: splits refracted white light into
429
+ * a rainbow via temporal accumulation, no extra rays. Global control only.
430
+ */
431
+ dispersion: number;
343
432
  /** One stochastic direct shadow ray per pixel per frame instead of one per light. */
344
433
  stochasticLights: boolean;
345
434
  /** Adaptive quality governor toggle. */
@@ -360,6 +449,17 @@ export class RealtimeRaytracer {
360
449
  taaBlend: number;
361
450
  /** ReSTIR direct lighting toggle. */
362
451
  restir: boolean;
452
+ /**
453
+ * EXPERIMENTAL — ReSTIR GI (temporal-only) toggle. Only takes effect when
454
+ * `gi` and `denoise` are also on (injected at the à-trous stage). Default false.
455
+ */
456
+ restirGI: boolean;
457
+ /** EXPERIMENTAL — temporal M-cap for the ReSTIR GI reservoir. */
458
+ restirGIMCap: number;
459
+ /** EXPERIMENTAL — ReSTIR GI (v2) spatial-reuse taps per frame (0..4, 0 = v1). */
460
+ restirGISpatialTaps: number;
461
+ /** EXPERIMENTAL — ReSTIR GI reservoir-sample validation period (0 = off, default 8). */
462
+ restirGIValidate: number;
363
463
  /** Procedural-sky state. */
364
464
  sky: SkyState;
365
465
  /** Distance-fog state. */