three-gpu-pathtracer 0.0.5 → 0.0.6

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 (42) hide show
  1. package/LICENSE +21 -21
  2. package/README.md +781 -728
  3. package/build/index.module.js +5223 -3956
  4. package/build/index.module.js.map +1 -1
  5. package/build/index.umd.cjs +5226 -3954
  6. package/build/index.umd.cjs.map +1 -1
  7. package/package.json +68 -60
  8. package/src/core/DynamicPathTracingSceneGenerator.js +119 -111
  9. package/src/core/MaterialReducer.js +256 -256
  10. package/src/core/PathTracingRenderer.js +255 -255
  11. package/src/core/PathTracingSceneGenerator.js +68 -68
  12. package/src/index.js +33 -26
  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/LambertPathTracingMaterial.js +285 -285
  17. package/src/materials/MaterialBase.js +56 -56
  18. package/src/materials/PhysicalPathTracingMaterial.js +922 -848
  19. package/src/{core → objects}/EquirectCamera.js +13 -13
  20. package/src/{core → objects}/PhysicalCamera.js +28 -28
  21. package/src/objects/PhysicalSpotLight.js +14 -0
  22. package/src/objects/ShapedAreaLight.js +12 -0
  23. package/src/shader/shaderEnvMapSampling.js +59 -59
  24. package/src/shader/shaderGGXFunctions.js +108 -108
  25. package/src/shader/shaderIridescenceFunctions.js +130 -0
  26. package/src/shader/shaderLightSampling.js +231 -87
  27. package/src/shader/shaderMaterialSampling.js +546 -501
  28. package/src/shader/shaderSheenFunctions.js +98 -0
  29. package/src/shader/shaderStructs.js +307 -191
  30. package/src/shader/shaderUtils.js +350 -287
  31. package/src/uniforms/EquirectHdrInfoUniform.js +259 -263
  32. package/src/uniforms/IESProfilesTexture.js +100 -0
  33. package/src/uniforms/LightsInfoUniformStruct.js +162 -0
  34. package/src/uniforms/MaterialsTexture.js +406 -319
  35. package/src/uniforms/PhysicalCameraUniform.js +36 -36
  36. package/src/uniforms/RenderTarget2DArray.js +93 -93
  37. package/src/utils/BlurredEnvMapGenerator.js +113 -113
  38. package/src/utils/GeometryPreparationUtils.js +194 -194
  39. package/src/utils/IESLoader.js +325 -0
  40. package/src/utils/UVUnwrapper.js +101 -101
  41. package/src/workers/PathTracingSceneWorker.js +42 -41
  42. package/src/uniforms/LightsTexture.js +0 -83
package/package.json CHANGED
@@ -1,60 +1,68 @@
1
- {
2
- "name": "three-gpu-pathtracer",
3
- "version": "0.0.5",
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
- "parcel": "^2.4.0",
35
- "process": "^0.11.10",
36
- "rollup": "^2.70.0",
37
- "three": "^0.141.0"
38
- },
39
- "peerDependencies": {
40
- "three": "^0.139.2",
41
- "xatlas-web": "^0.1.0"
42
- },
43
- "scripts": {
44
- "start": "cd example && parcel serve ./*.html --dist-dir ./dev-bundle/ --no-cache --no-hmr",
45
- "build-examples": "cd example && parcel build ./*.html --dist-dir ./bundle/ --public-url . --no-cache --no-content-hash",
46
- "build": "rollup -c",
47
- "lint": "eslint \"./src/**/*.{js,ts}\" \"./example/*.js\"",
48
- "prepublishOnly": "npm run build"
49
- },
50
- "repository": {
51
- "type": "git",
52
- "url": "git+https://github.com/gkjohnson/three-gpu-pathtracer.git"
53
- },
54
- "author": "Garrett Johnson <garrett.kjohnson@gmail.com>",
55
- "license": "MIT",
56
- "bugs": {
57
- "url": "https://github.com/gkjohnson/three-gpu-pathtracer/issues"
58
- },
59
- "homepage": "https://github.com/gkjohnson/three-gpu-pathtracer#readme"
60
- }
1
+ {
2
+ "name": "three-gpu-pathtracer",
3
+ "version": "0.0.6",
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.141.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,111 +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.staticGeometryGenerator = new StaticGeometryGenerator( scene );
21
-
22
- }
23
-
24
- reset() {
25
-
26
- this.bvh = null;
27
- this.geometry.dispose();
28
- this.geometry = new BufferGeometry();
29
- this.materials = null;
30
- this.textures = null;
31
- this.staticGeometryGenerator = new StaticGeometryGenerator( this.objects );
32
-
33
- }
34
-
35
- dispose() {}
36
-
37
- generate() {
38
-
39
- const { objects, staticGeometryGenerator, geometry } = this;
40
- if ( this.bvh === null ) {
41
-
42
- const attributes = [ 'position', 'normal', 'tangent', 'uv' ];
43
-
44
- for ( let i = 0, l = objects.length; i < l; i ++ ) {
45
-
46
- objects[ i ].traverse( c => {
47
-
48
- if ( c.isMesh ) {
49
-
50
- const normalMapRequired = ! ! c.material.normalMap;
51
- setCommonAttributes( c.geometry, { attributes, normalMapRequired } );
52
-
53
- }
54
-
55
- } );
56
-
57
- }
58
-
59
- const textureSet = new Set();
60
- const materials = staticGeometryGenerator.getMaterials();
61
- materials.forEach( material => {
62
-
63
- for ( const key in material ) {
64
-
65
- const value = material[ key ];
66
- if ( value && value.isTexture ) {
67
-
68
- textureSet.add( value );
69
-
70
- }
71
-
72
- }
73
-
74
- } );
75
-
76
- staticGeometryGenerator.attributes = attributes;
77
- staticGeometryGenerator.generate( geometry );
78
-
79
- const materialIndexAttribute = getGroupMaterialIndicesAttribute( geometry, materials, materials );
80
- geometry.setAttribute( 'materialIndex', materialIndexAttribute );
81
- geometry.clearGroups();
82
-
83
- this.bvh = new MeshBVH( geometry );
84
- this.materials = materials;
85
- this.textures = Array.from( textureSet );
86
-
87
- return {
88
- bvh: this.bvh,
89
- materials: this.materials,
90
- textures: this.textures,
91
- objects,
92
- };
93
-
94
- } else {
95
-
96
- const { bvh } = this;
97
- staticGeometryGenerator.generate( geometry );
98
- bvh.refit();
99
- return {
100
- bvh: this.bvh,
101
- materials: this.materials,
102
- textures: this.textures,
103
- objects,
104
- };
105
-
106
- }
107
-
108
- }
109
-
110
-
111
- }
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' ];
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
+ }