@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.js
CHANGED
|
@@ -1155,6 +1155,24 @@ const $12b21d24d1192a04$export$a815acccbd2c9a49 = {
|
|
|
1155
1155
|
},
|
|
1156
1156
|
"distanceFalloff": {
|
|
1157
1157
|
value: 1
|
|
1158
|
+
},
|
|
1159
|
+
"fog": {
|
|
1160
|
+
value: false
|
|
1161
|
+
},
|
|
1162
|
+
"fogExp": {
|
|
1163
|
+
value: false
|
|
1164
|
+
},
|
|
1165
|
+
"fogDensity": {
|
|
1166
|
+
value: 0
|
|
1167
|
+
},
|
|
1168
|
+
"fogNear": {
|
|
1169
|
+
value: Infinity
|
|
1170
|
+
},
|
|
1171
|
+
"fogFar": {
|
|
1172
|
+
value: Infinity
|
|
1173
|
+
},
|
|
1174
|
+
"colorMultiply": {
|
|
1175
|
+
value: true
|
|
1158
1176
|
}
|
|
1159
1177
|
},
|
|
1160
1178
|
vertexShader: (
|
|
@@ -1186,8 +1204,15 @@ const $12b21d24d1192a04$export$a815acccbd2c9a49 = {
|
|
|
1186
1204
|
uniform bool logDepth;
|
|
1187
1205
|
uniform bool ortho;
|
|
1188
1206
|
uniform bool screenSpaceRadius;
|
|
1207
|
+
uniform bool fog;
|
|
1208
|
+
uniform bool fogExp;
|
|
1209
|
+
uniform bool colorMultiply;
|
|
1210
|
+
uniform float fogDensity;
|
|
1211
|
+
uniform float fogNear;
|
|
1212
|
+
uniform float fogFar;
|
|
1189
1213
|
uniform float radius;
|
|
1190
1214
|
uniform float distanceFalloff;
|
|
1215
|
+
uniform vec3 cameraPos;
|
|
1191
1216
|
varying vec2 vUv;
|
|
1192
1217
|
highp float linearize_depth(highp float d, highp float zNear,highp float zFar)
|
|
1193
1218
|
{
|
|
@@ -1267,12 +1292,11 @@ const $12b21d24d1192a04$export$a815acccbd2c9a49 = {
|
|
|
1267
1292
|
void main() {
|
|
1268
1293
|
//vec4 texel = texture2D(tDiffuse, vUv);//vec3(0.0);
|
|
1269
1294
|
vec4 sceneTexel = texture2D(sceneDiffuse, vUv);
|
|
1270
|
-
|
|
1271
|
-
#ifdef HALFRES
|
|
1272
1295
|
float depth = texture2D(
|
|
1273
1296
|
sceneDepth,
|
|
1274
1297
|
vUv
|
|
1275
1298
|
).x;
|
|
1299
|
+
#ifdef HALFRES
|
|
1276
1300
|
vec4 texel;
|
|
1277
1301
|
if (depth == 1.0) {
|
|
1278
1302
|
texel = vec4(0.0, 0.0, 0.0, 1.0);
|
|
@@ -1320,10 +1344,24 @@ const $12b21d24d1192a04$export$a815acccbd2c9a49 = {
|
|
|
1320
1344
|
|
|
1321
1345
|
|
|
1322
1346
|
float finalAo = pow(texel.a, intensity);
|
|
1347
|
+
float fogFactor;
|
|
1348
|
+
float fogDepth = distance(
|
|
1349
|
+
cameraPos,
|
|
1350
|
+
getWorldPos(depth, vUv)
|
|
1351
|
+
);
|
|
1352
|
+
if (fog) {
|
|
1353
|
+
if (fogExp) {
|
|
1354
|
+
fogFactor = 1.0 - exp( - fogDensity * fogDensity * fogDepth * fogDepth );
|
|
1355
|
+
} else {
|
|
1356
|
+
fogFactor = smoothstep( fogNear, fogFar, fogDepth );
|
|
1357
|
+
}
|
|
1358
|
+
}
|
|
1359
|
+
finalAo = mix(finalAo, 1.0, fogFactor);
|
|
1360
|
+
vec3 aoApplied = color * mix(vec3(1.0), sceneTexel.rgb, float(colorMultiply));
|
|
1323
1361
|
if (renderMode == 0.0) {
|
|
1324
|
-
gl_FragColor = vec4( mix(sceneTexel.rgb,
|
|
1362
|
+
gl_FragColor = vec4( mix(sceneTexel.rgb, aoApplied, 1.0 - finalAo), sceneTexel.a);
|
|
1325
1363
|
} else if (renderMode == 1.0) {
|
|
1326
|
-
gl_FragColor = vec4( mix(vec3(1.0),
|
|
1364
|
+
gl_FragColor = vec4( mix(vec3(1.0), aoApplied, 1.0 - finalAo), sceneTexel.a);
|
|
1327
1365
|
} else if (renderMode == 2.0) {
|
|
1328
1366
|
gl_FragColor = vec4( sceneTexel.rgb, sceneTexel.a);
|
|
1329
1367
|
} else if (renderMode == 3.0) {
|
|
@@ -1332,7 +1370,7 @@ const $12b21d24d1192a04$export$a815acccbd2c9a49 = {
|
|
|
1332
1370
|
} else if (abs(vUv.x - 0.5) < 1.0 / resolution.x) {
|
|
1333
1371
|
gl_FragColor = vec4(1.0);
|
|
1334
1372
|
} else {
|
|
1335
|
-
gl_FragColor = vec4( mix(sceneTexel.rgb,
|
|
1373
|
+
gl_FragColor = vec4( mix(sceneTexel.rgb, aoApplied, 1.0 - finalAo), sceneTexel.a);
|
|
1336
1374
|
}
|
|
1337
1375
|
} else if (renderMode == 4.0) {
|
|
1338
1376
|
if (vUv.x < 0.5) {
|
|
@@ -1340,7 +1378,7 @@ const $12b21d24d1192a04$export$a815acccbd2c9a49 = {
|
|
|
1340
1378
|
} else if (abs(vUv.x - 0.5) < 1.0 / resolution.x) {
|
|
1341
1379
|
gl_FragColor = vec4(1.0);
|
|
1342
1380
|
} else {
|
|
1343
|
-
gl_FragColor = vec4( mix(vec3(1.0),
|
|
1381
|
+
gl_FragColor = vec4( mix(vec3(1.0), aoApplied, 1.0 - finalAo), sceneTexel.a);
|
|
1344
1382
|
}
|
|
1345
1383
|
}
|
|
1346
1384
|
#include <dithering_fragment>
|
|
@@ -1764,7 +1802,8 @@ class $87431ee93b037844$export$2489f9981ab0fa82 extends Pass {
|
|
|
1764
1802
|
logarithmicDepthBuffer: false,
|
|
1765
1803
|
screenSpaceRadius: false,
|
|
1766
1804
|
halfRes: false,
|
|
1767
|
-
depthAwareUpsampling: true
|
|
1805
|
+
depthAwareUpsampling: true,
|
|
1806
|
+
colorMultiply: true
|
|
1768
1807
|
}, {
|
|
1769
1808
|
set: (target, propName, value) => {
|
|
1770
1809
|
const oldProp = target[propName];
|
|
@@ -1798,6 +1837,7 @@ class $87431ee93b037844$export$2489f9981ab0fa82 extends Pass {
|
|
|
1798
1837
|
value: null
|
|
1799
1838
|
}
|
|
1800
1839
|
},
|
|
1840
|
+
depthWrite: false,
|
|
1801
1841
|
vertexShader: `
|
|
1802
1842
|
varying vec2 vUv;
|
|
1803
1843
|
void main() {
|
|
@@ -1823,6 +1863,11 @@ class $87431ee93b037844$export$2489f9981ab0fa82 extends Pass {
|
|
|
1823
1863
|
magFilter: LinearFilter,
|
|
1824
1864
|
depthBuffer: false
|
|
1825
1865
|
});
|
|
1866
|
+
this.outputTargetInternal = new WebGLRenderTarget(this.width, this.height, {
|
|
1867
|
+
minFilter: LinearFilter,
|
|
1868
|
+
magFilter: LinearFilter,
|
|
1869
|
+
depthBuffer: false
|
|
1870
|
+
});
|
|
1826
1871
|
this.bluenoise = new DataTexture($87431ee93b037844$var$bluenoiseBits, 128, 128);
|
|
1827
1872
|
this.bluenoise.colorSpace = NoColorSpace;
|
|
1828
1873
|
this.bluenoise.wrapS = RepeatWrapping;
|
|
@@ -1832,6 +1877,7 @@ class $87431ee93b037844$export$2489f9981ab0fa82 extends Pass {
|
|
|
1832
1877
|
this.bluenoise.needsUpdate = true;
|
|
1833
1878
|
this.lastTime = 0;
|
|
1834
1879
|
this.needsDepthTexture = true;
|
|
1880
|
+
this.needsSwap = true;
|
|
1835
1881
|
this._r = new Vector2();
|
|
1836
1882
|
this._c = new Color();
|
|
1837
1883
|
}
|
|
@@ -1972,6 +2018,7 @@ class $87431ee93b037844$export$2489f9981ab0fa82 extends Pass {
|
|
|
1972
2018
|
this.readTargetInternal.setSize(width * c, height * c);
|
|
1973
2019
|
if (this.configuration.halfRes)
|
|
1974
2020
|
this.depthDownsampleTarget.setSize(width * c, height * c);
|
|
2021
|
+
this.outputTargetInternal.setSize(width, height);
|
|
1975
2022
|
}
|
|
1976
2023
|
setDepthTexture(depthTexture) {
|
|
1977
2024
|
this.depthTexture = depthTexture;
|
|
@@ -1985,6 +2032,10 @@ class $87431ee93b037844$export$2489f9981ab0fa82 extends Pass {
|
|
|
1985
2032
|
this.configureDenoisePass(this.configuration.logarithmicDepthBuffer);
|
|
1986
2033
|
this.configureEffectCompositer(this.configuration.logarithmicDepthBuffer);
|
|
1987
2034
|
}
|
|
2035
|
+
if (inputBuffer.texture.type !== this.outputTargetInternal.texture.type) {
|
|
2036
|
+
this.outputTargetInternal.texture.type = inputBuffer.texture.type;
|
|
2037
|
+
this.outputTargetInternal.texture.needsUpdate = true;
|
|
2038
|
+
}
|
|
1988
2039
|
let gl;
|
|
1989
2040
|
let ext;
|
|
1990
2041
|
let timerQuery;
|
|
@@ -2024,7 +2075,7 @@ class $87431ee93b037844$export$2489f9981ab0fa82 extends Pass {
|
|
|
2024
2075
|
this.effectShaderQuad.material.uniforms["projViewMat"].value = this.camera.projectionMatrix.clone().multiply(this.camera.matrixWorldInverse.clone());
|
|
2025
2076
|
this.effectShaderQuad.material.uniforms["projectionMatrixInv"].value = this.camera.projectionMatrixInverse;
|
|
2026
2077
|
this.effectShaderQuad.material.uniforms["viewMatrixInv"].value = this.camera.matrixWorld;
|
|
2027
|
-
this.effectShaderQuad.material.uniforms["cameraPos"].value = this.camera.
|
|
2078
|
+
this.effectShaderQuad.material.uniforms["cameraPos"].value = this.camera.getWorldPosition(new Vector3());
|
|
2028
2079
|
this.effectShaderQuad.material.uniforms["resolution"].value = this.configuration.halfRes ? this._r.clone().multiplyScalar(0.5).floor() : this._r;
|
|
2029
2080
|
this.effectShaderQuad.material.uniforms["time"].value = performance.now() / 1e3;
|
|
2030
2081
|
this.effectShaderQuad.material.uniforms["samples"].value = this.samples;
|
|
@@ -2050,7 +2101,7 @@ class $87431ee93b037844$export$2489f9981ab0fa82 extends Pass {
|
|
|
2050
2101
|
this.poissonBlurQuad.material.uniforms["viewMat"].value = this.camera.matrixWorldInverse;
|
|
2051
2102
|
this.poissonBlurQuad.material.uniforms["projectionMatrixInv"].value = this.camera.projectionMatrixInverse;
|
|
2052
2103
|
this.poissonBlurQuad.material.uniforms["viewMatrixInv"].value = this.camera.matrixWorld;
|
|
2053
|
-
this.poissonBlurQuad.material.uniforms["cameraPos"].value = this.camera.
|
|
2104
|
+
this.poissonBlurQuad.material.uniforms["cameraPos"].value = this.camera.getWorldPosition(new Vector3());
|
|
2054
2105
|
this.poissonBlurQuad.material.uniforms["resolution"].value = this.configuration.halfRes ? this._r.clone().multiplyScalar(0.5).floor() : this._r;
|
|
2055
2106
|
this.poissonBlurQuad.material.uniforms["time"].value = performance.now() / 1e3;
|
|
2056
2107
|
this.poissonBlurQuad.material.uniforms["blueNoise"].value = this.bluenoise;
|
|
@@ -2085,8 +2136,29 @@ class $87431ee93b037844$export$2489f9981ab0fa82 extends Pass {
|
|
|
2085
2136
|
this.effectCompositerQuad.material.uniforms["gammaCorrection"].value = this.autosetGamma ? this.renderToScreen : this.configuration.gammaCorrection;
|
|
2086
2137
|
this.effectCompositerQuad.material.uniforms["tDiffuse"].value = this.writeTargetInternal.texture;
|
|
2087
2138
|
this.effectCompositerQuad.material.uniforms["color"].value = this._c.copy(this.configuration.color).convertSRGBToLinear();
|
|
2088
|
-
|
|
2139
|
+
this.effectCompositerQuad.material.uniforms["colorMultiply"].value = this.configuration.colorMultiply;
|
|
2140
|
+
this.effectCompositerQuad.material.uniforms["cameraPos"].value = this.camera.getWorldPosition(new Vector3());
|
|
2141
|
+
this.effectCompositerQuad.material.uniforms["fog"].value = !!this.scene.fog;
|
|
2142
|
+
if (this.scene.fog) {
|
|
2143
|
+
if (this.scene.fog.isFog) {
|
|
2144
|
+
this.effectCompositerQuad.material.uniforms["fogExp"].value = false;
|
|
2145
|
+
this.effectCompositerQuad.material.uniforms["fogNear"].value = this.scene.fog.near;
|
|
2146
|
+
this.effectCompositerQuad.material.uniforms["fogFar"].value = this.scene.fog.far;
|
|
2147
|
+
} else if (this.scene.fog.isFogExp2) {
|
|
2148
|
+
this.effectCompositerQuad.material.uniforms["fogExp"].value = true;
|
|
2149
|
+
this.effectCompositerQuad.material.uniforms["fogDensity"].value = this.scene.fog.density;
|
|
2150
|
+
} else
|
|
2151
|
+
console.error(`Unsupported fog type ${this.scene.fog.constructor.name} in SSAOPass.`);
|
|
2152
|
+
}
|
|
2153
|
+
renderer.setRenderTarget(
|
|
2154
|
+
/* this.renderToScreen ? null :
|
|
2155
|
+
outputBuffer*/
|
|
2156
|
+
this.outputTargetInternal
|
|
2157
|
+
);
|
|
2089
2158
|
this.effectCompositerQuad.render(renderer);
|
|
2159
|
+
renderer.setRenderTarget(this.renderToScreen ? null : outputBuffer);
|
|
2160
|
+
this.copyQuad.material.uniforms["tDiffuse"].value = this.outputTargetInternal.texture;
|
|
2161
|
+
this.copyQuad.render(renderer);
|
|
2090
2162
|
if (this.debugMode) {
|
|
2091
2163
|
gl.endQuery(ext.TIME_ELAPSED_EXT);
|
|
2092
2164
|
$87431ee93b037844$var$checkTimerQuery(timerQuery, gl, this);
|