three-realtime-rt 0.4.2 → 0.5.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/README.md +151 -10
- package/package.json +2 -1
- package/src/CompositePass.js +6 -2
- package/src/DenoisePass.js +33 -5
- package/src/GBufferPass.js +132 -46
- package/src/GIReservoirPass.js +572 -0
- package/src/RTLightingPass.js +63 -5
- package/src/RealtimeRaytracer.js +106 -6
- package/src/SceneCompiler.js +174 -25
- package/src/bvhAnyHit.glsl.js +15 -0
- package/src/index.d.ts +58 -3
package/src/index.d.ts
CHANGED
|
@@ -161,12 +161,35 @@ export interface RealtimeRaytracerOptions {
|
|
|
161
161
|
* matters most to each pixel. Cost is flat in light count.
|
|
162
162
|
*/
|
|
163
163
|
restir?: boolean;
|
|
164
|
-
/**
|
|
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
|
+
* Global fallback index of refraction for transmissive surfaces. A
|
|
178
|
+
* `MeshPhysicalMaterial.ior` overrides this per material for fully-transmissive
|
|
179
|
+
* glass (encoded in the G-buffer, supported range [1.0, 1.98]); `material.ior`
|
|
180
|
+
* wins when present. This value applies to partial-transmission glass and as
|
|
181
|
+
* the default when no per-material ior is carried.
|
|
182
|
+
*/
|
|
165
183
|
ior?: number;
|
|
166
184
|
/** History length cap: higher = smoother but slower to react. */
|
|
167
185
|
maxHistory?: number;
|
|
168
186
|
/** Clamp on indirect luminance to suppress fireflies. 0 disables. */
|
|
169
187
|
fireflyClamp?: number;
|
|
188
|
+
/**
|
|
189
|
+
* BVH-cost heatmap scale for the mode-7 debug view: shadow-ray node-visit
|
|
190
|
+
* count is multiplied by this before the palette (default 1/96).
|
|
191
|
+
*/
|
|
192
|
+
costScale?: number;
|
|
170
193
|
/** Reproject accumulated lighting through camera motion. */
|
|
171
194
|
temporalReprojection?: boolean;
|
|
172
195
|
/**
|
|
@@ -176,6 +199,12 @@ export interface RealtimeRaytracerOptions {
|
|
|
176
199
|
taa?: boolean;
|
|
177
200
|
/** Fresh-sample weight in the TAA blend (lower = smoother/more AA, more lag). */
|
|
178
201
|
taaBlend?: number;
|
|
202
|
+
/**
|
|
203
|
+
* Scales the TAA sub-pixel jitter amplitude. Set to your canvas scale when
|
|
204
|
+
* rendering a reduced drawing buffer CSS-stretched to the screen, so jitter
|
|
205
|
+
* stays constant in screen pixels (no visible wobble at low quality). Default 1.
|
|
206
|
+
*/
|
|
207
|
+
taaJitterScale?: number;
|
|
179
208
|
/** Edge-aware à-trous denoise on the irradiance buffer. */
|
|
180
209
|
denoise?: boolean;
|
|
181
210
|
/**
|
|
@@ -235,6 +264,16 @@ export interface CompileSceneOptions {
|
|
|
235
264
|
* normal attribute current (e.g. call `geometry.computeVertexNormals()` after
|
|
236
265
|
* deforming). The live vertex count is fixed at compile time — changing it
|
|
237
266
|
* throws; call `compileScene()` again after a topology change.
|
|
267
|
+
*
|
|
268
|
+
* A **`SkinnedMesh` is auto-detected** (no flag needed) and CPU-skinned into the
|
|
269
|
+
* dynamic BVH every frame from its live skeleton pose, so an animated character
|
|
270
|
+
* casts a moving traced shadow and rasterizes in its animated pose (the G-buffer
|
|
271
|
+
* skins via three's standard skinning chunks). Pose the skeleton *before*
|
|
272
|
+
* `updateDynamic()` — `mixer.update(dt)` then `characterRoot.updateMatrixWorld(true)`
|
|
273
|
+
* — since the skinning reads each bone's `matrixWorld`. Cost is O(source verts ×
|
|
274
|
+
* 4 bones); secondary-ray normals are per-face (recomputed from the skinned
|
|
275
|
+
* triangles), while primary visibility keeps smooth skinned normals from the
|
|
276
|
+
* raster path. Budget ~10–20k skinned source verts for a sub-2 ms frame.
|
|
238
277
|
*/
|
|
239
278
|
dynamicMeshes?: Object3D[];
|
|
240
279
|
}
|
|
@@ -298,8 +337,14 @@ export class RealtimeRaytracer {
|
|
|
298
337
|
compiled: CompiledScene | null;
|
|
299
338
|
/** Accumulated frame counter. */
|
|
300
339
|
frame: number;
|
|
301
|
-
/** Debug view: 0 composite, 1 albedo, 2 normal, 3 irradiance, 4 worldPos, 5 emissive, 6 specular. */
|
|
340
|
+
/** Debug view: 0 composite, 1 albedo, 2 normal, 3 irradiance, 4 worldPos, 5 emissive, 6 specular, 7 bvh cost. */
|
|
302
341
|
outputMode: number;
|
|
342
|
+
/**
|
|
343
|
+
* BVH-cost heatmap scale (outputMode 7): the per-pixel shadow-ray node-visit
|
|
344
|
+
* count is multiplied by this before the palette (default 1/96 — ~96 visits
|
|
345
|
+
* saturate to white). Live-tunable.
|
|
346
|
+
*/
|
|
347
|
+
costScale: number;
|
|
303
348
|
|
|
304
349
|
/** Resolution scale for the ray traced lighting; assigning reallocates targets. */
|
|
305
350
|
get renderScale(): number;
|
|
@@ -338,7 +383,10 @@ export class RealtimeRaytracer {
|
|
|
338
383
|
refraction: boolean;
|
|
339
384
|
/** Alpha-blended transparency: composite `transparent` meshes over the geometry behind them. */
|
|
340
385
|
transparency: boolean;
|
|
341
|
-
/**
|
|
386
|
+
/**
|
|
387
|
+
* Global fallback index of refraction. `MeshPhysicalMaterial.ior` overrides it
|
|
388
|
+
* per material for fully-transmissive glass (range [1.0, 1.98]).
|
|
389
|
+
*/
|
|
342
390
|
ior: number;
|
|
343
391
|
/** One stochastic direct shadow ray per pixel per frame instead of one per light. */
|
|
344
392
|
stochasticLights: boolean;
|
|
@@ -360,6 +408,13 @@ export class RealtimeRaytracer {
|
|
|
360
408
|
taaBlend: number;
|
|
361
409
|
/** ReSTIR direct lighting toggle. */
|
|
362
410
|
restir: boolean;
|
|
411
|
+
/**
|
|
412
|
+
* EXPERIMENTAL — ReSTIR GI (temporal-only) toggle. Only takes effect when
|
|
413
|
+
* `gi` and `denoise` are also on (injected at the à-trous stage). Default false.
|
|
414
|
+
*/
|
|
415
|
+
restirGI: boolean;
|
|
416
|
+
/** EXPERIMENTAL — temporal M-cap for the ReSTIR GI reservoir. */
|
|
417
|
+
restirGIMCap: number;
|
|
363
418
|
/** Procedural-sky state. */
|
|
364
419
|
sky: SkyState;
|
|
365
420
|
/** Distance-fog state. */
|