three-gpu-pathtracer 0.0.13 → 0.0.15

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 (65) hide show
  1. package/README.md +46 -3
  2. package/build/index.module.js +3107 -2141
  3. package/build/index.module.js.map +1 -1
  4. package/build/index.umd.cjs +3119 -2154
  5. package/build/index.umd.cjs.map +1 -1
  6. package/package.json +1 -1
  7. package/src/core/PathTracingRenderer.js +1 -1
  8. package/src/detectors/CompatibilityDetector.js +38 -0
  9. package/src/detectors/MaterialCompileDetector.js +50 -0
  10. package/src/detectors/PrecisionDetector.js +85 -0
  11. package/src/detectors/PrecisionMaterial.js +160 -0
  12. package/src/index.js +7 -7
  13. package/src/materials/{GraphMaterial.js → debug/GraphMaterial.js} +1 -1
  14. package/src/materials/{AlphaDisplayMaterial.js → fullscreen/AlphaDisplayMaterial.js} +3 -1
  15. package/src/materials/{BlendMaterial.js → fullscreen/BlendMaterial.js} +1 -1
  16. package/src/materials/{DenoiseMaterial.js → fullscreen/DenoiseMaterial.js} +1 -1
  17. package/src/materials/fullscreen/GradientMapMaterial.js +82 -0
  18. package/src/materials/{LambertPathTracingMaterial.js → pathtracing/LambertPathTracingMaterial.js} +18 -7
  19. package/src/materials/pathtracing/PhysicalPathTracingMaterial.js +557 -0
  20. package/src/materials/pathtracing/glsl/attenuateHit.glsl.js +177 -0
  21. package/src/materials/pathtracing/glsl/cameraUtils.glsl.js +84 -0
  22. package/src/materials/pathtracing/glsl/directLightContribution.glsl.js +91 -0
  23. package/src/materials/pathtracing/glsl/getSurfaceRecord.glsl.js +323 -0
  24. package/src/materials/pathtracing/glsl/renderStructs.glsl.js +50 -0
  25. package/src/materials/pathtracing/glsl/traceScene.glsl.js +52 -0
  26. package/src/materials/{AmbientOcclusionMaterial.js → surface/AmbientOcclusionMaterial.js} +16 -8
  27. package/src/materials/surface/FogVolumeMaterial.js +23 -0
  28. package/src/objects/PhysicalCamera.js +14 -0
  29. package/src/objects/PhysicalSpotLight.js +11 -0
  30. package/src/objects/ShapedAreaLight.js +10 -0
  31. package/src/shader/bsdf/bsdfSampling.glsl.js +499 -0
  32. package/src/shader/bsdf/fog.glsl.js +22 -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} +1 -1
  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} +1 -1
  43. package/src/shader/{shaderSobolSampling.js → rand/sobol.glsl.js} +3 -3
  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 +13 -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} +3 -123
  52. package/src/uniforms/EquirectHdrInfoUniform.js +11 -15
  53. package/src/uniforms/MaterialsTexture.js +79 -2
  54. package/src/utils/BlurredEnvMapGenerator.js +2 -2
  55. package/src/utils/SobolNumberMapGenerator.js +3 -3
  56. package/src/utils/macroify.js +9 -0
  57. package/src/materials/PhysicalPathTracingMaterial.js +0 -1013
  58. package/src/shader/shaderBvhAnyHit.js +0 -76
  59. package/src/shader/shaderEnvMapSampling.js +0 -58
  60. package/src/shader/shaderGGXFunctions.js +0 -100
  61. package/src/shader/shaderIridescenceFunctions.js +0 -135
  62. package/src/shader/shaderLightSampling.js +0 -229
  63. package/src/shader/shaderMaterialSampling.js +0 -510
  64. package/src/shader/shaderSheenFunctions.js +0 -98
  65. package/src/shader/shaderUtils.js +0 -377
package/README.md CHANGED
@@ -3,7 +3,7 @@
3
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
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
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)
6
+ [![twitter](https://flat.badgen.net/badge/twitter/@garrettkjohnson/?icon&label)](https://twitter.com/garrettkjohnson)
7
7
  [![sponsors](https://img.shields.io/github/sponsors/gkjohnson?style=flat-square&color=1da1f2)](https://github.com/sponsors/gkjohnson/)
8
8
 
9
9
  ![](https://user-images.githubusercontent.com/734200/162287477-96696b18-890b-4c1b-8a73-d662e577cc48.png)
@@ -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)
@@ -130,7 +132,7 @@ ptMaterial.materials.updateFrom( materials, textures );
130
132
  ptMaterial.lights.updateFrom( lights );
131
133
 
132
134
  // set the environment map
133
- const texture = await new RGBELoader().loadAsync( envMapUrl );
135
+ const texture = await new RGBELoader().setDataType( THREE.FloatType ).loadAsync( envMapUrl );
134
136
  ptRenderer.material.envMapInfo.updateFrom( texture );
135
137
 
136
138
  animate();
@@ -164,7 +166,7 @@ import { BlurredEnvMapGenerator } from 'three-gpu-pathtracer';
164
166
 
165
167
  // ...
166
168
 
167
- const envMap = await new RGBELoader().loadAsync( envMapUrl );
169
+ const envMap = await new RGBELoader().setDataType( THREE.FloatType ).loadAsync( envMapUrl );
168
170
  const generator = new BlurredEnvMapGenerator( renderer );
169
171
  const blurredEnvMap = generator.generate( envMap, 0.35 );
170
172
 
@@ -628,7 +630,10 @@ _extends MaterialBase_
628
630
  ```js
629
631
  {
630
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.
631
635
  bounces = 3 : Number,
636
+ transmissiveBounces = 10 : Number,
632
637
 
633
638
  // The number of additional transmissive ray bounces to allow on top of existing bounces for object opacity / transmission.
634
639
  transmissiveBounces = 5 : Number,
@@ -684,6 +689,19 @@ _extends MaterialBase_
684
689
  }
685
690
  ```
686
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
+
687
705
  ## DenoiseMaterial
688
706
 
689
707
  _extends MaterialBase_
@@ -862,6 +880,29 @@ mergeMeshes( meshes : Array<Mesh> ) : {
862
880
 
863
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.
864
882
 
883
+ ## CompatibilityDetector
884
+
885
+ Detects whether the path tracer can run on the current device by checking whether struct precision is reliable and the material shader will compile.
886
+
887
+ ### constructor
888
+
889
+ ```js
890
+ constructor( renderer : WebGLRenderer, material : Material )
891
+ ```
892
+
893
+ Takes a WebGLRenderer to use and material to test again.
894
+
895
+ ### .detect
896
+
897
+ ```js
898
+ detect() : {
899
+ pass: Boolean,
900
+ message: String
901
+ }
902
+ ```
903
+
904
+ Returns `pass === true` if the path tracer can run. If it cannot run then a message is returned indicating why.
905
+
865
906
  ## Shader Chunks
866
907
 
867
908
  **shaderMaterialSampling**
@@ -958,4 +999,6 @@ Set of randomness and other light transport utilities for use in a shader. See t
958
999
 
959
1000
  [knightcrawler25/GLSL-PathTracer](https://github.com/knightcrawler25/GLSL-PathTracer/)
960
1001
 
1002
+ [DassaultSystemes-Technology/dspbr-pt](https://github.com/DassaultSystemes-Technology/dspbr-pt)
1003
+
961
1004