three-gpu-pathtracer 0.0.4 → 0.0.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -31,12 +31,16 @@ _More features and capabilities in progress!_
31
31
 
32
32
  [Morph Target Support](https://gkjohnson.github.io/three-gpu-pathtracer/example/bundle/skinnedMesh.html#morphtarget)
33
33
 
34
+ [Area Light Support](https://gkjohnson.github.io/three-gpu-pathtracer/example/bundle/areaLight.html)
35
+
34
36
  **Test Scenes**
35
37
 
36
38
  [Material Test Orb](https://gkjohnson.github.io/three-gpu-pathtracer/example/bundle/materialBall.html)
37
39
 
38
40
  [Transmission Preset Orb](https://gkjohnson.github.io/three-gpu-pathtracer/example/bundle/materialBall.html#transmission)
39
41
 
42
+ [Model Viewer Fidelity Scene Comparisons](https://gkjohnson.github.io/three-gpu-pathtracer/example/bundle/viewerTest.html#khronos-DragonAttenuation)
43
+
40
44
  **Light Baking**
41
45
 
42
46
  [Ambient Occlusion Material](https://gkjohnson.github.io/three-gpu-pathtracer/example/bundle/aoRender.html)
@@ -56,6 +60,9 @@ import {
56
60
 
57
61
  // init scene, renderer, camera, controls, etc
58
62
 
63
+ renderer.outputEncoding = THREE.sRGBEncoding;
64
+ renderer.toneMapping = THREE.ACESFilmicToneMapping;
65
+
59
66
  // initialize the path tracing material and renderer
60
67
  const ptMaterial = new PhysicalPathTracingMaterial();
61
68
  const ptRenderer = new PathTracingRenderer( renderer );
@@ -79,7 +86,7 @@ scene.updateMatrixWorld();
79
86
 
80
87
  // initialize the scene and update the material properties with the bvh, materials, etc
81
88
  const generator = new PathTracingSceneGenerator();
82
- const { bvh, textures, materials } = generator.generate( scene );
89
+ const { bvh, textures, materials, lights } = generator.generate( scene );
83
90
 
84
91
  // update bvh and geometry attribute textures
85
92
  ptMaterial.bvh.updateFrom( bvh );
@@ -92,6 +99,10 @@ ptMaterial.materialIndexAttribute.updateFrom( geometry.attributes.materialIndex
92
99
  ptMaterial.textures.setTextures( renderer, 2048, 2048, textures );
93
100
  ptMaterial.materials.updateFrom( materials, textures );
94
101
 
102
+ // update the lights
103
+ ptMaterial.lights.updateFrom( lights );
104
+ ptMaterial.lightCount = lights.length;
105
+
95
106
  // set the environment map
96
107
  const texture = await new RGBELoader().loadAsync( envMapUrl );
97
108
  ptRenderer.material.envMapInfo.updateFrom( texture );
@@ -161,7 +172,7 @@ import { PathTracingSceneWorker } from 'three-gpu-pathtracer/src/workers/PathTra
161
172
 
162
173
  // initialize the scene and update the material properties with the bvh, materials, etc
163
174
  const generator = new PathTracingSceneWorker();
164
- const { bvh, textures, materials } = await generator.generate( scene );
175
+ const { bvh, textures, materials, lights } = await generator.generate( scene );
165
176
 
166
177
  // ...
167
178
  ```
@@ -265,10 +276,11 @@ Utility class for generating the set of data required for initializing the path
265
276
  ### .generate
266
277
 
267
278
  ```js
268
- generate( scene : Object3D, options = {} : Object ) : {
279
+ generate( scene : Object3D | Array<Object3D>, options = {} : Object ) : {
269
280
  bvh : MeshBVH,
270
281
  materials : Array<Material>,
271
- textures : Array<Texture>
282
+ textures : Array<Texture>,
283
+ lights : Array<Light>
272
284
  }
273
285
  ```
274
286
 
@@ -283,10 +295,11 @@ See note in [Asyncronous Generation](#asynchronous-generation) use snippet.
283
295
  ### .generate
284
296
 
285
297
  ```js
286
- async generate( scene : Object3D, options = {} : Object ) : {
298
+ async generate( scene : Object3D | Array<Object3D>, options = {} : Object ) : {
287
299
  bvh : MeshBVH,
288
300
  materials : Array<Material>,
289
- textures : Array<Texture>
301
+ textures : Array<Texture>,
302
+ lights : Array<Light>
290
303
  }
291
304
  ```
292
305
 
@@ -350,6 +363,12 @@ anamorphicRatio = 1 : Number
350
363
 
351
364
  The anamorphic ratio of the lens. A higher value will stretch the bokeh effect horizontally.
352
365
 
366
+ ## EquirectCamera
367
+
368
+ _extends THREE.Camera_
369
+
370
+ A class indicating that the path tracer should render an equirectangular view. Does not work with three.js raster rendering.
371
+
353
372
  ## DynamicPathTracingSceneGenerator
354
373
 
355
374
  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.
@@ -361,7 +380,7 @@ If geometry or materials are added or removed from the scene then `reset` must b
361
380
  ### constructor
362
381
 
363
382
  ```js
364
- constructor( scene : Object3D )
383
+ constructor( scene : Object3D | Array<Object3D> )
365
384
  ```
366
385
 
367
386
  Takes the scene to convert.
@@ -449,6 +468,10 @@ _extends MaterialBase_
449
468
  materials: MaterialsTexture,
450
469
  textures: RenderTarget2DArray,
451
470
 
471
+ // Light information
472
+ lights: LightsTexture,
473
+ lightCount = 0: Number,
474
+
452
475
  // Environment Map information
453
476
  envMapInfo: EquirectHdrInfoUniform,
454
477
  environmentRotation: Matrix3,
@@ -486,7 +509,6 @@ _extends MaterialBase_
486
509
  // The number of transparent pixels to allow on top of existing bounces for object transparency.
487
510
  TRANSPARENT_TRAVERSALS = 5 : Number,
488
511
 
489
-
490
512
  }
491
513
  ```
492
514
 
@@ -527,6 +549,16 @@ _extends DataTexture_
527
549
 
528
550
  Helper texture uniform for encoding materials as texture data.
529
551
 
552
+ ### .threeCompatibilityTransforms
553
+
554
+ ```js
555
+ threeCompatibilityTransforms = false : Boolean
556
+ ```
557
+
558
+ 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.
559
+
560
+ See fallback order documentation [here](https://threejs.org/docs/#api/en/textures/Texture.offset).
561
+
530
562
  ### .setSide
531
563
 
532
564
  ```js
@@ -561,6 +593,20 @@ Updates the size and values of the texture to align with the provided set of mat
561
593
 
562
594
  The "matte" and "side" values must be updated explicitly.
563
595
 
596
+ ## LightsTexture
597
+
598
+ _extends DataTexture_
599
+
600
+ Helper texture uniform for encoding lights as texture data.
601
+
602
+ ### .updateFrom
603
+
604
+ ```js
605
+ updateFrom( lights : Array<Light> ) : void
606
+ ```
607
+
608
+ Updates the size and values of the texture to align with the provided set of lights.
609
+
564
610
  ## EquirectHdrInfoUniform
565
611
 
566
612
  Stores the environment map contents along with the intensity distribution information to support multiple importance sampling.
@@ -593,13 +639,17 @@ Merges the set of meshes into a single geometry with a `materialIndex` vertex at
593
639
 
594
640
  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.
595
641
 
642
+ **shaderLightSampling**
643
+
644
+ 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.
645
+
596
646
  **shaderStructs**
597
647
 
598
- Material 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.
648
+ 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.
599
649
 
600
650
  **shaderUtils**
601
651
 
602
- Set of randomness and other light transmport 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.
652
+ 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.
603
653
 
604
654
  # Gotchas
605
655