three-gpu-pathtracer 0.0.13 → 0.0.14
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 +981 -961
- package/build/index.module.js +6965 -6508
- package/build/index.module.js.map +1 -1
- package/build/index.umd.cjs +6959 -6505
- package/build/index.umd.cjs.map +1 -1
- package/package.json +73 -73
- package/src/core/DynamicPathTracingSceneGenerator.js +119 -119
- package/src/core/MaterialReducer.js +256 -256
- package/src/core/PathTracingRenderer.js +346 -346
- package/src/core/PathTracingSceneGenerator.js +69 -69
- package/src/core/QuiltPathTracingRenderer.js +223 -223
- package/src/index.js +36 -40
- package/src/materials/MaterialBase.js +56 -56
- package/src/materials/{GraphMaterial.js → debug/GraphMaterial.js} +243 -243
- package/src/materials/{AlphaDisplayMaterial.js → fullscreen/AlphaDisplayMaterial.js} +48 -48
- package/src/materials/{BlendMaterial.js → fullscreen/BlendMaterial.js} +67 -67
- package/src/materials/{DenoiseMaterial.js → fullscreen/DenoiseMaterial.js} +142 -142
- package/src/materials/{LambertPathTracingMaterial.js → pathtracing/LambertPathTracingMaterial.js} +296 -285
- package/src/materials/pathtracing/PhysicalPathTracingMaterial.js +635 -0
- package/src/materials/pathtracing/glsl/attenuateHit.glsl.js +179 -0
- package/src/materials/pathtracing/glsl/cameraUtils.glsl.js +81 -0
- package/src/materials/pathtracing/glsl/getSurfaceRecord.glsl.js +317 -0
- package/src/materials/pathtracing/glsl/traceScene.glsl.js +54 -0
- package/src/materials/{AmbientOcclusionMaterial.js → surface/AmbientOcclusionMaterial.js} +207 -199
- package/src/materials/surface/FogVolumeMaterial.js +23 -0
- 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/bsdf/bsdfSampling.glsl.js +490 -0
- package/src/shader/bsdf/fog.glsl.js +23 -0
- package/src/shader/bsdf/ggx.glsl.js +102 -0
- package/src/shader/bsdf/iridescence.glsl.js +135 -0
- package/src/shader/bsdf/sheen.glsl.js +98 -0
- package/src/shader/{shaderLayerTexelFetchFunctions.js → common/arraySamplerTexelFetch.glsl.js} +25 -25
- package/src/shader/common/bvhAnyHit.glsl.js +76 -0
- package/src/shader/common/fresnel.glsl.js +98 -0
- package/src/shader/common/intersectShapes.glsl.js +62 -0
- package/src/shader/common/math.glsl.js +81 -0
- package/src/shader/common/utils.glsl.js +116 -0
- package/src/shader/{shaderRandFunctions.js → rand/pcg.glsl.js} +57 -57
- package/src/shader/{shaderSobolSampling.js → rand/sobol.glsl.js} +256 -256
- package/src/shader/sampling/equirectSampling.glsl.js +62 -0
- package/src/shader/sampling/lightSampling.glsl.js +223 -0
- package/src/shader/sampling/shapeSampling.glsl.js +86 -0
- package/src/shader/structs/cameraStruct.glsl.js +13 -0
- package/src/shader/structs/equirectStruct.glsl.js +14 -0
- package/src/shader/structs/fogMaterialBvh.glsl.js +62 -0
- package/src/shader/structs/lightsStruct.glsl.js +78 -0
- package/src/shader/{shaderStructs.js → structs/materialStruct.glsl.js} +207 -327
- 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 +277 -273
- package/src/uniforms/FloatAttributeTextureArray.js +169 -169
- package/src/uniforms/IESProfilesTexture.js +100 -100
- package/src/uniforms/LightsInfoUniformStruct.js +212 -212
- package/src/uniforms/MaterialsTexture.js +503 -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/utils/macroify.js +9 -0
- package/src/workers/PathTracingSceneWorker.js +42 -42
- package/src/materials/PhysicalPathTracingMaterial.js +0 -1013
- package/src/shader/shaderBvhAnyHit.js +0 -76
- package/src/shader/shaderEnvMapSampling.js +0 -58
- package/src/shader/shaderGGXFunctions.js +0 -100
- package/src/shader/shaderIridescenceFunctions.js +0 -135
- package/src/shader/shaderLightSampling.js +0 -229
- package/src/shader/shaderMaterialSampling.js +0 -510
- package/src/shader/shaderSheenFunctions.js +0 -98
- package/src/shader/shaderUtils.js +0 -377
|
@@ -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
|
+
}
|