@react-three/postprocessing 2.8.1 → 2.8.3
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/TiltShift2.d.ts +3 -3
- package/dist/index.cjs +5 -5
- package/dist/index.js +6 -6
- package/package.json +1 -1
|
@@ -5,15 +5,15 @@ export declare class TiltShiftEffect extends Effect {
|
|
|
5
5
|
taper, // [0, 1], can go beyond 1 for extra
|
|
6
6
|
start, // [0,1] percentage x,y of screenspace
|
|
7
7
|
end, // [0,1] percentage x,y of screenspace
|
|
8
|
-
|
|
8
|
+
samples, // number of blur samples
|
|
9
9
|
direction }?: {
|
|
10
10
|
blendFunction?: BlendFunction;
|
|
11
11
|
blur?: number;
|
|
12
12
|
taper?: number;
|
|
13
13
|
start?: number[];
|
|
14
14
|
end?: number[];
|
|
15
|
-
|
|
15
|
+
samples?: number;
|
|
16
16
|
direction?: number[];
|
|
17
17
|
});
|
|
18
18
|
}
|
|
19
|
-
export declare const TiltShift2: import("react").ForwardRefExoticComponent<Pick<import("../util").EffectProps<typeof TiltShiftEffect>, "children" | "attach" | "attachArray" | "attachObject" | "attachFns" | "args" | "key" | "onUpdate" | "blendFunction" | "opacity" | "blur" | "
|
|
19
|
+
export declare const TiltShift2: import("react").ForwardRefExoticComponent<Pick<import("../util").EffectProps<typeof TiltShiftEffect>, "children" | "attach" | "attachArray" | "attachObject" | "attachFns" | "args" | "key" | "onUpdate" | "blendFunction" | "opacity" | "blur" | "samples" | "taper" | "start" | "end" | "direction" | keyof TiltShiftEffect> & import("react").RefAttributes<typeof TiltShiftEffect>>;
|
package/dist/index.cjs
CHANGED
|
@@ -733,7 +733,7 @@ var TiltShift = wrapEffect(postprocessing.TiltShiftEffect, {
|
|
|
733
733
|
});
|
|
734
734
|
|
|
735
735
|
var TiltShiftShader = {
|
|
736
|
-
fragmentShader: "\n\n // original shader by Evan Wallace\n\n #define MAX_ITERATIONS 100\n\n uniform float blur;\n uniform float taper;\n uniform vec2 start;\n uniform vec2 end;\n uniform vec2 direction;\n uniform int
|
|
736
|
+
fragmentShader: "\n\n // original shader by Evan Wallace\n\n #define MAX_ITERATIONS 100\n\n uniform float blur;\n uniform float taper;\n uniform vec2 start;\n uniform vec2 end;\n uniform vec2 direction;\n uniform int samples;\n\n float random(vec3 scale, float seed) {\n /* use the fragment position for a different seed per-pixel */\n return fract(sin(dot(gl_FragCoord.xyz + seed, scale)) * 43758.5453 + seed);\n }\n\n void mainImage(const in vec4 inputColor, const in vec2 uv, out vec4 outputColor) {\n vec4 color = vec4(0.0);\n float total = 0.0;\n vec2 startPixel = vec2(start.x * resolution.x, start.y * resolution.y);\n vec2 endPixel = vec2(end.x * resolution.x, end.y * resolution.y);\n float f_samples = float(samples);\n float half_samples = f_samples / 2.0;\n\n // use screen diagonal to normalize blur radii\n float maxScreenDistance = distance(vec2(0.0), resolution); // diagonal distance\n float gradientRadius = taper * (maxScreenDistance);\n float blurRadius = blur * (maxScreenDistance / 16.0);\n\n /* randomize the lookup values to hide the fixed number of samples */\n float offset = random(vec3(12.9898, 78.233, 151.7182), 0.0);\n vec2 normal = normalize(vec2(startPixel.y - endPixel.y, endPixel.x - startPixel.x));\n float radius = smoothstep(0.0, 1.0, abs(dot(uv * resolution - startPixel, normal)) / gradientRadius) * blurRadius;\n\n #pragma unroll_loop_start\n for (int i = 0; i <= MAX_ITERATIONS; i++) {\n if (i >= samples) { break; } // return early if over sample count\n float f_i = float(i);\n float s_i = -half_samples + f_i;\n float percent = (s_i + offset - 0.5) / half_samples;\n float weight = 1.0 - abs(percent);\n vec4 sample_i = texture2D(inputBuffer, uv + normalize(direction) / resolution * percent * radius);\n /* switch to pre-multiplied alpha to correctly blur transparent images */\n sample_i.rgb *= sample_i.a;\n color += sample_i * weight;\n total += weight;\n }\n #pragma unroll_loop_end\n\n outputColor = color / total;\n\n /* switch back from pre-multiplied alpha */\n outputColor.rgb /= outputColor.a + 0.00001;\n }\n "
|
|
737
737
|
};
|
|
738
738
|
var TiltShiftEffect = /*#__PURE__*/function (_Effect) {
|
|
739
739
|
_inheritsLoose__default["default"](TiltShiftEffect, _Effect);
|
|
@@ -743,22 +743,22 @@ var TiltShiftEffect = /*#__PURE__*/function (_Effect) {
|
|
|
743
743
|
_ref$blendFunction = _ref.blendFunction,
|
|
744
744
|
blendFunction = _ref$blendFunction === void 0 ? postprocessing.BlendFunction.NORMAL : _ref$blendFunction,
|
|
745
745
|
_ref$blur = _ref.blur,
|
|
746
|
-
blur = _ref$blur === void 0 ?
|
|
746
|
+
blur = _ref$blur === void 0 ? 0.15 : _ref$blur,
|
|
747
747
|
_ref$taper = _ref.taper,
|
|
748
748
|
taper = _ref$taper === void 0 ? 0.5 : _ref$taper,
|
|
749
749
|
_ref$start = _ref.start,
|
|
750
750
|
start = _ref$start === void 0 ? [0.5, 0.0] : _ref$start,
|
|
751
751
|
_ref$end = _ref.end,
|
|
752
752
|
end = _ref$end === void 0 ? [0.5, 1.0] : _ref$end,
|
|
753
|
-
_ref$
|
|
754
|
-
|
|
753
|
+
_ref$samples = _ref.samples,
|
|
754
|
+
samples = _ref$samples === void 0 ? 10.0 : _ref$samples,
|
|
755
755
|
_ref$direction = _ref.direction,
|
|
756
756
|
direction = _ref$direction === void 0 ? [1, 1] : _ref$direction;
|
|
757
757
|
|
|
758
758
|
return _Effect.call(this, 'TiltShiftEffect', TiltShiftShader.fragmentShader, {
|
|
759
759
|
blendFunction: blendFunction,
|
|
760
760
|
attributes: postprocessing.EffectAttribute.CONVOLUTION,
|
|
761
|
-
uniforms: new Map([['blur', new THREE.Uniform(blur)], ['taper', new THREE.Uniform(taper)], ['start', new THREE.Uniform(start)], ['end', new THREE.Uniform(end)], ['
|
|
761
|
+
uniforms: new Map([['blur', new THREE.Uniform(blur)], ['taper', new THREE.Uniform(taper)], ['start', new THREE.Uniform(start)], ['end', new THREE.Uniform(end)], ['samples', new THREE.Uniform(samples)], ['direction', new THREE.Uniform(direction)]])
|
|
762
762
|
}) || this;
|
|
763
763
|
}
|
|
764
764
|
|
package/dist/index.js
CHANGED
|
@@ -627,7 +627,7 @@ const TiltShiftShader = {
|
|
|
627
627
|
uniform vec2 start;
|
|
628
628
|
uniform vec2 end;
|
|
629
629
|
uniform vec2 direction;
|
|
630
|
-
uniform int
|
|
630
|
+
uniform int samples;
|
|
631
631
|
|
|
632
632
|
float random(vec3 scale, float seed) {
|
|
633
633
|
/* use the fragment position for a different seed per-pixel */
|
|
@@ -639,7 +639,7 @@ const TiltShiftShader = {
|
|
|
639
639
|
float total = 0.0;
|
|
640
640
|
vec2 startPixel = vec2(start.x * resolution.x, start.y * resolution.y);
|
|
641
641
|
vec2 endPixel = vec2(end.x * resolution.x, end.y * resolution.y);
|
|
642
|
-
float f_samples = float(
|
|
642
|
+
float f_samples = float(samples);
|
|
643
643
|
float half_samples = f_samples / 2.0;
|
|
644
644
|
|
|
645
645
|
// use screen diagonal to normalize blur radii
|
|
@@ -654,7 +654,7 @@ const TiltShiftShader = {
|
|
|
654
654
|
|
|
655
655
|
#pragma unroll_loop_start
|
|
656
656
|
for (int i = 0; i <= MAX_ITERATIONS; i++) {
|
|
657
|
-
if (i >=
|
|
657
|
+
if (i >= samples) { break; } // return early if over sample count
|
|
658
658
|
float f_i = float(i);
|
|
659
659
|
float s_i = -half_samples + f_i;
|
|
660
660
|
float percent = (s_i + offset - 0.5) / half_samples;
|
|
@@ -678,7 +678,7 @@ class TiltShiftEffect extends Effect {
|
|
|
678
678
|
constructor(_temp) {
|
|
679
679
|
let {
|
|
680
680
|
blendFunction = BlendFunction.NORMAL,
|
|
681
|
-
blur =
|
|
681
|
+
blur = 0.15,
|
|
682
682
|
// [0, 1], can go beyond 1 for extra
|
|
683
683
|
taper = 0.5,
|
|
684
684
|
// [0, 1], can go beyond 1 for extra
|
|
@@ -686,7 +686,7 @@ class TiltShiftEffect extends Effect {
|
|
|
686
686
|
// [0,1] percentage x,y of screenspace
|
|
687
687
|
end = [0.5, 1.0],
|
|
688
688
|
// [0,1] percentage x,y of screenspace
|
|
689
|
-
|
|
689
|
+
samples = 10.0,
|
|
690
690
|
// number of blur samples
|
|
691
691
|
direction = [1, 1] // direction of blur
|
|
692
692
|
|
|
@@ -694,7 +694,7 @@ class TiltShiftEffect extends Effect {
|
|
|
694
694
|
super('TiltShiftEffect', TiltShiftShader.fragmentShader, {
|
|
695
695
|
blendFunction,
|
|
696
696
|
attributes: EffectAttribute.CONVOLUTION,
|
|
697
|
-
uniforms: new Map([['blur', new Uniform(blur)], ['taper', new Uniform(taper)], ['start', new Uniform(start)], ['end', new Uniform(end)], ['
|
|
697
|
+
uniforms: new Map([['blur', new Uniform(blur)], ['taper', new Uniform(taper)], ['start', new Uniform(start)], ['end', new Uniform(end)], ['samples', new Uniform(samples)], ['direction', new Uniform(direction)]])
|
|
698
698
|
});
|
|
699
699
|
}
|
|
700
700
|
|