three-gpu-pathtracer 0.0.23 → 0.0.25
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 +53 -528
- package/build/index.module.js +319 -66
- package/build/index.module.js.map +1 -1
- package/build/index.umd.cjs +318 -64
- package/build/index.umd.cjs.map +1 -1
- package/package.json +35 -18
- package/src/core/PathTracingSceneGenerator.js +21 -2
- package/src/core/WebGLPathTracer.js +16 -7
- package/src/core/utils/mergeGeometries.js +14 -1
- package/src/core/utils/sceneUpdateUtils.js +8 -12
- package/src/detectors/PrecisionMaterial.js +9 -9
- package/src/index.d.ts +2 -1
- package/src/index.js +1 -0
- package/src/materials/pathtracing/PhysicalPathTracingMaterial.js +2 -1
- package/src/materials/pathtracing/glsl/attenuate_hit_function.glsl.js +2 -1
- package/src/materials/pathtracing/glsl/camera_util_functions.glsl.js +1 -1
- package/src/materials/pathtracing/glsl/get_surface_record_function.glsl.js +2 -1
- package/src/materials/surface/AmbientOcclusionMaterial.js +2 -0
- package/src/objects/PhysicalSpotLight.js +2 -0
- package/src/shader/bsdf/bsdf_functions.glsl.js +0 -1
- package/src/shader/bvh/inside_fog_volume_function.glsl.js +1 -1
- package/src/shader/structs/material_struct.glsl.js +3 -1
- package/src/textures/BlueNoiseTexture.js +6 -6
- package/src/textures/ProceduralEquirectTexture.js +8 -7
- package/src/textures/turquinMetal.png +0 -0
- package/src/uniforms/EquirectHdrInfoUniform.js +9 -4
- package/src/uniforms/FloatAttributeTextureArray.js +11 -11
- package/src/uniforms/MaterialsTexture.js +13 -10
- package/src/webgpu/API.md +762 -0
- package/src/webgpu/AtlasTexture.js +471 -0
- package/src/webgpu/BlurredEnvMapGenerator.js +129 -0
- package/src/webgpu/EquirectBackgroundInfo.js +97 -0
- package/src/webgpu/EquirectHdrInfoNode.js +151 -0
- package/src/webgpu/LightsInfoNode.js +224 -0
- package/src/webgpu/MegaKernelPathTracer.js +277 -0
- package/src/webgpu/PathTracerBackend.js +216 -0
- package/src/webgpu/TurquinTexture.js +169 -0
- package/src/webgpu/WaveFrontPathTracer.js +586 -0
- package/src/webgpu/WebGPUPathTracer.js +1302 -0
- package/src/webgpu/compute/ComputeKernel.js +92 -0
- package/src/webgpu/compute/CopyBufferKernel.js +40 -0
- package/src/webgpu/compute/PathTracerMegaKernel.js +470 -0
- package/src/webgpu/compute/SampleDebugKernel.js +51 -0
- package/src/webgpu/compute/TallySampleCountsKernel.js +111 -0
- package/src/webgpu/compute/ZeroOutBufferKernel.js +35 -0
- package/src/webgpu/compute/ZeroOutKernel.js +31 -0
- package/src/webgpu/compute/wavefront/LogicKernel.js +349 -0
- package/src/webgpu/compute/wavefront/MaterialKernel.js +371 -0
- package/src/webgpu/compute/wavefront/PopulatePixelIndicesKernel.js +72 -0
- package/src/webgpu/compute/wavefront/QueueLengthToDispatchKernel.js +38 -0
- package/src/webgpu/compute/wavefront/ResetSlotsKernel.js +66 -0
- package/src/webgpu/compute/wavefront/TraceRayKernel.js +71 -0
- package/src/webgpu/compute/wavefront/TraceShadowRayKernel.js +67 -0
- package/src/webgpu/compute/wavefront/structs.js +155 -0
- package/src/webgpu/constants.js +62 -0
- package/src/webgpu/denoise/OIDNDenoiser.js +431 -0
- package/src/webgpu/index.d.ts +176 -0
- package/src/webgpu/index.js +11 -0
- package/src/webgpu/materials/GltfCompliantMaterial.js +608 -0
- package/src/webgpu/materials/GraphMaterial.js +331 -0
- package/src/webgpu/materials/PathtracingMaterial.js +89 -0
- package/src/webgpu/materials/RenderToScreenMaterial.js +150 -0
- package/src/webgpu/materials/debug/AtlasDebugMaterial.js +41 -0
- package/src/webgpu/materials/debug/SampleDensityMaterial.js +61 -0
- package/src/webgpu/nodes/PathtracerBVHComputeData.js +1037 -0
- package/src/webgpu/nodes/debugBounds.wgsl.js +228 -0
- package/src/webgpu/nodes/eon.wgsl.js +262 -0
- package/src/webgpu/nodes/ggx.wgsl.js +190 -0
- package/src/webgpu/nodes/lights.wgsl.js +203 -0
- package/src/webgpu/nodes/material.wgsl.js +990 -0
- package/src/webgpu/nodes/rand/bluedither.wgsl.js +92 -0
- package/src/webgpu/nodes/rand/pcg.wgsl.js +81 -0
- package/src/webgpu/nodes/rand/sobol.wgsl.js +287 -0
- package/src/webgpu/nodes/random.wgsl.js +20 -0
- package/src/webgpu/nodes/reset.wgsl.js +21 -0
- package/src/webgpu/nodes/sampling.wgsl.js +193 -0
- package/src/webgpu/nodes/sheen.wgsl.js +148 -0
- package/src/webgpu/nodes/structs.wgsl.js +272 -0
- package/src/webgpu/nodes/utils.wgsl.js +366 -0
- package/src/webgpu/shims/ArrayCameraShim.js +74 -0
- package/src/webgpu/shims/EquirectCameraShim.js +37 -0
- package/src/webgpu/shims/PhysicalCameraShim.js +151 -0
- package/src/webgpu/upscale/FSRUpscaler.js +108 -0
|
@@ -0,0 +1,762 @@
|
|
|
1
|
+
<!-- This file is generated automatically. Do not edit it directly. -->
|
|
2
|
+
# three-gpu-pathtracer/webgpu
|
|
3
|
+
|
|
4
|
+
## Random Strategies
|
|
5
|
+
|
|
6
|
+
### RANDOM_PCG
|
|
7
|
+
|
|
8
|
+
```js
|
|
9
|
+
RANDOM_PCG: Object
|
|
10
|
+
```
|
|
11
|
+
|
|
12
|
+
Uncorrelated pseudo random samples. Converges slowest but never shows structured artifacts.
|
|
13
|
+
|
|
14
|
+
### RANDOM_SOBOL
|
|
15
|
+
|
|
16
|
+
```js
|
|
17
|
+
RANDOM_SOBOL: Object
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
Sobol low discrepancy samples, scrambled per pixel. Converges faster than `RANDOM_PCG`.
|
|
21
|
+
|
|
22
|
+
### RANDOM_BLUE_DITHER
|
|
23
|
+
|
|
24
|
+
```js
|
|
25
|
+
RANDOM_BLUE_DITHER: Object
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
The same Sobol sequence for every pixel, offset by a blue noise dither so early frames read as
|
|
29
|
+
smooth grain rather than clumped noise. The default.
|
|
30
|
+
|
|
31
|
+
## Transmissive Background Modes
|
|
32
|
+
|
|
33
|
+
### TRANSMISSIVE_BACKGROUND_ENVIRONMENT
|
|
34
|
+
|
|
35
|
+
```js
|
|
36
|
+
TRANSMISSIVE_BACKGROUND_ENVIRONMENT: number
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
Sample the environment map, so glass shows what is behind it.
|
|
40
|
+
|
|
41
|
+
### TRANSMISSIVE_BACKGROUND_OVERLAY
|
|
42
|
+
|
|
43
|
+
```js
|
|
44
|
+
TRANSMISSIVE_BACKGROUND_OVERLAY: number
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
Set the opacity from the transmitted light intensity, tinted by the environment lighting.
|
|
48
|
+
|
|
49
|
+
### TRANSMISSIVE_BACKGROUND_TRANSPARENT
|
|
50
|
+
|
|
51
|
+
```js
|
|
52
|
+
TRANSMISSIVE_BACKGROUND_TRANSPARENT: number
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
Attenuate the background by the transmitted light, so glass renders against transparency.
|
|
56
|
+
|
|
57
|
+
## BlurredEnvMapGenerator
|
|
58
|
+
|
|
59
|
+
Produces a PMREM prefiltered, optionally downsampled equirectangular copy of an environment
|
|
60
|
+
map. Blurring removes the small bright details that make an environment slow to converge.
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
### .constructor
|
|
64
|
+
|
|
65
|
+
```js
|
|
66
|
+
constructor( renderer: WebGPURenderer )
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
### .dispose
|
|
70
|
+
|
|
71
|
+
```js
|
|
72
|
+
dispose(): void
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
Frees every GPU resource held by the generator.
|
|
76
|
+
|
|
77
|
+
|
|
78
|
+
### .generate
|
|
79
|
+
|
|
80
|
+
```js
|
|
81
|
+
async generate(
|
|
82
|
+
texture: Texture,
|
|
83
|
+
blur = 0: number,
|
|
84
|
+
width = null: number,
|
|
85
|
+
height = null: number
|
|
86
|
+
): Promise<Texture>
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
Renders a blurred copy of the given environment map. The source texture is left untouched.
|
|
90
|
+
|
|
91
|
+
> [!NOTE]
|
|
92
|
+
> The returned texture is owned by the caller and must be disposed.
|
|
93
|
+
|
|
94
|
+
## FSRUpscaler
|
|
95
|
+
|
|
96
|
+
Upscales a path traced image to the drawing buffer size with FSR. Pass one to
|
|
97
|
+
"WebGPUPathTracer.setUpscaler".
|
|
98
|
+
|
|
99
|
+
The "Upscaler" class is passed in rather than imported so it does not become a dependency.
|
|
100
|
+
|
|
101
|
+
```js
|
|
102
|
+
import { Upscaler } from '@pmndrs/upscaler';
|
|
103
|
+
pathTracer.setUpscaler( new FSRUpscaler( { Upscaler } ) );
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
|
|
107
|
+
### .constructor
|
|
108
|
+
|
|
109
|
+
```js
|
|
110
|
+
constructor(
|
|
111
|
+
{
|
|
112
|
+
// The `Upscaler` class from `@pmndrs/upscaler`.
|
|
113
|
+
Upscaler: function,
|
|
114
|
+
sharpness?: number,
|
|
115
|
+
}
|
|
116
|
+
)
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
Every field below can also be assigned after construction.
|
|
120
|
+
|
|
121
|
+
### .init
|
|
122
|
+
|
|
123
|
+
```js
|
|
124
|
+
init( renderer: WebGPURenderer ): void
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
|
|
128
|
+
### .upscale
|
|
129
|
+
|
|
130
|
+
```js
|
|
131
|
+
upscale( source: Texture, camera: Camera ): Texture
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
Upscales a texture to the renderer's drawing buffer size.
|
|
135
|
+
|
|
136
|
+
|
|
137
|
+
## OIDNDenoiser
|
|
138
|
+
|
|
139
|
+
Runs Open Image Denoise over a path traced image. Pass one to
|
|
140
|
+
"WebGPUPathTracer.setDenoiser", or drive it directly with "denoise".
|
|
141
|
+
|
|
142
|
+
"initUNetFromURL" and the weights are passed in rather than imported so neither the library
|
|
143
|
+
nor the network files become a dependency.
|
|
144
|
+
|
|
145
|
+
```js
|
|
146
|
+
import { initUNetFromURL } from 'oidn-web';
|
|
147
|
+
pathTracer.setDenoiser( new OIDNDenoiser( { initUNetFromURL, auxWeightsUrl } ) );
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
Weights come from the oidn-weights repository, where the "_small" and "_large" variants trade
|
|
151
|
+
quality against download size and per tile cost.
|
|
152
|
+
|
|
153
|
+
|
|
154
|
+
### .texture
|
|
155
|
+
|
|
156
|
+
```js
|
|
157
|
+
texture: ExternalTexture | null
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
The denoised result, or null until the first tile has been produced.
|
|
161
|
+
|
|
162
|
+
|
|
163
|
+
### .complete
|
|
164
|
+
|
|
165
|
+
```js
|
|
166
|
+
complete: boolean
|
|
167
|
+
```
|
|
168
|
+
|
|
169
|
+
Whether a pass has finished. Stays true until reset.
|
|
170
|
+
|
|
171
|
+
|
|
172
|
+
### .running
|
|
173
|
+
|
|
174
|
+
```js
|
|
175
|
+
running: boolean
|
|
176
|
+
```
|
|
177
|
+
|
|
178
|
+
Whether a pass is running. The work is spread over several frames.
|
|
179
|
+
|
|
180
|
+
|
|
181
|
+
### .constructor
|
|
182
|
+
|
|
183
|
+
```js
|
|
184
|
+
constructor(
|
|
185
|
+
{
|
|
186
|
+
initUNetFromURL: function,
|
|
187
|
+
|
|
188
|
+
// Weights for the guided model.
|
|
189
|
+
auxWeightsUrl: string,
|
|
190
|
+
|
|
191
|
+
// Weights for the color only model, needed only when
|
|
192
|
+
// `useAuxiliaryBuffers` is `false`.
|
|
193
|
+
colorWeightsUrl?: string,
|
|
194
|
+
useAuxiliaryBuffers?: boolean,
|
|
195
|
+
maxTileSize?: number | null,
|
|
196
|
+
|
|
197
|
+
// `false` pins every tile to `maxTileSize`. An object tunes
|
|
198
|
+
// the adaptive sizing.
|
|
199
|
+
dynamicTile?: DynamicTileSetting | null,
|
|
200
|
+
}
|
|
201
|
+
)
|
|
202
|
+
```
|
|
203
|
+
|
|
204
|
+
Every field below can also be assigned after construction.
|
|
205
|
+
|
|
206
|
+
### .init
|
|
207
|
+
|
|
208
|
+
```js
|
|
209
|
+
init( renderer: WebGPURenderer ): void
|
|
210
|
+
```
|
|
211
|
+
|
|
212
|
+
|
|
213
|
+
### .setScene
|
|
214
|
+
|
|
215
|
+
```js
|
|
216
|
+
setScene( scene: Scene, camera: Camera ): void
|
|
217
|
+
```
|
|
218
|
+
|
|
219
|
+
|
|
220
|
+
### .update
|
|
221
|
+
|
|
222
|
+
```js
|
|
223
|
+
update( target: Texture ): Texture | null
|
|
224
|
+
```
|
|
225
|
+
|
|
226
|
+
Renders the auxiliary buffers and starts a pass. Safe to call every frame.
|
|
227
|
+
|
|
228
|
+
|
|
229
|
+
### .denoise
|
|
230
|
+
|
|
231
|
+
```js
|
|
232
|
+
async denoise(
|
|
233
|
+
color: Texture,
|
|
234
|
+
albedo = null: Texture | null,
|
|
235
|
+
normal = null: Texture | null
|
|
236
|
+
): void
|
|
237
|
+
```
|
|
238
|
+
|
|
239
|
+
Runs a pass unless one is already running or finished. The optional albedo and normal
|
|
240
|
+
buffers guide the filter and select the guided model. Both hold [0,1] values, with normals
|
|
241
|
+
mapped so a flat normal is (0.5, 0.5, 1).
|
|
242
|
+
|
|
243
|
+
|
|
244
|
+
### .reset
|
|
245
|
+
|
|
246
|
+
```js
|
|
247
|
+
reset(): void
|
|
248
|
+
```
|
|
249
|
+
|
|
250
|
+
Drops any running pass and the last result. Call it whenever the image changes, such as when
|
|
251
|
+
the camera moves.
|
|
252
|
+
|
|
253
|
+
|
|
254
|
+
## WebGPUPathTracer
|
|
255
|
+
|
|
256
|
+
Progressive path tracer running on WebGPU. Call [WebGPUPathTracer#setScene](WebGPUPathTracer#setScene) once,
|
|
257
|
+
then [WebGPUPathTracer#renderSample](WebGPUPathTracer#renderSample) every frame to accumulate samples into the canvas.
|
|
258
|
+
|
|
259
|
+
The scene is captured when `setScene` is called, so changes to geometry, materials, lights, or
|
|
260
|
+
the environment afterward require the matching `update*` function. Any change that invalidates
|
|
261
|
+
the accumulated image restarts it.
|
|
262
|
+
|
|
263
|
+
|
|
264
|
+
### .maxBounces
|
|
265
|
+
|
|
266
|
+
```js
|
|
267
|
+
maxBounces: number = 15
|
|
268
|
+
```
|
|
269
|
+
|
|
270
|
+
Maximum number of times a ray can scatter before the path is terminated. Higher values
|
|
271
|
+
resolve more indirect light at the cost of speed.
|
|
272
|
+
|
|
273
|
+
|
|
274
|
+
### .frameBudget
|
|
275
|
+
|
|
276
|
+
```js
|
|
277
|
+
frameBudget: number = 250000
|
|
278
|
+
```
|
|
279
|
+
|
|
280
|
+
Number of path slots dispatched per [WebGPUPathTracer#renderSample](WebGPUPathTracer#renderSample) call,
|
|
281
|
+
independent of resolution. Raising it trades frame rate for convergence speed.
|
|
282
|
+
|
|
283
|
+
|
|
284
|
+
### .maxTransparentBounces
|
|
285
|
+
|
|
286
|
+
```js
|
|
287
|
+
maxTransparentBounces: number = 5
|
|
288
|
+
```
|
|
289
|
+
|
|
290
|
+
Maximum number of alpha tested surfaces a ray can pass through. Counted separately from
|
|
291
|
+
[WebGPUPathTracer#maxBounces](WebGPUPathTracer#maxBounces) so foliage and cutouts cannot exhaust the bounce budget.
|
|
292
|
+
|
|
293
|
+
|
|
294
|
+
### .maxSamples
|
|
295
|
+
|
|
296
|
+
```js
|
|
297
|
+
maxSamples: number = 0
|
|
298
|
+
```
|
|
299
|
+
|
|
300
|
+
Stops accumulating once every pixel reaches this many samples. A denoiser only runs once the
|
|
301
|
+
render has stopped, so it has no effect while this is `0`.
|
|
302
|
+
|
|
303
|
+
> [!NOTE]
|
|
304
|
+
> `0` renders indefinitely.
|
|
305
|
+
|
|
306
|
+
### .transmissiveBackground
|
|
307
|
+
|
|
308
|
+
```js
|
|
309
|
+
transmissiveBackground: number = TRANSMISSIVE_BACKGROUND_OVERLAY
|
|
310
|
+
```
|
|
311
|
+
|
|
312
|
+
How the background is treated behind transmissive surfaces. One of
|
|
313
|
+
`TRANSMISSIVE_BACKGROUND_OVERLAY`, `TRANSMISSIVE_BACKGROUND_ENVIRONMENT`, or
|
|
314
|
+
`TRANSMISSIVE_BACKGROUND_TRANSPARENT`.
|
|
315
|
+
|
|
316
|
+
|
|
317
|
+
### .filterGlossyFactor
|
|
318
|
+
|
|
319
|
+
```js
|
|
320
|
+
filterGlossyFactor: number = 1
|
|
321
|
+
```
|
|
322
|
+
|
|
323
|
+
Blurs sharp reflections seen through rough surfaces to suppress fireflies. Higher values
|
|
324
|
+
remove more noise and more detail.
|
|
325
|
+
|
|
326
|
+
> [!NOTE]
|
|
327
|
+
> `0` disables the filter.
|
|
328
|
+
|
|
329
|
+
### .multipleImportanceSampling
|
|
330
|
+
|
|
331
|
+
```js
|
|
332
|
+
multipleImportanceSampling: boolean = true
|
|
333
|
+
```
|
|
334
|
+
|
|
335
|
+
Whether to combine light sampling and bsdf sampling with MIS. Disabling it makes lights
|
|
336
|
+
noticeably noisier.
|
|
337
|
+
|
|
338
|
+
|
|
339
|
+
### .clampDirect
|
|
340
|
+
|
|
341
|
+
```js
|
|
342
|
+
clampDirect: number = 0
|
|
343
|
+
```
|
|
344
|
+
|
|
345
|
+
Upper bound on the contribution of a directly lit path segment, for suppressing fireflies.
|
|
346
|
+
|
|
347
|
+
> [!NOTE]
|
|
348
|
+
> `0` disables the clamp. Clamping darkens the image and biases the result.
|
|
349
|
+
|
|
350
|
+
### .clampIndirect
|
|
351
|
+
|
|
352
|
+
```js
|
|
353
|
+
clampIndirect: number = 10
|
|
354
|
+
```
|
|
355
|
+
|
|
356
|
+
Upper bound on the contribution of an indirectly lit path segment, for suppressing
|
|
357
|
+
fireflies.
|
|
358
|
+
|
|
359
|
+
> [!NOTE]
|
|
360
|
+
> `0` disables the clamp. Clamping darkens the image and biases the result.
|
|
361
|
+
|
|
362
|
+
### .target
|
|
363
|
+
|
|
364
|
+
```js
|
|
365
|
+
readonly target: Texture | null
|
|
366
|
+
```
|
|
367
|
+
|
|
368
|
+
The render target the accumulated samples are written into.
|
|
369
|
+
|
|
370
|
+
|
|
371
|
+
### .fadeState
|
|
372
|
+
|
|
373
|
+
```js
|
|
374
|
+
readonly fadeState: number
|
|
375
|
+
```
|
|
376
|
+
|
|
377
|
+
Progress of the fade from the low resolution preview to the full render, from 0 to 1.
|
|
378
|
+
|
|
379
|
+
|
|
380
|
+
### .lowResTarget
|
|
381
|
+
|
|
382
|
+
```js
|
|
383
|
+
readonly lowResTarget: Texture
|
|
384
|
+
```
|
|
385
|
+
|
|
386
|
+
The low resolution preview rendered while [WebGPUPathTracer#renderDelay](WebGPUPathTracer#renderDelay) elapses.
|
|
387
|
+
|
|
388
|
+
|
|
389
|
+
### .lowResMode
|
|
390
|
+
|
|
391
|
+
```js
|
|
392
|
+
readonly lowResMode: boolean
|
|
393
|
+
```
|
|
394
|
+
|
|
395
|
+
Whether the tracer is currently rendering the low resolution preview.
|
|
396
|
+
|
|
397
|
+
|
|
398
|
+
### .textureAtlas
|
|
399
|
+
|
|
400
|
+
```js
|
|
401
|
+
readonly textureAtlas: AtlasTexture
|
|
402
|
+
```
|
|
403
|
+
|
|
404
|
+
The atlas every scene texture is packed into for the kernels to sample.
|
|
405
|
+
|
|
406
|
+
|
|
407
|
+
### .minSamples
|
|
408
|
+
|
|
409
|
+
```js
|
|
410
|
+
minSamples: number = 1
|
|
411
|
+
```
|
|
412
|
+
|
|
413
|
+
Samples every pixel must reach before the full resolution render is faded in.
|
|
414
|
+
|
|
415
|
+
|
|
416
|
+
### .renderDelay
|
|
417
|
+
|
|
418
|
+
```js
|
|
419
|
+
renderDelay: number = 500
|
|
420
|
+
```
|
|
421
|
+
|
|
422
|
+
Milliseconds to show the low resolution preview for after a reset.
|
|
423
|
+
|
|
424
|
+
|
|
425
|
+
### .fadeDuration
|
|
426
|
+
|
|
427
|
+
```js
|
|
428
|
+
fadeDuration: number = 500
|
|
429
|
+
```
|
|
430
|
+
|
|
431
|
+
Milliseconds taken to cross fade from the preview to the full render.
|
|
432
|
+
|
|
433
|
+
|
|
434
|
+
### .dynamicLowRes
|
|
435
|
+
|
|
436
|
+
```js
|
|
437
|
+
dynamicLowRes: boolean = true
|
|
438
|
+
```
|
|
439
|
+
|
|
440
|
+
Whether to render a low resolution preview while the camera is moving.
|
|
441
|
+
|
|
442
|
+
|
|
443
|
+
### .lowResScale
|
|
444
|
+
|
|
445
|
+
```js
|
|
446
|
+
lowResScale: number = 0.1
|
|
447
|
+
```
|
|
448
|
+
|
|
449
|
+
Resolution of the low resolution preview, as a fraction of the render size.
|
|
450
|
+
|
|
451
|
+
|
|
452
|
+
### .renderScale
|
|
453
|
+
|
|
454
|
+
```js
|
|
455
|
+
renderScale: number = 1
|
|
456
|
+
```
|
|
457
|
+
|
|
458
|
+
Resolution the path tracer renders at, as a fraction of the canvas size. Lowering it
|
|
459
|
+
converges faster at the cost of detail, and pairs with an upscaler.
|
|
460
|
+
|
|
461
|
+
|
|
462
|
+
### .synchronizeRenderSize
|
|
463
|
+
|
|
464
|
+
```js
|
|
465
|
+
synchronizeRenderSize: boolean = true
|
|
466
|
+
```
|
|
467
|
+
|
|
468
|
+
Whether to track the canvas size automatically. Set to `false` to drive the render
|
|
469
|
+
size with [WebGPUPathTracer#setSize](WebGPUPathTracer#setSize).
|
|
470
|
+
|
|
471
|
+
|
|
472
|
+
### .generateMissingAttributes
|
|
473
|
+
|
|
474
|
+
```js
|
|
475
|
+
generateMissingAttributes: boolean = true
|
|
476
|
+
```
|
|
477
|
+
|
|
478
|
+
Whether to generate the attributes in [WebGPUPathTracer#commonAttributes](WebGPUPathTracer#commonAttributes) on
|
|
479
|
+
geometry that is missing them when the scene is set.
|
|
480
|
+
|
|
481
|
+
|
|
482
|
+
### .commonAttributes
|
|
483
|
+
|
|
484
|
+
```js
|
|
485
|
+
commonAttributes: Array<string> = [ 'normal', 'tangent' ]
|
|
486
|
+
```
|
|
487
|
+
|
|
488
|
+
Vertex attributes every geometry is expected to provide.
|
|
489
|
+
|
|
490
|
+
|
|
491
|
+
### .stableNoise
|
|
492
|
+
|
|
493
|
+
```js
|
|
494
|
+
stableNoise: boolean = true
|
|
495
|
+
```
|
|
496
|
+
|
|
497
|
+
Whether to restart the random sequence on reset so a given camera always produces the
|
|
498
|
+
same image.
|
|
499
|
+
|
|
500
|
+
|
|
501
|
+
### .pause
|
|
502
|
+
|
|
503
|
+
```js
|
|
504
|
+
pause: boolean = false
|
|
505
|
+
```
|
|
506
|
+
|
|
507
|
+
Whether to stop accumulating samples. The last image keeps being presented.
|
|
508
|
+
|
|
509
|
+
|
|
510
|
+
### .constructor
|
|
511
|
+
|
|
512
|
+
```js
|
|
513
|
+
constructor( renderer: WebGPURenderer )
|
|
514
|
+
```
|
|
515
|
+
|
|
516
|
+
### .getSampleCountsAsync
|
|
517
|
+
|
|
518
|
+
```js
|
|
519
|
+
async getSampleCountsAsync(): Promise<SampleCounts>
|
|
520
|
+
```
|
|
521
|
+
|
|
522
|
+
Measures the per pixel sample counts. Use `min` for convergence checks and `avg` to display.
|
|
523
|
+
|
|
524
|
+
> [!NOTE]
|
|
525
|
+
> The wavefront backend reduces the counts on the GPU and reads them back, so only call
|
|
526
|
+
> this when the numbers are needed.
|
|
527
|
+
|
|
528
|
+
### .setMultipleImportanceSampling
|
|
529
|
+
|
|
530
|
+
```js
|
|
531
|
+
setMultipleImportanceSampling( value: boolean ): void
|
|
532
|
+
```
|
|
533
|
+
|
|
534
|
+
|
|
535
|
+
### .setDenoiser
|
|
536
|
+
|
|
537
|
+
```js
|
|
538
|
+
setDenoiser( denoiser: OIDNDenoiser | null ): void
|
|
539
|
+
```
|
|
540
|
+
|
|
541
|
+
Attaches a denoiser, run once the render settles and displayed in place of the raw image.
|
|
542
|
+
Settings live on the instance. Pass null to remove it.
|
|
543
|
+
|
|
544
|
+
|
|
545
|
+
### .setUpscaler
|
|
546
|
+
|
|
547
|
+
```js
|
|
548
|
+
setUpscaler( upscaler: FSRUpscaler | null ): void
|
|
549
|
+
```
|
|
550
|
+
|
|
551
|
+
Attaches an upscaler, run before the image is presented so the render can happen below the
|
|
552
|
+
canvas resolution. Settings live on the instance. Pass null to remove it.
|
|
553
|
+
|
|
554
|
+
|
|
555
|
+
### .setScene
|
|
556
|
+
|
|
557
|
+
```js
|
|
558
|
+
setScene( scene: Scene, camera: Camera ): void
|
|
559
|
+
```
|
|
560
|
+
|
|
561
|
+
Captures the scene and camera and builds the acceleration structures the kernels trace
|
|
562
|
+
against. Call this once, then use the `update*` functions for later changes.
|
|
563
|
+
|
|
564
|
+
> [!NOTE]
|
|
565
|
+
> Geometry BVHs are built synchronously, so this blocks for large scenes.
|
|
566
|
+
|
|
567
|
+
### .setRandom
|
|
568
|
+
|
|
569
|
+
```js
|
|
570
|
+
setRandom( random: Object ): void
|
|
571
|
+
```
|
|
572
|
+
|
|
573
|
+
Replaces the random number generator and recompiles the kernels.
|
|
574
|
+
|
|
575
|
+
|
|
576
|
+
### .setCamera
|
|
577
|
+
|
|
578
|
+
```js
|
|
579
|
+
setCamera( camera: Camera ): void
|
|
580
|
+
```
|
|
581
|
+
|
|
582
|
+
Replaces the camera the rays are generated from. Cameras with a `getCameraRayFn`, such as
|
|
583
|
+
`PhysicalCamera` and `EquirectCamera`, provide their own ray generation.
|
|
584
|
+
|
|
585
|
+
|
|
586
|
+
### .updateMaterials
|
|
587
|
+
|
|
588
|
+
```js
|
|
589
|
+
updateMaterials(): void
|
|
590
|
+
```
|
|
591
|
+
|
|
592
|
+
Re-reads the material properties and textures from the scene. Call after changing any
|
|
593
|
+
material.
|
|
594
|
+
|
|
595
|
+
|
|
596
|
+
### .updateTransforms
|
|
597
|
+
|
|
598
|
+
```js
|
|
599
|
+
updateTransforms(): void
|
|
600
|
+
```
|
|
601
|
+
|
|
602
|
+
Re-reads the world matrices from the scene. Call after moving any object.
|
|
603
|
+
|
|
604
|
+
> [!NOTE]
|
|
605
|
+
> Changing geometry requires [WebGPUPathTracer#setScene](WebGPUPathTracer#setScene) instead, since the BVH
|
|
606
|
+
> must be rebuilt.
|
|
607
|
+
|
|
608
|
+
### .updateCamera
|
|
609
|
+
|
|
610
|
+
```js
|
|
611
|
+
updateCamera(): void
|
|
612
|
+
```
|
|
613
|
+
|
|
614
|
+
Re-reads the camera transform and projection. Call after moving the camera.
|
|
615
|
+
|
|
616
|
+
|
|
617
|
+
### .updateEnvironment
|
|
618
|
+
|
|
619
|
+
```js
|
|
620
|
+
updateEnvironment(): void
|
|
621
|
+
```
|
|
622
|
+
|
|
623
|
+
Re-reads `scene.environment` and `scene.background`, along with their intensity, rotation,
|
|
624
|
+
and blur.
|
|
625
|
+
|
|
626
|
+
|
|
627
|
+
### .updateLights
|
|
628
|
+
|
|
629
|
+
```js
|
|
630
|
+
updateLights(): void
|
|
631
|
+
```
|
|
632
|
+
|
|
633
|
+
Re-collects the lights in the scene. Call after adding, removing, or changing one.
|
|
634
|
+
|
|
635
|
+
|
|
636
|
+
### .setSize
|
|
637
|
+
|
|
638
|
+
```js
|
|
639
|
+
setSize( x: number, y: number ): void
|
|
640
|
+
```
|
|
641
|
+
|
|
642
|
+
Sets the resolution the path tracer renders at. Only used when
|
|
643
|
+
[WebGPUPathTracer#synchronizeRenderSize](WebGPUPathTracer#synchronizeRenderSize) is `false`.
|
|
644
|
+
|
|
645
|
+
|
|
646
|
+
### .reset
|
|
647
|
+
|
|
648
|
+
```js
|
|
649
|
+
reset(): void
|
|
650
|
+
```
|
|
651
|
+
|
|
652
|
+
Discards the accumulated image and starts over. The `update*` functions call this for you.
|
|
653
|
+
|
|
654
|
+
|
|
655
|
+
### .renderSample
|
|
656
|
+
|
|
657
|
+
```js
|
|
658
|
+
renderSample(): void
|
|
659
|
+
```
|
|
660
|
+
|
|
661
|
+
Accumulates one round of samples and presents the result to the canvas. Call once per frame.
|
|
662
|
+
|
|
663
|
+
|
|
664
|
+
### .renderDebugBounds
|
|
665
|
+
|
|
666
|
+
```js
|
|
667
|
+
renderDebugBounds(
|
|
668
|
+
{
|
|
669
|
+
// Count the top level object bounding boxes.
|
|
670
|
+
displayTLAS = true: boolean,
|
|
671
|
+
|
|
672
|
+
// Count the per object geometry bounding boxes.
|
|
673
|
+
displayBLAS = true: boolean,
|
|
674
|
+
|
|
675
|
+
// Only count boxes in front of the nearest hit, so occluded
|
|
676
|
+
// boxes do not contribute. Culling and material transparency
|
|
677
|
+
// are honored.
|
|
678
|
+
stopAtSurface = false: boolean,
|
|
679
|
+
|
|
680
|
+
// Node count that saturates to full heat.
|
|
681
|
+
saturationCount = 64: number,
|
|
682
|
+
}
|
|
683
|
+
): void
|
|
684
|
+
```
|
|
685
|
+
|
|
686
|
+
Draws a heatmap of how many BVH bounding boxes each camera ray intersects, for diagnosing
|
|
687
|
+
box overlap and traversal cost. Hotter pixels traverse more nodes.
|
|
688
|
+
|
|
689
|
+
|
|
690
|
+
### .renderTextureAtlas
|
|
691
|
+
|
|
692
|
+
```js
|
|
693
|
+
renderTextureAtlas( layer = 0: number ): void
|
|
694
|
+
```
|
|
695
|
+
|
|
696
|
+
Draws one layer of the texture atlas to the canvas, for debugging texture packing.
|
|
697
|
+
|
|
698
|
+
|
|
699
|
+
### .renderSampleDensity
|
|
700
|
+
|
|
701
|
+
```js
|
|
702
|
+
renderSampleDensity(): void
|
|
703
|
+
```
|
|
704
|
+
|
|
705
|
+
Draws a heatmap of the per pixel sample counts, for spotting pixels that converge slowly.
|
|
706
|
+
|
|
707
|
+
> [!NOTE]
|
|
708
|
+
> Measures on every call and draws with the previous result, since the readback lands a
|
|
709
|
+
> frame later.
|
|
710
|
+
|
|
711
|
+
### .dispose
|
|
712
|
+
|
|
713
|
+
```js
|
|
714
|
+
dispose(): void
|
|
715
|
+
```
|
|
716
|
+
|
|
717
|
+
Frees every GPU resource held by the tracer, including any attached denoiser and upscaler.
|
|
718
|
+
|
|
719
|
+
|
|
720
|
+
### .getRenderTime
|
|
721
|
+
|
|
722
|
+
```js
|
|
723
|
+
getRenderTime(): number
|
|
724
|
+
```
|
|
725
|
+
|
|
726
|
+
Milliseconds elapsed since the last reset.
|
|
727
|
+
|
|
728
|
+
|
|
729
|
+
## SampleCounts
|
|
730
|
+
|
|
731
|
+
|
|
732
|
+
### .min
|
|
733
|
+
|
|
734
|
+
```js
|
|
735
|
+
min: number
|
|
736
|
+
```
|
|
737
|
+
|
|
738
|
+
Lowest sample count of any pixel.
|
|
739
|
+
|
|
740
|
+
### .max
|
|
741
|
+
|
|
742
|
+
```js
|
|
743
|
+
max: number
|
|
744
|
+
```
|
|
745
|
+
|
|
746
|
+
Highest sample count of any pixel.
|
|
747
|
+
|
|
748
|
+
### .avg
|
|
749
|
+
|
|
750
|
+
```js
|
|
751
|
+
avg: number
|
|
752
|
+
```
|
|
753
|
+
|
|
754
|
+
Mean sample count across the image.
|
|
755
|
+
|
|
756
|
+
### .samplesPerSecond
|
|
757
|
+
|
|
758
|
+
```js
|
|
759
|
+
samplesPerSecond: number
|
|
760
|
+
```
|
|
761
|
+
|
|
762
|
+
Mean samples accumulated per second since the last reset.
|