three-gpu-pathtracer 0.0.13 → 0.0.14
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/LICENSE +21 -21
- package/README.md +981 -961
- package/build/index.module.js +6965 -6508
- package/build/index.module.js.map +1 -1
- package/build/index.umd.cjs +6959 -6505
- package/build/index.umd.cjs.map +1 -1
- package/package.json +73 -73
- package/src/core/DynamicPathTracingSceneGenerator.js +119 -119
- package/src/core/MaterialReducer.js +256 -256
- package/src/core/PathTracingRenderer.js +346 -346
- package/src/core/PathTracingSceneGenerator.js +69 -69
- package/src/core/QuiltPathTracingRenderer.js +223 -223
- package/src/index.js +36 -40
- package/src/materials/MaterialBase.js +56 -56
- package/src/materials/{GraphMaterial.js → debug/GraphMaterial.js} +243 -243
- package/src/materials/{AlphaDisplayMaterial.js → fullscreen/AlphaDisplayMaterial.js} +48 -48
- package/src/materials/{BlendMaterial.js → fullscreen/BlendMaterial.js} +67 -67
- package/src/materials/{DenoiseMaterial.js → fullscreen/DenoiseMaterial.js} +142 -142
- package/src/materials/{LambertPathTracingMaterial.js → pathtracing/LambertPathTracingMaterial.js} +296 -285
- package/src/materials/pathtracing/PhysicalPathTracingMaterial.js +635 -0
- package/src/materials/pathtracing/glsl/attenuateHit.glsl.js +179 -0
- package/src/materials/pathtracing/glsl/cameraUtils.glsl.js +81 -0
- package/src/materials/pathtracing/glsl/getSurfaceRecord.glsl.js +317 -0
- package/src/materials/pathtracing/glsl/traceScene.glsl.js +54 -0
- package/src/materials/{AmbientOcclusionMaterial.js → surface/AmbientOcclusionMaterial.js} +207 -199
- package/src/materials/surface/FogVolumeMaterial.js +23 -0
- package/src/objects/EquirectCamera.js +13 -13
- package/src/objects/PhysicalCamera.js +28 -28
- package/src/objects/PhysicalSpotLight.js +14 -14
- package/src/objects/ShapedAreaLight.js +12 -12
- package/src/shader/bsdf/bsdfSampling.glsl.js +490 -0
- package/src/shader/bsdf/fog.glsl.js +23 -0
- package/src/shader/bsdf/ggx.glsl.js +102 -0
- package/src/shader/bsdf/iridescence.glsl.js +135 -0
- package/src/shader/bsdf/sheen.glsl.js +98 -0
- package/src/shader/{shaderLayerTexelFetchFunctions.js → common/arraySamplerTexelFetch.glsl.js} +25 -25
- package/src/shader/common/bvhAnyHit.glsl.js +76 -0
- package/src/shader/common/fresnel.glsl.js +98 -0
- package/src/shader/common/intersectShapes.glsl.js +62 -0
- package/src/shader/common/math.glsl.js +81 -0
- package/src/shader/common/utils.glsl.js +116 -0
- package/src/shader/{shaderRandFunctions.js → rand/pcg.glsl.js} +57 -57
- package/src/shader/{shaderSobolSampling.js → rand/sobol.glsl.js} +256 -256
- package/src/shader/sampling/equirectSampling.glsl.js +62 -0
- package/src/shader/sampling/lightSampling.glsl.js +223 -0
- package/src/shader/sampling/shapeSampling.glsl.js +86 -0
- package/src/shader/structs/cameraStruct.glsl.js +13 -0
- package/src/shader/structs/equirectStruct.glsl.js +14 -0
- package/src/shader/structs/fogMaterialBvh.glsl.js +62 -0
- package/src/shader/structs/lightsStruct.glsl.js +78 -0
- package/src/shader/{shaderStructs.js → structs/materialStruct.glsl.js} +207 -327
- package/src/textures/GradientEquirectTexture.js +35 -35
- package/src/textures/ProceduralEquirectTexture.js +75 -75
- package/src/uniforms/AttributesTextureArray.js +35 -35
- package/src/uniforms/EquirectHdrInfoUniform.js +277 -273
- package/src/uniforms/FloatAttributeTextureArray.js +169 -169
- package/src/uniforms/IESProfilesTexture.js +100 -100
- package/src/uniforms/LightsInfoUniformStruct.js +212 -212
- package/src/uniforms/MaterialsTexture.js +503 -426
- package/src/uniforms/PhysicalCameraUniform.js +36 -36
- package/src/uniforms/RenderTarget2DArray.js +97 -97
- package/src/uniforms/utils.js +30 -30
- package/src/utils/BlurredEnvMapGenerator.js +116 -116
- package/src/utils/GeometryPreparationUtils.js +214 -214
- package/src/utils/IESLoader.js +325 -325
- package/src/utils/SobolNumberMapGenerator.js +80 -80
- package/src/utils/UVUnwrapper.js +101 -101
- package/src/utils/macroify.js +9 -0
- package/src/workers/PathTracingSceneWorker.js +42 -42
- package/src/materials/PhysicalPathTracingMaterial.js +0 -1013
- package/src/shader/shaderBvhAnyHit.js +0 -76
- package/src/shader/shaderEnvMapSampling.js +0 -58
- package/src/shader/shaderGGXFunctions.js +0 -100
- package/src/shader/shaderIridescenceFunctions.js +0 -135
- package/src/shader/shaderLightSampling.js +0 -229
- package/src/shader/shaderMaterialSampling.js +0 -510
- package/src/shader/shaderSheenFunctions.js +0 -98
- package/src/shader/shaderUtils.js +0 -377
package/README.md
CHANGED
|
@@ -1,961 +1,981 @@
|
|
|
1
|
-
# three-gpu-pathtracer
|
|
2
|
-
|
|
3
|
-
[](https://www.npmjs.com/package/three-gpu-pathtracer)
|
|
4
|
-
[](https://github.com/gkjohnson/three-gpu-pathtracer/actions)
|
|
5
|
-
[](https://github.com/gkjohnson/three-gpu-pathtracer/)
|
|
6
|
-
[](https://twitter.com/garrettkjohnson)
|
|
7
|
-
[](https://github.com/sponsors/gkjohnson/)
|
|
8
|
-
|
|
9
|
-

|
|
10
|
-
|
|
11
|
-
Path tracing project using [three-mesh-bvh](https://github.com/gkjohnson/three-mesh-bvh) and WebGL 2 to accelerate high quality, physically based rendering on the GPU. Features include support for GGX surface model, material information, textures, normal maps, emission, environment maps, tiled rendering, and more!
|
|
12
|
-
|
|
13
|
-
_More features and capabilities in progress!_
|
|
14
|
-
|
|
15
|
-
# Examples
|
|
16
|
-
|
|
17
|
-
**Setup**
|
|
18
|
-
|
|
19
|
-
[Basic Setup Example](https://gkjohnson.github.io/three-gpu-pathtracer/example/bundle/basic.html)
|
|
20
|
-
|
|
21
|
-
**Beauty Demos**
|
|
22
|
-
|
|
23
|
-
[Physically Based Materials](https://gkjohnson.github.io/three-gpu-pathtracer/example/bundle/index.html)
|
|
24
|
-
|
|
25
|
-
[Lego Models](https://gkjohnson.github.io/three-gpu-pathtracer/example/bundle/lego.html)
|
|
26
|
-
|
|
27
|
-
[Interior Scene](https://gkjohnson.github.io/three-gpu-pathtracer/example/bundle/interior.html)
|
|
28
|
-
|
|
29
|
-
[Depth of Field](https://gkjohnson.github.io/three-gpu-pathtracer/example/bundle/depthOfField.html)
|
|
30
|
-
|
|
31
|
-
**Features**
|
|
32
|
-
|
|
33
|
-
[Skinned Geometry Support](https://gkjohnson.github.io/three-gpu-pathtracer/example/bundle/skinnedMesh.html)
|
|
34
|
-
|
|
35
|
-
[Morph Target Support](https://gkjohnson.github.io/three-gpu-pathtracer/example/bundle/skinnedMesh.html#morphtarget)
|
|
36
|
-
|
|
37
|
-
[Area Light Support](https://gkjohnson.github.io/three-gpu-pathtracer/example/bundle/areaLight.html)
|
|
38
|
-
|
|
39
|
-
[Spot Light Support](https://gkjohnson.github.io/three-gpu-pathtracer/example/bundle/spotLights.html)
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
[
|
|
46
|
-
|
|
47
|
-
[
|
|
48
|
-
|
|
49
|
-
[
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
[
|
|
56
|
-
|
|
57
|
-
[
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
import
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
renderer
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
ptRenderer
|
|
95
|
-
ptRenderer.
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
geometry.attributes.
|
|
121
|
-
geometry.attributes.
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
ptMaterial.
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
//
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
const
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
//
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
```
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
```
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
```
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
```
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
```
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
```
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
```
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
```
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
```
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
```
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
```
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
```
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
```
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
quiltDimensions
|
|
327
|
-
```
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
viewCone
|
|
334
|
-
```
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
```
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
```
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
```
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
```
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
```
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
```
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
```
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
```
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
```
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
```
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
```
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
```
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
```
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
```
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
```
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
```
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
```
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
```
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
```
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
```
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
```
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
```
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
```
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
```
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
//
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
//
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
//
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
//
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
```
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
### .
|
|
766
|
-
|
|
767
|
-
```js
|
|
768
|
-
|
|
769
|
-
```
|
|
770
|
-
|
|
771
|
-
### .
|
|
772
|
-
|
|
773
|
-
```js
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
### .
|
|
807
|
-
|
|
808
|
-
```js
|
|
809
|
-
|
|
810
|
-
```
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
```
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
](https://www.npmjs.com/package/three-gpu-pathtracer)
|
|
4
|
+
[](https://github.com/gkjohnson/three-gpu-pathtracer/actions)
|
|
5
|
+
[](https://github.com/gkjohnson/three-gpu-pathtracer/)
|
|
6
|
+
[](https://twitter.com/garrettkjohnson)
|
|
7
|
+
[](https://github.com/sponsors/gkjohnson/)
|
|
8
|
+
|
|
9
|
+

|
|
10
|
+
|
|
11
|
+
Path tracing project using [three-mesh-bvh](https://github.com/gkjohnson/three-mesh-bvh) and WebGL 2 to accelerate high quality, physically based rendering on the GPU. Features include support for GGX surface model, material information, textures, normal maps, emission, environment maps, tiled rendering, and more!
|
|
12
|
+
|
|
13
|
+
_More features and capabilities in progress!_
|
|
14
|
+
|
|
15
|
+
# Examples
|
|
16
|
+
|
|
17
|
+
**Setup**
|
|
18
|
+
|
|
19
|
+
[Basic Setup Example](https://gkjohnson.github.io/three-gpu-pathtracer/example/bundle/basic.html)
|
|
20
|
+
|
|
21
|
+
**Beauty Demos**
|
|
22
|
+
|
|
23
|
+
[Physically Based Materials](https://gkjohnson.github.io/three-gpu-pathtracer/example/bundle/index.html)
|
|
24
|
+
|
|
25
|
+
[Lego Models](https://gkjohnson.github.io/three-gpu-pathtracer/example/bundle/lego.html)
|
|
26
|
+
|
|
27
|
+
[Interior Scene](https://gkjohnson.github.io/three-gpu-pathtracer/example/bundle/interior.html)
|
|
28
|
+
|
|
29
|
+
[Depth of Field](https://gkjohnson.github.io/three-gpu-pathtracer/example/bundle/depthOfField.html)
|
|
30
|
+
|
|
31
|
+
**Features**
|
|
32
|
+
|
|
33
|
+
[Skinned Geometry Support](https://gkjohnson.github.io/three-gpu-pathtracer/example/bundle/skinnedMesh.html)
|
|
34
|
+
|
|
35
|
+
[Morph Target Support](https://gkjohnson.github.io/three-gpu-pathtracer/example/bundle/skinnedMesh.html#morphtarget)
|
|
36
|
+
|
|
37
|
+
[Area Light Support](https://gkjohnson.github.io/three-gpu-pathtracer/example/bundle/areaLight.html)
|
|
38
|
+
|
|
39
|
+
[Spot Light Support](https://gkjohnson.github.io/three-gpu-pathtracer/example/bundle/spotLights.html)
|
|
40
|
+
|
|
41
|
+
[Volumetric Fog Support](https://gkjohnson.github.io/three-gpu-pathtracer/example/bundle/fog.html)
|
|
42
|
+
|
|
43
|
+
**Test Scenes**
|
|
44
|
+
|
|
45
|
+
[Material Test Orb](https://gkjohnson.github.io/three-gpu-pathtracer/example/bundle/materialBall.html)
|
|
46
|
+
|
|
47
|
+
[Transmission Preset Orb](https://gkjohnson.github.io/three-gpu-pathtracer/example/bundle/materialBall.html#transmission)
|
|
48
|
+
|
|
49
|
+
[Model Viewer Fidelity Scene Comparisons](https://gkjohnson.github.io/three-gpu-pathtracer/example/bundle/viewerTest.html)
|
|
50
|
+
|
|
51
|
+
[Physical Material Database](https://gkjohnson.github.io/three-gpu-pathtracer/example/bundle/materialDatabase.html)
|
|
52
|
+
|
|
53
|
+
**Tools**
|
|
54
|
+
|
|
55
|
+
[Animation Rendering](https://gkjohnson.github.io/three-gpu-pathtracer/example/bundle/renderVideo.html)
|
|
56
|
+
|
|
57
|
+
[Ambient Occlusion Material](https://gkjohnson.github.io/three-gpu-pathtracer/example/bundle/aoRender.html)
|
|
58
|
+
|
|
59
|
+
[Looking Glass Portrait Quilt Render](https://gkjohnson.github.io/three-gpu-pathtracer/example/bundle/lkg.html)
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
## Running examples locally
|
|
63
|
+
|
|
64
|
+
To run and modify the examples locally, make sure you have Node and NPM installed. Check the supported versions in [the test configuration](./.github/workflows/node.js.yml).
|
|
65
|
+
|
|
66
|
+
In order to install dependencies, you will need `make` and a C++ compiler available.
|
|
67
|
+
|
|
68
|
+
On Debian or Ubuntu, run `sudo apt install build-essential`. It should just work on MacOS.
|
|
69
|
+
|
|
70
|
+
- To install dependencies, run `npm install`
|
|
71
|
+
- To start the demos run `npm start`
|
|
72
|
+
- Visit `http://localhost:1234/<demo-name.html>`
|
|
73
|
+
|
|
74
|
+
# Use
|
|
75
|
+
|
|
76
|
+
**Basic Renderer**
|
|
77
|
+
|
|
78
|
+
```js
|
|
79
|
+
import * as THREE from 'three';
|
|
80
|
+
import { FullScreenQuad } from 'three/examples/jsm/postprocessing/Pass.js';
|
|
81
|
+
import {
|
|
82
|
+
PathTracingSceneGenerator,
|
|
83
|
+
PathTracingRenderer,
|
|
84
|
+
PhysicalPathTracingMaterial,
|
|
85
|
+
} from 'three-gpu-pathtracer';
|
|
86
|
+
|
|
87
|
+
// init scene, renderer, camera, controls, etc
|
|
88
|
+
|
|
89
|
+
renderer.outputEncoding = THREE.sRGBEncoding;
|
|
90
|
+
renderer.toneMapping = THREE.ACESFilmicToneMapping;
|
|
91
|
+
|
|
92
|
+
// initialize the path tracing material and renderer
|
|
93
|
+
const ptMaterial = new PhysicalPathTracingMaterial();
|
|
94
|
+
const ptRenderer = new PathTracingRenderer( renderer );
|
|
95
|
+
ptRenderer.setSize( window.innerWidth, window.innerHeight );
|
|
96
|
+
ptRenderer.camera = camera;
|
|
97
|
+
ptRenderer.material = ptMaterial;
|
|
98
|
+
|
|
99
|
+
// if rendering transparent background
|
|
100
|
+
ptRenderer.alpha = true;
|
|
101
|
+
|
|
102
|
+
// init quad for rendering to the canvas
|
|
103
|
+
const fsQuad = new FullScreenQuad( new THREE.MeshBasicMaterial( {
|
|
104
|
+
map: ptRenderer.target.texture,
|
|
105
|
+
|
|
106
|
+
// if rendering transparent background
|
|
107
|
+
blending: THREE.CustomBlending,
|
|
108
|
+
} ) );
|
|
109
|
+
|
|
110
|
+
// ensure scene matrices are up to date
|
|
111
|
+
scene.updateMatrixWorld();
|
|
112
|
+
|
|
113
|
+
// initialize the scene and update the material properties with the bvh, materials, etc
|
|
114
|
+
const generator = new PathTracingSceneGenerator();
|
|
115
|
+
const { bvh, textures, materials, lights } = generator.generate( scene );
|
|
116
|
+
|
|
117
|
+
// update bvh and geometry attribute textures
|
|
118
|
+
ptMaterial.bvh.updateFrom( bvh );
|
|
119
|
+
ptMaterial.attributesArray.updateFrom(
|
|
120
|
+
geometry.attributes.normal,
|
|
121
|
+
geometry.attributes.tangent,
|
|
122
|
+
geometry.attributes.uv,
|
|
123
|
+
geometry.attributes.color,
|
|
124
|
+
);
|
|
125
|
+
|
|
126
|
+
// update materials and texture arrays
|
|
127
|
+
ptMaterial.materialIndexAttribute.updateFrom( geometry.attributes.materialIndex );
|
|
128
|
+
ptMaterial.textures.setTextures( renderer, 2048, 2048, textures );
|
|
129
|
+
ptMaterial.materials.updateFrom( materials, textures );
|
|
130
|
+
|
|
131
|
+
// update the lights
|
|
132
|
+
ptMaterial.lights.updateFrom( lights );
|
|
133
|
+
|
|
134
|
+
// set the environment map
|
|
135
|
+
const texture = await new RGBELoader().setDataType( THREE.FloatType ).loadAsync( envMapUrl );
|
|
136
|
+
ptRenderer.material.envMapInfo.updateFrom( texture );
|
|
137
|
+
|
|
138
|
+
animate();
|
|
139
|
+
|
|
140
|
+
// ...
|
|
141
|
+
|
|
142
|
+
function animate() {
|
|
143
|
+
|
|
144
|
+
// if the camera position changes call "ptRenderer.reset()"
|
|
145
|
+
|
|
146
|
+
// update the camera and render one sample
|
|
147
|
+
camera.updateMatrixWorld();
|
|
148
|
+
ptRenderer.update();
|
|
149
|
+
|
|
150
|
+
// if using alpha = true then the target texture will change every frame
|
|
151
|
+
// so we must retrieve it before render.
|
|
152
|
+
fsQuad.material.map = ptRenderer.target.texture;
|
|
153
|
+
|
|
154
|
+
// copy the current state of the path tracer to canvas to display
|
|
155
|
+
fsQuad.render( renderer );
|
|
156
|
+
|
|
157
|
+
}
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
**Blurred Environment Map**
|
|
161
|
+
|
|
162
|
+
Using a pre blurred envioronment map can help improve frame convergence time at the cost of sharp environment reflections. If performance is concern then multiple importance sampling can be disabled and blurred environment map used.
|
|
163
|
+
|
|
164
|
+
```js
|
|
165
|
+
import { BlurredEnvMapGenerator } from 'three-gpu-pathtracer';
|
|
166
|
+
|
|
167
|
+
// ...
|
|
168
|
+
|
|
169
|
+
const envMap = await new RGBELoader().setDataType( THREE.FloatType ).loadAsync( envMapUrl );
|
|
170
|
+
const generator = new BlurredEnvMapGenerator( renderer );
|
|
171
|
+
const blurredEnvMap = generator.generate( envMap, 0.35 );
|
|
172
|
+
|
|
173
|
+
// render!
|
|
174
|
+
|
|
175
|
+
```
|
|
176
|
+
|
|
177
|
+
## Dynamic Scenes
|
|
178
|
+
|
|
179
|
+
Using the dynamic scene generator the same, frequently updated scene can be converted into a single reusable geometry multiple times and BVH refit which greatly improves subsequent scene updates. See `DynamicPathTracingSceneGenerator` docs for more info.
|
|
180
|
+
|
|
181
|
+
```js
|
|
182
|
+
import { DynamicPathTracingSceneGenerator } from 'three-gpu-pathtracer';
|
|
183
|
+
|
|
184
|
+
// ... initialize scene etc
|
|
185
|
+
|
|
186
|
+
const generator = new DynamicPathTracingSceneGenerator( scene );
|
|
187
|
+
const { bvh, textures, materials } = generator.generate( scene );
|
|
188
|
+
|
|
189
|
+
// ... update path tracer and render
|
|
190
|
+
```
|
|
191
|
+
|
|
192
|
+
## Asynchronous Scene Generation
|
|
193
|
+
|
|
194
|
+
_NOTE WebWorker syntax is inconsistently supported across bundlers and sometimes not supported at all so the PathTracingSceneWorker class is not exported from the package root. If needed the code from src/worker can be copied and modified to accomodate a particular build process._
|
|
195
|
+
|
|
196
|
+
```js
|
|
197
|
+
import { PathTracingSceneWorker } from 'three-gpu-pathtracer/src/workers/PathTracingSceneWorker.js';
|
|
198
|
+
|
|
199
|
+
// ...
|
|
200
|
+
|
|
201
|
+
// initialize the scene and update the material properties with the bvh, materials, etc
|
|
202
|
+
const generator = new PathTracingSceneWorker();
|
|
203
|
+
const { bvh, textures, materials, lights } = await generator.generate( scene );
|
|
204
|
+
|
|
205
|
+
// ...
|
|
206
|
+
```
|
|
207
|
+
|
|
208
|
+
# Exports
|
|
209
|
+
|
|
210
|
+
## PathTracingRenderer
|
|
211
|
+
|
|
212
|
+
Utility class for tracking and rendering a path traced scene to a render target.
|
|
213
|
+
|
|
214
|
+
### .samples
|
|
215
|
+
|
|
216
|
+
```js
|
|
217
|
+
readonly samples : Number
|
|
218
|
+
```
|
|
219
|
+
|
|
220
|
+
Number of samples per pixel that have been rendered to the target.
|
|
221
|
+
|
|
222
|
+
### .target
|
|
223
|
+
|
|
224
|
+
```js
|
|
225
|
+
readonly target : WebGLRenderTarget
|
|
226
|
+
```
|
|
227
|
+
|
|
228
|
+
The target being rendered to. The size of the target is updated with `setSize` and is initialized to a FloatType texture.
|
|
229
|
+
|
|
230
|
+
> **Note**
|
|
231
|
+
> Target will swap render targets after every full sample when alpha is enabled.
|
|
232
|
+
|
|
233
|
+
### .camera
|
|
234
|
+
|
|
235
|
+
```js
|
|
236
|
+
camera = null : Camera
|
|
237
|
+
```
|
|
238
|
+
|
|
239
|
+
The camera to render with. The view offset of the camera will be updated every sample to enable anti aliasing.
|
|
240
|
+
|
|
241
|
+
### .material
|
|
242
|
+
|
|
243
|
+
```js
|
|
244
|
+
material = null : ShaderMaterial
|
|
245
|
+
```
|
|
246
|
+
|
|
247
|
+
The Path Tracing material to render. This is expected to be a full screen quad material that respects the "opacity" field for every pixel so samples can be accumulated over time. The material is also expected to have `cameraWorldMatrix` and `invProjectionMatrix` fields of type `Matrix4`.
|
|
248
|
+
|
|
249
|
+
### .tiles
|
|
250
|
+
|
|
251
|
+
```js
|
|
252
|
+
tiles = ( 1, 1 ) : Vector2
|
|
253
|
+
```
|
|
254
|
+
|
|
255
|
+
Number of tiles on x and y to render to. Can be used to improve the responsiveness of a page while still rendering a high resolution target.
|
|
256
|
+
|
|
257
|
+
### .stableNoise
|
|
258
|
+
|
|
259
|
+
```js
|
|
260
|
+
stableNoise = false : Boolean
|
|
261
|
+
```
|
|
262
|
+
|
|
263
|
+
Whether to reset the random seed to `0` when restarting the render. If true then a consistent random sample pattern will appear when moving the camera, for example.
|
|
264
|
+
|
|
265
|
+
### .stableTiles
|
|
266
|
+
|
|
267
|
+
```js
|
|
268
|
+
stableTiles = true : Boolean
|
|
269
|
+
```
|
|
270
|
+
|
|
271
|
+
Whether the initial tile is reset to the top left tile when moving the camera or if it should continue to shift every frame.
|
|
272
|
+
|
|
273
|
+
### .alpha
|
|
274
|
+
|
|
275
|
+
```js
|
|
276
|
+
alpha = false : Boolean
|
|
277
|
+
```
|
|
278
|
+
|
|
279
|
+
Whether to support rendering scenes with transparent backgrounds. When transparent backgrounds are used two extra render targets are used, custom blending is performed, and PathTracingRenderer.target will change on every completed sample.
|
|
280
|
+
|
|
281
|
+
> **Note**
|
|
282
|
+
> When a transparent background is used the material used for the final render to the canvas must use the same "premultipliedAlpha" setting as the canvas otherwise the final image may look incorrect.
|
|
283
|
+
|
|
284
|
+
### constructor
|
|
285
|
+
|
|
286
|
+
```js
|
|
287
|
+
constructor( renderer : WebGLRenderer )
|
|
288
|
+
```
|
|
289
|
+
|
|
290
|
+
### .setSize
|
|
291
|
+
|
|
292
|
+
```js
|
|
293
|
+
setSize( size : Vector2 ) : void
|
|
294
|
+
```
|
|
295
|
+
|
|
296
|
+
Sets the size of the target to render to.
|
|
297
|
+
|
|
298
|
+
### .update
|
|
299
|
+
|
|
300
|
+
```js
|
|
301
|
+
update()
|
|
302
|
+
```
|
|
303
|
+
|
|
304
|
+
Renders a single sample to the target.
|
|
305
|
+
|
|
306
|
+
### .reset
|
|
307
|
+
|
|
308
|
+
```js
|
|
309
|
+
reset() : void
|
|
310
|
+
```
|
|
311
|
+
|
|
312
|
+
Resets and restarts the render from scratch.
|
|
313
|
+
|
|
314
|
+
## QuiltPathTracingRenderer
|
|
315
|
+
|
|
316
|
+
Renderer that supports rendering to a quilt renderer to rendering on displays such as the Looking Glass display.
|
|
317
|
+
|
|
318
|
+
### .viewCount
|
|
319
|
+
|
|
320
|
+
```js
|
|
321
|
+
viewCount = 48 : Number
|
|
322
|
+
```
|
|
323
|
+
|
|
324
|
+
The number of views to be rendered. If this is less than the product of the quiltDimensions then there will be gaps at the end of the quilt.
|
|
325
|
+
|
|
326
|
+
### .quiltDimensions
|
|
327
|
+
```js
|
|
328
|
+
quiltDimensions = Vector2( 8, 6 ) : Vector2
|
|
329
|
+
```
|
|
330
|
+
|
|
331
|
+
The number of quilt patches in each dimension.
|
|
332
|
+
|
|
333
|
+
### .viewCone
|
|
334
|
+
```js
|
|
335
|
+
viewCone = 35 * DEG2RAD : Number
|
|
336
|
+
```
|
|
337
|
+
|
|
338
|
+
The total angle sweep for the camera views rendered across the quilt.
|
|
339
|
+
|
|
340
|
+
### .viewFoV
|
|
341
|
+
|
|
342
|
+
```js
|
|
343
|
+
viewFoV = 14 * DEG2RAD : Number
|
|
344
|
+
```
|
|
345
|
+
|
|
346
|
+
The camera field of view to render.
|
|
347
|
+
|
|
348
|
+
### .displayDistance
|
|
349
|
+
|
|
350
|
+
```js
|
|
351
|
+
displayDistance = 1 : Number
|
|
352
|
+
```
|
|
353
|
+
|
|
354
|
+
The distance of the viewer to the display.
|
|
355
|
+
|
|
356
|
+
### .displayAspect
|
|
357
|
+
|
|
358
|
+
```js
|
|
359
|
+
displayAspect = 0.75 : Number
|
|
360
|
+
```
|
|
361
|
+
|
|
362
|
+
The aspect ratio of the display.
|
|
363
|
+
|
|
364
|
+
### .setFromDisplayView
|
|
365
|
+
|
|
366
|
+
```js
|
|
367
|
+
setFromDisplayView(
|
|
368
|
+
displayDistance : Number,
|
|
369
|
+
displayWidth : Number,
|
|
370
|
+
displayHeight : Number,
|
|
371
|
+
) : void
|
|
372
|
+
```
|
|
373
|
+
|
|
374
|
+
Updates the `displayDistance`, `displayAspect`, and the `viewFoV` from viewer and display information.
|
|
375
|
+
|
|
376
|
+
## PathTracingSceneGenerator
|
|
377
|
+
|
|
378
|
+
Utility class for generating the set of data required for initializing the path tracing material with a bvh, geometry, materials, and textures.
|
|
379
|
+
|
|
380
|
+
### .generate
|
|
381
|
+
|
|
382
|
+
```js
|
|
383
|
+
generate( scene : Object3D | Array<Object3D>, options = {} : Object ) : {
|
|
384
|
+
bvh : MeshBVH,
|
|
385
|
+
materials : Array<Material>,
|
|
386
|
+
textures : Array<Texture>,
|
|
387
|
+
lights : Array<Light>
|
|
388
|
+
}
|
|
389
|
+
```
|
|
390
|
+
|
|
391
|
+
Merges the geometry in the given scene with an additional "materialIndex" attribute that references the associated material array. Also produces a set of textures referenced by the scene materials.
|
|
392
|
+
|
|
393
|
+
## PathTracingSceneWorker
|
|
394
|
+
|
|
395
|
+
_extends PathTracingSceneGenerator_
|
|
396
|
+
|
|
397
|
+
See note in [Asyncronous Generation](#asynchronous-generation) use snippet.
|
|
398
|
+
|
|
399
|
+
### .generate
|
|
400
|
+
|
|
401
|
+
```js
|
|
402
|
+
async generate( scene : Object3D | Array<Object3D>, options = {} : Object ) : {
|
|
403
|
+
bvh : MeshBVH,
|
|
404
|
+
materials : Array<Material>,
|
|
405
|
+
textures : Array<Texture>,
|
|
406
|
+
lights : Array<Light>
|
|
407
|
+
}
|
|
408
|
+
```
|
|
409
|
+
|
|
410
|
+
### .dispose
|
|
411
|
+
|
|
412
|
+
```js
|
|
413
|
+
dispose() : void
|
|
414
|
+
```
|
|
415
|
+
|
|
416
|
+
## PhysicalCamera
|
|
417
|
+
|
|
418
|
+
_extends THREE.PerspectiveCamera_
|
|
419
|
+
|
|
420
|
+
An extension of the three.js PerspectiveCamera with some other parameters associated with depth of field. These parameters otherwise do not affect the camera behavior are are for convenience of use with the PhysicalCameraUniform and pathtracer.
|
|
421
|
+
|
|
422
|
+
### .focusDistance
|
|
423
|
+
|
|
424
|
+
```js
|
|
425
|
+
focusDistance = 25 : Number
|
|
426
|
+
```
|
|
427
|
+
|
|
428
|
+
The distance from the camera in meters that everything is is perfect focus.
|
|
429
|
+
|
|
430
|
+
### .fStop
|
|
431
|
+
|
|
432
|
+
```js
|
|
433
|
+
fStop = 1.4 : Number
|
|
434
|
+
```
|
|
435
|
+
|
|
436
|
+
The fstop value of the camera. If this is changed then the `bokehSize` field is implicitly updated.
|
|
437
|
+
|
|
438
|
+
### .bokehSize
|
|
439
|
+
|
|
440
|
+
```js
|
|
441
|
+
bokehSize : Number
|
|
442
|
+
```
|
|
443
|
+
|
|
444
|
+
The bokeh size as derived from the fStop and focal length in millimeters. If this is set then the fStop is implicitly updated.
|
|
445
|
+
|
|
446
|
+
### .apertureBlades
|
|
447
|
+
|
|
448
|
+
```js
|
|
449
|
+
apertureBlades = 0 : Number
|
|
450
|
+
```
|
|
451
|
+
|
|
452
|
+
The number of sides / blades on the aperture.
|
|
453
|
+
|
|
454
|
+
### .apertureRotation
|
|
455
|
+
|
|
456
|
+
```js
|
|
457
|
+
apertureRotation = 0 : Number
|
|
458
|
+
```
|
|
459
|
+
|
|
460
|
+
The rotation of the aperture shape in radians.
|
|
461
|
+
|
|
462
|
+
### .anamorphicRatio
|
|
463
|
+
|
|
464
|
+
```js
|
|
465
|
+
anamorphicRatio = 1 : Number
|
|
466
|
+
```
|
|
467
|
+
|
|
468
|
+
The anamorphic ratio of the lens. A higher value will stretch the bokeh effect horizontally.
|
|
469
|
+
|
|
470
|
+
## EquirectCamera
|
|
471
|
+
|
|
472
|
+
_extends THREE.Camera_
|
|
473
|
+
|
|
474
|
+
A class indicating that the path tracer should render an equirectangular view. Does not work with three.js raster rendering.
|
|
475
|
+
|
|
476
|
+
## PhysicalSpotLight
|
|
477
|
+
|
|
478
|
+
_extends THREE.SpotLight_
|
|
479
|
+
|
|
480
|
+
### .radius
|
|
481
|
+
|
|
482
|
+
```js
|
|
483
|
+
radius = 0 : Number
|
|
484
|
+
```
|
|
485
|
+
|
|
486
|
+
The radius of the spotlight surface. Increase this value to add softness to shadows.
|
|
487
|
+
|
|
488
|
+
### .iesTexture
|
|
489
|
+
|
|
490
|
+
```js
|
|
491
|
+
iesTexture = null : Texture
|
|
492
|
+
```
|
|
493
|
+
|
|
494
|
+
The loaded IES texture describing directional light intensity. These can be loaded with the `IESLoader`.
|
|
495
|
+
|
|
496
|
+
Premade IES profiles can be downloaded from [ieslibrary.com]. And custom profiles can be generated using [CNDL](https://cndl.io/).
|
|
497
|
+
|
|
498
|
+
## ShapedAreaLight
|
|
499
|
+
|
|
500
|
+
_extends THREE.RectAreaLight_
|
|
501
|
+
|
|
502
|
+
### .isCircular
|
|
503
|
+
|
|
504
|
+
```js
|
|
505
|
+
isCircular = false : Boolean
|
|
506
|
+
```
|
|
507
|
+
|
|
508
|
+
Whether the area light should be rendered as a circle or a rectangle.
|
|
509
|
+
|
|
510
|
+
## DynamicPathTracingSceneGenerator
|
|
511
|
+
|
|
512
|
+
A variation of the path tracing scene generator intended for quickly regenerating a scene BVH representation that updates frequently. Ie those with animated objects or animated skinned geometry.
|
|
513
|
+
|
|
514
|
+
In order to quickly update a dynamic scene the same BVH is reused across updates by refitting rather than regenerating. This is significantly faster but also results in a less optimal BVH after significant changes.
|
|
515
|
+
|
|
516
|
+
If geometry or materials are added or removed from the scene then `reset` must be called.
|
|
517
|
+
|
|
518
|
+
### constructor
|
|
519
|
+
|
|
520
|
+
```js
|
|
521
|
+
constructor( scene : Object3D | Array<Object3D> )
|
|
522
|
+
```
|
|
523
|
+
|
|
524
|
+
Takes the scene to convert.
|
|
525
|
+
|
|
526
|
+
### .generate
|
|
527
|
+
|
|
528
|
+
```js
|
|
529
|
+
generate() : {
|
|
530
|
+
bvh : MeshBVH,
|
|
531
|
+
materials : Array<Material>,
|
|
532
|
+
textures : Array<Texture>
|
|
533
|
+
}
|
|
534
|
+
```
|
|
535
|
+
|
|
536
|
+
Generates and refits the bvh to the current scene state. The same bvh, materials, and textures objects are returns after the initial call until `reset` is called.
|
|
537
|
+
|
|
538
|
+
### .reset
|
|
539
|
+
|
|
540
|
+
```js
|
|
541
|
+
reset() : void
|
|
542
|
+
```
|
|
543
|
+
|
|
544
|
+
Resets the generator so a new BVH is generated. This must be called when geometry, objects, or materials are added or removed from the scene.
|
|
545
|
+
|
|
546
|
+
## IESLoader
|
|
547
|
+
|
|
548
|
+
_extends Loader_
|
|
549
|
+
|
|
550
|
+
Loader for loading and parsing IES profile data. Load and parse functions return a `DataTexture` with the profile contents.
|
|
551
|
+
|
|
552
|
+
## BlurredEnvMapGenerator
|
|
553
|
+
|
|
554
|
+
Utility for generating a PMREM blurred environment map that can be used with the path tracer.
|
|
555
|
+
|
|
556
|
+
### constructor
|
|
557
|
+
|
|
558
|
+
```js
|
|
559
|
+
constructor( renderer : WebGLRenderer )
|
|
560
|
+
```
|
|
561
|
+
|
|
562
|
+
### .generate
|
|
563
|
+
|
|
564
|
+
```js
|
|
565
|
+
generate( texture : Texture, blur : Number ) : DataTexture
|
|
566
|
+
```
|
|
567
|
+
|
|
568
|
+
Takes a texture to blur and the amount to blur it. Returns a new `DataTexture` that has been PMREM blurred environment map that can have distribution data generated for importance sampling.
|
|
569
|
+
|
|
570
|
+
### .dispose
|
|
571
|
+
|
|
572
|
+
```js
|
|
573
|
+
dispose() : void
|
|
574
|
+
```
|
|
575
|
+
|
|
576
|
+
Disposes of the temporary files and textures for generation.
|
|
577
|
+
|
|
578
|
+
## GradientEquirectTexture
|
|
579
|
+
|
|
580
|
+
### .exponent
|
|
581
|
+
|
|
582
|
+
```js
|
|
583
|
+
exponent = 2 : Number
|
|
584
|
+
```
|
|
585
|
+
|
|
586
|
+
### .topColor
|
|
587
|
+
|
|
588
|
+
```js
|
|
589
|
+
topColor = 0xffffff : Color
|
|
590
|
+
```
|
|
591
|
+
|
|
592
|
+
### .bottomColor
|
|
593
|
+
|
|
594
|
+
```js
|
|
595
|
+
bottomColor = 0x000000 : Color
|
|
596
|
+
```
|
|
597
|
+
|
|
598
|
+
### constructor
|
|
599
|
+
|
|
600
|
+
```js
|
|
601
|
+
constructor( resolution = 512 : Number )
|
|
602
|
+
```
|
|
603
|
+
|
|
604
|
+
### .update
|
|
605
|
+
|
|
606
|
+
```js
|
|
607
|
+
update() : void
|
|
608
|
+
```
|
|
609
|
+
|
|
610
|
+
## MaterialBase
|
|
611
|
+
|
|
612
|
+
_extends THREE.ShaderMaterial_
|
|
613
|
+
|
|
614
|
+
Convenience base class that adds additional functions and implicitly adds object definitions for all uniforms of the shader to the object.
|
|
615
|
+
|
|
616
|
+
### .setDefine
|
|
617
|
+
|
|
618
|
+
```js
|
|
619
|
+
setDefine( name : string, value = undefined : any ) : void
|
|
620
|
+
```
|
|
621
|
+
|
|
622
|
+
Sets the define of the given name to the provided value. If the value is set to null or undefined then it is deleted from the defines of the material. If the define changed from the previous value then `Material.needsUpdate` is set to `true`.
|
|
623
|
+
|
|
624
|
+
## PhysicalPathTracingMaterial
|
|
625
|
+
|
|
626
|
+
_extends MaterialBase_
|
|
627
|
+
|
|
628
|
+
**Uniforms**
|
|
629
|
+
|
|
630
|
+
```js
|
|
631
|
+
{
|
|
632
|
+
// The number of ray bounces to test. Higher is better quality but slower performance.
|
|
633
|
+
// TransmissiveBounces indicates the number of additional transparent or translucent surfaces
|
|
634
|
+
// the ray can pass through.
|
|
635
|
+
bounces = 3 : Number,
|
|
636
|
+
transmissiveBounces = 10 : Number,
|
|
637
|
+
|
|
638
|
+
// The number of additional transmissive ray bounces to allow on top of existing bounces for object opacity / transmission.
|
|
639
|
+
transmissiveBounces = 5 : Number,
|
|
640
|
+
|
|
641
|
+
// The physical camera parameters to use
|
|
642
|
+
physicalCamera : PhysicalCameraUniform,
|
|
643
|
+
|
|
644
|
+
// Geometry and BVH information
|
|
645
|
+
bvh: MeshBVHUniformStruct,
|
|
646
|
+
attributesArray: AttributesTextureArray,
|
|
647
|
+
materialIndexAttribute: UIntVertexAttributeTexture,
|
|
648
|
+
materials: MaterialsTexture,
|
|
649
|
+
textures: RenderTarget2DArray,
|
|
650
|
+
|
|
651
|
+
// Light information
|
|
652
|
+
lights: LightsInfoUniformStruct,
|
|
653
|
+
iesProfiles: IESProfilesTexture,
|
|
654
|
+
|
|
655
|
+
// Environment Map information
|
|
656
|
+
envMapInfo: EquirectHdrInfoUniform,
|
|
657
|
+
environmentRotation: Matrix4,
|
|
658
|
+
environmentIntensity = 1: Number,
|
|
659
|
+
|
|
660
|
+
// background blur
|
|
661
|
+
backgroundBlur = 0: Number,
|
|
662
|
+
|
|
663
|
+
// Factor for alleviating bright pixels from rays that hit diffuse surfaces then
|
|
664
|
+
// specular surfaces. Setting this higher alleviates fireflies but will remove some
|
|
665
|
+
// specular caustics.
|
|
666
|
+
filterGlossyFactor = 0: Number,
|
|
667
|
+
|
|
668
|
+
// The equirectangular map to render as the background.
|
|
669
|
+
backgroundMap = null: Texture,
|
|
670
|
+
|
|
671
|
+
// The transparency to render the background with. Note that the "alpha" option
|
|
672
|
+
// must be set to true on PathTracingRenderer for this field to work properly.
|
|
673
|
+
backgroundAlpha: 1.0,
|
|
674
|
+
}
|
|
675
|
+
```
|
|
676
|
+
|
|
677
|
+
**Defines**
|
|
678
|
+
|
|
679
|
+
```js
|
|
680
|
+
{
|
|
681
|
+
|
|
682
|
+
// Whether to use multiple importance sampling to help the image converge more quickly.
|
|
683
|
+
FEATURE_MIS = 1 : Number,
|
|
684
|
+
|
|
685
|
+
// Whether to use russian roulette path termination. Path termination will kick in after
|
|
686
|
+
// a minimum three bounces have been performed.
|
|
687
|
+
FEATURE_RUSSIAN_ROULETTE = 1 : Number,
|
|
688
|
+
|
|
689
|
+
}
|
|
690
|
+
```
|
|
691
|
+
|
|
692
|
+
## FogVolumeMaterial
|
|
693
|
+
|
|
694
|
+
_extends MeshStandardMaterial_
|
|
695
|
+
|
|
696
|
+
A material used for rendering fog-like volumes within the scene. The `color`, `emissive`, and `emissiveIntensity` fields are all used in the render.
|
|
697
|
+
|
|
698
|
+
> *NOTE*
|
|
699
|
+
> Since fog models many particles throughout the scene and cause many extra bounces fog materials can dramatically impact render time.
|
|
700
|
+
|
|
701
|
+
### .density
|
|
702
|
+
|
|
703
|
+
The particulate density of the volume.
|
|
704
|
+
|
|
705
|
+
## DenoiseMaterial
|
|
706
|
+
|
|
707
|
+
_extends MaterialBase_
|
|
708
|
+
|
|
709
|
+
Denoise material based on [BrutPitt/glslSmartDeNoise](https://github.com/BrutPitt/glslSmartDeNoise) intended to be the final pass to the screen. Includes tonemapping and color space conversions.
|
|
710
|
+
|
|
711
|
+
**Uniforms**
|
|
712
|
+
|
|
713
|
+
```js
|
|
714
|
+
{
|
|
715
|
+
|
|
716
|
+
// sigma - sigma Standard Deviation
|
|
717
|
+
// kSigma - sigma coefficient
|
|
718
|
+
// kSigma * sigma = radius of the circular kernel
|
|
719
|
+
sigma = 5.0 : Number,
|
|
720
|
+
kSigma = 1.0 : Number,
|
|
721
|
+
|
|
722
|
+
// edge sharpening threshold
|
|
723
|
+
threshold = 0.03 : Number,
|
|
724
|
+
|
|
725
|
+
}
|
|
726
|
+
```
|
|
727
|
+
|
|
728
|
+
## RenderTarget2DArray
|
|
729
|
+
|
|
730
|
+
_extends WebGLArrayRenderTarget_
|
|
731
|
+
|
|
732
|
+
A convenience extension from `WebGLArrayRenderTarget` that affords easily creating a uniform texture array from an array of textures.
|
|
733
|
+
|
|
734
|
+
### .setTextures
|
|
735
|
+
|
|
736
|
+
```js
|
|
737
|
+
setTextures(
|
|
738
|
+
renderer : WebGLRenderer,
|
|
739
|
+
width : Number,
|
|
740
|
+
height : Number,
|
|
741
|
+
textures : Array<Texture>
|
|
742
|
+
) : void
|
|
743
|
+
```
|
|
744
|
+
|
|
745
|
+
Takes the rendering context to update the target for, the target dimensions of the texture array, and the array of textures to render into the 2D texture array. Every texture is stretched to the dimensions of the texture array at the same index they are provided in.
|
|
746
|
+
|
|
747
|
+
## PhysicalCameraUniform
|
|
748
|
+
|
|
749
|
+
Uniform for storing the camera parameters for use with the shader.
|
|
750
|
+
|
|
751
|
+
### .updateFrom
|
|
752
|
+
|
|
753
|
+
```js
|
|
754
|
+
updateFrom( camera : PerspectiveCamera | PhysicalCamera ) : void
|
|
755
|
+
```
|
|
756
|
+
|
|
757
|
+
Copies all fields from the passed PhysicalCamera if available otherwise the defaults are used.
|
|
758
|
+
|
|
759
|
+
## AttributesTextureArray
|
|
760
|
+
|
|
761
|
+
A combined texture array used to store normal, tangent, uv, and color attributes in the same texture sampler array rather than separate samplers. Necessary to save texture slots.
|
|
762
|
+
|
|
763
|
+
Normals, tangents, uvs, and color attribute data are stored in the 1st, 2nd, 3rd, and 4th layers of the array respectively.
|
|
764
|
+
|
|
765
|
+
### .updateNormalAttribute
|
|
766
|
+
|
|
767
|
+
```js
|
|
768
|
+
updateNormalAttribute( attr : BufferAttribute ) : void
|
|
769
|
+
```
|
|
770
|
+
|
|
771
|
+
### .updateTangentAttribute
|
|
772
|
+
|
|
773
|
+
```js
|
|
774
|
+
updateTangentAttribute( attr : BufferAttribute ) : void
|
|
775
|
+
```
|
|
776
|
+
|
|
777
|
+
### .updateUvAttribute
|
|
778
|
+
|
|
779
|
+
```js
|
|
780
|
+
updateUvAttribute( attr : BufferAttribute ) : void
|
|
781
|
+
```
|
|
782
|
+
|
|
783
|
+
### .updateColorAttribute
|
|
784
|
+
|
|
785
|
+
```js
|
|
786
|
+
updateColorAttribute( attr : BufferAttribute ) : void
|
|
787
|
+
```
|
|
788
|
+
|
|
789
|
+
### .updateFrom
|
|
790
|
+
|
|
791
|
+
```js
|
|
792
|
+
updateFrom(
|
|
793
|
+
normal : BufferAttribute,
|
|
794
|
+
tangent : BufferAttribute,
|
|
795
|
+
uv : BufferAttribute,
|
|
796
|
+
color : BufferAttribute
|
|
797
|
+
) : void
|
|
798
|
+
```
|
|
799
|
+
|
|
800
|
+
## MaterialsTexture
|
|
801
|
+
|
|
802
|
+
_extends DataTexture_
|
|
803
|
+
|
|
804
|
+
Helper texture uniform for encoding materials as texture data.
|
|
805
|
+
|
|
806
|
+
### .threeCompatibilityTransforms
|
|
807
|
+
|
|
808
|
+
```js
|
|
809
|
+
threeCompatibilityTransforms = false : Boolean
|
|
810
|
+
```
|
|
811
|
+
|
|
812
|
+
Three.js materials support only a single set of UV transforms in a certain fallback priority while the pathtracer supports a unique set of transforms per texture. Set this field to true in order to use the same uv transform handling as three.js materials.
|
|
813
|
+
|
|
814
|
+
See fallback order documentation [here](https://threejs.org/docs/#api/en/textures/Texture.offset).
|
|
815
|
+
|
|
816
|
+
### .setMatte
|
|
817
|
+
|
|
818
|
+
```js
|
|
819
|
+
setMatte( index : Number, matte : Boolean ) : void
|
|
820
|
+
```
|
|
821
|
+
|
|
822
|
+
Sets whether or not the material of the given index is matte or not. When "true" the background is rendered in place of the material.
|
|
823
|
+
|
|
824
|
+
### .setCastShadow
|
|
825
|
+
|
|
826
|
+
```js
|
|
827
|
+
setCastShadow( index : Number, enabled : Boolean ) : void
|
|
828
|
+
```
|
|
829
|
+
|
|
830
|
+
Sets whether or not the material of the given index will cast shadows. When "false" materials will not cast shadows on diffuse surfaces but will still be reflected. This is a good setting for lighting enclosed interiors with environment lighting.
|
|
831
|
+
|
|
832
|
+
### .updateFrom
|
|
833
|
+
|
|
834
|
+
```js
|
|
835
|
+
updateFrom( materials : Array<Material>, textures : Array<Texture> ) : void
|
|
836
|
+
```
|
|
837
|
+
|
|
838
|
+
Updates the size and values of the texture to align with the provided set of materials and textures.
|
|
839
|
+
|
|
840
|
+
The "matte" and "side" values must be updated explicitly.
|
|
841
|
+
|
|
842
|
+
> **Note**
|
|
843
|
+
> In order for volume transmission to work the "attenuationDistance" must be set to a value less than Infinity or "thickness" must be set to a value greater than 0.
|
|
844
|
+
|
|
845
|
+
## LightsInfoUniformStruct
|
|
846
|
+
|
|
847
|
+
Helper uniform for encoding lights as texture data with count.
|
|
848
|
+
|
|
849
|
+
### .updateFrom
|
|
850
|
+
|
|
851
|
+
```js
|
|
852
|
+
updateFrom( lights : Array<Light>, iesTextures = [] : Array<Texture> ) : void
|
|
853
|
+
```
|
|
854
|
+
|
|
855
|
+
Updates the size and values of the texture to align with the provided set of lights and IES textures.
|
|
856
|
+
|
|
857
|
+
## EquirectHdrInfoUniform
|
|
858
|
+
|
|
859
|
+
Stores the environment map contents along with the intensity distribution information to support multiple importance sampling.
|
|
860
|
+
|
|
861
|
+
### .updateFrom
|
|
862
|
+
|
|
863
|
+
```js
|
|
864
|
+
updateFrom( environmentMap : Texture ) : void
|
|
865
|
+
```
|
|
866
|
+
|
|
867
|
+
Takes an environment map to process into something usable by the path tracer. Is expected to be a DataTexture so the data can be read.
|
|
868
|
+
|
|
869
|
+
## Functions
|
|
870
|
+
|
|
871
|
+
### mergeMeshes
|
|
872
|
+
|
|
873
|
+
```js
|
|
874
|
+
mergeMeshes( meshes : Array<Mesh> ) : {
|
|
875
|
+
materials : Array<Material>,
|
|
876
|
+
textures : Array<Textures>,
|
|
877
|
+
geometry : BufferGeometry
|
|
878
|
+
}
|
|
879
|
+
```
|
|
880
|
+
|
|
881
|
+
Merges the set of meshes into a single geometry with a `materialIndex` vertex attribute included on the geometry identifying the associated material in the returned `materials` array.
|
|
882
|
+
|
|
883
|
+
## Shader Chunks
|
|
884
|
+
|
|
885
|
+
**shaderMaterialSampling**
|
|
886
|
+
|
|
887
|
+
Set of functions for performing material scatter and PDF sampling. See the [implementation](https://github.com/gkjohnson/three-gpu-pathtracer/blob/main/src/shader/shaderMaterialSampling.js) for full list of functions.
|
|
888
|
+
|
|
889
|
+
**shaderLightSampling**
|
|
890
|
+
|
|
891
|
+
Set of functions for performing light sampling. See the [implementation](https://github.com/gkjohnson/three-gpu-pathtracer/blob/main/src/shader/shaderLightSampling.js) for full list of functions.
|
|
892
|
+
|
|
893
|
+
**shaderStructs**
|
|
894
|
+
|
|
895
|
+
Material and light struct definition for use with uniforms. See the [implementation](https://github.com/gkjohnson/three-gpu-pathtracer/blob/main/src/shader/shaderStructs.js) for full list of functions.
|
|
896
|
+
|
|
897
|
+
**shaderUtils**
|
|
898
|
+
|
|
899
|
+
Set of randomness and other light transport utilities for use in a shader. See the [implementation](https://github.com/gkjohnson/three-gpu-pathtracer/blob/main/src/shader/shaderUtils.js) for full list of functions.
|
|
900
|
+
|
|
901
|
+
# Gotchas
|
|
902
|
+
|
|
903
|
+
- The project requires use of WebGL2.
|
|
904
|
+
- All textures must use the same wrap and interpolation flags.
|
|
905
|
+
- SpotLights, DirectionalLights, and PointLights are only supported with MIS.
|
|
906
|
+
- Only MeshStandardMaterial and MeshPhysicalMaterial are supported.
|
|
907
|
+
- Instanced geometry and interleaved buffers are not supported.
|
|
908
|
+
- Emissive materials are supported but do not take advantage of MIS.
|
|
909
|
+
|
|
910
|
+
# Screenshots
|
|
911
|
+
|
|
912
|
+

|
|
913
|
+
|
|
914
|
+
<p align="center">
|
|
915
|
+
<i>Sample materials</i>
|
|
916
|
+
</p>
|
|
917
|
+
|
|
918
|
+

|
|
919
|
+
|
|
920
|
+

|
|
921
|
+
|
|
922
|
+
<p align="center">
|
|
923
|
+
<i>"SD Macross City Standoff Diorama" scene by <a href="https://sketchfab.com/3d-models/sd-macross-city-standoff-diorama-b154220f7e7441799d6be2f7ff9658c7">tipatat</a></i>
|
|
924
|
+
</p>
|
|
925
|
+
|
|
926
|
+

|
|
927
|
+
|
|
928
|
+
<p align="center">
|
|
929
|
+
<i>"Interior Scene" model by <a href="https://sketchfab.com/3d-models/interior-scene-45ddbbc4c2dc4f8ca9ed99da9a78326a">Allay Design</a></i>
|
|
930
|
+
</p>
|
|
931
|
+
|
|
932
|
+

|
|
933
|
+
|
|
934
|
+

|
|
935
|
+
|
|
936
|
+
<p align="center">
|
|
937
|
+
<i>Perseverance Rover, Ingenuity Helicopter models by <a href="https://mars.nasa.gov/resources/25042/mars-perseverance-rover-3d-model/">NASA / JPL-Caltech</a></i>
|
|
938
|
+
</p>
|
|
939
|
+
|
|
940
|
+

|
|
941
|
+
|
|
942
|
+
<p align="center">
|
|
943
|
+
<i>Gelatinous Cube model by <a href="https://sketchfab.com/3d-models/gelatinous-cube-e08385238f4d4b59b012233a9fbdca21">glenatron</a></i>
|
|
944
|
+
</p>
|
|
945
|
+
|
|
946
|
+

|
|
947
|
+
|
|
948
|
+

|
|
949
|
+
|
|
950
|
+
<p align="center">
|
|
951
|
+
<i>Lego models courtesy of the <a href="https://omr.ldraw.org/">LDraw Official Model Repository</a></i>
|
|
952
|
+
</p>
|
|
953
|
+
|
|
954
|
+

|
|
955
|
+
|
|
956
|
+
<p align="center">
|
|
957
|
+
<i>Octopus Tea model by <a href="https://sketchfab.com/3d-models/cartoon-octopus-takes-a-tea-bath-107260cf0fd24202a67eb037a6c760a5
|
|
958
|
+
">AzTiZ</a></i>
|
|
959
|
+
</p>
|
|
960
|
+
|
|
961
|
+

|
|
962
|
+
<p align="center">
|
|
963
|
+
<i>Botanists Study model by <a href="https://sketchfab.com/3d-models/the-botanists-study-8b7b5743b1c848ed8ea58f5518c44e7e">riikkakilpelainen</a></i>
|
|
964
|
+
</p>
|
|
965
|
+
|
|
966
|
+

|
|
967
|
+
<p align="center">
|
|
968
|
+
<i>Japanese Bridge Garden model by <a href="https://sketchfab.com/3d-models/japanese-bridge-garden-d122e17593eb4012913cde927486d15a">kristenlee</a></i>
|
|
969
|
+
</p>
|
|
970
|
+
|
|
971
|
+
### Resources
|
|
972
|
+
|
|
973
|
+
[Raytracing in One Weekend Book](https://raytracing.github.io/)
|
|
974
|
+
|
|
975
|
+
[PBR Book](https://pbr-book.org/)
|
|
976
|
+
|
|
977
|
+
[knightcrawler25/GLSL-PathTracer](https://github.com/knightcrawler25/GLSL-PathTracer/)
|
|
978
|
+
|
|
979
|
+
[DassaultSystemes-Technology/dspbr-pt](https://github.com/DassaultSystemes-Technology/dspbr-pt)
|
|
980
|
+
|
|
981
|
+
|