@react-three/postprocessing 2.4.6 → 2.5.0
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/effects/SSR.d.ts +40 -34
- package/dist/index.cjs +16 -79
- package/dist/index.js +14 -74
- package/package.json +3 -3
package/dist/effects/SSR.d.ts
CHANGED
|
@@ -1,49 +1,55 @@
|
|
|
1
|
-
|
|
1
|
+
import React from 'react';
|
|
2
2
|
declare type SSRProps = {
|
|
3
|
-
/**
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
|
|
11
|
-
/**
|
|
3
|
+
/** whether you want to use Temporal Resolving to re-use reflections from the last frames; this will reduce noise tremendously but may result in "smearing" */
|
|
4
|
+
temporalResolve?: boolean;
|
|
5
|
+
/** a value between 0 and 1 to set how much the last frame's reflections should be blended in; higher values will result in less noisy reflections when moving the camera but a more smeary look */
|
|
6
|
+
temporalResolveMix?: number;
|
|
7
|
+
/** a value between 0 and 1 to set how much the reprojected reflection should be corrected; higher values will reduce smearing but will result in less flickering at reflection edges */
|
|
8
|
+
temporalResolveCorrectionMix?: number;
|
|
9
|
+
/** the maximum number of samples for reflections; settings it to 0 means unlimited samples; setting it to a value like 6 can help make camera movements less disruptive when calculating reflections */
|
|
10
|
+
maxSamples?: number;
|
|
11
|
+
/** whether to blur the reflections and blend these blurred reflections with the raw ones depending on the blurMix value */
|
|
12
|
+
ENABLE_BLUR?: boolean;
|
|
13
|
+
/** how much the blurred reflections should be mixed with the raw reflections */
|
|
14
|
+
blurMix?: number;
|
|
15
|
+
/** the sharpness of the Bilateral Filter used to blur reflections */
|
|
16
|
+
blurSharpness?: number;
|
|
17
|
+
/** the kernel size of the Bilateral Blur Filter; higher kernel sizes will result in blurrier reflections with more artifacts */
|
|
12
18
|
blurKernelSize?: number;
|
|
13
|
-
/**
|
|
19
|
+
/** how much the reflection ray should travel in each of its iteration; higher values will give deeper reflections but with more artifacts */
|
|
14
20
|
rayStep?: number;
|
|
15
|
-
/**
|
|
21
|
+
/** the intensity of the reflections */
|
|
16
22
|
intensity?: number;
|
|
17
|
-
/**
|
|
18
|
-
|
|
19
|
-
/**
|
|
20
|
-
|
|
21
|
-
/**
|
|
22
|
-
enableJittering?: boolean;
|
|
23
|
-
/** How intense jittering should be */
|
|
23
|
+
/** the maximum roughness a texel can have to have reflections calculated for it */
|
|
24
|
+
maxRoughness?: number;
|
|
25
|
+
/** 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 */
|
|
26
|
+
ENABLE_JITTERING?: boolean;
|
|
27
|
+
/** how intense jittering should be */
|
|
24
28
|
jitter?: number;
|
|
25
|
-
/**
|
|
29
|
+
/** 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 */
|
|
26
30
|
jitterSpread?: number;
|
|
27
|
-
/**
|
|
28
|
-
|
|
29
|
-
/**
|
|
31
|
+
/** how intense jittering should be in relation to a material's roughness */
|
|
32
|
+
jitterRough?: number;
|
|
33
|
+
/** the number of steps a reflection ray can maximally do to find an object it intersected (and thus reflects) */
|
|
30
34
|
MAX_STEPS?: number;
|
|
31
|
-
/**
|
|
35
|
+
/** 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 */
|
|
32
36
|
NUM_BINARY_SEARCH_STEPS?: number;
|
|
33
|
-
/**
|
|
37
|
+
/** 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 */
|
|
34
38
|
maxDepthDifference?: number;
|
|
35
|
-
/**
|
|
39
|
+
/** the maximum depth for which reflections will be calculated */
|
|
36
40
|
maxDepth?: number;
|
|
37
|
-
/**
|
|
41
|
+
/** 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 */
|
|
38
42
|
thickness?: number;
|
|
39
43
|
/** 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 */
|
|
40
44
|
ior?: number;
|
|
41
|
-
/**
|
|
42
|
-
|
|
43
|
-
/**
|
|
44
|
-
|
|
45
|
-
/**
|
|
46
|
-
|
|
45
|
+
/** if there should still be reflections for rays for which a reflecting point couldn't be found; enabling this will result in stretched looking reflections which can look good or bad depending on the angle */
|
|
46
|
+
STRETCH_MISSED_RAYS?: boolean;
|
|
47
|
+
/** 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; this setting can't be changed during run-time */
|
|
48
|
+
USE_MRT?: boolean;
|
|
49
|
+
/** if roughness maps should be taken account of when calculating reflections */
|
|
50
|
+
USE_ROUGHNESSMAP?: boolean;
|
|
51
|
+
/** if normal maps should be taken account of when calculating reflections */
|
|
52
|
+
USE_NORMALMAP?: boolean;
|
|
47
53
|
};
|
|
48
|
-
export declare const SSR:
|
|
54
|
+
export declare const SSR: React.ForwardRefExoticComponent<SSRProps & React.RefAttributes<SSREffect>>;
|
|
49
55
|
export {};
|
package/dist/index.cjs
CHANGED
|
@@ -701,101 +701,38 @@ var LUT = /*#__PURE__*/React.forwardRef(function LUT(_ref, ref) {
|
|
|
701
701
|
});
|
|
702
702
|
});
|
|
703
703
|
|
|
704
|
-
var _excluded = ["
|
|
704
|
+
var _excluded = ["ENABLE_BLUR", "USE_MRT"];
|
|
705
705
|
|
|
706
706
|
var SSR = /*#__PURE__*/React.forwardRef(function SSR(_ref, ref) {
|
|
707
|
-
var _ref$
|
|
708
|
-
|
|
709
|
-
_ref$
|
|
710
|
-
|
|
711
|
-
_ref$enabled = _ref.enabled,
|
|
712
|
-
enabled = _ref$enabled === void 0 ? true : _ref$enabled,
|
|
707
|
+
var _ref$ENABLE_BLUR = _ref.ENABLE_BLUR,
|
|
708
|
+
ENABLE_BLUR = _ref$ENABLE_BLUR === void 0 ? true : _ref$ENABLE_BLUR,
|
|
709
|
+
_ref$USE_MRT = _ref.USE_MRT,
|
|
710
|
+
USE_MRT = _ref$USE_MRT === void 0 ? true : _ref$USE_MRT,
|
|
713
711
|
props = _objectWithoutPropertiesLoose__default["default"](_ref, _excluded);
|
|
714
712
|
|
|
715
713
|
var _useThree = fiber.useThree(),
|
|
716
|
-
size = _useThree.size,
|
|
717
|
-
viewport = _useThree.viewport,
|
|
718
714
|
invalidate = _useThree.invalidate;
|
|
719
715
|
|
|
720
716
|
var _useContext = React.useContext(EffectComposerContext),
|
|
721
|
-
composer = _useContext.composer,
|
|
722
717
|
scene = _useContext.scene,
|
|
723
718
|
camera = _useContext.camera;
|
|
724
719
|
|
|
725
|
-
var
|
|
726
|
-
return new screenSpaceReflections.
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
blurWidth: blurSize,
|
|
730
|
-
blurHeight: blurSize,
|
|
731
|
-
blurKernelSize: postprocessing.KernelSize.SMALL,
|
|
732
|
-
rayStep: 0.1,
|
|
733
|
-
intensity: 1,
|
|
734
|
-
power: 1,
|
|
735
|
-
depthBlur: 0.1,
|
|
736
|
-
enableJittering: false,
|
|
737
|
-
jitter: 0.1,
|
|
738
|
-
jitterSpread: 0.1,
|
|
739
|
-
roughnessFadeOut: 1,
|
|
740
|
-
MAX_STEPS: 20,
|
|
741
|
-
NUM_BINARY_SEARCH_STEPS: 5,
|
|
742
|
-
maxDepthDifference: 1,
|
|
743
|
-
maxDepth: 1,
|
|
744
|
-
thickness: 10,
|
|
745
|
-
ior: 1.45,
|
|
746
|
-
useBlur: true,
|
|
747
|
-
useMRT: true,
|
|
748
|
-
useNormalMap: true,
|
|
749
|
-
useRoughnessMap: true
|
|
720
|
+
var effect = React.useMemo(function () {
|
|
721
|
+
return new screenSpaceReflections.SSREffect(scene, camera, _extends__default["default"]({
|
|
722
|
+
ENABLE_BLUR: ENABLE_BLUR,
|
|
723
|
+
USE_MRT: USE_MRT
|
|
750
724
|
}, props));
|
|
751
|
-
})
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
React.useEffect(function () {
|
|
725
|
+
}, [screenSpaceReflections.SSREffect, scene, camera, ENABLE_BLUR, USE_MRT]);
|
|
726
|
+
React.useLayoutEffect(function () {
|
|
755
727
|
Object.keys(props).forEach(function (key) {
|
|
756
|
-
return
|
|
728
|
+
return effect[key] = props[key];
|
|
757
729
|
});
|
|
758
730
|
invalidate();
|
|
759
731
|
}, [props]);
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
if (props.useBlur) {
|
|
766
|
-
pass.fullscreenMaterial.defines.USE_BLUR = '';
|
|
767
|
-
pass.reflectionsPass.fullscreenMaterial.defines.USE_BLUR = '';
|
|
768
|
-
} else {
|
|
769
|
-
delete pass.fullscreenMaterial.defines.USE_BLUR;
|
|
770
|
-
delete pass.reflectionsPass.fullscreenMaterial.defines.USE_BLUR;
|
|
771
|
-
} // Jitter
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
if (props.enableJittering) {
|
|
775
|
-
pass.reflectionsPass.fullscreenMaterial.defines.USE_JITTERING = '';
|
|
776
|
-
} else {
|
|
777
|
-
delete pass.reflectionsPass.fullscreenMaterial.defines.USE_JITTERING;
|
|
778
|
-
} // Enabled
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
pass.fullscreenMaterial.defines.RENDER_MODE = enabled ? 0 : 4; // Update materials
|
|
782
|
-
|
|
783
|
-
pass.reflectionsPass.fullscreenMaterial.needsUpdate = true;
|
|
784
|
-
pass.fullscreenMaterial.needsUpdate = true;
|
|
785
|
-
invalidate();
|
|
786
|
-
}, [enabled, props.useBlur, props.enableJittering, props.NUM_BINARY_SEARCH_STEPS, props.MAX_STEPS]);
|
|
787
|
-
React.useEffect(function () {
|
|
788
|
-
pass.setSize(size.width * viewport.dpr * resolutionScale, size.height * viewport.dpr * resolutionScale);
|
|
789
|
-
pass.kawaseBlurPass.setSize(blurSize, blurSize);
|
|
790
|
-
invalidate();
|
|
791
|
-
}, [resolutionScale, blurSize, size, viewport, composer, pass, invalidate]);
|
|
792
|
-
React.useLayoutEffect(function () {
|
|
793
|
-
composer.addPass(pass);
|
|
794
|
-
return function () {
|
|
795
|
-
composer.removePass(pass); //pass.dispose()
|
|
796
|
-
};
|
|
797
|
-
}, [composer, pass]);
|
|
798
|
-
return null;
|
|
732
|
+
return /*#__PURE__*/React__default["default"].createElement("primitive", {
|
|
733
|
+
ref: ref,
|
|
734
|
+
object: effect
|
|
735
|
+
});
|
|
799
736
|
});
|
|
800
737
|
|
|
801
738
|
exports.Bloom = Bloom;
|
package/dist/index.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
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
|
|
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';
|
|
2
2
|
import React, { forwardRef, useMemo, useLayoutEffect, createContext, useEffect, useRef, useImperativeHandle, useContext, useState } from 'react';
|
|
3
3
|
import { Vector2, HalfFloatType, Vector3, TextureLoader, sRGBEncoding, RepeatWrapping } from 'three';
|
|
4
4
|
import { useThree, useFrame, useLoader } from '@react-three/fiber';
|
|
5
5
|
import { isWebGL2Available } from 'three-stdlib';
|
|
6
6
|
import mergeRefs from 'react-merge-refs';
|
|
7
7
|
import _extends from '@babel/runtime/helpers/esm/extends';
|
|
8
|
-
import {
|
|
8
|
+
import { SSREffect } from 'screen-space-reflections';
|
|
9
9
|
|
|
10
10
|
const isRef = ref => !!ref.current;
|
|
11
11
|
|
|
@@ -597,90 +597,30 @@ const LUT = /*#__PURE__*/forwardRef(function LUT(_ref, ref) {
|
|
|
597
597
|
|
|
598
598
|
const SSR = /*#__PURE__*/forwardRef(function SSR(_ref, ref) {
|
|
599
599
|
let {
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
enabled = true,
|
|
600
|
+
ENABLE_BLUR = true,
|
|
601
|
+
USE_MRT = true,
|
|
603
602
|
...props
|
|
604
603
|
} = _ref;
|
|
605
604
|
const {
|
|
606
|
-
size,
|
|
607
|
-
viewport,
|
|
608
605
|
invalidate
|
|
609
606
|
} = useThree();
|
|
610
607
|
const {
|
|
611
|
-
composer,
|
|
612
608
|
scene,
|
|
613
609
|
camera
|
|
614
610
|
} = useContext(EffectComposerContext);
|
|
615
|
-
const
|
|
616
|
-
|
|
617
|
-
|
|
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,
|
|
611
|
+
const effect = useMemo(() => new SSREffect(scene, camera, {
|
|
612
|
+
ENABLE_BLUR,
|
|
613
|
+
USE_MRT,
|
|
639
614
|
...props
|
|
640
|
-
}));
|
|
641
|
-
|
|
642
|
-
Object.keys(props).forEach(key =>
|
|
615
|
+
}), [SSREffect, scene, camera, ENABLE_BLUR, USE_MRT]);
|
|
616
|
+
useLayoutEffect(() => {
|
|
617
|
+
Object.keys(props).forEach(key => effect[key] = props[key]);
|
|
643
618
|
invalidate();
|
|
644
619
|
}, [props]);
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
if (props.useBlur) {
|
|
651
|
-
pass.fullscreenMaterial.defines.USE_BLUR = '';
|
|
652
|
-
pass.reflectionsPass.fullscreenMaterial.defines.USE_BLUR = '';
|
|
653
|
-
} else {
|
|
654
|
-
delete pass.fullscreenMaterial.defines.USE_BLUR;
|
|
655
|
-
delete pass.reflectionsPass.fullscreenMaterial.defines.USE_BLUR;
|
|
656
|
-
} // Jitter
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
if (props.enableJittering) {
|
|
660
|
-
pass.reflectionsPass.fullscreenMaterial.defines.USE_JITTERING = '';
|
|
661
|
-
} else {
|
|
662
|
-
delete pass.reflectionsPass.fullscreenMaterial.defines.USE_JITTERING;
|
|
663
|
-
} // Enabled
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
pass.fullscreenMaterial.defines.RENDER_MODE = enabled ? 0 : 4; // Update materials
|
|
667
|
-
|
|
668
|
-
pass.reflectionsPass.fullscreenMaterial.needsUpdate = true;
|
|
669
|
-
pass.fullscreenMaterial.needsUpdate = true;
|
|
670
|
-
invalidate();
|
|
671
|
-
}, [enabled, props.useBlur, props.enableJittering, props.NUM_BINARY_SEARCH_STEPS, props.MAX_STEPS]);
|
|
672
|
-
useEffect(() => {
|
|
673
|
-
pass.setSize(size.width * viewport.dpr * resolutionScale, size.height * viewport.dpr * resolutionScale);
|
|
674
|
-
pass.kawaseBlurPass.setSize(blurSize, blurSize);
|
|
675
|
-
invalidate();
|
|
676
|
-
}, [resolutionScale, blurSize, size, viewport, composer, pass, invalidate]);
|
|
677
|
-
useLayoutEffect(() => {
|
|
678
|
-
composer.addPass(pass);
|
|
679
|
-
return () => {
|
|
680
|
-
composer.removePass(pass); //pass.dispose()
|
|
681
|
-
};
|
|
682
|
-
}, [composer, pass]);
|
|
683
|
-
return null;
|
|
620
|
+
return /*#__PURE__*/React.createElement("primitive", {
|
|
621
|
+
ref: ref,
|
|
622
|
+
object: effect
|
|
623
|
+
});
|
|
684
624
|
});
|
|
685
625
|
|
|
686
626
|
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.5.0",
|
|
4
4
|
"description": "postprocessing wrapper for React and @react-three/fiber",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"postprocessing",
|
|
@@ -39,9 +39,9 @@
|
|
|
39
39
|
"typegen": "tsc --emitDeclarationOnly || true"
|
|
40
40
|
},
|
|
41
41
|
"dependencies": {
|
|
42
|
-
"postprocessing": "^6.28.
|
|
42
|
+
"postprocessing": "^6.28.4",
|
|
43
43
|
"react-merge-refs": "^1.1.0",
|
|
44
|
-
"screen-space-reflections": "^
|
|
44
|
+
"screen-space-reflections": "^2.0.4",
|
|
45
45
|
"three-stdlib": "^2.8.11"
|
|
46
46
|
},
|
|
47
47
|
"devDependencies": {
|