@react-three/postprocessing 2.14.9 → 2.14.10
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/dist/index.cjs +82 -10
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +82 -10
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -1173,6 +1173,24 @@ const $12b21d24d1192a04$export$a815acccbd2c9a49 = {
|
|
|
1173
1173
|
},
|
|
1174
1174
|
"distanceFalloff": {
|
|
1175
1175
|
value: 1
|
|
1176
|
+
},
|
|
1177
|
+
"fog": {
|
|
1178
|
+
value: false
|
|
1179
|
+
},
|
|
1180
|
+
"fogExp": {
|
|
1181
|
+
value: false
|
|
1182
|
+
},
|
|
1183
|
+
"fogDensity": {
|
|
1184
|
+
value: 0
|
|
1185
|
+
},
|
|
1186
|
+
"fogNear": {
|
|
1187
|
+
value: Infinity
|
|
1188
|
+
},
|
|
1189
|
+
"fogFar": {
|
|
1190
|
+
value: Infinity
|
|
1191
|
+
},
|
|
1192
|
+
"colorMultiply": {
|
|
1193
|
+
value: true
|
|
1176
1194
|
}
|
|
1177
1195
|
},
|
|
1178
1196
|
vertexShader: (
|
|
@@ -1204,8 +1222,15 @@ const $12b21d24d1192a04$export$a815acccbd2c9a49 = {
|
|
|
1204
1222
|
uniform bool logDepth;
|
|
1205
1223
|
uniform bool ortho;
|
|
1206
1224
|
uniform bool screenSpaceRadius;
|
|
1225
|
+
uniform bool fog;
|
|
1226
|
+
uniform bool fogExp;
|
|
1227
|
+
uniform bool colorMultiply;
|
|
1228
|
+
uniform float fogDensity;
|
|
1229
|
+
uniform float fogNear;
|
|
1230
|
+
uniform float fogFar;
|
|
1207
1231
|
uniform float radius;
|
|
1208
1232
|
uniform float distanceFalloff;
|
|
1233
|
+
uniform vec3 cameraPos;
|
|
1209
1234
|
varying vec2 vUv;
|
|
1210
1235
|
highp float linearize_depth(highp float d, highp float zNear,highp float zFar)
|
|
1211
1236
|
{
|
|
@@ -1285,12 +1310,11 @@ const $12b21d24d1192a04$export$a815acccbd2c9a49 = {
|
|
|
1285
1310
|
void main() {
|
|
1286
1311
|
//vec4 texel = texture2D(tDiffuse, vUv);//vec3(0.0);
|
|
1287
1312
|
vec4 sceneTexel = texture2D(sceneDiffuse, vUv);
|
|
1288
|
-
|
|
1289
|
-
#ifdef HALFRES
|
|
1290
1313
|
float depth = texture2D(
|
|
1291
1314
|
sceneDepth,
|
|
1292
1315
|
vUv
|
|
1293
1316
|
).x;
|
|
1317
|
+
#ifdef HALFRES
|
|
1294
1318
|
vec4 texel;
|
|
1295
1319
|
if (depth == 1.0) {
|
|
1296
1320
|
texel = vec4(0.0, 0.0, 0.0, 1.0);
|
|
@@ -1338,10 +1362,24 @@ const $12b21d24d1192a04$export$a815acccbd2c9a49 = {
|
|
|
1338
1362
|
|
|
1339
1363
|
|
|
1340
1364
|
float finalAo = pow(texel.a, intensity);
|
|
1365
|
+
float fogFactor;
|
|
1366
|
+
float fogDepth = distance(
|
|
1367
|
+
cameraPos,
|
|
1368
|
+
getWorldPos(depth, vUv)
|
|
1369
|
+
);
|
|
1370
|
+
if (fog) {
|
|
1371
|
+
if (fogExp) {
|
|
1372
|
+
fogFactor = 1.0 - exp( - fogDensity * fogDensity * fogDepth * fogDepth );
|
|
1373
|
+
} else {
|
|
1374
|
+
fogFactor = smoothstep( fogNear, fogFar, fogDepth );
|
|
1375
|
+
}
|
|
1376
|
+
}
|
|
1377
|
+
finalAo = mix(finalAo, 1.0, fogFactor);
|
|
1378
|
+
vec3 aoApplied = color * mix(vec3(1.0), sceneTexel.rgb, float(colorMultiply));
|
|
1341
1379
|
if (renderMode == 0.0) {
|
|
1342
|
-
gl_FragColor = vec4( mix(sceneTexel.rgb,
|
|
1380
|
+
gl_FragColor = vec4( mix(sceneTexel.rgb, aoApplied, 1.0 - finalAo), sceneTexel.a);
|
|
1343
1381
|
} else if (renderMode == 1.0) {
|
|
1344
|
-
gl_FragColor = vec4( mix(vec3(1.0),
|
|
1382
|
+
gl_FragColor = vec4( mix(vec3(1.0), aoApplied, 1.0 - finalAo), sceneTexel.a);
|
|
1345
1383
|
} else if (renderMode == 2.0) {
|
|
1346
1384
|
gl_FragColor = vec4( sceneTexel.rgb, sceneTexel.a);
|
|
1347
1385
|
} else if (renderMode == 3.0) {
|
|
@@ -1350,7 +1388,7 @@ const $12b21d24d1192a04$export$a815acccbd2c9a49 = {
|
|
|
1350
1388
|
} else if (abs(vUv.x - 0.5) < 1.0 / resolution.x) {
|
|
1351
1389
|
gl_FragColor = vec4(1.0);
|
|
1352
1390
|
} else {
|
|
1353
|
-
gl_FragColor = vec4( mix(sceneTexel.rgb,
|
|
1391
|
+
gl_FragColor = vec4( mix(sceneTexel.rgb, aoApplied, 1.0 - finalAo), sceneTexel.a);
|
|
1354
1392
|
}
|
|
1355
1393
|
} else if (renderMode == 4.0) {
|
|
1356
1394
|
if (vUv.x < 0.5) {
|
|
@@ -1358,7 +1396,7 @@ const $12b21d24d1192a04$export$a815acccbd2c9a49 = {
|
|
|
1358
1396
|
} else if (abs(vUv.x - 0.5) < 1.0 / resolution.x) {
|
|
1359
1397
|
gl_FragColor = vec4(1.0);
|
|
1360
1398
|
} else {
|
|
1361
|
-
gl_FragColor = vec4( mix(vec3(1.0),
|
|
1399
|
+
gl_FragColor = vec4( mix(vec3(1.0), aoApplied, 1.0 - finalAo), sceneTexel.a);
|
|
1362
1400
|
}
|
|
1363
1401
|
}
|
|
1364
1402
|
#include <dithering_fragment>
|
|
@@ -1782,7 +1820,8 @@ class $87431ee93b037844$export$2489f9981ab0fa82 extends postprocessing.Pass {
|
|
|
1782
1820
|
logarithmicDepthBuffer: false,
|
|
1783
1821
|
screenSpaceRadius: false,
|
|
1784
1822
|
halfRes: false,
|
|
1785
|
-
depthAwareUpsampling: true
|
|
1823
|
+
depthAwareUpsampling: true,
|
|
1824
|
+
colorMultiply: true
|
|
1786
1825
|
}, {
|
|
1787
1826
|
set: (target, propName, value) => {
|
|
1788
1827
|
const oldProp = target[propName];
|
|
@@ -1816,6 +1855,7 @@ class $87431ee93b037844$export$2489f9981ab0fa82 extends postprocessing.Pass {
|
|
|
1816
1855
|
value: null
|
|
1817
1856
|
}
|
|
1818
1857
|
},
|
|
1858
|
+
depthWrite: false,
|
|
1819
1859
|
vertexShader: `
|
|
1820
1860
|
varying vec2 vUv;
|
|
1821
1861
|
void main() {
|
|
@@ -1841,6 +1881,11 @@ class $87431ee93b037844$export$2489f9981ab0fa82 extends postprocessing.Pass {
|
|
|
1841
1881
|
magFilter: THREE.LinearFilter,
|
|
1842
1882
|
depthBuffer: false
|
|
1843
1883
|
});
|
|
1884
|
+
this.outputTargetInternal = new THREE.WebGLRenderTarget(this.width, this.height, {
|
|
1885
|
+
minFilter: THREE.LinearFilter,
|
|
1886
|
+
magFilter: THREE.LinearFilter,
|
|
1887
|
+
depthBuffer: false
|
|
1888
|
+
});
|
|
1844
1889
|
this.bluenoise = new THREE.DataTexture($87431ee93b037844$var$bluenoiseBits, 128, 128);
|
|
1845
1890
|
this.bluenoise.colorSpace = THREE.NoColorSpace;
|
|
1846
1891
|
this.bluenoise.wrapS = THREE.RepeatWrapping;
|
|
@@ -1850,6 +1895,7 @@ class $87431ee93b037844$export$2489f9981ab0fa82 extends postprocessing.Pass {
|
|
|
1850
1895
|
this.bluenoise.needsUpdate = true;
|
|
1851
1896
|
this.lastTime = 0;
|
|
1852
1897
|
this.needsDepthTexture = true;
|
|
1898
|
+
this.needsSwap = true;
|
|
1853
1899
|
this._r = new THREE.Vector2();
|
|
1854
1900
|
this._c = new THREE.Color();
|
|
1855
1901
|
}
|
|
@@ -1990,6 +2036,7 @@ class $87431ee93b037844$export$2489f9981ab0fa82 extends postprocessing.Pass {
|
|
|
1990
2036
|
this.readTargetInternal.setSize(width * c, height * c);
|
|
1991
2037
|
if (this.configuration.halfRes)
|
|
1992
2038
|
this.depthDownsampleTarget.setSize(width * c, height * c);
|
|
2039
|
+
this.outputTargetInternal.setSize(width, height);
|
|
1993
2040
|
}
|
|
1994
2041
|
setDepthTexture(depthTexture) {
|
|
1995
2042
|
this.depthTexture = depthTexture;
|
|
@@ -2003,6 +2050,10 @@ class $87431ee93b037844$export$2489f9981ab0fa82 extends postprocessing.Pass {
|
|
|
2003
2050
|
this.configureDenoisePass(this.configuration.logarithmicDepthBuffer);
|
|
2004
2051
|
this.configureEffectCompositer(this.configuration.logarithmicDepthBuffer);
|
|
2005
2052
|
}
|
|
2053
|
+
if (inputBuffer.texture.type !== this.outputTargetInternal.texture.type) {
|
|
2054
|
+
this.outputTargetInternal.texture.type = inputBuffer.texture.type;
|
|
2055
|
+
this.outputTargetInternal.texture.needsUpdate = true;
|
|
2056
|
+
}
|
|
2006
2057
|
let gl;
|
|
2007
2058
|
let ext;
|
|
2008
2059
|
let timerQuery;
|
|
@@ -2042,7 +2093,7 @@ class $87431ee93b037844$export$2489f9981ab0fa82 extends postprocessing.Pass {
|
|
|
2042
2093
|
this.effectShaderQuad.material.uniforms["projViewMat"].value = this.camera.projectionMatrix.clone().multiply(this.camera.matrixWorldInverse.clone());
|
|
2043
2094
|
this.effectShaderQuad.material.uniforms["projectionMatrixInv"].value = this.camera.projectionMatrixInverse;
|
|
2044
2095
|
this.effectShaderQuad.material.uniforms["viewMatrixInv"].value = this.camera.matrixWorld;
|
|
2045
|
-
this.effectShaderQuad.material.uniforms["cameraPos"].value = this.camera.
|
|
2096
|
+
this.effectShaderQuad.material.uniforms["cameraPos"].value = this.camera.getWorldPosition(new THREE.Vector3());
|
|
2046
2097
|
this.effectShaderQuad.material.uniforms["resolution"].value = this.configuration.halfRes ? this._r.clone().multiplyScalar(0.5).floor() : this._r;
|
|
2047
2098
|
this.effectShaderQuad.material.uniforms["time"].value = performance.now() / 1e3;
|
|
2048
2099
|
this.effectShaderQuad.material.uniforms["samples"].value = this.samples;
|
|
@@ -2068,7 +2119,7 @@ class $87431ee93b037844$export$2489f9981ab0fa82 extends postprocessing.Pass {
|
|
|
2068
2119
|
this.poissonBlurQuad.material.uniforms["viewMat"].value = this.camera.matrixWorldInverse;
|
|
2069
2120
|
this.poissonBlurQuad.material.uniforms["projectionMatrixInv"].value = this.camera.projectionMatrixInverse;
|
|
2070
2121
|
this.poissonBlurQuad.material.uniforms["viewMatrixInv"].value = this.camera.matrixWorld;
|
|
2071
|
-
this.poissonBlurQuad.material.uniforms["cameraPos"].value = this.camera.
|
|
2122
|
+
this.poissonBlurQuad.material.uniforms["cameraPos"].value = this.camera.getWorldPosition(new THREE.Vector3());
|
|
2072
2123
|
this.poissonBlurQuad.material.uniforms["resolution"].value = this.configuration.halfRes ? this._r.clone().multiplyScalar(0.5).floor() : this._r;
|
|
2073
2124
|
this.poissonBlurQuad.material.uniforms["time"].value = performance.now() / 1e3;
|
|
2074
2125
|
this.poissonBlurQuad.material.uniforms["blueNoise"].value = this.bluenoise;
|
|
@@ -2103,8 +2154,29 @@ class $87431ee93b037844$export$2489f9981ab0fa82 extends postprocessing.Pass {
|
|
|
2103
2154
|
this.effectCompositerQuad.material.uniforms["gammaCorrection"].value = this.autosetGamma ? this.renderToScreen : this.configuration.gammaCorrection;
|
|
2104
2155
|
this.effectCompositerQuad.material.uniforms["tDiffuse"].value = this.writeTargetInternal.texture;
|
|
2105
2156
|
this.effectCompositerQuad.material.uniforms["color"].value = this._c.copy(this.configuration.color).convertSRGBToLinear();
|
|
2106
|
-
|
|
2157
|
+
this.effectCompositerQuad.material.uniforms["colorMultiply"].value = this.configuration.colorMultiply;
|
|
2158
|
+
this.effectCompositerQuad.material.uniforms["cameraPos"].value = this.camera.getWorldPosition(new THREE.Vector3());
|
|
2159
|
+
this.effectCompositerQuad.material.uniforms["fog"].value = !!this.scene.fog;
|
|
2160
|
+
if (this.scene.fog) {
|
|
2161
|
+
if (this.scene.fog.isFog) {
|
|
2162
|
+
this.effectCompositerQuad.material.uniforms["fogExp"].value = false;
|
|
2163
|
+
this.effectCompositerQuad.material.uniforms["fogNear"].value = this.scene.fog.near;
|
|
2164
|
+
this.effectCompositerQuad.material.uniforms["fogFar"].value = this.scene.fog.far;
|
|
2165
|
+
} else if (this.scene.fog.isFogExp2) {
|
|
2166
|
+
this.effectCompositerQuad.material.uniforms["fogExp"].value = true;
|
|
2167
|
+
this.effectCompositerQuad.material.uniforms["fogDensity"].value = this.scene.fog.density;
|
|
2168
|
+
} else
|
|
2169
|
+
console.error(`Unsupported fog type ${this.scene.fog.constructor.name} in SSAOPass.`);
|
|
2170
|
+
}
|
|
2171
|
+
renderer.setRenderTarget(
|
|
2172
|
+
/* this.renderToScreen ? null :
|
|
2173
|
+
outputBuffer*/
|
|
2174
|
+
this.outputTargetInternal
|
|
2175
|
+
);
|
|
2107
2176
|
this.effectCompositerQuad.render(renderer);
|
|
2177
|
+
renderer.setRenderTarget(this.renderToScreen ? null : outputBuffer);
|
|
2178
|
+
this.copyQuad.material.uniforms["tDiffuse"].value = this.outputTargetInternal.texture;
|
|
2179
|
+
this.copyQuad.render(renderer);
|
|
2108
2180
|
if (this.debugMode) {
|
|
2109
2181
|
gl.endQuery(ext.TIME_ELAPSED_EXT);
|
|
2110
2182
|
$87431ee93b037844$var$checkTimerQuery(timerQuery, gl, this);
|