three-gpu-pathtracer 0.0.11 → 0.0.12

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 (53) hide show
  1. package/LICENSE +21 -21
  2. package/README.md +886 -886
  3. package/build/index.module.js +6478 -6470
  4. package/build/index.module.js.map +1 -1
  5. package/build/index.umd.cjs +6473 -6465
  6. package/build/index.umd.cjs.map +1 -1
  7. package/package.json +72 -69
  8. package/src/core/DynamicPathTracingSceneGenerator.js +119 -119
  9. package/src/core/MaterialReducer.js +256 -256
  10. package/src/core/PathTracingRenderer.js +275 -275
  11. package/src/core/PathTracingSceneGenerator.js +69 -69
  12. package/src/index.js +39 -39
  13. package/src/materials/AlphaDisplayMaterial.js +48 -48
  14. package/src/materials/AmbientOcclusionMaterial.js +199 -199
  15. package/src/materials/BlendMaterial.js +67 -67
  16. package/src/materials/DenoiseMaterial.js +142 -142
  17. package/src/materials/GraphMaterial.js +243 -243
  18. package/src/materials/LambertPathTracingMaterial.js +285 -285
  19. package/src/materials/MaterialBase.js +56 -56
  20. package/src/materials/PhysicalPathTracingMaterial.js +982 -982
  21. package/src/objects/EquirectCamera.js +13 -13
  22. package/src/objects/PhysicalCamera.js +28 -28
  23. package/src/objects/PhysicalSpotLight.js +14 -14
  24. package/src/objects/ShapedAreaLight.js +12 -12
  25. package/src/shader/shaderBvhAnyHit.js +76 -0
  26. package/src/shader/shaderEnvMapSampling.js +58 -58
  27. package/src/shader/shaderGGXFunctions.js +100 -100
  28. package/src/shader/shaderIridescenceFunctions.js +130 -130
  29. package/src/shader/shaderLayerTexelFetchFunctions.js +25 -25
  30. package/src/shader/shaderLightSampling.js +229 -229
  31. package/src/shader/shaderMaterialSampling.js +506 -498
  32. package/src/shader/shaderRandFunctions.js +57 -57
  33. package/src/shader/shaderSheenFunctions.js +98 -98
  34. package/src/shader/shaderSobolSampling.js +256 -256
  35. package/src/shader/shaderStructs.js +325 -325
  36. package/src/shader/shaderUtils.js +361 -361
  37. package/src/textures/GradientEquirectTexture.js +35 -35
  38. package/src/textures/ProceduralEquirectTexture.js +75 -75
  39. package/src/uniforms/AttributesTextureArray.js +35 -35
  40. package/src/uniforms/EquirectHdrInfoUniform.js +259 -259
  41. package/src/uniforms/FloatAttributeTextureArray.js +169 -169
  42. package/src/uniforms/IESProfilesTexture.js +100 -100
  43. package/src/uniforms/LightsInfoUniformStruct.js +207 -207
  44. package/src/uniforms/MaterialsTexture.js +426 -426
  45. package/src/uniforms/PhysicalCameraUniform.js +36 -36
  46. package/src/uniforms/RenderTarget2DArray.js +97 -97
  47. package/src/uniforms/utils.js +30 -30
  48. package/src/utils/BlurredEnvMapGenerator.js +116 -116
  49. package/src/utils/GeometryPreparationUtils.js +214 -214
  50. package/src/utils/IESLoader.js +325 -325
  51. package/src/utils/SobolNumberMapGenerator.js +80 -80
  52. package/src/utils/UVUnwrapper.js +101 -101
  53. package/src/workers/PathTracingSceneWorker.js +42 -42
package/package.json CHANGED
@@ -1,69 +1,72 @@
1
- {
2
- "name": "three-gpu-pathtracer",
3
- "version": "0.0.11",
4
- "description": "Path tracing renderer and utilities for three.js built on top of three-mesh-bvh.",
5
- "module": "src/index.js",
6
- "main": "build/index.umd.cjs",
7
- "type": "module",
8
- "sideEffects": false,
9
- "files": [
10
- "src/*",
11
- "build/*"
12
- ],
13
- "keywords": [
14
- "webgl",
15
- "threejs",
16
- "performance",
17
- "geometry",
18
- "graphics",
19
- "mesh",
20
- "renderer",
21
- "raytracing",
22
- "bvh",
23
- "three-js",
24
- "path-tracing",
25
- "three-mesh-bvh",
26
- "rtx"
27
- ],
28
- "dependencies": {
29
- "three-mesh-bvh": "^0.5.19"
30
- },
31
- "devDependencies": {
32
- "canvas-capture": "^2.0.5",
33
- "eslint": "^7.32.0",
34
- "eslint-config-mdcs": "^5.0.0",
35
- "node-fetch": "^3.2.9",
36
- "parcel": "^2.4.0",
37
- "pixelmatch": "^5.3.0",
38
- "pngjs": "^6.0.0",
39
- "process": "^0.11.10",
40
- "puppeteer": "^15.4.0",
41
- "rollup": "^2.70.0",
42
- "simple-git": "^3.10.0",
43
- "three": "^0.147.0",
44
- "yargs": "^17.5.1"
45
- },
46
- "peerDependencies": {
47
- "three": ">=0.139.2",
48
- "xatlas-web": "^0.1.0"
49
- },
50
- "scripts": {
51
- "start": "cd example && parcel serve ./*.html --dist-dir ./dev-bundle/ --no-cache --no-hmr",
52
- "build-examples": "cd example && parcel build ./*.html --dist-dir ./bundle/ --public-url . --no-cache --no-content-hash",
53
- "update-screenshots": "node ./scripts/push-screenshots.js",
54
- "screenshot-diff": "node ./scripts/regression-test.js",
55
- "build": "rollup -c",
56
- "lint": "eslint \"./src/**/*.{js,ts}\" \"./example/*.js\"",
57
- "prepublishOnly": "npm run build"
58
- },
59
- "repository": {
60
- "type": "git",
61
- "url": "git+https://github.com/gkjohnson/three-gpu-pathtracer.git"
62
- },
63
- "author": "Garrett Johnson <garrett.kjohnson@gmail.com>",
64
- "license": "MIT",
65
- "bugs": {
66
- "url": "https://github.com/gkjohnson/three-gpu-pathtracer/issues"
67
- },
68
- "homepage": "https://github.com/gkjohnson/three-gpu-pathtracer#readme"
69
- }
1
+ {
2
+ "name": "three-gpu-pathtracer",
3
+ "version": "0.0.12",
4
+ "description": "Path tracing renderer and utilities for three.js built on top of three-mesh-bvh.",
5
+ "module": "src/index.js",
6
+ "main": "build/index.umd.cjs",
7
+ "type": "module",
8
+ "sideEffects": false,
9
+ "files": [
10
+ "src/*",
11
+ "build/*"
12
+ ],
13
+ "keywords": [
14
+ "webgl",
15
+ "threejs",
16
+ "performance",
17
+ "geometry",
18
+ "graphics",
19
+ "mesh",
20
+ "renderer",
21
+ "raytracing",
22
+ "bvh",
23
+ "three-js",
24
+ "path-tracing",
25
+ "three-mesh-bvh",
26
+ "rtx",
27
+ "path-tracer",
28
+ "path",
29
+ "tracer"
30
+ ],
31
+ "dependencies": {
32
+ "three-mesh-bvh": "^0.5.19"
33
+ },
34
+ "devDependencies": {
35
+ "canvas-capture": "^2.0.5",
36
+ "eslint": "^7.32.0",
37
+ "eslint-config-mdcs": "^5.0.0",
38
+ "node-fetch": "^3.2.9",
39
+ "parcel": "^2.4.0",
40
+ "pixelmatch": "^5.3.0",
41
+ "pngjs": "^6.0.0",
42
+ "process": "^0.11.10",
43
+ "puppeteer": "^15.4.0",
44
+ "rollup": "^2.70.0",
45
+ "simple-git": "^3.10.0",
46
+ "three": "^0.147.0",
47
+ "yargs": "^17.5.1"
48
+ },
49
+ "peerDependencies": {
50
+ "three": ">=0.139.2",
51
+ "xatlas-web": "^0.1.0"
52
+ },
53
+ "scripts": {
54
+ "start": "cd example && parcel serve ./*.html --dist-dir ./dev-bundle/ --no-cache --no-hmr",
55
+ "build-examples": "cd example && parcel build ./*.html --dist-dir ./bundle/ --public-url . --no-cache --no-content-hash",
56
+ "update-screenshots": "node ./scripts/push-screenshots.js",
57
+ "screenshot-diff": "node ./scripts/regression-test.js",
58
+ "build": "rollup -c",
59
+ "lint": "eslint \"./src/**/*.{js,ts}\" \"./example/*.js\"",
60
+ "prepublishOnly": "npm run build"
61
+ },
62
+ "repository": {
63
+ "type": "git",
64
+ "url": "git+https://github.com/gkjohnson/three-gpu-pathtracer.git"
65
+ },
66
+ "author": "Garrett Johnson <garrett.kjohnson@gmail.com>",
67
+ "license": "MIT",
68
+ "bugs": {
69
+ "url": "https://github.com/gkjohnson/three-gpu-pathtracer/issues"
70
+ },
71
+ "homepage": "https://github.com/gkjohnson/three-gpu-pathtracer#readme"
72
+ }
@@ -1,119 +1,119 @@
1
- import { BufferGeometry } from 'three';
2
- import { StaticGeometryGenerator, MeshBVH } from 'three-mesh-bvh';
3
- import { setCommonAttributes, getGroupMaterialIndicesAttribute } from '../utils/GeometryPreparationUtils.js';
4
-
5
- export class DynamicPathTracingSceneGenerator {
6
-
7
- get initialized() {
8
-
9
- return Boolean( this.bvh );
10
-
11
- }
12
-
13
- constructor( scene ) {
14
-
15
- this.objects = Array.isArray( scene ) ? scene : [ scene ];
16
- this.bvh = null;
17
- this.geometry = new BufferGeometry();
18
- this.materials = null;
19
- this.textures = null;
20
- this.lights = [];
21
- this.staticGeometryGenerator = new StaticGeometryGenerator( this.objects );
22
-
23
- }
24
-
25
- reset() {
26
-
27
- this.bvh = null;
28
- this.geometry.dispose();
29
- this.geometry = new BufferGeometry();
30
- this.materials = null;
31
- this.textures = null;
32
- this.lights = [];
33
- this.staticGeometryGenerator = new StaticGeometryGenerator( this.objects );
34
-
35
- }
36
-
37
- dispose() {}
38
-
39
- generate() {
40
-
41
- const { objects, staticGeometryGenerator, geometry } = this;
42
- if ( this.bvh === null ) {
43
-
44
- const attributes = [ 'position', 'normal', 'tangent', 'uv', 'color' ];
45
-
46
- for ( let i = 0, l = objects.length; i < l; i ++ ) {
47
-
48
- objects[ i ].traverse( c => {
49
-
50
- if ( c.isMesh ) {
51
-
52
- const normalMapRequired = ! ! c.material.normalMap;
53
- setCommonAttributes( c.geometry, { attributes, normalMapRequired } );
54
-
55
- } else if ( c.isRectAreaLight || c.isSpotLight ) {
56
-
57
- this.lights.push( c );
58
-
59
- }
60
-
61
- } );
62
-
63
- }
64
-
65
- const textureSet = new Set();
66
- const materials = staticGeometryGenerator.getMaterials();
67
- materials.forEach( material => {
68
-
69
- for ( const key in material ) {
70
-
71
- const value = material[ key ];
72
- if ( value && value.isTexture ) {
73
-
74
- textureSet.add( value );
75
-
76
- }
77
-
78
- }
79
-
80
- } );
81
-
82
- staticGeometryGenerator.attributes = attributes;
83
- staticGeometryGenerator.generate( geometry );
84
-
85
- const materialIndexAttribute = getGroupMaterialIndicesAttribute( geometry, materials, materials );
86
- geometry.setAttribute( 'materialIndex', materialIndexAttribute );
87
- geometry.clearGroups();
88
-
89
- this.bvh = new MeshBVH( geometry );
90
- this.materials = materials;
91
- this.textures = Array.from( textureSet );
92
-
93
- return {
94
- lights: this.lights,
95
- bvh: this.bvh,
96
- materials: this.materials,
97
- textures: this.textures,
98
- objects,
99
- };
100
-
101
- } else {
102
-
103
- const { bvh } = this;
104
- staticGeometryGenerator.generate( geometry );
105
- bvh.refit();
106
- return {
107
- lights: this.lights,
108
- bvh: this.bvh,
109
- materials: this.materials,
110
- textures: this.textures,
111
- objects,
112
- };
113
-
114
- }
115
-
116
- }
117
-
118
-
119
- }
1
+ import { BufferGeometry } from 'three';
2
+ import { StaticGeometryGenerator, MeshBVH } from 'three-mesh-bvh';
3
+ import { setCommonAttributes, getGroupMaterialIndicesAttribute } from '../utils/GeometryPreparationUtils.js';
4
+
5
+ export class DynamicPathTracingSceneGenerator {
6
+
7
+ get initialized() {
8
+
9
+ return Boolean( this.bvh );
10
+
11
+ }
12
+
13
+ constructor( scene ) {
14
+
15
+ this.objects = Array.isArray( scene ) ? scene : [ scene ];
16
+ this.bvh = null;
17
+ this.geometry = new BufferGeometry();
18
+ this.materials = null;
19
+ this.textures = null;
20
+ this.lights = [];
21
+ this.staticGeometryGenerator = new StaticGeometryGenerator( this.objects );
22
+
23
+ }
24
+
25
+ reset() {
26
+
27
+ this.bvh = null;
28
+ this.geometry.dispose();
29
+ this.geometry = new BufferGeometry();
30
+ this.materials = null;
31
+ this.textures = null;
32
+ this.lights = [];
33
+ this.staticGeometryGenerator = new StaticGeometryGenerator( this.objects );
34
+
35
+ }
36
+
37
+ dispose() {}
38
+
39
+ generate() {
40
+
41
+ const { objects, staticGeometryGenerator, geometry } = this;
42
+ if ( this.bvh === null ) {
43
+
44
+ const attributes = [ 'position', 'normal', 'tangent', 'uv', 'color' ];
45
+
46
+ for ( let i = 0, l = objects.length; i < l; i ++ ) {
47
+
48
+ objects[ i ].traverse( c => {
49
+
50
+ if ( c.isMesh ) {
51
+
52
+ const normalMapRequired = ! ! c.material.normalMap;
53
+ setCommonAttributes( c.geometry, { attributes, normalMapRequired } );
54
+
55
+ } else if ( c.isRectAreaLight || c.isSpotLight ) {
56
+
57
+ this.lights.push( c );
58
+
59
+ }
60
+
61
+ } );
62
+
63
+ }
64
+
65
+ const textureSet = new Set();
66
+ const materials = staticGeometryGenerator.getMaterials();
67
+ materials.forEach( material => {
68
+
69
+ for ( const key in material ) {
70
+
71
+ const value = material[ key ];
72
+ if ( value && value.isTexture ) {
73
+
74
+ textureSet.add( value );
75
+
76
+ }
77
+
78
+ }
79
+
80
+ } );
81
+
82
+ staticGeometryGenerator.attributes = attributes;
83
+ staticGeometryGenerator.generate( geometry );
84
+
85
+ const materialIndexAttribute = getGroupMaterialIndicesAttribute( geometry, materials, materials );
86
+ geometry.setAttribute( 'materialIndex', materialIndexAttribute );
87
+ geometry.clearGroups();
88
+
89
+ this.bvh = new MeshBVH( geometry );
90
+ this.materials = materials;
91
+ this.textures = Array.from( textureSet );
92
+
93
+ return {
94
+ lights: this.lights,
95
+ bvh: this.bvh,
96
+ materials: this.materials,
97
+ textures: this.textures,
98
+ objects,
99
+ };
100
+
101
+ } else {
102
+
103
+ const { bvh } = this;
104
+ staticGeometryGenerator.generate( geometry );
105
+ bvh.refit();
106
+ return {
107
+ lights: this.lights,
108
+ bvh: this.bvh,
109
+ materials: this.materials,
110
+ textures: this.textures,
111
+ objects,
112
+ };
113
+
114
+ }
115
+
116
+ }
117
+
118
+
119
+ }