shaders 2.5.94 → 2.5.96
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/Blur-CXXttTb1.js +138 -0
- package/dist/core/{ChannelBlur-CCaPXjka.js → ChannelBlur-gzP71FWd.js} +37 -2
- package/dist/core/{Crescent-DPxGWdPH.js → Crescent-BkRt-XWy.js} +1 -1
- package/dist/core/{Cross-CDyzf8TT.js → Cross-kkY7feuC.js} +1 -1
- package/dist/core/{Crystal-DSuN8TNY.js → Crystal-xVyUhVD-.js} +1 -1
- package/dist/core/CursorRipples-Cgm7N0Bp.js +289 -0
- package/dist/core/CursorTrail-CCRbdwHJ.js +263 -0
- package/dist/core/{Ellipse-BNmzdnpK.js → Ellipse-CXxGqTYI.js} +1 -1
- package/dist/core/{Emboss-nrduRrVs.js → Emboss-ClQV27Mt.js} +1 -1
- package/dist/core/{Flower-B4xPp0Qa.js → Flower-MAwlZEv8.js} +1 -1
- package/dist/core/{Glass-CRfTkmRy.js → Glass-DDBKYclp.js} +46 -8
- package/dist/core/Glow-BwaPYDRZ.js +174 -0
- package/dist/core/GridDistortion-DtaRNrTZ.js +278 -0
- package/dist/core/Liquify-cE5dxrfh.js +351 -0
- package/dist/core/{Neon-CUKnkAK8.js → Neon-Dg8UfC7P.js} +1 -1
- package/dist/core/{Polygon-C1y6Nyh4.js → Polygon-DRCs3CYs.js} +1 -1
- package/dist/core/ProgressiveBlur-B8xwWyTM.js +236 -0
- package/dist/core/{Ring-Chj1tp_P.js → Ring-QApyKPzE.js} +1 -1
- package/dist/core/{RoundedRect-BEj6tE1e.js → RoundedRect-Ca9af9xe.js} +1 -1
- package/dist/core/{Shatter-CZMOHj60.js → Shatter-BssZTRYJ.js} +154 -66
- package/dist/core/{Star-fPw1j10r.js → Star-DiXwnPGP.js} +1 -1
- package/dist/core/TiltShift-CI3FlfYk.js +252 -0
- package/dist/core/{Trapezoid-Cr61vRvN.js → Trapezoid-BX_hmeZJ.js} +1 -1
- package/dist/core/{Vesica-AXTA8DJU.js → Vesica-DU0f85NG.js} +1 -1
- package/dist/core/{VideoTexture-BobyGZGr.js → VideoTexture-DJrkry82.js} +1 -1
- package/dist/core/{WebcamTexture-BXj7sqND.js → WebcamTexture-Cf8J7JB1.js} +1 -1
- package/dist/core/computeBlur-C3oX720H.js +141 -0
- package/dist/core/effects/glass.d.ts +1 -1
- package/dist/core/effects/glass.d.ts.map +1 -1
- package/dist/core/index.js +213 -128
- package/dist/core/registry.js +102 -101
- package/dist/core/renderer.d.ts +19 -1
- package/dist/core/renderer.d.ts.map +1 -1
- package/dist/core/shaderRegistry-B_84rvO8.js +244 -0
- package/dist/core/shaders/Blur/index.d.ts.map +1 -1
- package/dist/core/shaders/Blur/index.js +2 -1
- package/dist/core/shaders/BrightnessContrast/index.js +1 -1
- package/dist/core/shaders/Bulge/index.js +1 -1
- package/dist/core/shaders/CRTScreen/index.js +1 -1
- package/dist/core/shaders/ChannelBlur/index.d.ts.map +1 -1
- package/dist/core/shaders/ChannelBlur/index.js +2 -1
- package/dist/core/shaders/Checkerboard/index.js +1 -1
- package/dist/core/shaders/ChromaFlow/index.js +1 -1
- package/dist/core/shaders/ChromaticAberration/index.js +1 -1
- package/dist/core/shaders/Circle/index.js +1 -1
- package/dist/core/shaders/ConcentricSpin/index.js +1 -1
- package/dist/core/shaders/ConicGradient/index.js +1 -1
- package/dist/core/shaders/ContourLines/index.js +1 -1
- package/dist/core/shaders/Crescent/index.js +2 -2
- package/dist/core/shaders/Cross/index.js +2 -2
- package/dist/core/shaders/Crystal/index.js +2 -2
- package/dist/core/shaders/CursorRipples/index.d.ts.map +1 -1
- package/dist/core/shaders/CursorRipples/index.js +1 -1
- package/dist/core/shaders/CursorTrail/index.d.ts.map +1 -1
- package/dist/core/shaders/CursorTrail/index.js +1 -1
- package/dist/core/shaders/DOMTexture/index.js +1 -1
- package/dist/core/shaders/DiamondGradient/index.js +1 -1
- package/dist/core/shaders/DiffuseBlur/index.js +1 -1
- package/dist/core/shaders/Dither/index.js +1 -1
- package/dist/core/shaders/DotGrid/index.js +1 -1
- package/dist/core/shaders/DropShadow/index.js +1 -1
- package/dist/core/shaders/Duotone/index.js +1 -1
- package/dist/core/shaders/Ellipse/index.js +2 -2
- package/dist/core/shaders/Emboss/index.js +2 -2
- package/dist/core/shaders/FallingLines/index.js +1 -1
- package/dist/core/shaders/FilmGrain/index.js +1 -1
- package/dist/core/shaders/FloatingParticles/index.js +1 -1
- package/dist/core/shaders/FlowField/index.js +1 -1
- package/dist/core/shaders/Flower/index.js +2 -2
- package/dist/core/shaders/FlowingGradient/index.js +1 -1
- package/dist/core/shaders/Form3D/index.js +1 -1
- package/dist/core/shaders/Glass/index.d.ts.map +1 -1
- package/dist/core/shaders/Glass/index.js +3 -2
- package/dist/core/shaders/GlassTiles/index.js +1 -1
- package/dist/core/shaders/Glitch/index.js +1 -1
- package/dist/core/shaders/Glow/index.d.ts.map +1 -1
- package/dist/core/shaders/Glow/index.js +2 -1
- package/dist/core/shaders/Godrays/index.js +1 -1
- package/dist/core/shaders/Grayscale/index.js +1 -1
- package/dist/core/shaders/Grid/index.js +1 -1
- package/dist/core/shaders/GridDistortion/index.d.ts.map +1 -1
- package/dist/core/shaders/GridDistortion/index.js +1 -1
- package/dist/core/shaders/Group/index.js +1 -1
- package/dist/core/shaders/Halftone/index.js +1 -1
- package/dist/core/shaders/HexGrid/index.js +1 -1
- package/dist/core/shaders/HueShift/index.js +1 -1
- package/dist/core/shaders/ImageTexture/index.js +1 -1
- package/dist/core/shaders/Invert/index.js +1 -1
- package/dist/core/shaders/Kaleidoscope/index.js +1 -1
- package/dist/core/shaders/LensFlare/index.js +1 -1
- package/dist/core/shaders/LinearBlur/index.js +1 -1
- package/dist/core/shaders/LinearGradient/index.js +1 -1
- package/dist/core/shaders/Liquify/index.d.ts.map +1 -1
- package/dist/core/shaders/Liquify/index.js +1 -1
- package/dist/core/shaders/Mirror/index.js +1 -1
- package/dist/core/shaders/MultiPointGradient/index.js +1 -1
- package/dist/core/shaders/Neon/index.js +2 -2
- package/dist/core/shaders/Paper/index.js +1 -1
- package/dist/core/shaders/Perspective/index.js +1 -1
- package/dist/core/shaders/Pixelate/index.js +1 -1
- package/dist/core/shaders/Plasma/index.js +1 -1
- package/dist/core/shaders/PolarCoordinates/index.js +1 -1
- package/dist/core/shaders/Polygon/index.js +2 -2
- package/dist/core/shaders/Posterize/index.js +1 -1
- package/dist/core/shaders/ProgressiveBlur/index.d.ts.map +1 -1
- package/dist/core/shaders/ProgressiveBlur/index.js +2 -1
- package/dist/core/shaders/RadialGradient/index.js +1 -1
- package/dist/core/shaders/RectangularCoordinates/index.js +1 -1
- package/dist/core/shaders/Ring/index.js +2 -2
- package/dist/core/shaders/Ripples/index.js +1 -1
- package/dist/core/shaders/RoundedRect/index.js +2 -2
- package/dist/core/shaders/Saturation/index.js +1 -1
- package/dist/core/shaders/Sharpness/index.js +1 -1
- package/dist/core/shaders/Shatter/index.d.ts.map +1 -1
- package/dist/core/shaders/Shatter/index.js +1 -1
- package/dist/core/shaders/SimplexNoise/index.js +1 -1
- package/dist/core/shaders/SineWave/index.js +1 -1
- package/dist/core/shaders/Solarize/index.js +1 -1
- package/dist/core/shaders/SolidColor/index.js +1 -1
- package/dist/core/shaders/Spherize/index.js +1 -1
- package/dist/core/shaders/Spiral/index.js +1 -1
- package/dist/core/shaders/Star/index.js +2 -2
- package/dist/core/shaders/Strands/index.js +1 -1
- package/dist/core/shaders/Stretch/index.js +1 -1
- package/dist/core/shaders/Stripes/index.js +1 -1
- package/dist/core/shaders/StudioBackground/index.js +1 -1
- package/dist/core/shaders/Swirl/index.js +1 -1
- package/dist/core/shaders/TiltShift/index.d.ts.map +1 -1
- package/dist/core/shaders/TiltShift/index.js +2 -1
- package/dist/core/shaders/Tint/index.js +1 -1
- package/dist/core/shaders/Trapezoid/index.js +2 -2
- package/dist/core/shaders/Tritone/index.js +1 -1
- package/dist/core/shaders/Truchet/index.js +1 -1
- package/dist/core/shaders/Twirl/index.js +1 -1
- package/dist/core/shaders/Vesica/index.js +2 -2
- package/dist/core/shaders/Vibrance/index.js +1 -1
- package/dist/core/shaders/VideoTexture/index.js +2 -2
- package/dist/core/shaders/Vignette/index.js +1 -1
- package/dist/core/shaders/Voronoi/index.js +1 -1
- package/dist/core/shaders/WaveDistortion/index.js +1 -1
- package/dist/core/shaders/Weave/index.js +1 -1
- package/dist/core/shaders/WebcamTexture/index.js +2 -2
- package/dist/core/shaders/ZoomBlur/index.js +1 -1
- package/dist/core/types.d.ts +49 -0
- package/dist/core/types.d.ts.map +1 -1
- package/dist/core/utilities/computeBlur.d.ts +50 -0
- package/dist/core/utilities/computeBlur.d.ts.map +1 -0
- package/dist/js/createShader.js +1 -1
- package/dist/react/Shader.js +1 -1
- package/dist/registry.js +2 -2
- package/dist/solid/engine/Shader.js +1 -1
- package/dist/svelte/index.js +1 -1
- package/dist/vue/Shader.vue_vue_type_script_setup_true_lang.js +1 -1
- package/package.json +1 -1
- package/dist/core/Blur-DTyNQt1R.js +0 -78
- package/dist/core/CursorRipples-Bo-3LZoC.js +0 -186
- package/dist/core/CursorTrail-C-0lpOV1.js +0 -160
- package/dist/core/Glow-CKWIRcBt.js +0 -108
- package/dist/core/GridDistortion-DXM5MgSc.js +0 -183
- package/dist/core/Liquify-CqcAWBwZ.js +0 -228
- package/dist/core/ProgressiveBlur-BcHBSVDo.js +0 -128
- package/dist/core/TiltShift-BysRsV8v.js +0 -141
- package/dist/core/shaderRegistry-BzOzMO4V.js +0 -244
- /package/dist/core/{BrightnessContrast-BoR9bi58.js → BrightnessContrast-CJTOpQCn.js} +0 -0
- /package/dist/core/{Bulge-DN2R75Hp.js → Bulge-Chpbxxzj.js} +0 -0
- /package/dist/core/{CRTScreen-DolQEkb1.js → CRTScreen-CTwXU-NX.js} +0 -0
- /package/dist/core/{Checkerboard-_IUtUrDv.js → Checkerboard-ucave4-a.js} +0 -0
- /package/dist/core/{ChromaFlow-Cq6hDVjX.js → ChromaFlow-BZXyVHtK.js} +0 -0
- /package/dist/core/{ChromaticAberration-G8_bwQtD.js → ChromaticAberration-DsMj-vBw.js} +0 -0
- /package/dist/core/{Circle--0oHzoCi.js → Circle-QgCuVo44.js} +0 -0
- /package/dist/core/{ConcentricSpin-BzxzMieZ.js → ConcentricSpin-Crfxti93.js} +0 -0
- /package/dist/core/{ConicGradient-BXXizzIs.js → ConicGradient-CQAPYlQg.js} +0 -0
- /package/dist/core/{ContourLines-C0XSJEkE.js → ContourLines-KTHC32hd.js} +0 -0
- /package/dist/core/{DOMTexture-Dw3Qakny.js → DOMTexture-D-RkeyMs.js} +0 -0
- /package/dist/core/{DiamondGradient-TsOxHjg_.js → DiamondGradient-BC3ugP8a.js} +0 -0
- /package/dist/core/{DiffuseBlur-BqIV4JLM.js → DiffuseBlur-eyM1v3ad.js} +0 -0
- /package/dist/core/{Dither-D_YF6z03.js → Dither-CDfDotR6.js} +0 -0
- /package/dist/core/{DotGrid-CiDt4NmI.js → DotGrid-T9YbgC3V.js} +0 -0
- /package/dist/core/{DropShadow-BRoXryDA.js → DropShadow-jMhnYPXZ.js} +0 -0
- /package/dist/core/{Duotone-CGHcHB9f.js → Duotone-Bl02WcA2.js} +0 -0
- /package/dist/core/{FallingLines-vdw8KxhV.js → FallingLines-CArEXajJ.js} +0 -0
- /package/dist/core/{FilmGrain-BqQeKO6Z.js → FilmGrain-Ph73aoC_.js} +0 -0
- /package/dist/core/{FloatingParticles-DR5cv6Eh.js → FloatingParticles-BtwGRl_d.js} +0 -0
- /package/dist/core/{FlowField-DpP32B1X.js → FlowField-RyqiRxyI.js} +0 -0
- /package/dist/core/{FlowingGradient-lSouJxmq.js → FlowingGradient-C0Zoyfd6.js} +0 -0
- /package/dist/core/{Form3D-DQD-0zrd.js → Form3D-rKpxb9t3.js} +0 -0
- /package/dist/core/{GlassTiles-B7aAvcTQ.js → GlassTiles-k1C4a4u8.js} +0 -0
- /package/dist/core/{Glitch-CgmgjLea.js → Glitch-DzPMkBu4.js} +0 -0
- /package/dist/core/{Godrays-o-3Im6H1.js → Godrays-DAYmq-BP.js} +0 -0
- /package/dist/core/{Grayscale-Bip62olI.js → Grayscale-lYKBBkGY.js} +0 -0
- /package/dist/core/{Grid-hwQnF_hs.js → Grid-BJ-nxN3i.js} +0 -0
- /package/dist/core/{Group-BexPm4Fb.js → Group-DpozigtX.js} +0 -0
- /package/dist/core/{Halftone-onLYU4dF.js → Halftone-BVL2oy37.js} +0 -0
- /package/dist/core/{HexGrid-BkqEEgfh.js → HexGrid-D-EmQ4kI.js} +0 -0
- /package/dist/core/{HueShift-BldS-av9.js → HueShift-D9K0ynaS.js} +0 -0
- /package/dist/core/{ImageTexture-DLCjc5cM.js → ImageTexture-CArkZMfh.js} +0 -0
- /package/dist/core/{Invert-C2LI5GXr.js → Invert-DCnwo_Xq.js} +0 -0
- /package/dist/core/{Kaleidoscope-CxWjs5jx.js → Kaleidoscope-BytHro3k.js} +0 -0
- /package/dist/core/{LensFlare-BNO7tCXH.js → LensFlare-B0vv4x97.js} +0 -0
- /package/dist/core/{LinearBlur-Ds6rm8u-.js → LinearBlur-BFewxPjV.js} +0 -0
- /package/dist/core/{LinearGradient-BZjDhnZp.js → LinearGradient-BKUf_u7r.js} +0 -0
- /package/dist/core/{Mirror-5W3sul9v.js → Mirror-DIle92J8.js} +0 -0
- /package/dist/core/{MultiPointGradient-lpUGnrLq.js → MultiPointGradient-DDwac_mm.js} +0 -0
- /package/dist/core/{Paper-14yYPnWW.js → Paper-bMSMCeYK.js} +0 -0
- /package/dist/core/{Perspective-POVbIGPc.js → Perspective-BmfvQV6W.js} +0 -0
- /package/dist/core/{Pixelate-CxUxBDeN.js → Pixelate-Dl26r6IT.js} +0 -0
- /package/dist/core/{Plasma-DM9TU0VN.js → Plasma-CJWS1TvX.js} +0 -0
- /package/dist/core/{PolarCoordinates-t4Wa00gQ.js → PolarCoordinates-lq6K4WBm.js} +0 -0
- /package/dist/core/{Posterize-Dk4DE8Ee.js → Posterize-BjH7Zscm.js} +0 -0
- /package/dist/core/{RadialGradient-CSXQIa5L.js → RadialGradient-DiGFPgrn.js} +0 -0
- /package/dist/core/{RectangularCoordinates-YaZ_uRXb.js → RectangularCoordinates-COkNDxi0.js} +0 -0
- /package/dist/core/{Ripples-wJx2FwJY.js → Ripples-C8Q17Hvz.js} +0 -0
- /package/dist/core/{Saturation-B500nPZH.js → Saturation-CgDaiq6n.js} +0 -0
- /package/dist/core/{Sharpness-NqY4_gKZ.js → Sharpness-CRXT0D30.js} +0 -0
- /package/dist/core/{SimplexNoise-2-J7EbY9.js → SimplexNoise-KfTCAfpL.js} +0 -0
- /package/dist/core/{SineWave-OWJVWsI1.js → SineWave-Ckeap_YM.js} +0 -0
- /package/dist/core/{Solarize-CEhQxL9Z.js → Solarize-DhtQYYpW.js} +0 -0
- /package/dist/core/{SolidColor-Dlzm61ZG.js → SolidColor-6yUkGybH.js} +0 -0
- /package/dist/core/{Spherize-CXf4_Mkm.js → Spherize-8LXrGGG_.js} +0 -0
- /package/dist/core/{Spiral-CSXNX92f.js → Spiral-Bs7uZrBr.js} +0 -0
- /package/dist/core/{Strands-BPVy1zbt.js → Strands-DsAAVemq.js} +0 -0
- /package/dist/core/{Stretch-CFAjfvny.js → Stretch-D7P2R5lV.js} +0 -0
- /package/dist/core/{Stripes-BSGzno-I.js → Stripes-DF8agIiJ.js} +0 -0
- /package/dist/core/{StudioBackground-81AihXcZ.js → StudioBackground-BFeNfwEu.js} +0 -0
- /package/dist/core/{Swirl-D_ZvZtDS.js → Swirl-BwezrSAA.js} +0 -0
- /package/dist/core/{Tint-C6xN-Qot.js → Tint-BdXlqlzz.js} +0 -0
- /package/dist/core/{Tritone-Dk8GcpYo.js → Tritone-BlJ7cchN.js} +0 -0
- /package/dist/core/{Truchet-BFd2XYD3.js → Truchet-Bnn0fwbF.js} +0 -0
- /package/dist/core/{Twirl-CA0r8U7e.js → Twirl-C5ijhqz1.js} +0 -0
- /package/dist/core/{Vibrance-Dq1jBFJb.js → Vibrance-dqIV6GBe.js} +0 -0
- /package/dist/core/{Vignette-DB8x78Up.js → Vignette-DB1wO1dm.js} +0 -0
- /package/dist/core/{Voronoi-ALXxxHBo.js → Voronoi-C3WIJFWc.js} +0 -0
- /package/dist/core/{WaveDistortion-CHb75HO3.js → WaveDistortion-BKma8-Ju.js} +0 -0
- /package/dist/core/{Weave-j4CrCig4.js → Weave-xuu_vQ5e.js} +0 -0
- /package/dist/core/{ZoomBlur-Cl75kL8E.js → ZoomBlur-UcS2iFT2.js} +0 -0
- /package/dist/core/{browser-DIoaEnIX.js → browser-ClWxLlIB.js} +0 -0
- /package/dist/core/{sdf-Bux00UoZ.js → sdf-DyC2H_qS.js} +0 -0
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
import { t as unpremultiplyAlpha } from "./alpha-C4ptedXe.js";
|
|
2
|
+
import { n as createVariableGaussianBlurCompute, t as createGaussianBlurCompute } from "./computeBlur-C3oX720H.js";
|
|
3
|
+
import { Fn, If, clamp, convertToTexture, dot, float, instanceIndex, int, mix, pow, screenUV, texture, textureLoad, textureStore, uint, uvec2, vec2, vec3, vec4, viewportSize } from "three/tsl";
|
|
4
|
+
const componentDefinition = {
|
|
5
|
+
name: "Blur",
|
|
6
|
+
category: "Blurs",
|
|
7
|
+
description: "A simple Gaussian blur effect",
|
|
8
|
+
requiresRTT: true,
|
|
9
|
+
requiresChild: true,
|
|
10
|
+
props: { intensity: {
|
|
11
|
+
default: 50,
|
|
12
|
+
description: "Intensity of the blur effect",
|
|
13
|
+
ui: {
|
|
14
|
+
type: ["range", "map"],
|
|
15
|
+
min: 0,
|
|
16
|
+
max: 200,
|
|
17
|
+
step: 1,
|
|
18
|
+
label: "Intensity",
|
|
19
|
+
group: "Effect"
|
|
20
|
+
}
|
|
21
|
+
} },
|
|
22
|
+
computeNode: ({ childNode, onCleanup, dimensions, renderer, uniforms }) => {
|
|
23
|
+
if (!childNode) return null;
|
|
24
|
+
const childTexture = convertToTexture(childNode);
|
|
25
|
+
onCleanup(() => {
|
|
26
|
+
if (childTexture?.renderTarget?.dispose) childTexture.renderTarget.dispose();
|
|
27
|
+
});
|
|
28
|
+
const dpr = renderer?.getPixelRatio?.() ?? 1;
|
|
29
|
+
const texWidth = Math.round(dimensions.width * dpr);
|
|
30
|
+
const texHeight = Math.round(dimensions.height * dpr);
|
|
31
|
+
const mapInfo = uniforms.intensity.mapComputeInfo;
|
|
32
|
+
if (mapInfo) {
|
|
33
|
+
const { computeNodes: blurNodes, outputTexture: outputTexture$1, blurMapWriteNode } = createVariableGaussianBlurCompute(childTexture, texWidth, texHeight, onCleanup);
|
|
34
|
+
const w = uint(texWidth);
|
|
35
|
+
const h = uint(texHeight);
|
|
36
|
+
const { sourceTexture, channel, inputMin, inputMax, outputMin, outputMax, curve } = mapInfo;
|
|
37
|
+
const fillBlurMap = Fn(() => {
|
|
38
|
+
const idx = instanceIndex;
|
|
39
|
+
const x = idx.mod(w);
|
|
40
|
+
const y = idx.div(w);
|
|
41
|
+
If(y.lessThan(h), () => {
|
|
42
|
+
const sample = textureLoad(sourceTexture, uvec2(x, y), int(0));
|
|
43
|
+
let raw;
|
|
44
|
+
if (channel === "alpha") raw = sample.a;
|
|
45
|
+
else if (channel === "alphaInverted") raw = sample.a.oneMinus();
|
|
46
|
+
else if (channel === "luminanceInverted") raw = dot(sample.rgb, vec3(.2126, .7152, .0722)).oneMinus();
|
|
47
|
+
else raw = dot(sample.rgb, vec3(.2126, .7152, .0722));
|
|
48
|
+
const inputRange = inputMax.sub(inputMin).max(float(1e-4));
|
|
49
|
+
const radius = mix(outputMin, outputMax, pow(clamp(raw.sub(inputMin).div(inputRange), float(0), float(1)), pow(float(2), curve.negate().mul(float(2))))).mul(float(.36));
|
|
50
|
+
textureStore(blurMapWriteNode, uvec2(x, y), vec4(radius, float(0), float(0), float(1))).toWriteOnly();
|
|
51
|
+
});
|
|
52
|
+
})().compute(texWidth * texHeight, [256]);
|
|
53
|
+
return {
|
|
54
|
+
outputs: {
|
|
55
|
+
childTexture,
|
|
56
|
+
blurredTexture: outputTexture$1
|
|
57
|
+
},
|
|
58
|
+
getComputeNodes: () => [fillBlurMap, ...blurNodes]
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
const { computeNodes, outputTexture, updateRadius } = createGaussianBlurCompute(childTexture, texWidth, texHeight, onCleanup);
|
|
62
|
+
return {
|
|
63
|
+
outputs: {
|
|
64
|
+
childTexture,
|
|
65
|
+
blurredTexture: outputTexture
|
|
66
|
+
},
|
|
67
|
+
getComputeNodes: () => {
|
|
68
|
+
const intensityEntry = uniforms.intensity;
|
|
69
|
+
const intensity = intensityEntry.getCpuValue?.() ?? (typeof intensityEntry.uniform.value === "number" ? intensityEntry.uniform.value : null);
|
|
70
|
+
if (intensity !== null) updateRadius(intensity * .36);
|
|
71
|
+
return computeNodes;
|
|
72
|
+
}
|
|
73
|
+
};
|
|
74
|
+
},
|
|
75
|
+
fragmentNode: ({ uniforms, childNode, onCleanup, computeOutputs }) => {
|
|
76
|
+
if (!childNode) return vec4(0, 0, 0, 0);
|
|
77
|
+
if (computeOutputs?.blurredTexture) {
|
|
78
|
+
const sharp = computeOutputs.childTexture.sample(screenUV);
|
|
79
|
+
const blurred = texture(computeOutputs.blurredTexture).sample(screenUV);
|
|
80
|
+
const intensityPin = uniforms.intensity.uniform.mul(float(0));
|
|
81
|
+
return unpremultiplyAlpha(vec4(blurred.rgb.add(intensityPin), sharp.a));
|
|
82
|
+
}
|
|
83
|
+
const childTexture = convertToTexture(childNode);
|
|
84
|
+
onCleanup(() => {
|
|
85
|
+
if (childTexture?.renderTarget?.dispose) childTexture.renderTarget.dispose();
|
|
86
|
+
});
|
|
87
|
+
const weights = [
|
|
88
|
+
.056,
|
|
89
|
+
.135,
|
|
90
|
+
.278,
|
|
91
|
+
.487,
|
|
92
|
+
.726,
|
|
93
|
+
.923,
|
|
94
|
+
1,
|
|
95
|
+
.923,
|
|
96
|
+
.726,
|
|
97
|
+
.487,
|
|
98
|
+
.278,
|
|
99
|
+
.135,
|
|
100
|
+
.056
|
|
101
|
+
];
|
|
102
|
+
const weightSum = 6.214;
|
|
103
|
+
const scaledIntensity = uniforms.intensity.uniform.mul(.06);
|
|
104
|
+
const horizontalTexture = convertToTexture(Fn(() => {
|
|
105
|
+
const uv$1 = screenUV;
|
|
106
|
+
const blurRadius = scaledIntensity;
|
|
107
|
+
const pixelSize = vec2(1).div(viewportSize);
|
|
108
|
+
const total = vec4(0).toVar();
|
|
109
|
+
for (let x = -6; x <= 6; x++) {
|
|
110
|
+
const weight = float(weights[x + 6] / weightSum);
|
|
111
|
+
const offset = vec2(float(x), float(0)).mul(blurRadius).mul(pixelSize);
|
|
112
|
+
const sampleCoord = uv$1.add(offset);
|
|
113
|
+
const sample = childTexture.sample(sampleCoord).mul(weight);
|
|
114
|
+
total.assign(total.add(sample));
|
|
115
|
+
}
|
|
116
|
+
return total;
|
|
117
|
+
})());
|
|
118
|
+
onCleanup(() => {
|
|
119
|
+
if (horizontalTexture?.renderTarget?.dispose) horizontalTexture.renderTarget.dispose();
|
|
120
|
+
});
|
|
121
|
+
return Fn(() => {
|
|
122
|
+
const uv$1 = screenUV;
|
|
123
|
+
const blurRadius = scaledIntensity;
|
|
124
|
+
const pixelSize = vec2(1).div(viewportSize);
|
|
125
|
+
const total = vec4(0).toVar();
|
|
126
|
+
for (let y = -6; y <= 6; y++) {
|
|
127
|
+
const weight = float(weights[y + 6] / weightSum);
|
|
128
|
+
const offset = vec2(float(0), float(y)).mul(blurRadius).mul(pixelSize);
|
|
129
|
+
const sampleCoord = uv$1.add(offset);
|
|
130
|
+
const sample = horizontalTexture.sample(sampleCoord).mul(weight);
|
|
131
|
+
total.assign(total.add(sample));
|
|
132
|
+
}
|
|
133
|
+
return unpremultiplyAlpha(total);
|
|
134
|
+
})();
|
|
135
|
+
}
|
|
136
|
+
};
|
|
137
|
+
var Blur_default = componentDefinition;
|
|
138
|
+
export { componentDefinition as n, Blur_default as t };
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { t as unpremultiplyAlpha } from "./alpha-C4ptedXe.js";
|
|
2
|
-
import {
|
|
2
|
+
import { t as createGaussianBlurCompute } from "./computeBlur-C3oX720H.js";
|
|
3
|
+
import { Fn, convertToTexture, float, mix, screenUV, texture, vec2, vec4, viewportSize } from "three/tsl";
|
|
3
4
|
const componentDefinition = {
|
|
4
5
|
name: "ChannelBlur",
|
|
5
6
|
category: "Blurs",
|
|
@@ -44,8 +45,42 @@ const componentDefinition = {
|
|
|
44
45
|
}
|
|
45
46
|
}
|
|
46
47
|
},
|
|
47
|
-
|
|
48
|
+
computeNode: ({ childNode, onCleanup, dimensions, renderer, uniforms }) => {
|
|
49
|
+
if (!childNode) return null;
|
|
50
|
+
const childTexture = convertToTexture(childNode);
|
|
51
|
+
onCleanup(() => {
|
|
52
|
+
if (childTexture?.renderTarget?.dispose) childTexture.renderTarget.dispose();
|
|
53
|
+
});
|
|
54
|
+
const dpr = renderer?.getPixelRatio?.() ?? 1;
|
|
55
|
+
const { computeNodes, outputTexture, updateRadius } = createGaussianBlurCompute(childTexture, Math.round(dimensions.width * dpr), Math.round(dimensions.height * dpr), onCleanup);
|
|
56
|
+
return {
|
|
57
|
+
outputs: {
|
|
58
|
+
childTexture,
|
|
59
|
+
blurredTexture: outputTexture
|
|
60
|
+
},
|
|
61
|
+
getComputeNodes: () => {
|
|
62
|
+
const r = uniforms.redIntensity.uniform.value * .1;
|
|
63
|
+
const g = uniforms.greenIntensity.uniform.value * .1;
|
|
64
|
+
const b = uniforms.blueIntensity.uniform.value * .1;
|
|
65
|
+
updateRadius(Math.max(r, g, b, .01));
|
|
66
|
+
return computeNodes;
|
|
67
|
+
}
|
|
68
|
+
};
|
|
69
|
+
},
|
|
70
|
+
fragmentNode: ({ uniforms, childNode, onCleanup, computeOutputs }) => {
|
|
48
71
|
if (!childNode) return vec4(0, 0, 0, 0);
|
|
72
|
+
if (computeOutputs?.blurredTexture) {
|
|
73
|
+
const sharp = computeOutputs.childTexture.sample(screenUV);
|
|
74
|
+
const blurred = texture(computeOutputs.blurredTexture).sample(screenUV);
|
|
75
|
+
const redRadius$1 = uniforms.redIntensity.uniform.mul(.1);
|
|
76
|
+
const greenRadius$1 = uniforms.greenIntensity.uniform.mul(.1);
|
|
77
|
+
const blueRadius$1 = uniforms.blueIntensity.uniform.mul(.1);
|
|
78
|
+
const maxRadius = redRadius$1.max(greenRadius$1).max(blueRadius$1).max(float(.01));
|
|
79
|
+
const rMix = redRadius$1.div(maxRadius);
|
|
80
|
+
const gMix = greenRadius$1.div(maxRadius);
|
|
81
|
+
const bMix = blueRadius$1.div(maxRadius);
|
|
82
|
+
return unpremultiplyAlpha(vec4(mix(sharp.r, blurred.r, rMix), mix(sharp.g, blurred.g, gMix), mix(sharp.b, blurred.b, bMix), sharp.a));
|
|
83
|
+
}
|
|
49
84
|
const childTexture = convertToTexture(childNode);
|
|
50
85
|
onCleanup(() => {
|
|
51
86
|
if (childTexture?.renderTarget?.dispose) childTexture.renderTarget.dispose();
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { a as transformColor, l as transformPosition, o as transformColorSpace, t as colorSpaceOptions } from "./transformations-B5lM6fYX.js";
|
|
2
2
|
import { t as mixColors } from "./colorMixing-BPpDnR5I.js";
|
|
3
|
-
import { i as crescentSdf } from "./sdf-
|
|
3
|
+
import { i as crescentSdf } from "./sdf-DyC2H_qS.js";
|
|
4
4
|
import { cos, float, screenUV, sin, smoothstep, vec2, vec4, viewportSize } from "three/tsl";
|
|
5
5
|
var transformStrokePosition = (value) => {
|
|
6
6
|
return {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { a as transformColor, l as transformPosition, o as transformColorSpace, t as colorSpaceOptions } from "./transformations-B5lM6fYX.js";
|
|
2
2
|
import { t as mixColors } from "./colorMixing-BPpDnR5I.js";
|
|
3
|
-
import { a as crossSdf } from "./sdf-
|
|
3
|
+
import { a as crossSdf } from "./sdf-DyC2H_qS.js";
|
|
4
4
|
import { cos, float, screenUV, sin, smoothstep, vec2, vec4, viewportSize } from "three/tsl";
|
|
5
5
|
var transformStrokePosition = (value) => {
|
|
6
6
|
return {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { a as transformColor, l as transformPosition } from "./transformations-B5lM6fYX.js";
|
|
2
|
-
import { n as createAnalyticSdfSampler, r as createSvgSdfSampler } from "./sdf-
|
|
2
|
+
import { n as createAnalyticSdfSampler, r as createSvgSdfSampler } from "./sdf-DyC2H_qS.js";
|
|
3
3
|
import { Fn, atan, clamp, convertToTexture, cos, dot, float, fract, max, min, mix, mx_worley_noise_float, pow, screenUV, sin, smoothstep, sqrt, vec2, vec3, vec4, viewportSize } from "three/tsl";
|
|
4
4
|
var transformBoolean = (value) => value ? 1 : 0;
|
|
5
5
|
var DEFAULT_SHAPE_CONFIG = JSON.stringify({
|
|
@@ -0,0 +1,289 @@
|
|
|
1
|
+
import { t as applyEdgeHandling } from "./edges-CfGcQniB.js";
|
|
2
|
+
import { c as transformEdges } from "./transformations-B5lM6fYX.js";
|
|
3
|
+
import { t as unpremultiplyAlpha } from "./alpha-C4ptedXe.js";
|
|
4
|
+
import { StorageTexture } from "three/webgpu";
|
|
5
|
+
import { DataTexture, FloatType, LinearFilter as LinearFilter$1, RGFormat } from "three";
|
|
6
|
+
import { Fn, If, attributeArray, convertToTexture, float, instanceIndex, screenUV, storageTexture, texture, textureStore, uint, uniform, uvec2, vec2, vec4 } from "three/tsl";
|
|
7
|
+
var GRID_SIZE = 128;
|
|
8
|
+
const componentDefinition = {
|
|
9
|
+
name: "CursorRipples",
|
|
10
|
+
category: "Interactive",
|
|
11
|
+
description: "Fluid-like ripple distortion",
|
|
12
|
+
requiresRTT: true,
|
|
13
|
+
requiresChild: true,
|
|
14
|
+
props: {
|
|
15
|
+
intensity: {
|
|
16
|
+
default: 10,
|
|
17
|
+
description: "Strength of the ripple distortion",
|
|
18
|
+
ui: {
|
|
19
|
+
type: ["range", "map"],
|
|
20
|
+
min: 0,
|
|
21
|
+
max: 20,
|
|
22
|
+
step: .1,
|
|
23
|
+
label: "Intensity",
|
|
24
|
+
group: "Effect"
|
|
25
|
+
}
|
|
26
|
+
},
|
|
27
|
+
decay: {
|
|
28
|
+
default: 10,
|
|
29
|
+
description: "How quickly ripples fade (higher = faster)",
|
|
30
|
+
ui: {
|
|
31
|
+
type: "range",
|
|
32
|
+
min: 0,
|
|
33
|
+
max: 20,
|
|
34
|
+
step: .1,
|
|
35
|
+
label: "Decay",
|
|
36
|
+
group: "Effect"
|
|
37
|
+
}
|
|
38
|
+
},
|
|
39
|
+
radius: {
|
|
40
|
+
default: .5,
|
|
41
|
+
description: "Radius of cursor influence",
|
|
42
|
+
ui: {
|
|
43
|
+
type: "range",
|
|
44
|
+
min: .1,
|
|
45
|
+
max: 1,
|
|
46
|
+
step: .1,
|
|
47
|
+
label: "Radius",
|
|
48
|
+
group: "Effect"
|
|
49
|
+
}
|
|
50
|
+
},
|
|
51
|
+
chromaticSplit: {
|
|
52
|
+
default: 1,
|
|
53
|
+
description: "RGB channel separation along ripple edges",
|
|
54
|
+
ui: {
|
|
55
|
+
type: ["range", "map"],
|
|
56
|
+
min: 0,
|
|
57
|
+
max: 3,
|
|
58
|
+
step: .1,
|
|
59
|
+
label: "Chromatic Split",
|
|
60
|
+
group: "Effect"
|
|
61
|
+
}
|
|
62
|
+
},
|
|
63
|
+
edges: {
|
|
64
|
+
default: "stretch",
|
|
65
|
+
description: "How to handle edges when distortion pushes content out of bounds",
|
|
66
|
+
transform: transformEdges,
|
|
67
|
+
compileTime: true,
|
|
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
|
+
group: "Effect"
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
},
|
|
93
|
+
computeNode: ({ uniforms, onCleanup, dimensions }) => {
|
|
94
|
+
const bufferA = attributeArray(GRID_SIZE * GRID_SIZE, "float");
|
|
95
|
+
const bufferB = attributeArray(GRID_SIZE * GRID_SIZE, "float");
|
|
96
|
+
const dispTex = new StorageTexture(GRID_SIZE, GRID_SIZE);
|
|
97
|
+
dispTex.type = FloatType;
|
|
98
|
+
const dispTexNode = storageTexture(dispTex);
|
|
99
|
+
onCleanup(() => {
|
|
100
|
+
dispTex.dispose();
|
|
101
|
+
});
|
|
102
|
+
const cursorXU = uniform(.5);
|
|
103
|
+
const cursorYU = uniform(.5);
|
|
104
|
+
const mouseSpeedU = uniform(0);
|
|
105
|
+
const dtU = uniform(.016);
|
|
106
|
+
const decayU = uniform(10);
|
|
107
|
+
const radiusU = uniform(.025);
|
|
108
|
+
const aspectU = uniform(1);
|
|
109
|
+
const gs = uint(GRID_SIZE);
|
|
110
|
+
const gsm1 = uint(GRID_SIZE - 1);
|
|
111
|
+
const buildPropagateKernel = (readBuf, writeBuf) => Fn(() => {
|
|
112
|
+
const idx = instanceIndex;
|
|
113
|
+
const j = idx.mod(gs);
|
|
114
|
+
const i = idx.div(gs);
|
|
115
|
+
If(i.greaterThan(uint(0)).and(i.lessThan(gsm1)).and(j.greaterThan(uint(0))).and(j.lessThan(gsm1)), () => {
|
|
116
|
+
const left = readBuf.element(idx.sub(uint(1)));
|
|
117
|
+
const right = readBuf.element(idx.add(uint(1)));
|
|
118
|
+
const up = readBuf.element(idx.sub(gs));
|
|
119
|
+
const down = readBuf.element(idx.add(gs));
|
|
120
|
+
const avg = left.add(right).add(up).add(down).mul(float(.5));
|
|
121
|
+
const prev = writeBuf.element(idx);
|
|
122
|
+
const dampFactor = float(1).sub(decayU.mul(float(.004)));
|
|
123
|
+
const next = avg.sub(prev).mul(dampFactor).toVar();
|
|
124
|
+
const cellX = j.toFloat().add(float(.5)).div(float(GRID_SIZE));
|
|
125
|
+
const cellY = i.toFloat().add(float(.5)).div(float(GRID_SIZE));
|
|
126
|
+
const ddx = aspectU.greaterThanEqual(float(1)).select(cellX.sub(cursorXU).mul(aspectU), cellX.sub(cursorXU));
|
|
127
|
+
const ddy = aspectU.greaterThanEqual(float(1)).select(cellY.sub(cursorYU), cellY.sub(cursorYU).div(aspectU));
|
|
128
|
+
const distSq = ddx.mul(ddx).add(ddy.mul(ddy));
|
|
129
|
+
const influenceRadius = radiusU.mul(float(3));
|
|
130
|
+
If(distSq.lessThan(influenceRadius.mul(influenceRadius)).and(mouseSpeedU.greaterThan(float(.01))), () => {
|
|
131
|
+
const influence = distSq.negate().div(radiusU.mul(radiusU)).exp();
|
|
132
|
+
next.assign(next.sub(influence.mul(mouseSpeedU).mul(dtU).mul(float(3))));
|
|
133
|
+
});
|
|
134
|
+
writeBuf.element(idx).assign(next);
|
|
135
|
+
});
|
|
136
|
+
})().compute(GRID_SIZE * GRID_SIZE, [256]);
|
|
137
|
+
const buildGradientKernel = (srcBuf) => Fn(() => {
|
|
138
|
+
const idx = instanceIndex;
|
|
139
|
+
const j = idx.mod(gs);
|
|
140
|
+
const i = idx.div(gs);
|
|
141
|
+
If(i.greaterThan(uint(0)).and(i.lessThan(gsm1)).and(j.greaterThan(uint(0))).and(j.lessThan(gsm1)), () => {
|
|
142
|
+
const right = srcBuf.element(idx.add(uint(1)));
|
|
143
|
+
const left = srcBuf.element(idx.sub(uint(1)));
|
|
144
|
+
const down = srcBuf.element(idx.add(gs));
|
|
145
|
+
const up = srcBuf.element(idx.sub(gs));
|
|
146
|
+
const dx = right.sub(left).mul(float(.5));
|
|
147
|
+
const dy = down.sub(up).mul(float(.5));
|
|
148
|
+
textureStore(dispTexNode, uvec2(j, i), vec4(dx, dy, float(0), float(1))).toWriteOnly();
|
|
149
|
+
});
|
|
150
|
+
})().compute(GRID_SIZE * GRID_SIZE, [256]);
|
|
151
|
+
const propagateAtoB = buildPropagateKernel(bufferA, bufferB);
|
|
152
|
+
const gradientB = buildGradientKernel(bufferB);
|
|
153
|
+
const propagateBtoA = buildPropagateKernel(bufferB, bufferA);
|
|
154
|
+
const gradientA = buildGradientKernel(bufferA);
|
|
155
|
+
let direction = 0;
|
|
156
|
+
let prevX = .5;
|
|
157
|
+
let prevY = .5;
|
|
158
|
+
let lastTime = Date.now();
|
|
159
|
+
let lastActiveTime = Date.now();
|
|
160
|
+
return {
|
|
161
|
+
outputs: { displacement: dispTex },
|
|
162
|
+
getComputeNodes: (params) => {
|
|
163
|
+
const currentTime = Date.now();
|
|
164
|
+
const dt = Math.min((currentTime - lastTime) / 1e3, .016);
|
|
165
|
+
lastTime = currentTime;
|
|
166
|
+
const aspect = dimensions.width / dimensions.height;
|
|
167
|
+
const decay = uniforms.decay.uniform.value;
|
|
168
|
+
const radius = uniforms.radius.uniform.value * .05;
|
|
169
|
+
const rawVelX = dt > 0 ? (params.pointer.x - prevX) / dt : 0;
|
|
170
|
+
const rawVelY = dt > 0 ? (params.pointer.y - prevY) / dt : 0;
|
|
171
|
+
const mouseSpeed = Math.min(Math.sqrt(rawVelX * rawVelX + rawVelY * rawVelY), 2);
|
|
172
|
+
prevX = params.pointer.x;
|
|
173
|
+
prevY = params.pointer.y;
|
|
174
|
+
if (mouseSpeed > .01) lastActiveTime = currentTime;
|
|
175
|
+
const dampFactor = 1 - decay * .004;
|
|
176
|
+
const settleTime = dampFactor >= 1 ? Infinity : Math.min(3e4, Math.log(1e-6) / Math.log(Math.max(dampFactor, .001)) * 16.67);
|
|
177
|
+
if (currentTime - lastActiveTime > settleTime) return null;
|
|
178
|
+
cursorXU.value = params.pointer.x;
|
|
179
|
+
cursorYU.value = params.pointer.y;
|
|
180
|
+
mouseSpeedU.value = mouseSpeed;
|
|
181
|
+
dtU.value = dt;
|
|
182
|
+
decayU.value = decay;
|
|
183
|
+
radiusU.value = radius;
|
|
184
|
+
aspectU.value = aspect;
|
|
185
|
+
const nodes = direction === 0 ? [propagateAtoB, gradientB] : [propagateBtoA, gradientA];
|
|
186
|
+
direction = 1 - direction;
|
|
187
|
+
return nodes;
|
|
188
|
+
}
|
|
189
|
+
};
|
|
190
|
+
},
|
|
191
|
+
fragmentNode: ({ uniforms, onBeforeRender, childNode, onCleanup, dimensions, computeOutputs }) => {
|
|
192
|
+
if (!childNode) return vec4(0, 0, 0, 0);
|
|
193
|
+
const childTexture = convertToTexture(childNode);
|
|
194
|
+
onCleanup(() => {
|
|
195
|
+
if (childTexture?.renderTarget?.dispose) childTexture.renderTarget.dispose();
|
|
196
|
+
});
|
|
197
|
+
let displacement;
|
|
198
|
+
if (computeOutputs?.displacement) displacement = texture(computeOutputs.displacement).sample(screenUV).xy;
|
|
199
|
+
else {
|
|
200
|
+
const buffers = [new Float32Array(GRID_SIZE * GRID_SIZE), new Float32Array(GRID_SIZE * GRID_SIZE)];
|
|
201
|
+
let currentBuffer = 0;
|
|
202
|
+
const displacementData = new Float32Array(GRID_SIZE * GRID_SIZE * 2);
|
|
203
|
+
const displacementTexture = new DataTexture(displacementData, GRID_SIZE, GRID_SIZE, RGFormat, FloatType);
|
|
204
|
+
displacementTexture.magFilter = LinearFilter$1;
|
|
205
|
+
displacementTexture.minFilter = LinearFilter$1;
|
|
206
|
+
displacementTexture.needsUpdate = true;
|
|
207
|
+
const displacementField = texture(displacementTexture);
|
|
208
|
+
let prevX = .5;
|
|
209
|
+
let prevY = .5;
|
|
210
|
+
let lastTime = Date.now();
|
|
211
|
+
let prevMaxAbsVal = 1;
|
|
212
|
+
onBeforeRender(({ pointer }) => {
|
|
213
|
+
const currentTime = Date.now();
|
|
214
|
+
const dt = Math.min((currentTime - lastTime) / 1e3, .016);
|
|
215
|
+
lastTime = currentTime;
|
|
216
|
+
const aspect = dimensions.width / dimensions.height;
|
|
217
|
+
const substeps = 1;
|
|
218
|
+
const decay = uniforms.decay.uniform.value;
|
|
219
|
+
const radius = uniforms.radius.uniform.value * .05;
|
|
220
|
+
const rawVelX = dt > 0 ? (pointer.x - prevX) / dt : 0;
|
|
221
|
+
const rawVelY = dt > 0 ? (pointer.y - prevY) / dt : 0;
|
|
222
|
+
const mouseSpeed = Math.min(Math.sqrt(rawVelX * rawVelX + rawVelY * rawVelY), 2);
|
|
223
|
+
prevX = pointer.x;
|
|
224
|
+
prevY = pointer.y;
|
|
225
|
+
if (mouseSpeed <= .01 && prevMaxAbsVal < 1e-6) return;
|
|
226
|
+
const dampFactor = 1 - decay * .004;
|
|
227
|
+
let maxAbsVal = 0;
|
|
228
|
+
for (let s = 0; s < substeps; s++) {
|
|
229
|
+
const curr$1 = buffers[currentBuffer];
|
|
230
|
+
const prev = buffers[1 - currentBuffer];
|
|
231
|
+
if (s === 0 && mouseSpeed > .01) {
|
|
232
|
+
const influenceRadius = radius * 3;
|
|
233
|
+
const minJ = Math.max(1, Math.floor((pointer.x - influenceRadius) * GRID_SIZE));
|
|
234
|
+
const maxJ = Math.min(GRID_SIZE - 2, Math.ceil((pointer.x + influenceRadius) * GRID_SIZE));
|
|
235
|
+
const minI = Math.max(1, Math.floor((pointer.y - influenceRadius) * GRID_SIZE));
|
|
236
|
+
const maxI = Math.min(GRID_SIZE - 2, Math.ceil((pointer.y + influenceRadius) * GRID_SIZE));
|
|
237
|
+
for (let i = minI; i <= maxI; i++) for (let j = minJ; j <= maxJ; j++) {
|
|
238
|
+
const idx = i * GRID_SIZE + j;
|
|
239
|
+
const cellX = (j + .5) / GRID_SIZE;
|
|
240
|
+
const cellY = (i + .5) / GRID_SIZE;
|
|
241
|
+
const ddx = aspect >= 1 ? (cellX - pointer.x) * aspect : cellX - pointer.x;
|
|
242
|
+
const ddy = aspect >= 1 ? cellY - pointer.y : (cellY - pointer.y) / aspect;
|
|
243
|
+
const dist = Math.sqrt(ddx * ddx + ddy * ddy);
|
|
244
|
+
if (dist < influenceRadius) {
|
|
245
|
+
const influence = Math.exp(-dist * dist / (radius * radius));
|
|
246
|
+
curr$1[idx] -= influence * mouseSpeed * dt * 3;
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
for (let i = 1; i < GRID_SIZE - 1; i++) for (let j = 1; j < GRID_SIZE - 1; j++) {
|
|
251
|
+
const idx = i * GRID_SIZE + j;
|
|
252
|
+
const next = ((curr$1[idx - 1] + curr$1[idx + 1] + curr$1[idx - GRID_SIZE] + curr$1[idx + GRID_SIZE]) * .5 - prev[idx]) * dampFactor;
|
|
253
|
+
prev[idx] = next;
|
|
254
|
+
const absNext = next < 0 ? -next : next;
|
|
255
|
+
if (absNext > maxAbsVal) maxAbsVal = absNext;
|
|
256
|
+
}
|
|
257
|
+
currentBuffer = 1 - currentBuffer;
|
|
258
|
+
}
|
|
259
|
+
prevMaxAbsVal = maxAbsVal;
|
|
260
|
+
const curr = buffers[currentBuffer];
|
|
261
|
+
for (let i = 1; i < GRID_SIZE - 1; i++) for (let j = 1; j < GRID_SIZE - 1; j++) {
|
|
262
|
+
const idx = i * GRID_SIZE + j;
|
|
263
|
+
const dIdx = idx * 2;
|
|
264
|
+
displacementData[dIdx] = (curr[idx + 1] - curr[idx - 1]) * .5;
|
|
265
|
+
displacementData[dIdx + 1] = (curr[idx + GRID_SIZE] - curr[idx - GRID_SIZE]) * .5;
|
|
266
|
+
}
|
|
267
|
+
displacementTexture.needsUpdate = true;
|
|
268
|
+
});
|
|
269
|
+
onCleanup(() => {
|
|
270
|
+
displacementTexture.dispose();
|
|
271
|
+
});
|
|
272
|
+
displacement = displacementField.sample(screenUV).xy;
|
|
273
|
+
}
|
|
274
|
+
const intensityScale = uniforms.intensity.uniform.mul(.1);
|
|
275
|
+
const scaledDisplacement = displacement.mul(intensityScale);
|
|
276
|
+
const maxDisp = float(.15);
|
|
277
|
+
const clampedDisplacement = scaledDisplacement.clamp(vec2(maxDisp.negate(), maxDisp.negate()), vec2(maxDisp, maxDisp));
|
|
278
|
+
const chromaticScale = uniforms.chromaticSplit.uniform.mul(.1);
|
|
279
|
+
const rUV = screenUV.sub(clampedDisplacement.mul(float(1).add(chromaticScale)));
|
|
280
|
+
const gUV = screenUV.sub(clampedDisplacement);
|
|
281
|
+
const bUV = screenUV.sub(clampedDisplacement.mul(float(1).sub(chromaticScale)));
|
|
282
|
+
const rSample = applyEdgeHandling(rUV, childTexture.sample(rUV), childTexture, uniforms.edges.uniform.value);
|
|
283
|
+
const gSample = applyEdgeHandling(gUV, childTexture.sample(gUV), childTexture, uniforms.edges.uniform.value);
|
|
284
|
+
const bSample = applyEdgeHandling(bUV, childTexture.sample(bUV), childTexture, uniforms.edges.uniform.value);
|
|
285
|
+
return unpremultiplyAlpha(vec4(rSample.r, gSample.g, bSample.b, gSample.a));
|
|
286
|
+
}
|
|
287
|
+
};
|
|
288
|
+
var CursorRipples_default = componentDefinition;
|
|
289
|
+
export { componentDefinition as n, CursorRipples_default as t };
|