three-gpu-pathtracer 0.0.12 → 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/README.md +102 -7
- package/build/index.module.js +2891 -2065
- package/build/index.module.js.map +1 -1
- package/build/index.umd.cjs +2886 -2062
- package/build/index.umd.cjs.map +1 -1
- package/package.json +2 -1
- package/src/core/PathTracingRenderer.js +87 -16
- package/src/core/PathTracingSceneGenerator.js +1 -1
- package/src/core/QuiltPathTracingRenderer.js +223 -0
- package/src/index.js +5 -8
- package/src/materials/{GraphMaterial.js → debug/GraphMaterial.js} +1 -1
- package/src/materials/{AlphaDisplayMaterial.js → fullscreen/AlphaDisplayMaterial.js} +1 -1
- package/src/materials/{BlendMaterial.js → fullscreen/BlendMaterial.js} +1 -1
- package/src/materials/{DenoiseMaterial.js → fullscreen/DenoiseMaterial.js} +1 -1
- package/src/materials/{LambertPathTracingMaterial.js → pathtracing/LambertPathTracingMaterial.js} +18 -7
- 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} +16 -8
- package/src/materials/surface/FogVolumeMaterial.js +23 -0
- 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} +1 -1
- 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} +1 -1
- package/src/shader/{shaderSobolSampling.js → rand/sobol.glsl.js} +3 -3
- 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} +5 -123
- package/src/uniforms/EquirectHdrInfoUniform.js +29 -11
- package/src/uniforms/LightsInfoUniformStruct.js +9 -4
- package/src/uniforms/MaterialsTexture.js +80 -3
- package/src/utils/BlurredEnvMapGenerator.js +2 -2
- package/src/utils/SobolNumberMapGenerator.js +3 -3
- package/src/utils/macroify.js +9 -0
- package/src/materials/PhysicalPathTracingMaterial.js +0 -982
- 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 -130
- package/src/shader/shaderLightSampling.js +0 -229
- package/src/shader/shaderMaterialSampling.js +0 -506
- package/src/shader/shaderSheenFunctions.js +0 -98
- package/src/shader/shaderUtils.js +0 -361
package/README.md
CHANGED
|
@@ -38,6 +38,8 @@ _More features and capabilities in progress!_
|
|
|
38
38
|
|
|
39
39
|
[Spot Light Support](https://gkjohnson.github.io/three-gpu-pathtracer/example/bundle/spotLights.html)
|
|
40
40
|
|
|
41
|
+
[Volumetric Fog Support](https://gkjohnson.github.io/three-gpu-pathtracer/example/bundle/fog.html)
|
|
42
|
+
|
|
41
43
|
**Test Scenes**
|
|
42
44
|
|
|
43
45
|
[Material Test Orb](https://gkjohnson.github.io/three-gpu-pathtracer/example/bundle/materialBall.html)
|
|
@@ -54,6 +56,9 @@ _More features and capabilities in progress!_
|
|
|
54
56
|
|
|
55
57
|
[Ambient Occlusion Material](https://gkjohnson.github.io/three-gpu-pathtracer/example/bundle/aoRender.html)
|
|
56
58
|
|
|
59
|
+
[Looking Glass Portrait Quilt Render](https://gkjohnson.github.io/three-gpu-pathtracer/example/bundle/lkg.html)
|
|
60
|
+
|
|
61
|
+
|
|
57
62
|
## Running examples locally
|
|
58
63
|
|
|
59
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).
|
|
@@ -127,7 +132,7 @@ ptMaterial.materials.updateFrom( materials, textures );
|
|
|
127
132
|
ptMaterial.lights.updateFrom( lights );
|
|
128
133
|
|
|
129
134
|
// set the environment map
|
|
130
|
-
const texture = await new RGBELoader().loadAsync( envMapUrl );
|
|
135
|
+
const texture = await new RGBELoader().setDataType( THREE.FloatType ).loadAsync( envMapUrl );
|
|
131
136
|
ptRenderer.material.envMapInfo.updateFrom( texture );
|
|
132
137
|
|
|
133
138
|
animate();
|
|
@@ -161,7 +166,7 @@ import { BlurredEnvMapGenerator } from 'three-gpu-pathtracer';
|
|
|
161
166
|
|
|
162
167
|
// ...
|
|
163
168
|
|
|
164
|
-
const envMap = await new RGBELoader().loadAsync( envMapUrl );
|
|
169
|
+
const envMap = await new RGBELoader().setDataType( THREE.FloatType ).loadAsync( envMapUrl );
|
|
165
170
|
const generator = new BlurredEnvMapGenerator( renderer );
|
|
166
171
|
const blurredEnvMap = generator.generate( envMap, 0.35 );
|
|
167
172
|
|
|
@@ -222,6 +227,9 @@ readonly target : WebGLRenderTarget
|
|
|
222
227
|
|
|
223
228
|
The target being rendered to. The size of the target is updated with `setSize` and is initialized to a FloatType texture.
|
|
224
229
|
|
|
230
|
+
> **Note**
|
|
231
|
+
> Target will swap render targets after every full sample when alpha is enabled.
|
|
232
|
+
|
|
225
233
|
### .camera
|
|
226
234
|
|
|
227
235
|
```js
|
|
@@ -271,7 +279,7 @@ alpha = false : Boolean
|
|
|
271
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.
|
|
272
280
|
|
|
273
281
|
> **Note**
|
|
274
|
-
> When a transparent background is used
|
|
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.
|
|
275
283
|
|
|
276
284
|
### constructor
|
|
277
285
|
|
|
@@ -303,6 +311,68 @@ reset() : void
|
|
|
303
311
|
|
|
304
312
|
Resets and restarts the render from scratch.
|
|
305
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
|
+
|
|
306
376
|
## PathTracingSceneGenerator
|
|
307
377
|
|
|
308
378
|
Utility class for generating the set of data required for initializing the path tracing material with a bvh, geometry, materials, and textures.
|
|
@@ -560,7 +630,13 @@ _extends MaterialBase_
|
|
|
560
630
|
```js
|
|
561
631
|
{
|
|
562
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.
|
|
563
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,
|
|
564
640
|
|
|
565
641
|
// The physical camera parameters to use
|
|
566
642
|
physicalCamera : PhysicalCameraUniform,
|
|
@@ -603,15 +679,29 @@ _extends MaterialBase_
|
|
|
603
679
|
```js
|
|
604
680
|
{
|
|
605
681
|
|
|
606
|
-
// Whether to use multiple importance sampling to help the image converge more quickly
|
|
682
|
+
// Whether to use multiple importance sampling to help the image converge more quickly.
|
|
607
683
|
FEATURE_MIS = 1 : Number,
|
|
608
684
|
|
|
609
|
-
//
|
|
610
|
-
|
|
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,
|
|
611
688
|
|
|
612
689
|
}
|
|
613
690
|
```
|
|
614
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
|
+
|
|
615
705
|
## DenoiseMaterial
|
|
616
706
|
|
|
617
707
|
_extends MaterialBase_
|
|
@@ -812,7 +902,10 @@ Set of randomness and other light transport utilities for use in a shader. See t
|
|
|
812
902
|
|
|
813
903
|
- The project requires use of WebGL2.
|
|
814
904
|
- All textures must use the same wrap and interpolation flags.
|
|
815
|
-
-
|
|
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.
|
|
816
909
|
|
|
817
910
|
# Screenshots
|
|
818
911
|
|
|
@@ -883,4 +976,6 @@ Set of randomness and other light transport utilities for use in a shader. See t
|
|
|
883
976
|
|
|
884
977
|
[knightcrawler25/GLSL-PathTracer](https://github.com/knightcrawler25/GLSL-PathTracer/)
|
|
885
978
|
|
|
979
|
+
[DassaultSystemes-Technology/dspbr-pt](https://github.com/DassaultSystemes-Technology/dspbr-pt)
|
|
980
|
+
|
|
886
981
|
|