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.
Files changed (78) hide show
  1. package/LICENSE +21 -21
  2. package/README.md +981 -961
  3. package/build/index.module.js +6965 -6508
  4. package/build/index.module.js.map +1 -1
  5. package/build/index.umd.cjs +6959 -6505
  6. package/build/index.umd.cjs.map +1 -1
  7. package/package.json +73 -73
  8. package/src/core/DynamicPathTracingSceneGenerator.js +119 -119
  9. package/src/core/MaterialReducer.js +256 -256
  10. package/src/core/PathTracingRenderer.js +346 -346
  11. package/src/core/PathTracingSceneGenerator.js +69 -69
  12. package/src/core/QuiltPathTracingRenderer.js +223 -223
  13. package/src/index.js +36 -40
  14. package/src/materials/MaterialBase.js +56 -56
  15. package/src/materials/{GraphMaterial.js → debug/GraphMaterial.js} +243 -243
  16. package/src/materials/{AlphaDisplayMaterial.js → fullscreen/AlphaDisplayMaterial.js} +48 -48
  17. package/src/materials/{BlendMaterial.js → fullscreen/BlendMaterial.js} +67 -67
  18. package/src/materials/{DenoiseMaterial.js → fullscreen/DenoiseMaterial.js} +142 -142
  19. package/src/materials/{LambertPathTracingMaterial.js → pathtracing/LambertPathTracingMaterial.js} +296 -285
  20. package/src/materials/pathtracing/PhysicalPathTracingMaterial.js +635 -0
  21. package/src/materials/pathtracing/glsl/attenuateHit.glsl.js +179 -0
  22. package/src/materials/pathtracing/glsl/cameraUtils.glsl.js +81 -0
  23. package/src/materials/pathtracing/glsl/getSurfaceRecord.glsl.js +317 -0
  24. package/src/materials/pathtracing/glsl/traceScene.glsl.js +54 -0
  25. package/src/materials/{AmbientOcclusionMaterial.js → surface/AmbientOcclusionMaterial.js} +207 -199
  26. package/src/materials/surface/FogVolumeMaterial.js +23 -0
  27. package/src/objects/EquirectCamera.js +13 -13
  28. package/src/objects/PhysicalCamera.js +28 -28
  29. package/src/objects/PhysicalSpotLight.js +14 -14
  30. package/src/objects/ShapedAreaLight.js +12 -12
  31. package/src/shader/bsdf/bsdfSampling.glsl.js +490 -0
  32. package/src/shader/bsdf/fog.glsl.js +23 -0
  33. package/src/shader/bsdf/ggx.glsl.js +102 -0
  34. package/src/shader/bsdf/iridescence.glsl.js +135 -0
  35. package/src/shader/bsdf/sheen.glsl.js +98 -0
  36. package/src/shader/{shaderLayerTexelFetchFunctions.js → common/arraySamplerTexelFetch.glsl.js} +25 -25
  37. package/src/shader/common/bvhAnyHit.glsl.js +76 -0
  38. package/src/shader/common/fresnel.glsl.js +98 -0
  39. package/src/shader/common/intersectShapes.glsl.js +62 -0
  40. package/src/shader/common/math.glsl.js +81 -0
  41. package/src/shader/common/utils.glsl.js +116 -0
  42. package/src/shader/{shaderRandFunctions.js → rand/pcg.glsl.js} +57 -57
  43. package/src/shader/{shaderSobolSampling.js → rand/sobol.glsl.js} +256 -256
  44. package/src/shader/sampling/equirectSampling.glsl.js +62 -0
  45. package/src/shader/sampling/lightSampling.glsl.js +223 -0
  46. package/src/shader/sampling/shapeSampling.glsl.js +86 -0
  47. package/src/shader/structs/cameraStruct.glsl.js +13 -0
  48. package/src/shader/structs/equirectStruct.glsl.js +14 -0
  49. package/src/shader/structs/fogMaterialBvh.glsl.js +62 -0
  50. package/src/shader/structs/lightsStruct.glsl.js +78 -0
  51. package/src/shader/{shaderStructs.js → structs/materialStruct.glsl.js} +207 -327
  52. package/src/textures/GradientEquirectTexture.js +35 -35
  53. package/src/textures/ProceduralEquirectTexture.js +75 -75
  54. package/src/uniforms/AttributesTextureArray.js +35 -35
  55. package/src/uniforms/EquirectHdrInfoUniform.js +277 -273
  56. package/src/uniforms/FloatAttributeTextureArray.js +169 -169
  57. package/src/uniforms/IESProfilesTexture.js +100 -100
  58. package/src/uniforms/LightsInfoUniformStruct.js +212 -212
  59. package/src/uniforms/MaterialsTexture.js +503 -426
  60. package/src/uniforms/PhysicalCameraUniform.js +36 -36
  61. package/src/uniforms/RenderTarget2DArray.js +97 -97
  62. package/src/uniforms/utils.js +30 -30
  63. package/src/utils/BlurredEnvMapGenerator.js +116 -116
  64. package/src/utils/GeometryPreparationUtils.js +214 -214
  65. package/src/utils/IESLoader.js +325 -325
  66. package/src/utils/SobolNumberMapGenerator.js +80 -80
  67. package/src/utils/UVUnwrapper.js +101 -101
  68. package/src/utils/macroify.js +9 -0
  69. package/src/workers/PathTracingSceneWorker.js +42 -42
  70. package/src/materials/PhysicalPathTracingMaterial.js +0 -1013
  71. package/src/shader/shaderBvhAnyHit.js +0 -76
  72. package/src/shader/shaderEnvMapSampling.js +0 -58
  73. package/src/shader/shaderGGXFunctions.js +0 -100
  74. package/src/shader/shaderIridescenceFunctions.js +0 -135
  75. package/src/shader/shaderLightSampling.js +0 -229
  76. package/src/shader/shaderMaterialSampling.js +0 -510
  77. package/src/shader/shaderSheenFunctions.js +0 -98
  78. package/src/shader/shaderUtils.js +0 -377
package/README.md CHANGED
@@ -1,961 +1,981 @@
1
- # three-gpu-pathtracer
2
-
3
- [![npm version](https://img.shields.io/npm/v/three-gpu-pathtracer.svg?style=flat-square)](https://www.npmjs.com/package/three-gpu-pathtracer)
4
- [![build](https://img.shields.io/github/actions/workflow/status/gkjohnson/three-gpu-pathtracer/node.js.yml?style=flat-square&label=build&branch=main)](https://github.com/gkjohnson/three-gpu-pathtracer/actions)
5
- [![github](https://flat.badgen.net/badge/icon/github?icon=github&label)](https://github.com/gkjohnson/three-gpu-pathtracer/)
6
- [![twitter](https://flat.badgen.net/twitter/follow/garrettkjohnson)](https://twitter.com/garrettkjohnson)
7
- [![sponsors](https://img.shields.io/github/sponsors/gkjohnson?style=flat-square&color=1da1f2)](https://github.com/sponsors/gkjohnson/)
8
-
9
- ![](https://user-images.githubusercontent.com/734200/162287477-96696b18-890b-4c1b-8a73-d662e577cc48.png)
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
- **Test Scenes**
42
-
43
- [Material Test Orb](https://gkjohnson.github.io/three-gpu-pathtracer/example/bundle/materialBall.html)
44
-
45
- [Transmission Preset Orb](https://gkjohnson.github.io/three-gpu-pathtracer/example/bundle/materialBall.html#transmission)
46
-
47
- [Model Viewer Fidelity Scene Comparisons](https://gkjohnson.github.io/three-gpu-pathtracer/example/bundle/viewerTest.html)
48
-
49
- [Physical Material Database](https://gkjohnson.github.io/three-gpu-pathtracer/example/bundle/materialDatabase.html)
50
-
51
- **Tools**
52
-
53
- [Animation Rendering](https://gkjohnson.github.io/three-gpu-pathtracer/example/bundle/renderVideo.html)
54
-
55
- [Ambient Occlusion Material](https://gkjohnson.github.io/three-gpu-pathtracer/example/bundle/aoRender.html)
56
-
57
- [Looking Glass Portrait Quilt Render](https://gkjohnson.github.io/three-gpu-pathtracer/example/bundle/lkg.html)
58
-
59
-
60
- ## Running examples locally
61
-
62
- 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).
63
-
64
- In order to install dependencies, you will need `make` and a C++ compiler available.
65
-
66
- On Debian or Ubuntu, run `sudo apt install build-essential`. It should just work on MacOS.
67
-
68
- - To install dependencies, run `npm install`
69
- - To start the demos run `npm start`
70
- - Visit `http://localhost:1234/<demo-name.html>`
71
-
72
- # Use
73
-
74
- **Basic Renderer**
75
-
76
- ```js
77
- import * as THREE from 'three';
78
- import { FullScreenQuad } from 'three/examples/jsm/postprocessing/Pass.js';
79
- import {
80
- PathTracingSceneGenerator,
81
- PathTracingRenderer,
82
- PhysicalPathTracingMaterial,
83
- } from 'three-gpu-pathtracer';
84
-
85
- // init scene, renderer, camera, controls, etc
86
-
87
- renderer.outputEncoding = THREE.sRGBEncoding;
88
- renderer.toneMapping = THREE.ACESFilmicToneMapping;
89
-
90
- // initialize the path tracing material and renderer
91
- const ptMaterial = new PhysicalPathTracingMaterial();
92
- const ptRenderer = new PathTracingRenderer( renderer );
93
- ptRenderer.setSize( window.innerWidth, window.innerHeight );
94
- ptRenderer.camera = camera;
95
- ptRenderer.material = ptMaterial;
96
-
97
- // if rendering transparent background
98
- ptRenderer.alpha = true;
99
-
100
- // init quad for rendering to the canvas
101
- const fsQuad = new FullScreenQuad( new THREE.MeshBasicMaterial( {
102
- map: ptRenderer.target.texture,
103
-
104
- // if rendering transparent background
105
- blending: THREE.CustomBlending,
106
- } ) );
107
-
108
- // ensure scene matrices are up to date
109
- scene.updateMatrixWorld();
110
-
111
- // initialize the scene and update the material properties with the bvh, materials, etc
112
- const generator = new PathTracingSceneGenerator();
113
- const { bvh, textures, materials, lights } = generator.generate( scene );
114
-
115
- // update bvh and geometry attribute textures
116
- ptMaterial.bvh.updateFrom( bvh );
117
- ptMaterial.attributesArray.updateFrom(
118
- geometry.attributes.normal,
119
- geometry.attributes.tangent,
120
- geometry.attributes.uv,
121
- geometry.attributes.color,
122
- );
123
-
124
- // update materials and texture arrays
125
- ptMaterial.materialIndexAttribute.updateFrom( geometry.attributes.materialIndex );
126
- ptMaterial.textures.setTextures( renderer, 2048, 2048, textures );
127
- ptMaterial.materials.updateFrom( materials, textures );
128
-
129
- // update the lights
130
- ptMaterial.lights.updateFrom( lights );
131
-
132
- // set the environment map
133
- const texture = await new RGBELoader().loadAsync( envMapUrl );
134
- ptRenderer.material.envMapInfo.updateFrom( texture );
135
-
136
- animate();
137
-
138
- // ...
139
-
140
- function animate() {
141
-
142
- // if the camera position changes call "ptRenderer.reset()"
143
-
144
- // update the camera and render one sample
145
- camera.updateMatrixWorld();
146
- ptRenderer.update();
147
-
148
- // if using alpha = true then the target texture will change every frame
149
- // so we must retrieve it before render.
150
- fsQuad.material.map = ptRenderer.target.texture;
151
-
152
- // copy the current state of the path tracer to canvas to display
153
- fsQuad.render( renderer );
154
-
155
- }
156
- ```
157
-
158
- **Blurred Environment Map**
159
-
160
- 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.
161
-
162
- ```js
163
- import { BlurredEnvMapGenerator } from 'three-gpu-pathtracer';
164
-
165
- // ...
166
-
167
- const envMap = await new RGBELoader().loadAsync( envMapUrl );
168
- const generator = new BlurredEnvMapGenerator( renderer );
169
- const blurredEnvMap = generator.generate( envMap, 0.35 );
170
-
171
- // render!
172
-
173
- ```
174
-
175
- ## Dynamic Scenes
176
-
177
- 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.
178
-
179
- ```js
180
- import { DynamicPathTracingSceneGenerator } from 'three-gpu-pathtracer';
181
-
182
- // ... initialize scene etc
183
-
184
- const generator = new DynamicPathTracingSceneGenerator( scene );
185
- const { bvh, textures, materials } = generator.generate( scene );
186
-
187
- // ... update path tracer and render
188
- ```
189
-
190
- ## Asynchronous Scene Generation
191
-
192
- _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._
193
-
194
- ```js
195
- import { PathTracingSceneWorker } from 'three-gpu-pathtracer/src/workers/PathTracingSceneWorker.js';
196
-
197
- // ...
198
-
199
- // initialize the scene and update the material properties with the bvh, materials, etc
200
- const generator = new PathTracingSceneWorker();
201
- const { bvh, textures, materials, lights } = await generator.generate( scene );
202
-
203
- // ...
204
- ```
205
-
206
- # Exports
207
-
208
- ## PathTracingRenderer
209
-
210
- Utility class for tracking and rendering a path traced scene to a render target.
211
-
212
- ### .samples
213
-
214
- ```js
215
- readonly samples : Number
216
- ```
217
-
218
- Number of samples per pixel that have been rendered to the target.
219
-
220
- ### .target
221
-
222
- ```js
223
- readonly target : WebGLRenderTarget
224
- ```
225
-
226
- The target being rendered to. The size of the target is updated with `setSize` and is initialized to a FloatType texture.
227
-
228
- > **Note**
229
- > Target will swap render targets after every full sample when alpha is enabled.
230
-
231
- ### .camera
232
-
233
- ```js
234
- camera = null : Camera
235
- ```
236
-
237
- The camera to render with. The view offset of the camera will be updated every sample to enable anti aliasing.
238
-
239
- ### .material
240
-
241
- ```js
242
- material = null : ShaderMaterial
243
- ```
244
-
245
- 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`.
246
-
247
- ### .tiles
248
-
249
- ```js
250
- tiles = ( 1, 1 ) : Vector2
251
- ```
252
-
253
- 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.
254
-
255
- ### .stableNoise
256
-
257
- ```js
258
- stableNoise = false : Boolean
259
- ```
260
-
261
- 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.
262
-
263
- ### .stableTiles
264
-
265
- ```js
266
- stableTiles = true : Boolean
267
- ```
268
-
269
- Whether the initial tile is reset to the top left tile when moving the camera or if it should continue to shift every frame.
270
-
271
- ### .alpha
272
-
273
- ```js
274
- alpha = false : Boolean
275
- ```
276
-
277
- 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.
278
-
279
- > **Note**
280
- > 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.
281
-
282
- ### constructor
283
-
284
- ```js
285
- constructor( renderer : WebGLRenderer )
286
- ```
287
-
288
- ### .setSize
289
-
290
- ```js
291
- setSize( size : Vector2 ) : void
292
- ```
293
-
294
- Sets the size of the target to render to.
295
-
296
- ### .update
297
-
298
- ```js
299
- update()
300
- ```
301
-
302
- Renders a single sample to the target.
303
-
304
- ### .reset
305
-
306
- ```js
307
- reset() : void
308
- ```
309
-
310
- Resets and restarts the render from scratch.
311
-
312
- ## QuiltPathTracingRenderer
313
-
314
- Renderer that supports rendering to a quilt renderer to rendering on displays such as the Looking Glass display.
315
-
316
- ### .viewCount
317
-
318
- ```js
319
- viewCount = 48 : Number
320
- ```
321
-
322
- 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.
323
-
324
- ### .quiltDimensions
325
- ```js
326
- quiltDimensions = Vector2( 8, 6 ) : Vector2
327
- ```
328
-
329
- The number of quilt patches in each dimension.
330
-
331
- ### .viewCone
332
- ```js
333
- viewCone = 35 * DEG2RAD : Number
334
- ```
335
-
336
- The total angle sweep for the camera views rendered across the quilt.
337
-
338
- ### .viewFoV
339
-
340
- ```js
341
- viewFoV = 14 * DEG2RAD : Number
342
- ```
343
-
344
- The camera field of view to render.
345
-
346
- ### .displayDistance
347
-
348
- ```js
349
- displayDistance = 1 : Number
350
- ```
351
-
352
- The distance of the viewer to the display.
353
-
354
- ### .displayAspect
355
-
356
- ```js
357
- displayAspect = 0.75 : Number
358
- ```
359
-
360
- The aspect ratio of the display.
361
-
362
- ### .setFromDisplayView
363
-
364
- ```js
365
- setFromDisplayView(
366
- displayDistance : Number,
367
- displayWidth : Number,
368
- displayHeight : Number,
369
- ) : void
370
- ```
371
-
372
- Updates the `displayDistance`, `displayAspect`, and the `viewFoV` from viewer and display information.
373
-
374
- ## PathTracingSceneGenerator
375
-
376
- Utility class for generating the set of data required for initializing the path tracing material with a bvh, geometry, materials, and textures.
377
-
378
- ### .generate
379
-
380
- ```js
381
- generate( scene : Object3D | Array<Object3D>, options = {} : Object ) : {
382
- bvh : MeshBVH,
383
- materials : Array<Material>,
384
- textures : Array<Texture>,
385
- lights : Array<Light>
386
- }
387
- ```
388
-
389
- 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.
390
-
391
- ## PathTracingSceneWorker
392
-
393
- _extends PathTracingSceneGenerator_
394
-
395
- See note in [Asyncronous Generation](#asynchronous-generation) use snippet.
396
-
397
- ### .generate
398
-
399
- ```js
400
- async generate( scene : Object3D | Array<Object3D>, options = {} : Object ) : {
401
- bvh : MeshBVH,
402
- materials : Array<Material>,
403
- textures : Array<Texture>,
404
- lights : Array<Light>
405
- }
406
- ```
407
-
408
- ### .dispose
409
-
410
- ```js
411
- dispose() : void
412
- ```
413
-
414
- ## PhysicalCamera
415
-
416
- _extends THREE.PerspectiveCamera_
417
-
418
- 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.
419
-
420
- ### .focusDistance
421
-
422
- ```js
423
- focusDistance = 25 : Number
424
- ```
425
-
426
- The distance from the camera in meters that everything is is perfect focus.
427
-
428
- ### .fStop
429
-
430
- ```js
431
- fStop = 1.4 : Number
432
- ```
433
-
434
- The fstop value of the camera. If this is changed then the `bokehSize` field is implicitly updated.
435
-
436
- ### .bokehSize
437
-
438
- ```js
439
- bokehSize : Number
440
- ```
441
-
442
- The bokeh size as derived from the fStop and focal length in millimeters. If this is set then the fStop is implicitly updated.
443
-
444
- ### .apertureBlades
445
-
446
- ```js
447
- apertureBlades = 0 : Number
448
- ```
449
-
450
- The number of sides / blades on the aperture.
451
-
452
- ### .apertureRotation
453
-
454
- ```js
455
- apertureRotation = 0 : Number
456
- ```
457
-
458
- The rotation of the aperture shape in radians.
459
-
460
- ### .anamorphicRatio
461
-
462
- ```js
463
- anamorphicRatio = 1 : Number
464
- ```
465
-
466
- The anamorphic ratio of the lens. A higher value will stretch the bokeh effect horizontally.
467
-
468
- ## EquirectCamera
469
-
470
- _extends THREE.Camera_
471
-
472
- A class indicating that the path tracer should render an equirectangular view. Does not work with three.js raster rendering.
473
-
474
- ## PhysicalSpotLight
475
-
476
- _extends THREE.SpotLight_
477
-
478
- ### .radius
479
-
480
- ```js
481
- radius = 0 : Number
482
- ```
483
-
484
- The radius of the spotlight surface. Increase this value to add softness to shadows.
485
-
486
- ### .iesTexture
487
-
488
- ```js
489
- iesTexture = null : Texture
490
- ```
491
-
492
- The loaded IES texture describing directional light intensity. These can be loaded with the `IESLoader`.
493
-
494
- Premade IES profiles can be downloaded from [ieslibrary.com]. And custom profiles can be generated using [CNDL](https://cndl.io/).
495
-
496
- ## ShapedAreaLight
497
-
498
- _extends THREE.RectAreaLight_
499
-
500
- ### .isCircular
501
-
502
- ```js
503
- isCircular = false : Boolean
504
- ```
505
-
506
- Whether the area light should be rendered as a circle or a rectangle.
507
-
508
- ## DynamicPathTracingSceneGenerator
509
-
510
- 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.
511
-
512
- 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.
513
-
514
- If geometry or materials are added or removed from the scene then `reset` must be called.
515
-
516
- ### constructor
517
-
518
- ```js
519
- constructor( scene : Object3D | Array<Object3D> )
520
- ```
521
-
522
- Takes the scene to convert.
523
-
524
- ### .generate
525
-
526
- ```js
527
- generate() : {
528
- bvh : MeshBVH,
529
- materials : Array<Material>,
530
- textures : Array<Texture>
531
- }
532
- ```
533
-
534
- 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.
535
-
536
- ### .reset
537
-
538
- ```js
539
- reset() : void
540
- ```
541
-
542
- 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.
543
-
544
- ## IESLoader
545
-
546
- _extends Loader_
547
-
548
- Loader for loading and parsing IES profile data. Load and parse functions return a `DataTexture` with the profile contents.
549
-
550
- ## BlurredEnvMapGenerator
551
-
552
- Utility for generating a PMREM blurred environment map that can be used with the path tracer.
553
-
554
- ### constructor
555
-
556
- ```js
557
- constructor( renderer : WebGLRenderer )
558
- ```
559
-
560
- ### .generate
561
-
562
- ```js
563
- generate( texture : Texture, blur : Number ) : DataTexture
564
- ```
565
-
566
- 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.
567
-
568
- ### .dispose
569
-
570
- ```js
571
- dispose() : void
572
- ```
573
-
574
- Disposes of the temporary files and textures for generation.
575
-
576
- ## GradientEquirectTexture
577
-
578
- ### .exponent
579
-
580
- ```js
581
- exponent = 2 : Number
582
- ```
583
-
584
- ### .topColor
585
-
586
- ```js
587
- topColor = 0xffffff : Color
588
- ```
589
-
590
- ### .bottomColor
591
-
592
- ```js
593
- bottomColor = 0x000000 : Color
594
- ```
595
-
596
- ### constructor
597
-
598
- ```js
599
- constructor( resolution = 512 : Number )
600
- ```
601
-
602
- ### .update
603
-
604
- ```js
605
- update() : void
606
- ```
607
-
608
- ## MaterialBase
609
-
610
- _extends THREE.ShaderMaterial_
611
-
612
- Convenience base class that adds additional functions and implicitly adds object definitions for all uniforms of the shader to the object.
613
-
614
- ### .setDefine
615
-
616
- ```js
617
- setDefine( name : string, value = undefined : any ) : void
618
- ```
619
-
620
- 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`.
621
-
622
- ## PhysicalPathTracingMaterial
623
-
624
- _extends MaterialBase_
625
-
626
- **Uniforms**
627
-
628
- ```js
629
- {
630
- // The number of ray bounces to test. Higher is better quality but slower performance.
631
- bounces = 3 : Number,
632
-
633
- // The number of additional transmissive ray bounces to allow on top of existing bounces for object opacity / transmission.
634
- transmissiveBounces = 5 : Number,
635
-
636
- // The physical camera parameters to use
637
- physicalCamera : PhysicalCameraUniform,
638
-
639
- // Geometry and BVH information
640
- bvh: MeshBVHUniformStruct,
641
- attributesArray: AttributesTextureArray,
642
- materialIndexAttribute: UIntVertexAttributeTexture,
643
- materials: MaterialsTexture,
644
- textures: RenderTarget2DArray,
645
-
646
- // Light information
647
- lights: LightsInfoUniformStruct,
648
- iesProfiles: IESProfilesTexture,
649
-
650
- // Environment Map information
651
- envMapInfo: EquirectHdrInfoUniform,
652
- environmentRotation: Matrix4,
653
- environmentIntensity = 1: Number,
654
-
655
- // background blur
656
- backgroundBlur = 0: Number,
657
-
658
- // Factor for alleviating bright pixels from rays that hit diffuse surfaces then
659
- // specular surfaces. Setting this higher alleviates fireflies but will remove some
660
- // specular caustics.
661
- filterGlossyFactor = 0: Number,
662
-
663
- // The equirectangular map to render as the background.
664
- backgroundMap = null: Texture,
665
-
666
- // The transparency to render the background with. Note that the "alpha" option
667
- // must be set to true on PathTracingRenderer for this field to work properly.
668
- backgroundAlpha: 1.0,
669
- }
670
- ```
671
-
672
- **Defines**
673
-
674
- ```js
675
- {
676
-
677
- // Whether to use multiple importance sampling to help the image converge more quickly.
678
- FEATURE_MIS = 1 : Number,
679
-
680
- // Whether to use russian roulette path termination. Path termination will kick in after
681
- // a minimum three bounces have been performed.
682
- FEATURE_RUSSIAN_ROULETTE = 1 : Number,
683
-
684
- }
685
- ```
686
-
687
- ## DenoiseMaterial
688
-
689
- _extends MaterialBase_
690
-
691
- 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.
692
-
693
- **Uniforms**
694
-
695
- ```js
696
- {
697
-
698
- // sigma - sigma Standard Deviation
699
- // kSigma - sigma coefficient
700
- // kSigma * sigma = radius of the circular kernel
701
- sigma = 5.0 : Number,
702
- kSigma = 1.0 : Number,
703
-
704
- // edge sharpening threshold
705
- threshold = 0.03 : Number,
706
-
707
- }
708
- ```
709
-
710
- ## RenderTarget2DArray
711
-
712
- _extends WebGLArrayRenderTarget_
713
-
714
- A convenience extension from `WebGLArrayRenderTarget` that affords easily creating a uniform texture array from an array of textures.
715
-
716
- ### .setTextures
717
-
718
- ```js
719
- setTextures(
720
- renderer : WebGLRenderer,
721
- width : Number,
722
- height : Number,
723
- textures : Array<Texture>
724
- ) : void
725
- ```
726
-
727
- 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.
728
-
729
- ## PhysicalCameraUniform
730
-
731
- Uniform for storing the camera parameters for use with the shader.
732
-
733
- ### .updateFrom
734
-
735
- ```js
736
- updateFrom( camera : PerspectiveCamera | PhysicalCamera ) : void
737
- ```
738
-
739
- Copies all fields from the passed PhysicalCamera if available otherwise the defaults are used.
740
-
741
- ## AttributesTextureArray
742
-
743
- 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.
744
-
745
- Normals, tangents, uvs, and color attribute data are stored in the 1st, 2nd, 3rd, and 4th layers of the array respectively.
746
-
747
- ### .updateNormalAttribute
748
-
749
- ```js
750
- updateNormalAttribute( attr : BufferAttribute ) : void
751
- ```
752
-
753
- ### .updateTangentAttribute
754
-
755
- ```js
756
- updateTangentAttribute( attr : BufferAttribute ) : void
757
- ```
758
-
759
- ### .updateUvAttribute
760
-
761
- ```js
762
- updateUvAttribute( attr : BufferAttribute ) : void
763
- ```
764
-
765
- ### .updateColorAttribute
766
-
767
- ```js
768
- updateColorAttribute( attr : BufferAttribute ) : void
769
- ```
770
-
771
- ### .updateFrom
772
-
773
- ```js
774
- updateFrom(
775
- normal : BufferAttribute,
776
- tangent : BufferAttribute,
777
- uv : BufferAttribute,
778
- color : BufferAttribute
779
- ) : void
780
- ```
781
-
782
- ## MaterialsTexture
783
-
784
- _extends DataTexture_
785
-
786
- Helper texture uniform for encoding materials as texture data.
787
-
788
- ### .threeCompatibilityTransforms
789
-
790
- ```js
791
- threeCompatibilityTransforms = false : Boolean
792
- ```
793
-
794
- 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.
795
-
796
- See fallback order documentation [here](https://threejs.org/docs/#api/en/textures/Texture.offset).
797
-
798
- ### .setMatte
799
-
800
- ```js
801
- setMatte( index : Number, matte : Boolean ) : void
802
- ```
803
-
804
- 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.
805
-
806
- ### .setCastShadow
807
-
808
- ```js
809
- setCastShadow( index : Number, enabled : Boolean ) : void
810
- ```
811
-
812
- 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.
813
-
814
- ### .updateFrom
815
-
816
- ```js
817
- updateFrom( materials : Array<Material>, textures : Array<Texture> ) : void
818
- ```
819
-
820
- Updates the size and values of the texture to align with the provided set of materials and textures.
821
-
822
- The "matte" and "side" values must be updated explicitly.
823
-
824
- > **Note**
825
- > 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.
826
-
827
- ## LightsInfoUniformStruct
828
-
829
- Helper uniform for encoding lights as texture data with count.
830
-
831
- ### .updateFrom
832
-
833
- ```js
834
- updateFrom( lights : Array<Light>, iesTextures = [] : Array<Texture> ) : void
835
- ```
836
-
837
- Updates the size and values of the texture to align with the provided set of lights and IES textures.
838
-
839
- ## EquirectHdrInfoUniform
840
-
841
- Stores the environment map contents along with the intensity distribution information to support multiple importance sampling.
842
-
843
- ### .updateFrom
844
-
845
- ```js
846
- updateFrom( environmentMap : Texture ) : void
847
- ```
848
-
849
- 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.
850
-
851
- ## Functions
852
-
853
- ### mergeMeshes
854
-
855
- ```js
856
- mergeMeshes( meshes : Array<Mesh> ) : {
857
- materials : Array<Material>,
858
- textures : Array<Textures>,
859
- geometry : BufferGeometry
860
- }
861
- ```
862
-
863
- 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.
864
-
865
- ## Shader Chunks
866
-
867
- **shaderMaterialSampling**
868
-
869
- 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.
870
-
871
- **shaderLightSampling**
872
-
873
- 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.
874
-
875
- **shaderStructs**
876
-
877
- 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.
878
-
879
- **shaderUtils**
880
-
881
- 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.
882
-
883
- # Gotchas
884
-
885
- - The project requires use of WebGL2.
886
- - All textures must use the same wrap and interpolation flags.
887
- - SpotLights, DirectionalLights, and PointLights are only supported with MIS.
888
- - Only MeshStandardMaterial and MeshPhysicalMaterial are supported.
889
- - Instanced geometry and interleaved buffers are not supported.
890
- - Emissive materials are supported but do not take advantage of MIS.
891
-
892
- # Screenshots
893
-
894
- ![](https://user-images.githubusercontent.com/734200/162584469-68e6df38-92da-4a13-b352-ca0bdea14548.png)
895
-
896
- <p align="center">
897
- <i>Sample materials</i>
898
- </p>
899
-
900
- ![](https://user-images.githubusercontent.com/734200/163835927-be75d2c0-f27b-4e4b-a3eb-2371043fa5e1.png)
901
-
902
- ![](https://user-images.githubusercontent.com/734200/163839431-ed75e64d-9ae4-4423-afca-55162a44873e.png)
903
-
904
- <p align="center">
905
- <i>"SD Macross City Standoff Diorama" scene by <a href="https://sketchfab.com/3d-models/sd-macross-city-standoff-diorama-b154220f7e7441799d6be2f7ff9658c7">tipatat</a></i>
906
- </p>
907
-
908
- ![](./docs/interior-scene-cropped.png)
909
-
910
- <p align="center">
911
- <i>"Interior Scene" model by <a href="https://sketchfab.com/3d-models/interior-scene-45ddbbc4c2dc4f8ca9ed99da9a78326a">Allay Design</a></i>
912
- </p>
913
-
914
- ![](https://user-images.githubusercontent.com/734200/161820794-df0da371-ee5c-4368-9e7b-5e7daf6cf3c7.png)
915
-
916
- ![](https://user-images.githubusercontent.com/734200/162550315-3cdabf40-3dea-4d7d-bcfc-eb543eea2d93.png)
917
-
918
- <p align="center">
919
- <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>
920
- </p>
921
-
922
- ![](https://user-images.githubusercontent.com/734200/161877900-566652e4-c799-4940-bccb-0c8f4cea5387.png)
923
-
924
- <p align="center">
925
- <i>Gelatinous Cube model by <a href="https://sketchfab.com/3d-models/gelatinous-cube-e08385238f4d4b59b012233a9fbdca21">glenatron</a></i>
926
- </p>
927
-
928
- ![](https://user-images.githubusercontent.com/734200/161822206-c27bf594-d648-4735-868e-4baf4e414802.png)
929
-
930
- ![](https://user-images.githubusercontent.com/734200/161822214-eace4297-03c4-4adc-b472-efe29a862685.png)
931
-
932
- <p align="center">
933
- <i>Lego models courtesy of the <a href="https://omr.ldraw.org/">LDraw Official Model Repository</a></i>
934
- </p>
935
-
936
- ![](https://user-images.githubusercontent.com/734200/161877196-7ae2769e-7e54-4694-9ca8-e8f5219d1c2d.png)
937
-
938
- <p align="center">
939
- <i>Octopus Tea model by <a href="https://sketchfab.com/3d-models/cartoon-octopus-takes-a-tea-bath-107260cf0fd24202a67eb037a6c760a5
940
- ">AzTiZ</a></i>
941
- </p>
942
-
943
- ![](https://user-images.githubusercontent.com/734200/173212652-de6a83e5-dd2c-49b5-8ed7-484ff8969b5b.png)
944
- <p align="center">
945
- <i>Botanists Study model by <a href="https://sketchfab.com/3d-models/the-botanists-study-8b7b5743b1c848ed8ea58f5518c44e7e">riikkakilpelainen</a></i>
946
- </p>
947
-
948
- ![](https://user-images.githubusercontent.com/734200/173170459-849b9343-efe3-4635-8719-346511472965.png)
949
- <p align="center">
950
- <i>Japanese Bridge Garden model by <a href="https://sketchfab.com/3d-models/japanese-bridge-garden-d122e17593eb4012913cde927486d15a">kristenlee</a></i>
951
- </p>
952
-
953
- ### Resources
954
-
955
- [Raytracing in One Weekend Book](https://raytracing.github.io/)
956
-
957
- [PBR Book](https://pbr-book.org/)
958
-
959
- [knightcrawler25/GLSL-PathTracer](https://github.com/knightcrawler25/GLSL-PathTracer/)
960
-
961
-
1
+ # three-gpu-pathtracer
2
+
3
+ [![npm version](https://img.shields.io/npm/v/three-gpu-pathtracer.svg?style=flat-square)](https://www.npmjs.com/package/three-gpu-pathtracer)
4
+ [![build](https://img.shields.io/github/actions/workflow/status/gkjohnson/three-gpu-pathtracer/node.js.yml?style=flat-square&label=build&branch=main)](https://github.com/gkjohnson/three-gpu-pathtracer/actions)
5
+ [![github](https://flat.badgen.net/badge/icon/github?icon=github&label)](https://github.com/gkjohnson/three-gpu-pathtracer/)
6
+ [![twitter](https://flat.badgen.net/twitter/follow/garrettkjohnson)](https://twitter.com/garrettkjohnson)
7
+ [![sponsors](https://img.shields.io/github/sponsors/gkjohnson?style=flat-square&color=1da1f2)](https://github.com/sponsors/gkjohnson/)
8
+
9
+ ![](https://user-images.githubusercontent.com/734200/162287477-96696b18-890b-4c1b-8a73-d662e577cc48.png)
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
+ ![](https://user-images.githubusercontent.com/734200/162584469-68e6df38-92da-4a13-b352-ca0bdea14548.png)
913
+
914
+ <p align="center">
915
+ <i>Sample materials</i>
916
+ </p>
917
+
918
+ ![](https://user-images.githubusercontent.com/734200/163835927-be75d2c0-f27b-4e4b-a3eb-2371043fa5e1.png)
919
+
920
+ ![](https://user-images.githubusercontent.com/734200/163839431-ed75e64d-9ae4-4423-afca-55162a44873e.png)
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
+ ![](./docs/interior-scene-cropped.png)
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
+ ![](https://user-images.githubusercontent.com/734200/161820794-df0da371-ee5c-4368-9e7b-5e7daf6cf3c7.png)
933
+
934
+ ![](https://user-images.githubusercontent.com/734200/162550315-3cdabf40-3dea-4d7d-bcfc-eb543eea2d93.png)
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
+ ![](https://user-images.githubusercontent.com/734200/161877900-566652e4-c799-4940-bccb-0c8f4cea5387.png)
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
+ ![](https://user-images.githubusercontent.com/734200/161822206-c27bf594-d648-4735-868e-4baf4e414802.png)
947
+
948
+ ![](https://user-images.githubusercontent.com/734200/161822214-eace4297-03c4-4adc-b472-efe29a862685.png)
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
+ ![](https://user-images.githubusercontent.com/734200/161877196-7ae2769e-7e54-4694-9ca8-e8f5219d1c2d.png)
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
+ ![](https://user-images.githubusercontent.com/734200/173212652-de6a83e5-dd2c-49b5-8ed7-484ff8969b5b.png)
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
+ ![](https://user-images.githubusercontent.com/734200/173170459-849b9343-efe3-4635-8719-346511472965.png)
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
+