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,142 +1,142 @@
|
|
|
1
|
-
import { NoBlending } from 'three';
|
|
2
|
-
import { MaterialBase } from './MaterialBase.js';
|
|
3
|
-
|
|
4
|
-
export class DenoiseMaterial extends MaterialBase {
|
|
5
|
-
|
|
6
|
-
constructor( parameters ) {
|
|
7
|
-
|
|
8
|
-
super( {
|
|
9
|
-
|
|
10
|
-
blending: NoBlending,
|
|
11
|
-
|
|
12
|
-
transparent: false,
|
|
13
|
-
|
|
14
|
-
depthWrite: false,
|
|
15
|
-
|
|
16
|
-
depthTest: false,
|
|
17
|
-
|
|
18
|
-
defines: {
|
|
19
|
-
|
|
20
|
-
USE_SLIDER: 0,
|
|
21
|
-
|
|
22
|
-
},
|
|
23
|
-
|
|
24
|
-
uniforms: {
|
|
25
|
-
|
|
26
|
-
sigma: { value: 5.0 },
|
|
27
|
-
threshold: { value: 0.03 },
|
|
28
|
-
kSigma: { value: 1.0 },
|
|
29
|
-
|
|
30
|
-
map: { value: null },
|
|
31
|
-
|
|
32
|
-
},
|
|
33
|
-
|
|
34
|
-
vertexShader: /* glsl */`
|
|
35
|
-
|
|
36
|
-
varying vec2 vUv;
|
|
37
|
-
|
|
38
|
-
void main() {
|
|
39
|
-
|
|
40
|
-
vUv = uv;
|
|
41
|
-
gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
|
|
42
|
-
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
`,
|
|
46
|
-
|
|
47
|
-
fragmentShader: /* glsl */`
|
|
48
|
-
|
|
49
|
-
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
50
|
-
// Copyright (c) 2018-2019 Michele Morrone
|
|
51
|
-
// All rights reserved.
|
|
52
|
-
//
|
|
53
|
-
// https://michelemorrone.eu - https://BrutPitt.com
|
|
54
|
-
//
|
|
55
|
-
// me@michelemorrone.eu - brutpitt@gmail.com
|
|
56
|
-
// twitter: @BrutPitt - github: BrutPitt
|
|
57
|
-
//
|
|
58
|
-
// https://github.com/BrutPitt/glslSmartDeNoise/
|
|
59
|
-
//
|
|
60
|
-
// This software is distributed under the terms of the BSD 2-Clause license
|
|
61
|
-
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
62
|
-
|
|
63
|
-
uniform sampler2D map;
|
|
64
|
-
|
|
65
|
-
uniform float sigma;
|
|
66
|
-
uniform float threshold;
|
|
67
|
-
uniform float kSigma;
|
|
68
|
-
|
|
69
|
-
varying vec2 vUv;
|
|
70
|
-
|
|
71
|
-
#define INV_SQRT_OF_2PI 0.39894228040143267793994605993439
|
|
72
|
-
#define INV_PI 0.31830988618379067153776752674503
|
|
73
|
-
|
|
74
|
-
// Parameters:
|
|
75
|
-
// sampler2D tex - sampler image / texture
|
|
76
|
-
// vec2 uv - actual fragment coord
|
|
77
|
-
// float sigma > 0 - sigma Standard Deviation
|
|
78
|
-
// float kSigma >= 0 - sigma coefficient
|
|
79
|
-
// kSigma * sigma --> radius of the circular kernel
|
|
80
|
-
// float threshold - edge sharpening threshold
|
|
81
|
-
vec4 smartDeNoise( sampler2D tex, vec2 uv, float sigma, float kSigma, float threshold ) {
|
|
82
|
-
|
|
83
|
-
float radius = round( kSigma * sigma );
|
|
84
|
-
float radQ = radius * radius;
|
|
85
|
-
|
|
86
|
-
float invSigmaQx2 = 0.5 / ( sigma * sigma );
|
|
87
|
-
float invSigmaQx2PI = INV_PI * invSigmaQx2;
|
|
88
|
-
|
|
89
|
-
float invThresholdSqx2 = 0.5 / ( threshold * threshold );
|
|
90
|
-
float invThresholdSqrt2PI = INV_SQRT_OF_2PI / threshold;
|
|
91
|
-
|
|
92
|
-
vec4 centrPx = texture2D( tex, uv );
|
|
93
|
-
centrPx.rgb *= centrPx.a;
|
|
94
|
-
|
|
95
|
-
float zBuff = 0.0;
|
|
96
|
-
vec4 aBuff = vec4( 0.0 );
|
|
97
|
-
vec2 size = vec2( textureSize( tex, 0 ) );
|
|
98
|
-
|
|
99
|
-
vec2 d;
|
|
100
|
-
for ( d.x = - radius; d.x <= radius; d.x ++ ) {
|
|
101
|
-
|
|
102
|
-
float pt = sqrt( radQ - d.x * d.x );
|
|
103
|
-
|
|
104
|
-
for ( d.y = - pt; d.y <= pt; d.y ++ ) {
|
|
105
|
-
|
|
106
|
-
float blurFactor = exp( - dot( d, d ) * invSigmaQx2 ) * invSigmaQx2PI;
|
|
107
|
-
|
|
108
|
-
vec4 walkPx = texture2D( tex, uv + d / size );
|
|
109
|
-
walkPx.rgb *= walkPx.a;
|
|
110
|
-
|
|
111
|
-
vec4 dC = walkPx - centrPx;
|
|
112
|
-
float deltaFactor = exp( - dot( dC.rgba, dC.rgba ) * invThresholdSqx2 ) * invThresholdSqrt2PI * blurFactor;
|
|
113
|
-
|
|
114
|
-
zBuff += deltaFactor;
|
|
115
|
-
aBuff += deltaFactor * walkPx;
|
|
116
|
-
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
return aBuff / zBuff;
|
|
122
|
-
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
void main() {
|
|
126
|
-
|
|
127
|
-
gl_FragColor = smartDeNoise( map, vec2( vUv.x, vUv.y ), sigma, kSigma, threshold );
|
|
128
|
-
#include <tonemapping_fragment>
|
|
129
|
-
#include <encodings_fragment>
|
|
130
|
-
#include <premultiplied_alpha_fragment>
|
|
131
|
-
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
`
|
|
135
|
-
|
|
136
|
-
} );
|
|
137
|
-
|
|
138
|
-
this.setValues( parameters );
|
|
139
|
-
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
}
|
|
1
|
+
import { NoBlending } from 'three';
|
|
2
|
+
import { MaterialBase } from './MaterialBase.js';
|
|
3
|
+
|
|
4
|
+
export class DenoiseMaterial extends MaterialBase {
|
|
5
|
+
|
|
6
|
+
constructor( parameters ) {
|
|
7
|
+
|
|
8
|
+
super( {
|
|
9
|
+
|
|
10
|
+
blending: NoBlending,
|
|
11
|
+
|
|
12
|
+
transparent: false,
|
|
13
|
+
|
|
14
|
+
depthWrite: false,
|
|
15
|
+
|
|
16
|
+
depthTest: false,
|
|
17
|
+
|
|
18
|
+
defines: {
|
|
19
|
+
|
|
20
|
+
USE_SLIDER: 0,
|
|
21
|
+
|
|
22
|
+
},
|
|
23
|
+
|
|
24
|
+
uniforms: {
|
|
25
|
+
|
|
26
|
+
sigma: { value: 5.0 },
|
|
27
|
+
threshold: { value: 0.03 },
|
|
28
|
+
kSigma: { value: 1.0 },
|
|
29
|
+
|
|
30
|
+
map: { value: null },
|
|
31
|
+
|
|
32
|
+
},
|
|
33
|
+
|
|
34
|
+
vertexShader: /* glsl */`
|
|
35
|
+
|
|
36
|
+
varying vec2 vUv;
|
|
37
|
+
|
|
38
|
+
void main() {
|
|
39
|
+
|
|
40
|
+
vUv = uv;
|
|
41
|
+
gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
|
|
42
|
+
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
`,
|
|
46
|
+
|
|
47
|
+
fragmentShader: /* glsl */`
|
|
48
|
+
|
|
49
|
+
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
50
|
+
// Copyright (c) 2018-2019 Michele Morrone
|
|
51
|
+
// All rights reserved.
|
|
52
|
+
//
|
|
53
|
+
// https://michelemorrone.eu - https://BrutPitt.com
|
|
54
|
+
//
|
|
55
|
+
// me@michelemorrone.eu - brutpitt@gmail.com
|
|
56
|
+
// twitter: @BrutPitt - github: BrutPitt
|
|
57
|
+
//
|
|
58
|
+
// https://github.com/BrutPitt/glslSmartDeNoise/
|
|
59
|
+
//
|
|
60
|
+
// This software is distributed under the terms of the BSD 2-Clause license
|
|
61
|
+
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
62
|
+
|
|
63
|
+
uniform sampler2D map;
|
|
64
|
+
|
|
65
|
+
uniform float sigma;
|
|
66
|
+
uniform float threshold;
|
|
67
|
+
uniform float kSigma;
|
|
68
|
+
|
|
69
|
+
varying vec2 vUv;
|
|
70
|
+
|
|
71
|
+
#define INV_SQRT_OF_2PI 0.39894228040143267793994605993439
|
|
72
|
+
#define INV_PI 0.31830988618379067153776752674503
|
|
73
|
+
|
|
74
|
+
// Parameters:
|
|
75
|
+
// sampler2D tex - sampler image / texture
|
|
76
|
+
// vec2 uv - actual fragment coord
|
|
77
|
+
// float sigma > 0 - sigma Standard Deviation
|
|
78
|
+
// float kSigma >= 0 - sigma coefficient
|
|
79
|
+
// kSigma * sigma --> radius of the circular kernel
|
|
80
|
+
// float threshold - edge sharpening threshold
|
|
81
|
+
vec4 smartDeNoise( sampler2D tex, vec2 uv, float sigma, float kSigma, float threshold ) {
|
|
82
|
+
|
|
83
|
+
float radius = round( kSigma * sigma );
|
|
84
|
+
float radQ = radius * radius;
|
|
85
|
+
|
|
86
|
+
float invSigmaQx2 = 0.5 / ( sigma * sigma );
|
|
87
|
+
float invSigmaQx2PI = INV_PI * invSigmaQx2;
|
|
88
|
+
|
|
89
|
+
float invThresholdSqx2 = 0.5 / ( threshold * threshold );
|
|
90
|
+
float invThresholdSqrt2PI = INV_SQRT_OF_2PI / threshold;
|
|
91
|
+
|
|
92
|
+
vec4 centrPx = texture2D( tex, uv );
|
|
93
|
+
centrPx.rgb *= centrPx.a;
|
|
94
|
+
|
|
95
|
+
float zBuff = 0.0;
|
|
96
|
+
vec4 aBuff = vec4( 0.0 );
|
|
97
|
+
vec2 size = vec2( textureSize( tex, 0 ) );
|
|
98
|
+
|
|
99
|
+
vec2 d;
|
|
100
|
+
for ( d.x = - radius; d.x <= radius; d.x ++ ) {
|
|
101
|
+
|
|
102
|
+
float pt = sqrt( radQ - d.x * d.x );
|
|
103
|
+
|
|
104
|
+
for ( d.y = - pt; d.y <= pt; d.y ++ ) {
|
|
105
|
+
|
|
106
|
+
float blurFactor = exp( - dot( d, d ) * invSigmaQx2 ) * invSigmaQx2PI;
|
|
107
|
+
|
|
108
|
+
vec4 walkPx = texture2D( tex, uv + d / size );
|
|
109
|
+
walkPx.rgb *= walkPx.a;
|
|
110
|
+
|
|
111
|
+
vec4 dC = walkPx - centrPx;
|
|
112
|
+
float deltaFactor = exp( - dot( dC.rgba, dC.rgba ) * invThresholdSqx2 ) * invThresholdSqrt2PI * blurFactor;
|
|
113
|
+
|
|
114
|
+
zBuff += deltaFactor;
|
|
115
|
+
aBuff += deltaFactor * walkPx;
|
|
116
|
+
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
return aBuff / zBuff;
|
|
122
|
+
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
void main() {
|
|
126
|
+
|
|
127
|
+
gl_FragColor = smartDeNoise( map, vec2( vUv.x, vUv.y ), sigma, kSigma, threshold );
|
|
128
|
+
#include <tonemapping_fragment>
|
|
129
|
+
#include <encodings_fragment>
|
|
130
|
+
#include <premultiplied_alpha_fragment>
|
|
131
|
+
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
`
|
|
135
|
+
|
|
136
|
+
} );
|
|
137
|
+
|
|
138
|
+
this.setValues( parameters );
|
|
139
|
+
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
}
|