three-gpu-pathtracer 0.0.12 → 0.0.13
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/LICENSE +21 -21
- package/README.md +961 -886
- package/build/index.module.js +6850 -6481
- package/build/index.module.js.map +1 -1
- package/build/index.umd.cjs +6845 -6475
- package/build/index.umd.cjs.map +1 -1
- package/package.json +73 -72
- package/src/core/DynamicPathTracingSceneGenerator.js +119 -119
- package/src/core/MaterialReducer.js +256 -256
- package/src/core/PathTracingRenderer.js +346 -275
- package/src/core/PathTracingSceneGenerator.js +69 -69
- package/src/core/QuiltPathTracingRenderer.js +223 -0
- package/src/index.js +40 -39
- package/src/materials/AlphaDisplayMaterial.js +48 -48
- package/src/materials/AmbientOcclusionMaterial.js +199 -199
- package/src/materials/BlendMaterial.js +67 -67
- package/src/materials/DenoiseMaterial.js +142 -142
- package/src/materials/GraphMaterial.js +243 -243
- package/src/materials/LambertPathTracingMaterial.js +285 -285
- package/src/materials/MaterialBase.js +56 -56
- package/src/materials/PhysicalPathTracingMaterial.js +1013 -982
- package/src/objects/EquirectCamera.js +13 -13
- package/src/objects/PhysicalCamera.js +28 -28
- package/src/objects/PhysicalSpotLight.js +14 -14
- package/src/objects/ShapedAreaLight.js +12 -12
- package/src/shader/shaderEnvMapSampling.js +58 -58
- package/src/shader/shaderGGXFunctions.js +100 -100
- package/src/shader/shaderIridescenceFunctions.js +135 -130
- package/src/shader/shaderLayerTexelFetchFunctions.js +25 -25
- package/src/shader/shaderLightSampling.js +229 -229
- package/src/shader/shaderMaterialSampling.js +510 -506
- package/src/shader/shaderRandFunctions.js +57 -57
- package/src/shader/shaderSheenFunctions.js +98 -98
- package/src/shader/shaderSobolSampling.js +256 -256
- package/src/shader/shaderStructs.js +327 -325
- package/src/shader/shaderUtils.js +377 -361
- package/src/textures/GradientEquirectTexture.js +35 -35
- package/src/textures/ProceduralEquirectTexture.js +75 -75
- package/src/uniforms/AttributesTextureArray.js +35 -35
- package/src/uniforms/EquirectHdrInfoUniform.js +273 -259
- package/src/uniforms/FloatAttributeTextureArray.js +169 -169
- package/src/uniforms/IESProfilesTexture.js +100 -100
- package/src/uniforms/LightsInfoUniformStruct.js +212 -207
- package/src/uniforms/MaterialsTexture.js +426 -426
- package/src/uniforms/PhysicalCameraUniform.js +36 -36
- package/src/uniforms/RenderTarget2DArray.js +97 -97
- package/src/uniforms/utils.js +30 -30
- package/src/utils/BlurredEnvMapGenerator.js +116 -116
- package/src/utils/GeometryPreparationUtils.js +214 -214
- package/src/utils/IESLoader.js +325 -325
- package/src/utils/SobolNumberMapGenerator.js +80 -80
- package/src/utils/UVUnwrapper.js +101 -101
- package/src/workers/PathTracingSceneWorker.js +42 -42
|
@@ -1,35 +1,35 @@
|
|
|
1
|
-
import { Color, Vector3 } from 'three';
|
|
2
|
-
import { ProceduralEquirectTexture } from './ProceduralEquirectTexture.js';
|
|
3
|
-
|
|
4
|
-
const _direction = new Vector3();
|
|
5
|
-
export class GradientEquirectTexture extends ProceduralEquirectTexture {
|
|
6
|
-
|
|
7
|
-
constructor( resolution = 512 ) {
|
|
8
|
-
|
|
9
|
-
super( resolution, resolution );
|
|
10
|
-
|
|
11
|
-
this.topColor = new Color().set( 0xffffff );
|
|
12
|
-
this.bottomColor = new Color().set( 0x000000 );
|
|
13
|
-
this.exponent = 2;
|
|
14
|
-
this.generationCallback = ( polar, uv, coord, color ) => {
|
|
15
|
-
|
|
16
|
-
_direction.setFromSpherical( polar );
|
|
17
|
-
|
|
18
|
-
const t = _direction.y * 0.5 + 0.5;
|
|
19
|
-
color.lerpColors( this.bottomColor, this.topColor, t ** this.exponent );
|
|
20
|
-
|
|
21
|
-
};
|
|
22
|
-
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
copy( other ) {
|
|
26
|
-
|
|
27
|
-
super.copy( other );
|
|
28
|
-
|
|
29
|
-
this.topColor.copy( other.topColor );
|
|
30
|
-
this.bottomColor.copy( other.bottomColor );
|
|
31
|
-
return this;
|
|
32
|
-
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
}
|
|
1
|
+
import { Color, Vector3 } from 'three';
|
|
2
|
+
import { ProceduralEquirectTexture } from './ProceduralEquirectTexture.js';
|
|
3
|
+
|
|
4
|
+
const _direction = new Vector3();
|
|
5
|
+
export class GradientEquirectTexture extends ProceduralEquirectTexture {
|
|
6
|
+
|
|
7
|
+
constructor( resolution = 512 ) {
|
|
8
|
+
|
|
9
|
+
super( resolution, resolution );
|
|
10
|
+
|
|
11
|
+
this.topColor = new Color().set( 0xffffff );
|
|
12
|
+
this.bottomColor = new Color().set( 0x000000 );
|
|
13
|
+
this.exponent = 2;
|
|
14
|
+
this.generationCallback = ( polar, uv, coord, color ) => {
|
|
15
|
+
|
|
16
|
+
_direction.setFromSpherical( polar );
|
|
17
|
+
|
|
18
|
+
const t = _direction.y * 0.5 + 0.5;
|
|
19
|
+
color.lerpColors( this.bottomColor, this.topColor, t ** this.exponent );
|
|
20
|
+
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
copy( other ) {
|
|
26
|
+
|
|
27
|
+
super.copy( other );
|
|
28
|
+
|
|
29
|
+
this.topColor.copy( other.topColor );
|
|
30
|
+
this.bottomColor.copy( other.bottomColor );
|
|
31
|
+
return this;
|
|
32
|
+
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
}
|
|
@@ -1,75 +1,75 @@
|
|
|
1
|
-
import {
|
|
2
|
-
ClampToEdgeWrapping,
|
|
3
|
-
Color,
|
|
4
|
-
DataTexture,
|
|
5
|
-
EquirectangularReflectionMapping,
|
|
6
|
-
FloatType,
|
|
7
|
-
LinearFilter,
|
|
8
|
-
RepeatWrapping,
|
|
9
|
-
RGBAFormat,
|
|
10
|
-
Spherical,
|
|
11
|
-
Vector2,
|
|
12
|
-
} from 'three';
|
|
13
|
-
|
|
14
|
-
const _uv = new Vector2();
|
|
15
|
-
const _coord = new Vector2();
|
|
16
|
-
const _polar = new Spherical();
|
|
17
|
-
const _color = new Color();
|
|
18
|
-
export class ProceduralEquirectTexture extends DataTexture {
|
|
19
|
-
|
|
20
|
-
constructor( width, height ) {
|
|
21
|
-
|
|
22
|
-
super(
|
|
23
|
-
new Float32Array( width * height * 4 ),
|
|
24
|
-
width, height, RGBAFormat, FloatType, EquirectangularReflectionMapping,
|
|
25
|
-
RepeatWrapping, ClampToEdgeWrapping, LinearFilter, LinearFilter,
|
|
26
|
-
);
|
|
27
|
-
|
|
28
|
-
this.generationCallback = null;
|
|
29
|
-
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
update() {
|
|
33
|
-
|
|
34
|
-
this.dispose();
|
|
35
|
-
this.needsUpdate = true;
|
|
36
|
-
|
|
37
|
-
const { data, width, height } = this.image;
|
|
38
|
-
for ( let x = 0; x < width; x ++ ) {
|
|
39
|
-
|
|
40
|
-
for ( let y = 0; y < height; y ++ ) {
|
|
41
|
-
|
|
42
|
-
_coord.set( width, height );
|
|
43
|
-
|
|
44
|
-
_uv.set( x / width, y / height );
|
|
45
|
-
_uv.x -= 0.5;
|
|
46
|
-
_uv.y = 1.0 - _uv.y;
|
|
47
|
-
|
|
48
|
-
_polar.theta = _uv.x * 2.0 * Math.PI;
|
|
49
|
-
_polar.phi = _uv.y * Math.PI;
|
|
50
|
-
_polar.radius = 1.0;
|
|
51
|
-
|
|
52
|
-
this.generationCallback( _polar, _uv, _coord, _color );
|
|
53
|
-
|
|
54
|
-
const i = y * width + x;
|
|
55
|
-
const i4 = 4 * i;
|
|
56
|
-
data[ i4 + 0 ] = _color.r;
|
|
57
|
-
data[ i4 + 1 ] = _color.g;
|
|
58
|
-
data[ i4 + 2 ] = _color.b;
|
|
59
|
-
data[ i4 + 3 ] = 1.0;
|
|
60
|
-
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
copy( other ) {
|
|
68
|
-
|
|
69
|
-
super.copy( other );
|
|
70
|
-
this.generationCallback = other.generationCallback;
|
|
71
|
-
return this;
|
|
72
|
-
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
}
|
|
1
|
+
import {
|
|
2
|
+
ClampToEdgeWrapping,
|
|
3
|
+
Color,
|
|
4
|
+
DataTexture,
|
|
5
|
+
EquirectangularReflectionMapping,
|
|
6
|
+
FloatType,
|
|
7
|
+
LinearFilter,
|
|
8
|
+
RepeatWrapping,
|
|
9
|
+
RGBAFormat,
|
|
10
|
+
Spherical,
|
|
11
|
+
Vector2,
|
|
12
|
+
} from 'three';
|
|
13
|
+
|
|
14
|
+
const _uv = new Vector2();
|
|
15
|
+
const _coord = new Vector2();
|
|
16
|
+
const _polar = new Spherical();
|
|
17
|
+
const _color = new Color();
|
|
18
|
+
export class ProceduralEquirectTexture extends DataTexture {
|
|
19
|
+
|
|
20
|
+
constructor( width, height ) {
|
|
21
|
+
|
|
22
|
+
super(
|
|
23
|
+
new Float32Array( width * height * 4 ),
|
|
24
|
+
width, height, RGBAFormat, FloatType, EquirectangularReflectionMapping,
|
|
25
|
+
RepeatWrapping, ClampToEdgeWrapping, LinearFilter, LinearFilter,
|
|
26
|
+
);
|
|
27
|
+
|
|
28
|
+
this.generationCallback = null;
|
|
29
|
+
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
update() {
|
|
33
|
+
|
|
34
|
+
this.dispose();
|
|
35
|
+
this.needsUpdate = true;
|
|
36
|
+
|
|
37
|
+
const { data, width, height } = this.image;
|
|
38
|
+
for ( let x = 0; x < width; x ++ ) {
|
|
39
|
+
|
|
40
|
+
for ( let y = 0; y < height; y ++ ) {
|
|
41
|
+
|
|
42
|
+
_coord.set( width, height );
|
|
43
|
+
|
|
44
|
+
_uv.set( x / width, y / height );
|
|
45
|
+
_uv.x -= 0.5;
|
|
46
|
+
_uv.y = 1.0 - _uv.y;
|
|
47
|
+
|
|
48
|
+
_polar.theta = _uv.x * 2.0 * Math.PI;
|
|
49
|
+
_polar.phi = _uv.y * Math.PI;
|
|
50
|
+
_polar.radius = 1.0;
|
|
51
|
+
|
|
52
|
+
this.generationCallback( _polar, _uv, _coord, _color );
|
|
53
|
+
|
|
54
|
+
const i = y * width + x;
|
|
55
|
+
const i4 = 4 * i;
|
|
56
|
+
data[ i4 + 0 ] = _color.r;
|
|
57
|
+
data[ i4 + 1 ] = _color.g;
|
|
58
|
+
data[ i4 + 2 ] = _color.b;
|
|
59
|
+
data[ i4 + 3 ] = 1.0;
|
|
60
|
+
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
copy( other ) {
|
|
68
|
+
|
|
69
|
+
super.copy( other );
|
|
70
|
+
this.generationCallback = other.generationCallback;
|
|
71
|
+
return this;
|
|
72
|
+
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
}
|
|
@@ -1,35 +1,35 @@
|
|
|
1
|
-
import { FloatAttributeTextureArray } from './FloatAttributeTextureArray.js';
|
|
2
|
-
|
|
3
|
-
export class AttributesTextureArray extends FloatAttributeTextureArray {
|
|
4
|
-
|
|
5
|
-
updateNormalAttribute( attr ) {
|
|
6
|
-
|
|
7
|
-
this.updateAttribute( 0, attr );
|
|
8
|
-
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
updateTangentAttribute( attr ) {
|
|
12
|
-
|
|
13
|
-
this.updateAttribute( 1, attr );
|
|
14
|
-
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
updateUvAttribute( attr ) {
|
|
18
|
-
|
|
19
|
-
this.updateAttribute( 2, attr );
|
|
20
|
-
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
updateColorAttribute( attr ) {
|
|
24
|
-
|
|
25
|
-
this.updateAttribute( 3, attr );
|
|
26
|
-
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
updateFrom( normal, tangent, uv, color ) {
|
|
30
|
-
|
|
31
|
-
this.setAttributes( [ normal, tangent, uv, color ] );
|
|
32
|
-
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
}
|
|
1
|
+
import { FloatAttributeTextureArray } from './FloatAttributeTextureArray.js';
|
|
2
|
+
|
|
3
|
+
export class AttributesTextureArray extends FloatAttributeTextureArray {
|
|
4
|
+
|
|
5
|
+
updateNormalAttribute( attr ) {
|
|
6
|
+
|
|
7
|
+
this.updateAttribute( 0, attr );
|
|
8
|
+
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
updateTangentAttribute( attr ) {
|
|
12
|
+
|
|
13
|
+
this.updateAttribute( 1, attr );
|
|
14
|
+
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
updateUvAttribute( attr ) {
|
|
18
|
+
|
|
19
|
+
this.updateAttribute( 2, attr );
|
|
20
|
+
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
updateColorAttribute( attr ) {
|
|
24
|
+
|
|
25
|
+
this.updateAttribute( 3, attr );
|
|
26
|
+
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
updateFrom( normal, tangent, uv, color ) {
|
|
30
|
+
|
|
31
|
+
this.setAttributes( [ normal, tangent, uv, color ] );
|
|
32
|
+
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
}
|