@react-three/postprocessing 2.3.2 → 2.4.1
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/README.md +1 -1
- package/dist/effects/SSR.d.ts +47 -0
- package/dist/{index.cjs.js → index.cjs} +108 -16
- package/dist/index.d.ts +1 -0
- package/dist/index.js +83 -2
- package/package.json +5 -9
package/README.md
CHANGED
|
@@ -124,4 +124,4 @@ Selection can be nested and group multiple object, higher up selection take prec
|
|
|
124
124
|
```
|
|
125
125
|
|
|
126
126
|
- [react-postprocessing exports](https://github.com/pmndrs/react-postprocessing/blob/master/api.md)
|
|
127
|
-
- [postprocessing docs](https://
|
|
127
|
+
- [postprocessing docs](https://pmndrs.github.io/postprocessing/public/docs/)
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
declare type SSRProps = {
|
|
3
|
+
/** Enables the effect pass */
|
|
4
|
+
enabled: boolean;
|
|
5
|
+
/** Size of the blur buffer */
|
|
6
|
+
blurSize: number;
|
|
7
|
+
/** Whether to blur the reflections and blend these blurred reflections depending on the roughness and depth of the reflection ray */
|
|
8
|
+
useBlur: boolean;
|
|
9
|
+
/** The kernel size of the blur pass which is used to blur reflections; higher kernel sizes will result in blurrier reflections with more artifacts */
|
|
10
|
+
blurKernelSize: number;
|
|
11
|
+
/** How much the reflection ray should travel in each of its iteration; higher values will give deeper reflections but with more artifacts */
|
|
12
|
+
rayStep: number;
|
|
13
|
+
/** The intensity of the reflections */
|
|
14
|
+
intensity: number;
|
|
15
|
+
/** The power by which the reflections should be potentiated; higher values will give a more intense and vibrant look */
|
|
16
|
+
power: number;
|
|
17
|
+
/** How much deep reflections will be blurred (as reflections become blurrier the further away the object they are reflecting is) */
|
|
18
|
+
depthBlur: number;
|
|
19
|
+
/** Whether jittering is enabled; jittering will randomly jitter the reflections resulting in a more noisy but overall more realistic look, enabling jittering can be expensive depending on the view angle */
|
|
20
|
+
enableJittering: boolean;
|
|
21
|
+
/** How intense jittering should be */
|
|
22
|
+
jitter: number;
|
|
23
|
+
/** How much the jittered rays should be spread; higher values will give a rougher look regarding the reflections but are more expensive to compute with */
|
|
24
|
+
jitterSpread: number;
|
|
25
|
+
/** Roughness fade out */
|
|
26
|
+
roughnessFadeOut: number;
|
|
27
|
+
/** The number of steps a reflection ray can maximally do to find an object it intersected (and thus reflects) */
|
|
28
|
+
MAX_STEPS: number;
|
|
29
|
+
/** Once we had our ray intersect something, we need to find the exact point in space it intersected and thus it reflects; this can be done through binary search with the given number of maximum steps */
|
|
30
|
+
NUM_BINARY_SEARCH_STEPS: number;
|
|
31
|
+
/** The maximum depth difference between a ray and the particular depth at its screen position after refining with binary search; lower values will result in better performance */
|
|
32
|
+
maxDepthDifference: number;
|
|
33
|
+
/** The maximum depth for which reflections will be calculated */
|
|
34
|
+
maxDepth: number;
|
|
35
|
+
/** The maximum depth difference between a ray and the particular depth at its screen position before refining with binary search; lower values will result in better performance */
|
|
36
|
+
thickness: number;
|
|
37
|
+
/** Index of Refraction, used for calculating fresnel; reflections tend to be more intense the steeper the angle between them and the viewer is, the ior parameter set how much the intensity varies */
|
|
38
|
+
ior: number;
|
|
39
|
+
/** WebGL2 only - whether to use multiple render targets when rendering the G-buffers (normals, depth and roughness); using them can improve performance as they will render all information to multiple buffers for each fragment in one run */
|
|
40
|
+
useMRT: boolean;
|
|
41
|
+
/** If normal maps should be taken account of when calculating reflections */
|
|
42
|
+
useNormalMap: boolean;
|
|
43
|
+
/** If roughness maps should be taken account of when calculating reflections */
|
|
44
|
+
useRoughnessMap: boolean;
|
|
45
|
+
};
|
|
46
|
+
export declare const SSR: React.ForwardRefExoticComponent<SSRProps & React.RefAttributes<SSRPass>>;
|
|
47
|
+
export {};
|
|
@@ -11,6 +11,7 @@ var _extends = require('@babel/runtime/helpers/extends');
|
|
|
11
11
|
var _construct = require('@babel/runtime/helpers/construct');
|
|
12
12
|
var threeStdlib = require('three-stdlib');
|
|
13
13
|
var mergeRefs = require('react-merge-refs');
|
|
14
|
+
var screenSpaceReflections = require('screen-space-reflections');
|
|
14
15
|
|
|
15
16
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
16
17
|
|
|
@@ -39,7 +40,7 @@ var _extends__default = /*#__PURE__*/_interopDefaultLegacy(_extends);
|
|
|
39
40
|
var _construct__default = /*#__PURE__*/_interopDefaultLegacy(_construct);
|
|
40
41
|
var mergeRefs__default = /*#__PURE__*/_interopDefaultLegacy(mergeRefs);
|
|
41
42
|
|
|
42
|
-
var _excluded$
|
|
43
|
+
var _excluded$8 = ["blendFunction", "opacity"];
|
|
43
44
|
|
|
44
45
|
var isRef = function isRef(ref) {
|
|
45
46
|
return !!ref.current;
|
|
@@ -56,7 +57,7 @@ var wrapEffect = function wrapEffect(effectImpl, defaultBlendMode) {
|
|
|
56
57
|
return /*#__PURE__*/React.forwardRef(function Wrap(_ref, ref) {
|
|
57
58
|
var blendFunction = _ref.blendFunction,
|
|
58
59
|
opacity = _ref.opacity,
|
|
59
|
-
props = _objectWithoutPropertiesLoose__default["default"](_ref, _excluded$
|
|
60
|
+
props = _objectWithoutPropertiesLoose__default["default"](_ref, _excluded$8);
|
|
60
61
|
|
|
61
62
|
var invalidate = fiber.useThree(function (state) {
|
|
62
63
|
return state.invalidate;
|
|
@@ -243,11 +244,11 @@ var EffectComposer = /*#__PURE__*/React__default["default"].memo( /*#__PURE__*/R
|
|
|
243
244
|
}, children));
|
|
244
245
|
}));
|
|
245
246
|
|
|
246
|
-
var _excluded$
|
|
247
|
+
var _excluded$7 = ["target", "depthTexture"];
|
|
247
248
|
var DepthOfField = /*#__PURE__*/React.forwardRef(function DepthOfField(_ref, ref) {
|
|
248
249
|
var target = _ref.target,
|
|
249
250
|
depthTexture = _ref.depthTexture,
|
|
250
|
-
props = _objectWithoutPropertiesLoose__default["default"](_ref, _excluded$
|
|
251
|
+
props = _objectWithoutPropertiesLoose__default["default"](_ref, _excluded$7);
|
|
251
252
|
|
|
252
253
|
var invalidate = fiber.useThree(function (state) {
|
|
253
254
|
return state.invalidate;
|
|
@@ -277,11 +278,11 @@ var DepthOfField = /*#__PURE__*/React.forwardRef(function DepthOfField(_ref, ref
|
|
|
277
278
|
|
|
278
279
|
var DotScreen = wrapEffect(postprocessing.DotScreenEffect);
|
|
279
280
|
|
|
280
|
-
var _excluded$
|
|
281
|
+
var _excluded$6 = ["active"];
|
|
281
282
|
var Glitch = /*#__PURE__*/React.forwardRef(function Glitch(_ref, ref) {
|
|
282
283
|
var _ref$active = _ref.active,
|
|
283
284
|
active = _ref$active === void 0 ? true : _ref$active,
|
|
284
|
-
props = _objectWithoutPropertiesLoose__default["default"](_ref, _excluded$
|
|
285
|
+
props = _objectWithoutPropertiesLoose__default["default"](_ref, _excluded$6);
|
|
285
286
|
|
|
286
287
|
var invalidate = fiber.useThree(function (state) {
|
|
287
288
|
return state.invalidate;
|
|
@@ -321,10 +322,10 @@ var GodRays = /*#__PURE__*/React.forwardRef(function GodRays(props, ref) {
|
|
|
321
322
|
});
|
|
322
323
|
});
|
|
323
324
|
|
|
324
|
-
var _excluded$
|
|
325
|
+
var _excluded$5 = ["size"];
|
|
325
326
|
var Grid = /*#__PURE__*/React.forwardRef(function Grid(_ref, ref) {
|
|
326
327
|
var size = _ref.size,
|
|
327
|
-
props = _objectWithoutPropertiesLoose__default["default"](_ref, _excluded$
|
|
328
|
+
props = _objectWithoutPropertiesLoose__default["default"](_ref, _excluded$5);
|
|
328
329
|
|
|
329
330
|
var invalidate = fiber.useThree(function (state) {
|
|
330
331
|
return state.invalidate;
|
|
@@ -347,7 +348,7 @@ var HueSaturation = wrapEffect(postprocessing.HueSaturationEffect);
|
|
|
347
348
|
|
|
348
349
|
var Noise = wrapEffect(postprocessing.NoiseEffect, postprocessing.BlendFunction.COLOR_DODGE);
|
|
349
350
|
|
|
350
|
-
var _excluded$
|
|
351
|
+
var _excluded$4 = ["enabled", "children"];
|
|
351
352
|
var selectionContext = /*#__PURE__*/React.createContext(null);
|
|
352
353
|
function Selection(_ref) {
|
|
353
354
|
var children = _ref.children,
|
|
@@ -373,7 +374,7 @@ function Select(_ref2) {
|
|
|
373
374
|
var _ref2$enabled = _ref2.enabled,
|
|
374
375
|
enabled = _ref2$enabled === void 0 ? false : _ref2$enabled,
|
|
375
376
|
children = _ref2.children,
|
|
376
|
-
props = _objectWithoutPropertiesLoose__default["default"](_ref2, _excluded$
|
|
377
|
+
props = _objectWithoutPropertiesLoose__default["default"](_ref2, _excluded$4);
|
|
377
378
|
|
|
378
379
|
var group = React.useRef(null);
|
|
379
380
|
var api = React.useContext(selectionContext);
|
|
@@ -405,7 +406,7 @@ function Select(_ref2) {
|
|
|
405
406
|
}, props), children);
|
|
406
407
|
}
|
|
407
408
|
|
|
408
|
-
var _excluded$
|
|
409
|
+
var _excluded$3 = ["selection", "selectionLayer", "blendFunction", "patternTexture", "edgeStrength", "pulseSpeed", "visibleEdgeColor", "hiddenEdgeColor", "width", "height", "kernelSize", "blur", "xRay"];
|
|
409
410
|
var Outline = /*#__PURE__*/React.forwardRef(function Outline(_ref, forwardRef) {
|
|
410
411
|
var _ref$selection = _ref.selection,
|
|
411
412
|
selection = _ref$selection === void 0 ? [] : _ref$selection,
|
|
@@ -422,7 +423,7 @@ var Outline = /*#__PURE__*/React.forwardRef(function Outline(_ref, forwardRef) {
|
|
|
422
423
|
kernelSize = _ref.kernelSize,
|
|
423
424
|
blur = _ref.blur,
|
|
424
425
|
xRay = _ref.xRay;
|
|
425
|
-
_objectWithoutPropertiesLoose__default["default"](_ref, _excluded$
|
|
426
|
+
_objectWithoutPropertiesLoose__default["default"](_ref, _excluded$3);
|
|
426
427
|
|
|
427
428
|
var invalidate = fiber.useThree(function (state) {
|
|
428
429
|
return state.invalidate;
|
|
@@ -666,11 +667,11 @@ var SMAA = /*#__PURE__*/React.forwardRef(function SMAA(_ref, ref) {
|
|
|
666
667
|
});
|
|
667
668
|
});
|
|
668
669
|
|
|
669
|
-
var _excluded$
|
|
670
|
+
var _excluded$2 = ["textureSrc", "texture"];
|
|
670
671
|
var Texture = /*#__PURE__*/React.forwardRef(function Texture(_ref, ref) {
|
|
671
672
|
var textureSrc = _ref.textureSrc,
|
|
672
673
|
texture = _ref.texture,
|
|
673
|
-
props = _objectWithoutPropertiesLoose__default["default"](_ref, _excluded$
|
|
674
|
+
props = _objectWithoutPropertiesLoose__default["default"](_ref, _excluded$2);
|
|
674
675
|
|
|
675
676
|
var t = fiber.useLoader(THREE.TextureLoader, textureSrc);
|
|
676
677
|
React.useLayoutEffect(function () {
|
|
@@ -695,11 +696,11 @@ var Vignette = wrapEffect(postprocessing.VignetteEffect);
|
|
|
695
696
|
|
|
696
697
|
var ShockWave = wrapEffect(postprocessing.ShockWaveEffect);
|
|
697
698
|
|
|
698
|
-
var _excluded = ["lut", "tetrahedralInterpolation"];
|
|
699
|
+
var _excluded$1 = ["lut", "tetrahedralInterpolation"];
|
|
699
700
|
var LUT = /*#__PURE__*/React.forwardRef(function LUT(_ref, ref) {
|
|
700
701
|
var lut = _ref.lut,
|
|
701
702
|
tetrahedralInterpolation = _ref.tetrahedralInterpolation,
|
|
702
|
-
props = _objectWithoutPropertiesLoose__default["default"](_ref, _excluded);
|
|
703
|
+
props = _objectWithoutPropertiesLoose__default["default"](_ref, _excluded$1);
|
|
703
704
|
|
|
704
705
|
var invalidate = fiber.useThree(function (state) {
|
|
705
706
|
return state.invalidate;
|
|
@@ -719,6 +720,96 @@ var LUT = /*#__PURE__*/React.forwardRef(function LUT(_ref, ref) {
|
|
|
719
720
|
});
|
|
720
721
|
});
|
|
721
722
|
|
|
723
|
+
var _excluded = ["blurSize", "enabled"];
|
|
724
|
+
|
|
725
|
+
var SSR = /*#__PURE__*/React.forwardRef(function SSR(_ref, ref) {
|
|
726
|
+
var _ref$blurSize = _ref.blurSize,
|
|
727
|
+
blurSize = _ref$blurSize === void 0 ? 512 : _ref$blurSize,
|
|
728
|
+
_ref$enabled = _ref.enabled,
|
|
729
|
+
enabled = _ref$enabled === void 0 ? true : _ref$enabled,
|
|
730
|
+
props = _objectWithoutPropertiesLoose__default["default"](_ref, _excluded);
|
|
731
|
+
|
|
732
|
+
var _useThree = fiber.useThree(),
|
|
733
|
+
size = _useThree.size,
|
|
734
|
+
viewport = _useThree.viewport,
|
|
735
|
+
invalidate = _useThree.invalidate;
|
|
736
|
+
|
|
737
|
+
var _useContext = React.useContext(EffectComposerContext),
|
|
738
|
+
composer = _useContext.composer,
|
|
739
|
+
scene = _useContext.scene,
|
|
740
|
+
camera = _useContext.camera;
|
|
741
|
+
|
|
742
|
+
var _useState = React.useState(_extends__default["default"]({
|
|
743
|
+
width: size.width,
|
|
744
|
+
height: size.height,
|
|
745
|
+
blurWidth: blurSize,
|
|
746
|
+
blurHeight: blurSize,
|
|
747
|
+
blurKernelSize: postprocessing.KernelSize.SMALL,
|
|
748
|
+
rayStep: 0.1,
|
|
749
|
+
intensity: 1,
|
|
750
|
+
power: 1,
|
|
751
|
+
depthBlur: 0.1,
|
|
752
|
+
enableJittering: false,
|
|
753
|
+
jitter: 0.1,
|
|
754
|
+
jitterSpread: 0.1,
|
|
755
|
+
roughnessFadeOut: 1,
|
|
756
|
+
MAX_STEPS: 20,
|
|
757
|
+
NUM_BINARY_SEARCH_STEPS: 5,
|
|
758
|
+
maxDepthDifference: 1,
|
|
759
|
+
maxDepth: 1,
|
|
760
|
+
thickness: 10,
|
|
761
|
+
ior: 1.45,
|
|
762
|
+
useBlur: true,
|
|
763
|
+
useMRT: true,
|
|
764
|
+
useNormalMap: true,
|
|
765
|
+
useRoughnessMap: true
|
|
766
|
+
}, props)),
|
|
767
|
+
options = _useState[0];
|
|
768
|
+
|
|
769
|
+
var _useState2 = React.useState(function () {
|
|
770
|
+
return new screenSpaceReflections.SSRPass(composer, scene, camera, options);
|
|
771
|
+
}),
|
|
772
|
+
pass = _useState2[0];
|
|
773
|
+
|
|
774
|
+
React.useEffect(function () {
|
|
775
|
+
Object.keys(props).forEach(function (key) {
|
|
776
|
+
return pass.reflectionUniforms[key] && (pass.reflectionUniforms[key].value = props[key]);
|
|
777
|
+
});
|
|
778
|
+
}, [props]);
|
|
779
|
+
React.useEffect(function () {
|
|
780
|
+
if (props.useBlur) {
|
|
781
|
+
pass.fullscreenMaterial.defines.USE_BLUR = '';
|
|
782
|
+
pass.reflectionsPass.fullscreenMaterial.defines.USE_BLUR = '';
|
|
783
|
+
} else {
|
|
784
|
+
delete pass.fullscreenMaterial.defines.USE_BLUR;
|
|
785
|
+
delete pass.reflectionsPass.fullscreenMaterial.defines.USE_BLUR;
|
|
786
|
+
}
|
|
787
|
+
|
|
788
|
+
if (props.enableJittering) {
|
|
789
|
+
pass.reflectionsPass.fullscreenMaterial.defines.USE_JITTERING = '';
|
|
790
|
+
} else {
|
|
791
|
+
delete pass.reflectionsPass.fullscreenMaterial.defines.USE_JITTERING;
|
|
792
|
+
}
|
|
793
|
+
|
|
794
|
+
pass.reflectionsPass.fullscreenMaterial.defines.MAX_STEPS = Math.ceil(props.MAX_STEPS);
|
|
795
|
+
pass.reflectionsPass.fullscreenMaterial.defines.NUM_BINARY_SEARCH_STEPS = Math.ceil(props.NUM_BINARY_SEARCH_STEPS);
|
|
796
|
+
pass.fullscreenMaterial.defines.RENDER_MODE = enabled ? 0 : 4;
|
|
797
|
+
pass.reflectionsPass.fullscreenMaterial.needsUpdate = true;
|
|
798
|
+
}, [enabled, props.useBlur, props.enableJittering, props.NUM_BINARY_SEARCH_STEPS, props.MAX_STEPS]);
|
|
799
|
+
React.useEffect(function () {
|
|
800
|
+
pass.setSize(size.width * viewport.dpr, size.height * viewport.dpr);
|
|
801
|
+
pass.kawaseBlurPass.setSize(blurSize, blurSize);
|
|
802
|
+
invalidate();
|
|
803
|
+
}, [blurSize, size, viewport, composer, pass, invalidate]);
|
|
804
|
+
React.useLayoutEffect(function () {
|
|
805
|
+
composer.addPass(pass);
|
|
806
|
+
return function () {
|
|
807
|
+
composer.removePass(pass);
|
|
808
|
+
};
|
|
809
|
+
}, [composer, pass]);
|
|
810
|
+
return null;
|
|
811
|
+
});
|
|
812
|
+
|
|
722
813
|
exports.Bloom = Bloom;
|
|
723
814
|
exports.BrightnessContrast = BrightnessContrast;
|
|
724
815
|
exports.ChromaticAberration = ChromaticAberration;
|
|
@@ -739,6 +830,7 @@ exports.Outline = Outline;
|
|
|
739
830
|
exports.Pixelation = Pixelation;
|
|
740
831
|
exports.SMAA = SMAA;
|
|
741
832
|
exports.SSAO = SSAO;
|
|
833
|
+
exports.SSR = SSR;
|
|
742
834
|
exports.Scanline = Scanline;
|
|
743
835
|
exports.Select = Select;
|
|
744
836
|
exports.Selection = Selection;
|
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { BlendFunction, BloomEffect, BrightnessContrastEffect, ChromaticAberrationEffect, ColorAverageEffect, ColorDepthEffect, DepthEffect, EffectComposer as EffectComposer$1, RenderPass, NormalPass, DepthDownsamplingPass, EffectPass, DepthOfFieldEffect, DotScreenEffect, GlitchEffect, GlitchMode, GodRaysEffect, GridEffect, HueSaturationEffect, NoiseEffect, OutlineEffect, PixelationEffect, ScanlineEffect, SelectiveBloomEffect, SepiaEffect, SSAOEffect, SMAAPreset, EdgeDetectionMode, SMAAImageLoader, SMAAEffect, TextureEffect, ToneMappingEffect, VignetteEffect, ShockWaveEffect, LUTEffect } from 'postprocessing';
|
|
1
|
+
import { BlendFunction, BloomEffect, BrightnessContrastEffect, ChromaticAberrationEffect, ColorAverageEffect, ColorDepthEffect, DepthEffect, EffectComposer as EffectComposer$1, RenderPass, NormalPass, DepthDownsamplingPass, EffectPass, DepthOfFieldEffect, DotScreenEffect, GlitchEffect, GlitchMode, GodRaysEffect, GridEffect, HueSaturationEffect, NoiseEffect, OutlineEffect, PixelationEffect, ScanlineEffect, SelectiveBloomEffect, SepiaEffect, SSAOEffect, SMAAPreset, EdgeDetectionMode, SMAAImageLoader, SMAAEffect, TextureEffect, ToneMappingEffect, VignetteEffect, ShockWaveEffect, LUTEffect, KernelSize } from 'postprocessing';
|
|
2
2
|
import React, { forwardRef, useMemo, useLayoutEffect, createContext, useEffect, useRef, useImperativeHandle, useContext, useState } from 'react';
|
|
3
3
|
import * as THREE from 'three';
|
|
4
4
|
import { Vector2, Vector3, TextureLoader, sRGBEncoding, RepeatWrapping } from 'three';
|
|
@@ -6,6 +6,7 @@ import { useThree, useFrame, useLoader } from '@react-three/fiber';
|
|
|
6
6
|
import { isWebGL2Available } from 'three-stdlib';
|
|
7
7
|
import mergeRefs from 'react-merge-refs';
|
|
8
8
|
import _extends from '@babel/runtime/helpers/esm/extends';
|
|
9
|
+
import { SSRPass } from 'screen-space-reflections';
|
|
9
10
|
|
|
10
11
|
const isRef = ref => !!ref.current;
|
|
11
12
|
|
|
@@ -595,4 +596,84 @@ const LUT = /*#__PURE__*/forwardRef(function LUT(_ref, ref) {
|
|
|
595
596
|
});
|
|
596
597
|
});
|
|
597
598
|
|
|
598
|
-
|
|
599
|
+
const SSR = /*#__PURE__*/forwardRef(function SSR(_ref, ref) {
|
|
600
|
+
let {
|
|
601
|
+
blurSize = 512,
|
|
602
|
+
enabled = true,
|
|
603
|
+
...props
|
|
604
|
+
} = _ref;
|
|
605
|
+
const {
|
|
606
|
+
size,
|
|
607
|
+
viewport,
|
|
608
|
+
invalidate
|
|
609
|
+
} = useThree();
|
|
610
|
+
const {
|
|
611
|
+
composer,
|
|
612
|
+
scene,
|
|
613
|
+
camera
|
|
614
|
+
} = useContext(EffectComposerContext);
|
|
615
|
+
const [options] = useState({
|
|
616
|
+
width: size.width,
|
|
617
|
+
height: size.height,
|
|
618
|
+
blurWidth: blurSize,
|
|
619
|
+
blurHeight: blurSize,
|
|
620
|
+
blurKernelSize: KernelSize.SMALL,
|
|
621
|
+
rayStep: 0.1,
|
|
622
|
+
intensity: 1,
|
|
623
|
+
power: 1,
|
|
624
|
+
depthBlur: 0.1,
|
|
625
|
+
enableJittering: false,
|
|
626
|
+
jitter: 0.1,
|
|
627
|
+
jitterSpread: 0.1,
|
|
628
|
+
roughnessFadeOut: 1,
|
|
629
|
+
MAX_STEPS: 20,
|
|
630
|
+
NUM_BINARY_SEARCH_STEPS: 5,
|
|
631
|
+
maxDepthDifference: 1,
|
|
632
|
+
maxDepth: 1,
|
|
633
|
+
thickness: 10,
|
|
634
|
+
ior: 1.45,
|
|
635
|
+
useBlur: true,
|
|
636
|
+
useMRT: true,
|
|
637
|
+
useNormalMap: true,
|
|
638
|
+
useRoughnessMap: true,
|
|
639
|
+
...props
|
|
640
|
+
});
|
|
641
|
+
const [pass] = useState(() => new SSRPass(composer, scene, camera, options));
|
|
642
|
+
useEffect(() => {
|
|
643
|
+
Object.keys(props).forEach(key => pass.reflectionUniforms[key] && (pass.reflectionUniforms[key].value = props[key]));
|
|
644
|
+
}, [props]);
|
|
645
|
+
useEffect(() => {
|
|
646
|
+
if (props.useBlur) {
|
|
647
|
+
pass.fullscreenMaterial.defines.USE_BLUR = '';
|
|
648
|
+
pass.reflectionsPass.fullscreenMaterial.defines.USE_BLUR = '';
|
|
649
|
+
} else {
|
|
650
|
+
delete pass.fullscreenMaterial.defines.USE_BLUR;
|
|
651
|
+
delete pass.reflectionsPass.fullscreenMaterial.defines.USE_BLUR;
|
|
652
|
+
}
|
|
653
|
+
|
|
654
|
+
if (props.enableJittering) {
|
|
655
|
+
pass.reflectionsPass.fullscreenMaterial.defines.USE_JITTERING = '';
|
|
656
|
+
} else {
|
|
657
|
+
delete pass.reflectionsPass.fullscreenMaterial.defines.USE_JITTERING;
|
|
658
|
+
}
|
|
659
|
+
|
|
660
|
+
pass.reflectionsPass.fullscreenMaterial.defines.MAX_STEPS = Math.ceil(props.MAX_STEPS);
|
|
661
|
+
pass.reflectionsPass.fullscreenMaterial.defines.NUM_BINARY_SEARCH_STEPS = Math.ceil(props.NUM_BINARY_SEARCH_STEPS);
|
|
662
|
+
pass.fullscreenMaterial.defines.RENDER_MODE = enabled ? 0 : 4;
|
|
663
|
+
pass.reflectionsPass.fullscreenMaterial.needsUpdate = true;
|
|
664
|
+
}, [enabled, props.useBlur, props.enableJittering, props.NUM_BINARY_SEARCH_STEPS, props.MAX_STEPS]);
|
|
665
|
+
useEffect(() => {
|
|
666
|
+
pass.setSize(size.width * viewport.dpr, size.height * viewport.dpr);
|
|
667
|
+
pass.kawaseBlurPass.setSize(blurSize, blurSize);
|
|
668
|
+
invalidate();
|
|
669
|
+
}, [blurSize, size, viewport, composer, pass, invalidate]);
|
|
670
|
+
useLayoutEffect(() => {
|
|
671
|
+
composer.addPass(pass);
|
|
672
|
+
return () => {
|
|
673
|
+
composer.removePass(pass);
|
|
674
|
+
};
|
|
675
|
+
}, [composer, pass]);
|
|
676
|
+
return null;
|
|
677
|
+
});
|
|
678
|
+
|
|
679
|
+
export { Bloom, BrightnessContrast, ChromaticAberration, ColorAverage, ColorDepth, Depth, DepthOfField, DotScreen, EffectComposer, EffectComposerContext, Glitch, GodRays, Grid, HueSaturation, LUT, Noise, Outline, Pixelation, SMAA, SSAO, SSR, Scanline, Select, Selection, SelectiveBloom, Sepia, ShockWave, Texture, ToneMapping, Vignette, selectionContext };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@react-three/postprocessing",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.4.1",
|
|
4
4
|
"description": "postprocessing wrapper for React and @react-three/fiber",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"postprocessing",
|
|
@@ -11,7 +11,8 @@
|
|
|
11
11
|
"3d"
|
|
12
12
|
],
|
|
13
13
|
"license": "MIT",
|
|
14
|
-
"
|
|
14
|
+
"type": "module",
|
|
15
|
+
"main": "dist/index.cjs",
|
|
15
16
|
"module": "dist/index.js",
|
|
16
17
|
"types": "dist/index.d.ts",
|
|
17
18
|
"sideEffects": false,
|
|
@@ -38,8 +39,9 @@
|
|
|
38
39
|
"typegen": "tsc --emitDeclarationOnly || true"
|
|
39
40
|
},
|
|
40
41
|
"dependencies": {
|
|
41
|
-
"postprocessing": "6.
|
|
42
|
+
"postprocessing": "^6.28.1",
|
|
42
43
|
"react-merge-refs": "^1.1.0",
|
|
44
|
+
"screen-space-reflections": "^1.0.6",
|
|
43
45
|
"three-stdlib": "^2.8.11"
|
|
44
46
|
},
|
|
45
47
|
"devDependencies": {
|
|
@@ -84,12 +86,6 @@
|
|
|
84
86
|
"peerDependencies": {
|
|
85
87
|
"@react-three/fiber": ">=7.0",
|
|
86
88
|
"react": ">=17.0",
|
|
87
|
-
"react-dom": ">=17.0",
|
|
88
89
|
"three": ">=0.136.0"
|
|
89
|
-
},
|
|
90
|
-
"peerDependenciesMeta": {
|
|
91
|
-
"react-dom": {
|
|
92
|
-
"optional": true
|
|
93
|
-
}
|
|
94
90
|
}
|
|
95
91
|
}
|