three-gpu-pathtracer 0.0.7 → 0.0.8

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 (48) hide show
  1. package/LICENSE +21 -21
  2. package/README.md +887 -815
  3. package/build/index.module.js +5796 -5451
  4. package/build/index.module.js.map +1 -1
  5. package/build/index.umd.cjs +5795 -5448
  6. package/build/index.umd.cjs.map +1 -1
  7. package/package.json +69 -68
  8. package/src/core/DynamicPathTracingSceneGenerator.js +119 -119
  9. package/src/core/MaterialReducer.js +256 -256
  10. package/src/core/PathTracingRenderer.js +270 -270
  11. package/src/core/PathTracingSceneGenerator.js +1 -1
  12. package/src/index.js +39 -35
  13. package/src/materials/AlphaDisplayMaterial.js +48 -48
  14. package/src/materials/AmbientOcclusionMaterial.js +197 -197
  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 +973 -970
  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/shaderEnvMapSampling.js +59 -59
  26. package/src/shader/shaderGGXFunctions.js +100 -100
  27. package/src/shader/shaderIridescenceFunctions.js +130 -130
  28. package/src/shader/shaderLayerTexelFetchFunctions.js +25 -0
  29. package/src/shader/shaderLightSampling.js +231 -231
  30. package/src/shader/shaderMaterialSampling.js +504 -542
  31. package/src/shader/shaderSheenFunctions.js +98 -98
  32. package/src/shader/shaderStructs.js +321 -321
  33. package/src/shader/shaderUtils.js +403 -364
  34. package/src/textures/GradientEquirectTexture.js +35 -0
  35. package/src/textures/ProceduralEquirectTexture.js +75 -0
  36. package/src/uniforms/AttributesTextureArray.js +35 -0
  37. package/src/uniforms/EquirectHdrInfoUniform.js +259 -259
  38. package/src/uniforms/FloatAttributeTextureArray.js +169 -0
  39. package/src/uniforms/IESProfilesTexture.js +100 -100
  40. package/src/uniforms/LightsInfoUniformStruct.js +162 -162
  41. package/src/uniforms/MaterialsTexture.js +420 -426
  42. package/src/uniforms/PhysicalCameraUniform.js +36 -36
  43. package/src/uniforms/RenderTarget2DArray.js +97 -93
  44. package/src/uniforms/utils.js +21 -0
  45. package/src/utils/BlurredEnvMapGenerator.js +116 -113
  46. package/src/utils/IESLoader.js +325 -325
  47. package/src/utils/UVUnwrapper.js +101 -101
  48. package/src/workers/PathTracingSceneWorker.js +42 -42
package/package.json CHANGED
@@ -1,68 +1,69 @@
1
- {
2
- "name": "three-gpu-pathtracer",
3
- "version": "0.0.7",
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.10"
30
- },
31
- "devDependencies": {
32
- "eslint": "^7.32.0",
33
- "eslint-config-mdcs": "^5.0.0",
34
- "node-fetch": "^3.2.9",
35
- "parcel": "^2.4.0",
36
- "pixelmatch": "^5.3.0",
37
- "pngjs": "^6.0.0",
38
- "process": "^0.11.10",
39
- "puppeteer": "^15.4.0",
40
- "rollup": "^2.70.0",
41
- "simple-git": "^3.10.0",
42
- "three": "^0.145.0",
43
- "yargs": "^17.5.1"
44
- },
45
- "peerDependencies": {
46
- "three": "^0.139.2",
47
- "xatlas-web": "^0.1.0"
48
- },
49
- "scripts": {
50
- "start": "cd example && parcel serve ./*.html --dist-dir ./dev-bundle/ --no-cache --no-hmr",
51
- "build-examples": "cd example && parcel build ./*.html --dist-dir ./bundle/ --public-url . --no-cache --no-content-hash",
52
- "update-screenshots": "node ./scripts/push-screenshots.js",
53
- "screenshot-diff": "node ./scripts/regression-test.js",
54
- "build": "rollup -c",
55
- "lint": "eslint \"./src/**/*.{js,ts}\" \"./example/*.js\"",
56
- "prepublishOnly": "npm run build"
57
- },
58
- "repository": {
59
- "type": "git",
60
- "url": "git+https://github.com/gkjohnson/three-gpu-pathtracer.git"
61
- },
62
- "author": "Garrett Johnson <garrett.kjohnson@gmail.com>",
63
- "license": "MIT",
64
- "bugs": {
65
- "url": "https://github.com/gkjohnson/three-gpu-pathtracer/issues"
66
- },
67
- "homepage": "https://github.com/gkjohnson/three-gpu-pathtracer#readme"
68
- }
1
+ {
2
+ "name": "three-gpu-pathtracer",
3
+ "version": "0.0.8",
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.145.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,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( scene );
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
+ }