shaders 2.2.24 → 2.2.25
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/core/AngularBlur-Dl2gwk68.js +64 -0
- package/dist/core/Ascii-Dha_QpT3.js +286 -0
- package/dist/core/Beam-CTN9Ni43.js +139 -0
- package/dist/core/Blob-CxFDZovO.js +218 -0
- package/dist/core/Blur-Y2FsmFk_.js +77 -0
- package/dist/core/Bulge-Cb-t0xqI.js +132 -0
- package/dist/core/CRTScreen-CtERsenz.js +112 -0
- package/dist/core/ChannelBlur-CvM6GJgZ.js +118 -0
- package/dist/core/Checkerboard-CgB-egNY.js +83 -0
- package/dist/core/ChromaFlow-vRCwhQpN.js +222 -0
- package/dist/core/ChromaticAberration-FTquTQIL.js +88 -0
- package/dist/core/Circle-Daziv5d7.js +67 -0
- package/dist/core/CursorTrail-Bsz9e6Fn.js +145 -0
- package/dist/core/DiffuseBlur-Cj2PtRNd.js +83 -0
- package/dist/core/Dither-D2Nf4p3w.js +66 -0
- package/dist/core/DotGrid-CzOwquo4.js +75 -0
- package/dist/core/Duotone-XuTN9tI7.js +65 -0
- package/dist/core/FilmGrain-D3-nbi12.js +28 -0
- package/dist/core/FloatingParticles-D9Nnu1qg.js +217 -0
- package/dist/core/GlassTiles-CnjCvajI.js +69 -0
- package/dist/core/Glow-BluFc9be.js +75 -0
- package/dist/core/Godrays-ChLh_vGl.js +144 -0
- package/dist/core/Grayscale-DRny75A9.js +20 -0
- package/dist/core/Grid-DgyDa4H1.js +58 -0
- package/dist/core/GridDistortion-BAspCYvp.js +188 -0
- package/dist/core/Group-Dul7PUBl.js +14 -0
- package/dist/core/Halftone-Ifv5F_FT.js +65 -0
- package/dist/core/HueShift-De8ukMWs.js +31 -0
- package/dist/core/ImageTexture-DvYcQgJB.js +143 -0
- package/dist/core/Invert-Fz0NtIJc.js +21 -0
- package/dist/core/LinearBlur-LmhnQoA4.js +62 -0
- package/dist/core/LinearGradient-xbloQjzt.js +133 -0
- package/dist/core/Liquify-DMe1V5-O.js +175 -0
- package/dist/core/Pixelate-Cv8537Pj.js +37 -0
- package/dist/core/PolarCoordinates-DDvDhBE-.js +112 -0
- package/dist/core/Posterize-3m3xkWOz.js +29 -0
- package/dist/core/ProgressiveBlur-EGkevObV.js +121 -0
- package/dist/core/RadialGradient-B7ZZB_VJ.js +71 -0
- package/dist/core/RectangularCoordinates-muWR8mZS.js +101 -0
- package/dist/core/Ripples-8XaZaXQF.js +117 -0
- package/dist/core/Saturation-CYFI1jzN.js +30 -0
- package/dist/core/SimplexNoise-DJUe0wz_.js +99 -0
- package/dist/core/SineWave-Dl3nFO1W.js +120 -0
- package/dist/core/SolidColor-CWGq_Bjq.js +21 -0
- package/dist/core/Spherize-C-jZEUsN.js +128 -0
- package/dist/core/Spiral-BSB_R39p.js +132 -0
- package/dist/core/Strands-0stO5BMy.js +161 -0
- package/dist/core/Stretch-B645paha.js +133 -0
- package/dist/core/Swirl-CVnbawit.js +173 -0
- package/dist/core/TiltShift-0CxNRI6L.js +134 -0
- package/dist/core/Tritone-Daa-I5UD.js +76 -0
- package/dist/core/Twirl-2CJVZEtk.js +96 -0
- package/dist/core/Vibrance-DRtecEvb.js +30 -0
- package/dist/core/WaveDistortion-BscXN2rs.js +173 -0
- package/dist/core/ZoomBlur-CAqK0Kju.js +62 -0
- package/dist/core/colorMixing-BXiTAqJU.js +69 -0
- package/dist/core/edges-Bn_OIa_h.js +26 -0
- package/dist/core/index.js +2257 -1606
- package/dist/core/shaders/AngularBlur/index.js +3 -7
- package/dist/core/shaders/Ascii/index.js +2 -6
- package/dist/core/shaders/Beam/index.js +4 -8
- package/dist/core/shaders/Blob/index.js +5 -9
- package/dist/core/shaders/Blur/index.js +2 -6
- package/dist/core/shaders/Bulge/index.js +4 -8
- package/dist/core/shaders/CRTScreen/index.js +2 -6
- package/dist/core/shaders/ChannelBlur/index.js +2 -6
- package/dist/core/shaders/Checkerboard/index.js +4 -8
- package/dist/core/shaders/ChromaFlow/index.js +3 -7
- package/dist/core/shaders/ChromaticAberration/index.js +3 -7
- package/dist/core/shaders/Circle/index.js +3 -7
- package/dist/core/shaders/CursorTrail/index.js +4 -8
- package/dist/core/shaders/DiffuseBlur/index.js +4 -8
- package/dist/core/shaders/Dither/index.js +3 -7
- package/dist/core/shaders/DotGrid/index.js +3 -7
- package/dist/core/shaders/Duotone/index.js +4 -8
- package/dist/core/shaders/FilmGrain/index.js +2 -6
- package/dist/core/shaders/FloatingParticles/index.js +3 -7
- package/dist/core/shaders/GlassTiles/index.js +2 -6
- package/dist/core/shaders/Glow/index.js +2 -6
- package/dist/core/shaders/Godrays/index.js +3 -7
- package/dist/core/shaders/Grayscale/index.js +2 -8
- package/dist/core/shaders/Grid/index.js +3 -7
- package/dist/core/shaders/GridDistortion/index.js +4 -8
- package/dist/core/shaders/Group/index.js +2 -6
- package/dist/core/shaders/Halftone/index.js +3 -7
- package/dist/core/shaders/HueShift/index.js +2 -8
- package/dist/core/shaders/ImageTexture/index.js +2 -6
- package/dist/core/shaders/Invert/index.js +2 -6
- package/dist/core/shaders/LinearBlur/index.js +3 -7
- package/dist/core/shaders/LinearGradient/index.js +4 -8
- package/dist/core/shaders/Liquify/index.js +4 -8
- package/dist/core/shaders/Pixelate/index.js +2 -6
- package/dist/core/shaders/PolarCoordinates/index.js +4 -8
- package/dist/core/shaders/Posterize/index.js +2 -7
- package/dist/core/shaders/ProgressiveBlur/index.js +3 -7
- package/dist/core/shaders/RadialGradient/index.js +4 -8
- package/dist/core/shaders/RectangularCoordinates/index.js +4 -8
- package/dist/core/shaders/Ripples/index.js +5 -9
- package/dist/core/shaders/Saturation/index.js +2 -8
- package/dist/core/shaders/SimplexNoise/index.js +5 -9
- package/dist/core/shaders/SineWave/index.js +3 -7
- package/dist/core/shaders/SolidColor/index.js +3 -7
- package/dist/core/shaders/Spherize/index.js +3 -7
- package/dist/core/shaders/Spiral/index.js +4 -8
- package/dist/core/shaders/Strands/index.js +4 -8
- package/dist/core/shaders/Stretch/index.js +4 -8
- package/dist/core/shaders/Swirl/index.js +5 -9
- package/dist/core/shaders/TiltShift/index.js +3 -7
- package/dist/core/shaders/Tritone/index.js +4 -8
- package/dist/core/shaders/Twirl/index.js +4 -8
- package/dist/core/shaders/Vibrance/index.js +2 -8
- package/dist/core/shaders/WaveDistortion/index.js +4 -8
- package/dist/core/shaders/ZoomBlur/index.js +3 -7
- package/dist/core/telemetry/index.js +189 -157
- package/dist/core/time-CTJvRUZ4.js +10 -0
- package/dist/core/transformations-DxfQXZWi.js +4715 -0
- package/dist/react/generatePresetCode-CCibXbtZ.js +645 -0
- package/dist/react/index.js +7645 -104827
- package/dist/react/utils/generatePresetCode.js +2 -5
- package/dist/solid/index.js +6670 -102727
- package/dist/solid/utils/generatePresetCode.js +583 -554
- package/dist/svelte/generatePresetCode-CymgoDq_.js +645 -0
- package/dist/svelte/index.js +6175 -102645
- package/dist/svelte/utils/generatePresetCode.js +2 -5
- package/dist/vue/generatePresetCode-CRJmU8iF.js +649 -0
- package/dist/vue/index.js +6929 -103706
- package/dist/vue/utils/generatePresetCode.js +2 -5
- package/package.json +4 -1
- package/dist/core/AngularBlur-ClvtyURQ.js +0 -56
- package/dist/core/Ascii-BT0-K_vw.js +0 -196
- package/dist/core/Beam-BAKql1AP.js +0 -116
- package/dist/core/Blob-CVSxhHJG.js +0 -169
- package/dist/core/Blur-C1TTBHCX.js +0 -64
- package/dist/core/Bulge-DV8tX-cw.js +0 -103
- package/dist/core/CRTScreen-VTJQoOeq.js +0 -91
- package/dist/core/ChannelBlur-BLZ9kBNA.js +0 -89
- package/dist/core/Checkerboard-DQ4Df3vm.js +0 -75
- package/dist/core/ChromaFlow-BggN1_Av.js +0 -134
- package/dist/core/ChromaticAberration-DlTaHNcp.js +0 -82
- package/dist/core/Circle-B9ObWlq5.js +0 -62
- package/dist/core/ColorAdjustment-FeXXpypd.js +0 -14
- package/dist/core/CursorTrail-C7QdUj8O.js +0 -105
- package/dist/core/DiffuseBlur-Mx6LBsqz.js +0 -69
- package/dist/core/Dither-CeIdV_9C.js +0 -61
- package/dist/core/DotGrid-D6xUvYrt.js +0 -61
- package/dist/core/Duotone-C2Pqt2gR.js +0 -66
- package/dist/core/FilmGrain-CJ9n_fgk.js +0 -28
- package/dist/core/FloatingParticles-iGtMs44K.js +0 -160
- package/dist/core/GlassTiles-D_lVyag2.js +0 -52
- package/dist/core/Glow-B0jj-6OC.js +0 -66
- package/dist/core/Godrays-DjLVuZa4.js +0 -105
- package/dist/core/Grayscale-BbsdDa_X.js +0 -21
- package/dist/core/Grid-ByjU-_ua.js +0 -50
- package/dist/core/GridDistortion-C_eIlhkW.js +0 -147
- package/dist/core/Group-CyaDLGpI.js +0 -17
- package/dist/core/Halftone-BvuAe_k-.js +0 -55
- package/dist/core/HueShift-B_qE9c08.js +0 -32
- package/dist/core/ImageTexture-h00TFC1l.js +0 -105
- package/dist/core/Invert-BEDDB0sm.js +0 -20
- package/dist/core/LinearBlur-CLKxuyeT.js +0 -56
- package/dist/core/LinearGradient-BPo8TX_M.js +0 -111
- package/dist/core/Liquify-DGkfeixZ.js +0 -139
- package/dist/core/Pixelate-Bzy_7LnJ.js +0 -38
- package/dist/core/PolarCoordinates-BUumPeTv.js +0 -103
- package/dist/core/Posterize-ggKIJlmm.js +0 -46
- package/dist/core/ProgressiveBlur-D6_6T7SS.js +0 -102
- package/dist/core/RadialGradient-DEY9fRqa.js +0 -71
- package/dist/core/RectangularCoordinates-CZ-cFrCh.js +0 -92
- package/dist/core/Ripples-BwNlcsnV.js +0 -106
- package/dist/core/Saturation-Dl3gCWuZ.js +0 -31
- package/dist/core/SimplexNoise-BhE_WyGt.js +0 -94
- package/dist/core/SineWave-Db_Y0Mcv.js +0 -107
- package/dist/core/SolidColor-CerOp4EQ.js +0 -22
- package/dist/core/Spherize-Dh8E5XwG.js +0 -103
- package/dist/core/Spiral-BvygQEfP.js +0 -115
- package/dist/core/Strands-maaPn4On.js +0 -125
- package/dist/core/Stretch-CnA0-nSz.js +0 -103
- package/dist/core/Swirl-CQBUahTB.js +0 -148
- package/dist/core/TSLBase-Bt7Z4hv_.js +0 -8053
- package/dist/core/TiltShift-qFj0oFzN.js +0 -114
- package/dist/core/Tritone-AiixmTg8.js +0 -75
- package/dist/core/Twirl-ooHQcV89.js +0 -82
- package/dist/core/Vibrance-C2FRlLkK.js +0 -31
- package/dist/core/WaveDistortion-CN8MjKlm.js +0 -132
- package/dist/core/ZoomBlur-CxWGx8PH.js +0 -56
- package/dist/core/colorMixing--dhzx0ch.js +0 -21
- package/dist/core/edges-CDzKsauJ.js +0 -15
- package/dist/core/three.tsl-Btj1hLsf.js +0 -43845
- package/dist/core/time-DbRMw6Jm.js +0 -10
- package/dist/core/transformations-CsrIJXh-.js +0 -3992
- package/dist/react/generatePresetCode-CVj6IV8Y.js +0 -646
- package/dist/svelte/generatePresetCode-CVj6IV8Y.js +0 -646
- package/dist/vue/generatePresetCode-DCaIsDhE.js +0 -652
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { n as transformAngle } from "./transformations-DxfQXZWi.js";
|
|
2
|
+
import * as TSL from "three/tsl";
|
|
3
|
+
const componentDefinition = {
|
|
4
|
+
name: "LinearBlur",
|
|
5
|
+
category: "Blurs",
|
|
6
|
+
description: "Directional motion blur in a specific angle",
|
|
7
|
+
requiresRTT: true,
|
|
8
|
+
requiresChild: true,
|
|
9
|
+
props: {
|
|
10
|
+
intensity: {
|
|
11
|
+
default: 30,
|
|
12
|
+
description: "Intensity of the linear blur effect",
|
|
13
|
+
ui: {
|
|
14
|
+
type: "range",
|
|
15
|
+
min: 0,
|
|
16
|
+
max: 100,
|
|
17
|
+
step: 1,
|
|
18
|
+
label: "Intensity"
|
|
19
|
+
}
|
|
20
|
+
},
|
|
21
|
+
angle: {
|
|
22
|
+
default: 0,
|
|
23
|
+
transform: transformAngle,
|
|
24
|
+
description: "Direction of the linear blur (in degrees)",
|
|
25
|
+
ui: {
|
|
26
|
+
type: "range",
|
|
27
|
+
min: 0,
|
|
28
|
+
max: 360,
|
|
29
|
+
step: 1,
|
|
30
|
+
label: "Angle"
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
},
|
|
34
|
+
fragmentNode: ({ uniforms, childNode, onCleanup }) => {
|
|
35
|
+
const { vec2: vec2$1, vec4: vec4$1, float: float$1, screenUV: screenUV$1, viewportSize: viewportSize$1, sin: sin$1, cos: cos$1, radians, Fn, convertToTexture: convertToTexture$1 } = TSL;
|
|
36
|
+
if (!childNode) return vec4$1(0, 0, 0, 0);
|
|
37
|
+
const childTexture = convertToTexture$1(childNode);
|
|
38
|
+
onCleanup(() => {
|
|
39
|
+
if (childTexture?.renderTarget?.dispose) childTexture.renderTarget.dispose();
|
|
40
|
+
});
|
|
41
|
+
const angleRad = radians(uniforms.angle.uniform);
|
|
42
|
+
const blurDirection = vec2$1(cos$1(angleRad), sin$1(angleRad));
|
|
43
|
+
return Fn(() => {
|
|
44
|
+
const uv = screenUV$1;
|
|
45
|
+
const texel = vec2$1(1).div(viewportSize$1);
|
|
46
|
+
const blurVector = blurDirection.mul(uniforms.intensity.uniform).mul(texel).mul(2);
|
|
47
|
+
const total = vec4$1(0).toVar();
|
|
48
|
+
const totalWeight = float$1(0).toVar();
|
|
49
|
+
for (let i = 0; i < 32; i++) {
|
|
50
|
+
const t = float$1(i).div(float$1(31)).sub(.5).mul(2);
|
|
51
|
+
const weight = float$1(1).div(float$1(2.506628)).mul(float$1(-.5).mul(t).mul(t).div(float$1(.64)).exp());
|
|
52
|
+
const coord = uv.add(blurVector.mul(t.mul(.5)));
|
|
53
|
+
const sample = childTexture.sample(coord).mul(weight);
|
|
54
|
+
total.assign(total.add(sample));
|
|
55
|
+
totalWeight.assign(totalWeight.add(weight));
|
|
56
|
+
}
|
|
57
|
+
return total.div(totalWeight);
|
|
58
|
+
})();
|
|
59
|
+
}
|
|
60
|
+
};
|
|
61
|
+
var LinearBlur_default = componentDefinition;
|
|
62
|
+
export { componentDefinition as n, LinearBlur_default as t };
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
import { a as transformEdges, i as transformColorSpace, n as transformAngle, o as transformPosition, r as transformColor, t as colorSpaceOptions } from "./transformations-DxfQXZWi.js";
|
|
2
|
+
import { t as mixColors } from "./colorMixing-BXiTAqJU.js";
|
|
3
|
+
import * as TSL from "three/tsl";
|
|
4
|
+
const componentDefinition = {
|
|
5
|
+
name: "LinearGradient",
|
|
6
|
+
category: "Base Layers",
|
|
7
|
+
description: "Create smooth linear color gradients",
|
|
8
|
+
acceptsUVContext: true,
|
|
9
|
+
props: {
|
|
10
|
+
colorA: {
|
|
11
|
+
default: "#1aff00",
|
|
12
|
+
transform: transformColor,
|
|
13
|
+
description: "The starting color of the gradient",
|
|
14
|
+
ui: {
|
|
15
|
+
type: "color",
|
|
16
|
+
label: "Color A"
|
|
17
|
+
}
|
|
18
|
+
},
|
|
19
|
+
colorB: {
|
|
20
|
+
default: "#0000ff",
|
|
21
|
+
transform: transformColor,
|
|
22
|
+
description: "The ending color of the gradient",
|
|
23
|
+
ui: {
|
|
24
|
+
type: "color",
|
|
25
|
+
label: "Color B"
|
|
26
|
+
}
|
|
27
|
+
},
|
|
28
|
+
start: {
|
|
29
|
+
default: {
|
|
30
|
+
x: 0,
|
|
31
|
+
y: .5
|
|
32
|
+
},
|
|
33
|
+
transform: transformPosition,
|
|
34
|
+
description: "The starting point of the gradient",
|
|
35
|
+
ui: {
|
|
36
|
+
type: "position",
|
|
37
|
+
label: "Start"
|
|
38
|
+
}
|
|
39
|
+
},
|
|
40
|
+
end: {
|
|
41
|
+
default: {
|
|
42
|
+
x: 1,
|
|
43
|
+
y: .5
|
|
44
|
+
},
|
|
45
|
+
transform: transformPosition,
|
|
46
|
+
description: "The ending point of the gradient",
|
|
47
|
+
ui: {
|
|
48
|
+
type: "position",
|
|
49
|
+
label: "End"
|
|
50
|
+
}
|
|
51
|
+
},
|
|
52
|
+
angle: {
|
|
53
|
+
default: 0,
|
|
54
|
+
transform: transformAngle,
|
|
55
|
+
description: "Additional rotation angle of the gradient (in degrees)",
|
|
56
|
+
ui: {
|
|
57
|
+
type: "range",
|
|
58
|
+
min: 0,
|
|
59
|
+
max: 360,
|
|
60
|
+
step: 1,
|
|
61
|
+
label: "Angle"
|
|
62
|
+
}
|
|
63
|
+
},
|
|
64
|
+
edges: {
|
|
65
|
+
default: "stretch",
|
|
66
|
+
transform: transformEdges,
|
|
67
|
+
description: "How to handle areas beyond the gradient endpoints",
|
|
68
|
+
ui: {
|
|
69
|
+
type: "select",
|
|
70
|
+
options: [
|
|
71
|
+
{
|
|
72
|
+
label: "Stretch",
|
|
73
|
+
value: "stretch"
|
|
74
|
+
},
|
|
75
|
+
{
|
|
76
|
+
label: "Transparent",
|
|
77
|
+
value: "transparent"
|
|
78
|
+
},
|
|
79
|
+
{
|
|
80
|
+
label: "Mirror",
|
|
81
|
+
value: "mirror"
|
|
82
|
+
},
|
|
83
|
+
{
|
|
84
|
+
label: "Wrap",
|
|
85
|
+
value: "wrap"
|
|
86
|
+
}
|
|
87
|
+
],
|
|
88
|
+
label: "Edges"
|
|
89
|
+
}
|
|
90
|
+
},
|
|
91
|
+
colorSpace: {
|
|
92
|
+
default: "linear",
|
|
93
|
+
transform: transformColorSpace,
|
|
94
|
+
description: "Color space for color interpolation",
|
|
95
|
+
ui: {
|
|
96
|
+
type: "select",
|
|
97
|
+
options: colorSpaceOptions,
|
|
98
|
+
label: "Color Space"
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
},
|
|
102
|
+
fragmentNode: ({ uniforms, uvContext }) => {
|
|
103
|
+
const { vec2: vec2$1, vec4: vec4$1, float: float$1, cos: cos$1, sin: sin$1, dot: dot$1, radians, screenUV: screenUV$1, length, normalize, abs: abs$1, mod, fract } = TSL;
|
|
104
|
+
const uv = uvContext ?? screenUV$1;
|
|
105
|
+
const startPos = vec2$1(uniforms.start.uniform[0], uniforms.start.uniform[1].oneMinus());
|
|
106
|
+
const endPos = vec2$1(uniforms.end.uniform[0], uniforms.end.uniform[1].oneMinus());
|
|
107
|
+
const gradientVector = endPos.sub(startPos);
|
|
108
|
+
const gradientLength = length(gradientVector);
|
|
109
|
+
const gradientDir = normalize(gradientVector);
|
|
110
|
+
const angleRad = radians(uniforms.angle.uniform).negate();
|
|
111
|
+
const cosAngle = cos$1(angleRad);
|
|
112
|
+
const sinAngle = sin$1(angleRad);
|
|
113
|
+
const midpoint = startPos.add(endPos).mul(.5);
|
|
114
|
+
const centeredUV = uv.sub(midpoint);
|
|
115
|
+
const t = dot$1(vec2$1(centeredUV.x.mul(cosAngle).sub(centeredUV.y.mul(sinAngle)), centeredUV.x.mul(sinAngle).add(centeredUV.y.mul(cosAngle))).add(midpoint).sub(startPos), gradientDir).div(gradientLength.max(1e-6));
|
|
116
|
+
const edgeMode = uniforms.edges.uniform;
|
|
117
|
+
const stretchT = t.clamp(float$1(0), float$1(1));
|
|
118
|
+
const inBoundsX = t.greaterThanEqual(float$1(0)).select(float$1(1), float$1(0));
|
|
119
|
+
const inBoundsY = t.lessThanEqual(float$1(1)).select(float$1(1), float$1(0));
|
|
120
|
+
const inBounds = inBoundsX.mul(inBoundsY);
|
|
121
|
+
const mirrorT = mod(abs$1(t), float$1(2));
|
|
122
|
+
const finalMirrorT = mirrorT.greaterThan(float$1(1)).select(float$1(2).sub(mirrorT), mirrorT);
|
|
123
|
+
const wrapT = fract(t);
|
|
124
|
+
const isMode1OrHigher = edgeMode.greaterThanEqual(float$1(.5));
|
|
125
|
+
const isMode2OrHigher = edgeMode.greaterThanEqual(float$1(1.5));
|
|
126
|
+
const finalT = edgeMode.greaterThanEqual(float$1(2.5)).select(wrapT, isMode2OrHigher.select(finalMirrorT, isMode1OrHigher.select(t, stretchT)));
|
|
127
|
+
const mixedColor = mixColors(uniforms.colorA.uniform, uniforms.colorB.uniform, finalT.clamp(float$1(0), float$1(1)), uniforms.colorSpace.uniform);
|
|
128
|
+
const finalAlpha = isMode1OrHigher.and(edgeMode.lessThan(float$1(1.5))).select(mixedColor.w.mul(inBounds), mixedColor.w);
|
|
129
|
+
return vec4$1(mixedColor.x, mixedColor.y, mixedColor.z, finalAlpha);
|
|
130
|
+
}
|
|
131
|
+
};
|
|
132
|
+
var LinearGradient_default = componentDefinition;
|
|
133
|
+
export { componentDefinition as n, LinearGradient_default as t };
|
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
import { t as applyEdgeHandling } from "./edges-Bn_OIa_h.js";
|
|
2
|
+
import { a as transformEdges } from "./transformations-DxfQXZWi.js";
|
|
3
|
+
import { DataTexture, FloatType, LinearFilter, RGFormat } from "three";
|
|
4
|
+
import * as TSL from "three/tsl";
|
|
5
|
+
var GRID_SIZE = 32;
|
|
6
|
+
var displacementStateCache = /* @__PURE__ */ new WeakMap();
|
|
7
|
+
var getOrCreateDisplacementState = (uniforms) => {
|
|
8
|
+
let state = displacementStateCache.get(uniforms);
|
|
9
|
+
if (!state) {
|
|
10
|
+
const data = new Float32Array(GRID_SIZE * GRID_SIZE * 2);
|
|
11
|
+
const texture = new DataTexture(data, GRID_SIZE, GRID_SIZE, RGFormat, FloatType);
|
|
12
|
+
texture.magFilter = LinearFilter;
|
|
13
|
+
texture.minFilter = LinearFilter;
|
|
14
|
+
texture.needsUpdate = true;
|
|
15
|
+
state = {
|
|
16
|
+
texture,
|
|
17
|
+
data,
|
|
18
|
+
tslNode: TSL.texture(texture),
|
|
19
|
+
initialized: false
|
|
20
|
+
};
|
|
21
|
+
displacementStateCache.set(uniforms, state);
|
|
22
|
+
}
|
|
23
|
+
return state;
|
|
24
|
+
};
|
|
25
|
+
const componentDefinition = {
|
|
26
|
+
name: "Liquify",
|
|
27
|
+
category: "Interactive",
|
|
28
|
+
description: "Liquid-like interactive deformation effect",
|
|
29
|
+
requiresRTT: true,
|
|
30
|
+
requiresChild: true,
|
|
31
|
+
props: {
|
|
32
|
+
intensity: {
|
|
33
|
+
default: 1,
|
|
34
|
+
description: "Strength of the distortion effect",
|
|
35
|
+
ui: {
|
|
36
|
+
type: "range",
|
|
37
|
+
min: 0,
|
|
38
|
+
max: 5,
|
|
39
|
+
step: .1,
|
|
40
|
+
label: "Intensity"
|
|
41
|
+
}
|
|
42
|
+
},
|
|
43
|
+
swirl: {
|
|
44
|
+
default: 0,
|
|
45
|
+
description: "Amount of swirl motion (0-1)",
|
|
46
|
+
ui: {
|
|
47
|
+
type: "range",
|
|
48
|
+
min: 0,
|
|
49
|
+
max: 1,
|
|
50
|
+
step: .01,
|
|
51
|
+
label: "Swirl"
|
|
52
|
+
}
|
|
53
|
+
},
|
|
54
|
+
decay: {
|
|
55
|
+
default: 3,
|
|
56
|
+
description: "Rate of distortion decay (higher = faster)",
|
|
57
|
+
ui: {
|
|
58
|
+
type: "range",
|
|
59
|
+
min: 0,
|
|
60
|
+
max: 10,
|
|
61
|
+
step: .1,
|
|
62
|
+
label: "Decay"
|
|
63
|
+
}
|
|
64
|
+
},
|
|
65
|
+
radius: {
|
|
66
|
+
default: 1,
|
|
67
|
+
description: "Radius of the distortion effect",
|
|
68
|
+
ui: {
|
|
69
|
+
type: "range",
|
|
70
|
+
min: 0,
|
|
71
|
+
max: 3,
|
|
72
|
+
step: .01,
|
|
73
|
+
label: "Radius"
|
|
74
|
+
}
|
|
75
|
+
},
|
|
76
|
+
edges: {
|
|
77
|
+
default: "stretch",
|
|
78
|
+
description: "How to handle edges when distortion pushes content out of bounds",
|
|
79
|
+
transform: transformEdges,
|
|
80
|
+
ui: {
|
|
81
|
+
type: "select",
|
|
82
|
+
options: [
|
|
83
|
+
{
|
|
84
|
+
label: "Stretch",
|
|
85
|
+
value: "stretch"
|
|
86
|
+
},
|
|
87
|
+
{
|
|
88
|
+
label: "Transparent",
|
|
89
|
+
value: "transparent"
|
|
90
|
+
},
|
|
91
|
+
{
|
|
92
|
+
label: "Mirror",
|
|
93
|
+
value: "mirror"
|
|
94
|
+
},
|
|
95
|
+
{
|
|
96
|
+
label: "Wrap",
|
|
97
|
+
value: "wrap"
|
|
98
|
+
}
|
|
99
|
+
],
|
|
100
|
+
label: "Edges"
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
},
|
|
104
|
+
uvTransformNode: ({ uv, uniforms }) => {
|
|
105
|
+
const { vec2: vec2$1, float: float$1 } = TSL;
|
|
106
|
+
const displacement = getOrCreateDisplacementState(uniforms).tslNode.sample(uv).xy;
|
|
107
|
+
const maxDisplacement = float$1(.2);
|
|
108
|
+
const clampedDisplacement = displacement.clamp(vec2$1(maxDisplacement.negate(), maxDisplacement.negate()), vec2$1(maxDisplacement, maxDisplacement));
|
|
109
|
+
return uv.sub(clampedDisplacement);
|
|
110
|
+
},
|
|
111
|
+
fragmentNode: ({ uniforms, onBeforeRender, childNode, onCleanup }) => {
|
|
112
|
+
const { vec2: vec2$1, vec4: vec4$1, float: float$1, uniform: uniform$1, screenUV: screenUV$1, convertToTexture: convertToTexture$1 } = TSL;
|
|
113
|
+
const { texture: displacementTexture, data: displacementData, tslNode: displacementField } = getOrCreateDisplacementState(uniforms);
|
|
114
|
+
const mouseVelX = uniform$1(0);
|
|
115
|
+
const mouseVelY = uniform$1(0);
|
|
116
|
+
let prevX = .5;
|
|
117
|
+
let prevY = .5;
|
|
118
|
+
let lastTime = Date.now();
|
|
119
|
+
onBeforeRender(({ pointer }) => {
|
|
120
|
+
const currentTime = Date.now();
|
|
121
|
+
const dt = Math.min((currentTime - lastTime) / 1e3, .016);
|
|
122
|
+
lastTime = currentTime;
|
|
123
|
+
const velX = dt > 0 ? (pointer.x - prevX) / dt : 0;
|
|
124
|
+
const velY = dt > 0 ? (pointer.y - prevY) / dt : 0;
|
|
125
|
+
mouseVelX.value = mouseVelX.value * .85 + velX * .15;
|
|
126
|
+
mouseVelY.value = mouseVelY.value * .85 + velY * .15;
|
|
127
|
+
const decay = uniforms.decay.uniform.value;
|
|
128
|
+
const intensity = uniforms.intensity.uniform.value;
|
|
129
|
+
const radius = uniforms.radius.uniform.value * .05;
|
|
130
|
+
const swirl = uniforms.swirl.uniform.value;
|
|
131
|
+
for (let i = 0; i < GRID_SIZE; i++) for (let j = 0; j < GRID_SIZE; j++) {
|
|
132
|
+
const idx = (i * GRID_SIZE + j) * 2;
|
|
133
|
+
displacementData[idx] *= 1 - decay * dt;
|
|
134
|
+
displacementData[idx + 1] *= 1 - decay * dt;
|
|
135
|
+
const cellX = (j + .5) / GRID_SIZE;
|
|
136
|
+
const cellY = (i + .5) / GRID_SIZE;
|
|
137
|
+
const dx = cellX - pointer.x;
|
|
138
|
+
const dy = cellY - pointer.y;
|
|
139
|
+
const dist = Math.sqrt(dx * dx + dy * dy);
|
|
140
|
+
if (dist < radius * 2 && Math.abs(velX) + Math.abs(velY) > .01) {
|
|
141
|
+
const influence = Math.exp(-dist * dist / (radius * radius));
|
|
142
|
+
displacementData[idx] += mouseVelX.value * influence * intensity * dt * .5;
|
|
143
|
+
displacementData[idx + 1] += mouseVelY.value * influence * intensity * dt * .5;
|
|
144
|
+
if (swirl > 0) {
|
|
145
|
+
const angle = Math.atan2(dy, dx) + Math.PI * .5;
|
|
146
|
+
displacementData[idx] += Math.cos(angle) * swirl * influence * dt * 2;
|
|
147
|
+
displacementData[idx + 1] += Math.sin(angle) * swirl * influence * dt * 2;
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
displacementData[idx] = Math.max(-1, Math.min(1, displacementData[idx]));
|
|
151
|
+
displacementData[idx + 1] = Math.max(-1, Math.min(1, displacementData[idx + 1]));
|
|
152
|
+
}
|
|
153
|
+
displacementTexture.needsUpdate = true;
|
|
154
|
+
prevX = pointer.x;
|
|
155
|
+
prevY = pointer.y;
|
|
156
|
+
});
|
|
157
|
+
onCleanup(() => {
|
|
158
|
+
displacementTexture.dispose();
|
|
159
|
+
displacementStateCache.delete(uniforms);
|
|
160
|
+
});
|
|
161
|
+
if (!childNode) return vec4$1(0, 0, 0, 0);
|
|
162
|
+
const childTexture = convertToTexture$1(childNode);
|
|
163
|
+
onCleanup(() => {
|
|
164
|
+
if (childTexture?.renderTarget?.dispose) childTexture.renderTarget.dispose();
|
|
165
|
+
});
|
|
166
|
+
const displacement = displacementField.sample(screenUV$1).xy;
|
|
167
|
+
const maxDisplacement = float$1(.2);
|
|
168
|
+
const negMaxDisplacement = float$1(-.2);
|
|
169
|
+
const clampedDisplacement = displacement.clamp(vec2$1(negMaxDisplacement, negMaxDisplacement), vec2$1(maxDisplacement, maxDisplacement));
|
|
170
|
+
const distortedUV = screenUV$1.sub(clampedDisplacement);
|
|
171
|
+
return applyEdgeHandling(distortedUV, childTexture.sample(distortedUV), childTexture, uniforms.edges.uniform);
|
|
172
|
+
}
|
|
173
|
+
};
|
|
174
|
+
var Liquify_default = componentDefinition;
|
|
175
|
+
export { componentDefinition as n, Liquify_default as t };
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import * as TSL from "three/tsl";
|
|
2
|
+
const componentDefinition = {
|
|
3
|
+
name: "Pixelate",
|
|
4
|
+
category: "Stylize",
|
|
5
|
+
description: "Pixelation effect with adjustable cell size",
|
|
6
|
+
requiresRTT: true,
|
|
7
|
+
requiresChild: true,
|
|
8
|
+
props: { scale: {
|
|
9
|
+
default: 50,
|
|
10
|
+
description: "Pixel size - higher values create larger, more visible pixels",
|
|
11
|
+
ui: {
|
|
12
|
+
type: "range",
|
|
13
|
+
min: 1,
|
|
14
|
+
max: 200,
|
|
15
|
+
step: 1,
|
|
16
|
+
label: "Scale"
|
|
17
|
+
}
|
|
18
|
+
} },
|
|
19
|
+
uvTransformNode: ({ uv, uniforms }) => {
|
|
20
|
+
const { floor } = TSL;
|
|
21
|
+
const pixelSize = uniforms.scale.uniform;
|
|
22
|
+
return floor(uv.mul(pixelSize)).div(pixelSize);
|
|
23
|
+
},
|
|
24
|
+
fragmentNode: ({ uniforms, childNode, onCleanup }) => {
|
|
25
|
+
const { vec4: vec4$1, floor, screenUV: screenUV$1, convertToTexture: convertToTexture$1 } = TSL;
|
|
26
|
+
if (!childNode) return vec4$1(0, 0, 0, 0);
|
|
27
|
+
const childTexture = convertToTexture$1(childNode);
|
|
28
|
+
onCleanup(() => {
|
|
29
|
+
if (childTexture?.renderTarget?.dispose) childTexture.renderTarget.dispose();
|
|
30
|
+
});
|
|
31
|
+
const pixelSize = uniforms.scale.uniform;
|
|
32
|
+
const pixelatedUV = floor(screenUV$1.mul(pixelSize)).div(pixelSize);
|
|
33
|
+
return childTexture.sample(pixelatedUV);
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
var Pixelate_default = componentDefinition;
|
|
37
|
+
export { componentDefinition as n, Pixelate_default as t };
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
import { t as applyEdgeHandling } from "./edges-Bn_OIa_h.js";
|
|
2
|
+
import { a as transformEdges, o as transformPosition } from "./transformations-DxfQXZWi.js";
|
|
3
|
+
import * as TSL from "three/tsl";
|
|
4
|
+
const componentDefinition = {
|
|
5
|
+
name: "PolarCoordinates",
|
|
6
|
+
category: "Distortions",
|
|
7
|
+
description: "Convert rectangular coordinates to polar space",
|
|
8
|
+
requiresRTT: true,
|
|
9
|
+
requiresChild: true,
|
|
10
|
+
props: {
|
|
11
|
+
center: {
|
|
12
|
+
default: {
|
|
13
|
+
x: .5,
|
|
14
|
+
y: .5
|
|
15
|
+
},
|
|
16
|
+
transform: transformPosition,
|
|
17
|
+
description: "The center point for polar coordinate conversion",
|
|
18
|
+
ui: {
|
|
19
|
+
type: "position",
|
|
20
|
+
label: "Center"
|
|
21
|
+
}
|
|
22
|
+
},
|
|
23
|
+
wrap: {
|
|
24
|
+
default: 1,
|
|
25
|
+
description: "Controls how much of the angular range to use (1 = full 360°, 0.5 = 180°)",
|
|
26
|
+
ui: {
|
|
27
|
+
type: "range",
|
|
28
|
+
min: 0,
|
|
29
|
+
max: 2,
|
|
30
|
+
step: .01,
|
|
31
|
+
label: "Wrap"
|
|
32
|
+
}
|
|
33
|
+
},
|
|
34
|
+
radius: {
|
|
35
|
+
default: 1,
|
|
36
|
+
description: "Controls how much of the radius range to use (affects the radial mapping)",
|
|
37
|
+
ui: {
|
|
38
|
+
type: "range",
|
|
39
|
+
min: 0,
|
|
40
|
+
max: 2,
|
|
41
|
+
step: .01,
|
|
42
|
+
label: "Radius"
|
|
43
|
+
}
|
|
44
|
+
},
|
|
45
|
+
intensity: {
|
|
46
|
+
default: 1,
|
|
47
|
+
description: "Blends between original UVs (0) and polar coordinates (1)",
|
|
48
|
+
ui: {
|
|
49
|
+
type: "range",
|
|
50
|
+
min: 0,
|
|
51
|
+
max: 1,
|
|
52
|
+
step: .01,
|
|
53
|
+
label: "Intensity"
|
|
54
|
+
}
|
|
55
|
+
},
|
|
56
|
+
edges: {
|
|
57
|
+
default: "transparent",
|
|
58
|
+
description: "How to handle edges when distortion pushes content out of bounds",
|
|
59
|
+
transform: transformEdges,
|
|
60
|
+
ui: {
|
|
61
|
+
type: "select",
|
|
62
|
+
options: [
|
|
63
|
+
{
|
|
64
|
+
label: "Stretch",
|
|
65
|
+
value: "stretch"
|
|
66
|
+
},
|
|
67
|
+
{
|
|
68
|
+
label: "Transparent",
|
|
69
|
+
value: "transparent"
|
|
70
|
+
},
|
|
71
|
+
{
|
|
72
|
+
label: "Mirror",
|
|
73
|
+
value: "mirror"
|
|
74
|
+
},
|
|
75
|
+
{
|
|
76
|
+
label: "Wrap",
|
|
77
|
+
value: "wrap"
|
|
78
|
+
}
|
|
79
|
+
],
|
|
80
|
+
label: "Edges"
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
},
|
|
84
|
+
uvTransformNode: ({ uv, uniforms, viewportSize: viewportSize$1 }) => {
|
|
85
|
+
const { vec2: vec2$1, length, atan: atan$1, PI, mix: mix$1 } = TSL;
|
|
86
|
+
const aspect = viewportSize$1.x.div(viewportSize$1.y);
|
|
87
|
+
const aspectCorrectedUV = vec2$1(uv.x.mul(aspect), uv.y);
|
|
88
|
+
const centerPos = vec2$1(uniforms.center.uniform.x.mul(aspect), uniforms.center.uniform.y.oneMinus());
|
|
89
|
+
const delta = aspectCorrectedUV.sub(centerPos);
|
|
90
|
+
const normalizedAngle = atan$1(delta.y, delta.x).add(PI).div(PI.mul(2));
|
|
91
|
+
const r = length(delta);
|
|
92
|
+
return mix$1(uv, vec2$1(normalizedAngle.mul(uniforms.wrap.uniform), r.mul(uniforms.radius.uniform)), uniforms.intensity.uniform);
|
|
93
|
+
},
|
|
94
|
+
fragmentNode: ({ uniforms, childNode, onCleanup }) => {
|
|
95
|
+
const { vec2: vec2$1, vec4: vec4$1, length, atan: atan$1, screenUV: screenUV$1, viewportSize: viewportSize$1, convertToTexture: convertToTexture$1, PI, mix: mix$1 } = TSL;
|
|
96
|
+
if (!childNode) return vec4$1(0, 0, 0, 0);
|
|
97
|
+
const childTexture = convertToTexture$1(childNode);
|
|
98
|
+
onCleanup(() => {
|
|
99
|
+
if (childTexture?.renderTarget?.dispose) childTexture.renderTarget.dispose();
|
|
100
|
+
});
|
|
101
|
+
const aspect = viewportSize$1.x.div(viewportSize$1.y);
|
|
102
|
+
const aspectCorrectedUV = vec2$1(screenUV$1.x.mul(aspect), screenUV$1.y);
|
|
103
|
+
const centerPos = vec2$1(uniforms.center.uniform.x.mul(aspect), uniforms.center.uniform.y.oneMinus());
|
|
104
|
+
const delta = aspectCorrectedUV.sub(centerPos);
|
|
105
|
+
const normalizedAngle = atan$1(delta.y, delta.x).add(PI).div(PI.mul(2));
|
|
106
|
+
const r = length(delta);
|
|
107
|
+
const blendedUV = mix$1(screenUV$1, vec2$1(normalizedAngle.mul(uniforms.wrap.uniform), r.mul(uniforms.radius.uniform)), uniforms.intensity.uniform);
|
|
108
|
+
return applyEdgeHandling(blendedUV, childTexture.sample(blendedUV), childTexture, uniforms.edges.uniform);
|
|
109
|
+
}
|
|
110
|
+
};
|
|
111
|
+
var PolarCoordinates_default = componentDefinition;
|
|
112
|
+
export { componentDefinition as n, PolarCoordinates_default as t };
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import * as TSL from "three/tsl";
|
|
2
|
+
import { posterize } from "three/src/nodes/display/PosterizeNode";
|
|
3
|
+
const componentDefinition = {
|
|
4
|
+
name: "Posterize",
|
|
5
|
+
category: "Adjustments",
|
|
6
|
+
description: "Reduce color depth to create a poster effect",
|
|
7
|
+
requiresChild: true,
|
|
8
|
+
props: { intensity: {
|
|
9
|
+
default: 5,
|
|
10
|
+
description: "The intensity of the posterization effect (lower is more posterized)",
|
|
11
|
+
ui: {
|
|
12
|
+
type: "range",
|
|
13
|
+
min: 2,
|
|
14
|
+
max: 20,
|
|
15
|
+
step: 1,
|
|
16
|
+
label: "Intensity"
|
|
17
|
+
}
|
|
18
|
+
} },
|
|
19
|
+
fragmentNode: ({ uniforms, childNode }) => {
|
|
20
|
+
const { vec4: vec4$1, int } = TSL;
|
|
21
|
+
if (!childNode) {
|
|
22
|
+
console.error("You must pass a child component into the Posterize shader.");
|
|
23
|
+
return vec4$1(0);
|
|
24
|
+
}
|
|
25
|
+
return posterize(childNode || vec4$1(0, 0, 0, 0), int(uniforms.intensity.uniform));
|
|
26
|
+
}
|
|
27
|
+
};
|
|
28
|
+
var Posterize_default = componentDefinition;
|
|
29
|
+
export { componentDefinition as n, Posterize_default as t };
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
import { n as transformAngle, o as transformPosition } from "./transformations-DxfQXZWi.js";
|
|
2
|
+
import * as TSL from "three/tsl";
|
|
3
|
+
const componentDefinition = {
|
|
4
|
+
name: "ProgressiveBlur",
|
|
5
|
+
category: "Blurs",
|
|
6
|
+
description: "Blur that increases progressively in one direction",
|
|
7
|
+
requiresRTT: true,
|
|
8
|
+
requiresChild: true,
|
|
9
|
+
props: {
|
|
10
|
+
intensity: {
|
|
11
|
+
default: 50,
|
|
12
|
+
description: "Maximum intensity of the blur effect",
|
|
13
|
+
ui: {
|
|
14
|
+
type: "range",
|
|
15
|
+
min: 0,
|
|
16
|
+
max: 100,
|
|
17
|
+
step: 1,
|
|
18
|
+
label: "Intensity"
|
|
19
|
+
}
|
|
20
|
+
},
|
|
21
|
+
angle: {
|
|
22
|
+
default: 0,
|
|
23
|
+
transform: transformAngle,
|
|
24
|
+
description: "Direction of the blur gradient (in degrees)",
|
|
25
|
+
ui: {
|
|
26
|
+
type: "range",
|
|
27
|
+
min: 0,
|
|
28
|
+
max: 360,
|
|
29
|
+
step: 1,
|
|
30
|
+
label: "Angle"
|
|
31
|
+
}
|
|
32
|
+
},
|
|
33
|
+
center: {
|
|
34
|
+
default: {
|
|
35
|
+
x: 0,
|
|
36
|
+
y: .5
|
|
37
|
+
},
|
|
38
|
+
transform: transformPosition,
|
|
39
|
+
description: "Center point where blur begins",
|
|
40
|
+
ui: {
|
|
41
|
+
type: "position",
|
|
42
|
+
label: "Center"
|
|
43
|
+
}
|
|
44
|
+
},
|
|
45
|
+
falloff: {
|
|
46
|
+
default: 1,
|
|
47
|
+
description: "Distance over which blur transitions to full strength",
|
|
48
|
+
ui: {
|
|
49
|
+
type: "range",
|
|
50
|
+
min: 0,
|
|
51
|
+
max: 1,
|
|
52
|
+
step: .01,
|
|
53
|
+
label: "Falloff"
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
},
|
|
57
|
+
fragmentNode: ({ uniforms, childNode, onCleanup }) => {
|
|
58
|
+
const { vec2: vec2$1, vec4: vec4$1, float: float$1, screenUV: screenUV$1, viewportSize: viewportSize$1, sin: sin$1, cos: cos$1, radians, max: max$1, smoothstep, Fn, convertToTexture: convertToTexture$1 } = TSL;
|
|
59
|
+
if (!childNode) return vec4$1(0, 0, 0, 0);
|
|
60
|
+
const childTexture = convertToTexture$1(childNode);
|
|
61
|
+
onCleanup(() => {
|
|
62
|
+
if (childTexture?.renderTarget?.dispose) childTexture.renderTarget.dispose();
|
|
63
|
+
});
|
|
64
|
+
const angleRad = radians(uniforms.angle.uniform);
|
|
65
|
+
const direction = vec2$1(cos$1(angleRad), sin$1(angleRad));
|
|
66
|
+
const centerPosition = vec2$1(uniforms.center.uniform[0], uniforms.center.uniform[1].oneMinus());
|
|
67
|
+
const centeredUV = screenUV$1.sub(centerPosition);
|
|
68
|
+
const directionalDist = max$1(float$1(0), centeredUV.dot(direction));
|
|
69
|
+
const falloff = max$1(float$1(.001), uniforms.falloff.uniform);
|
|
70
|
+
const blurAmount = smoothstep(float$1(0), falloff, directionalDist);
|
|
71
|
+
const scaledIntensity = uniforms.intensity.uniform.mul(.06);
|
|
72
|
+
const blurRadius = blurAmount.mul(scaledIntensity);
|
|
73
|
+
const weights = [
|
|
74
|
+
.056,
|
|
75
|
+
.135,
|
|
76
|
+
.278,
|
|
77
|
+
.487,
|
|
78
|
+
.726,
|
|
79
|
+
.923,
|
|
80
|
+
1,
|
|
81
|
+
.923,
|
|
82
|
+
.726,
|
|
83
|
+
.487,
|
|
84
|
+
.278,
|
|
85
|
+
.135,
|
|
86
|
+
.056
|
|
87
|
+
];
|
|
88
|
+
const weightSum = 6.214;
|
|
89
|
+
const horizontalTexture = convertToTexture$1(Fn(() => {
|
|
90
|
+
const uv = screenUV$1;
|
|
91
|
+
const pixelSize = vec2$1(1).div(viewportSize$1);
|
|
92
|
+
const total = vec4$1(0).toVar();
|
|
93
|
+
for (let x = -6; x <= 6; x++) {
|
|
94
|
+
const weight = float$1(weights[x + 6] / weightSum);
|
|
95
|
+
const offset = vec2$1(float$1(x), float$1(0)).mul(blurRadius).mul(pixelSize);
|
|
96
|
+
const sampleCoord = uv.add(offset);
|
|
97
|
+
const sample = childTexture.sample(sampleCoord).mul(weight);
|
|
98
|
+
total.assign(total.add(sample));
|
|
99
|
+
}
|
|
100
|
+
return total;
|
|
101
|
+
})());
|
|
102
|
+
onCleanup(() => {
|
|
103
|
+
if (horizontalTexture?.renderTarget?.dispose) horizontalTexture.renderTarget.dispose();
|
|
104
|
+
});
|
|
105
|
+
return Fn(() => {
|
|
106
|
+
const uv = screenUV$1;
|
|
107
|
+
const pixelSize = vec2$1(1).div(viewportSize$1);
|
|
108
|
+
const total = vec4$1(0).toVar();
|
|
109
|
+
for (let y = -6; y <= 6; y++) {
|
|
110
|
+
const weight = float$1(weights[y + 6] / weightSum);
|
|
111
|
+
const offset = vec2$1(float$1(0), float$1(y)).mul(blurRadius).mul(pixelSize);
|
|
112
|
+
const sampleCoord = uv.add(offset);
|
|
113
|
+
const sample = horizontalTexture.sample(sampleCoord).mul(weight);
|
|
114
|
+
total.assign(total.add(sample));
|
|
115
|
+
}
|
|
116
|
+
return total;
|
|
117
|
+
})();
|
|
118
|
+
}
|
|
119
|
+
};
|
|
120
|
+
var ProgressiveBlur_default = componentDefinition;
|
|
121
|
+
export { componentDefinition as n, ProgressiveBlur_default as t };
|