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,236 @@
|
|
|
1
|
+
import { l as transformPosition, r as transformAngle } from "./transformations-B5lM6fYX.js";
|
|
2
|
+
import { t as unpremultiplyAlpha } from "./alpha-C4ptedXe.js";
|
|
3
|
+
import { n as createVariableGaussianBlurCompute } from "./computeBlur-C3oX720H.js";
|
|
4
|
+
import { Fn, If, clamp, convertToTexture, cos, dot, float, instanceIndex, int, max, mix, pow, radians, screenUV, sin, smoothstep, texture, textureLoad, textureStore, uint, uniform, uvec2, vec2, vec3, vec4, viewportSize } from "three/tsl";
|
|
5
|
+
const componentDefinition = {
|
|
6
|
+
name: "ProgressiveBlur",
|
|
7
|
+
category: "Blurs",
|
|
8
|
+
description: "Blur that increases progressively in one direction",
|
|
9
|
+
requiresRTT: true,
|
|
10
|
+
requiresChild: true,
|
|
11
|
+
props: {
|
|
12
|
+
intensity: {
|
|
13
|
+
default: 50,
|
|
14
|
+
description: "Maximum intensity of the blur effect",
|
|
15
|
+
ui: {
|
|
16
|
+
type: ["range", "map"],
|
|
17
|
+
min: 0,
|
|
18
|
+
max: 100,
|
|
19
|
+
step: 1,
|
|
20
|
+
label: "Intensity",
|
|
21
|
+
group: "Effect"
|
|
22
|
+
}
|
|
23
|
+
},
|
|
24
|
+
angle: {
|
|
25
|
+
default: 0,
|
|
26
|
+
transform: transformAngle,
|
|
27
|
+
description: "Direction of the blur gradient (in degrees)",
|
|
28
|
+
ui: {
|
|
29
|
+
type: ["range", "map"],
|
|
30
|
+
min: 0,
|
|
31
|
+
max: 360,
|
|
32
|
+
step: 1,
|
|
33
|
+
label: "Angle",
|
|
34
|
+
group: "Effect"
|
|
35
|
+
}
|
|
36
|
+
},
|
|
37
|
+
center: {
|
|
38
|
+
default: {
|
|
39
|
+
x: 0,
|
|
40
|
+
y: .5
|
|
41
|
+
},
|
|
42
|
+
transform: transformPosition,
|
|
43
|
+
description: "Center point where blur begins",
|
|
44
|
+
ui: {
|
|
45
|
+
type: "position",
|
|
46
|
+
label: "Center",
|
|
47
|
+
group: "Position"
|
|
48
|
+
}
|
|
49
|
+
},
|
|
50
|
+
falloff: {
|
|
51
|
+
default: 1,
|
|
52
|
+
description: "Distance over which blur transitions to full strength",
|
|
53
|
+
ui: {
|
|
54
|
+
type: ["range", "map"],
|
|
55
|
+
min: 0,
|
|
56
|
+
max: 1,
|
|
57
|
+
step: .1,
|
|
58
|
+
label: "Falloff",
|
|
59
|
+
group: "Effect"
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
},
|
|
63
|
+
computeNode: ({ childNode, onCleanup, dimensions, renderer, uniforms }) => {
|
|
64
|
+
if (!childNode) return null;
|
|
65
|
+
if (uniforms.angle.mapComputeInfo || uniforms.falloff.mapComputeInfo) return null;
|
|
66
|
+
const childTexture = convertToTexture(childNode);
|
|
67
|
+
onCleanup(() => {
|
|
68
|
+
if (childTexture?.renderTarget?.dispose) childTexture.renderTarget.dispose();
|
|
69
|
+
});
|
|
70
|
+
const dpr = renderer?.getPixelRatio?.() ?? 1;
|
|
71
|
+
const texWidth = Math.round(dimensions.width * dpr);
|
|
72
|
+
const texHeight = Math.round(dimensions.height * dpr);
|
|
73
|
+
const { computeNodes: blurNodes, outputTexture, blurMapWriteNode } = createVariableGaussianBlurCompute(childTexture, texWidth, texHeight, onCleanup);
|
|
74
|
+
const angleU = uniform(0);
|
|
75
|
+
const centerXU = uniform(0);
|
|
76
|
+
const centerYU = uniform(.5);
|
|
77
|
+
const falloffU = uniform(1);
|
|
78
|
+
const aspectU = uniform(1);
|
|
79
|
+
const w = uint(texWidth);
|
|
80
|
+
const h = uint(texHeight);
|
|
81
|
+
function readScalar(entry) {
|
|
82
|
+
return entry.getCpuValue?.() ?? (typeof entry.uniform.value === "number" ? entry.uniform.value : null);
|
|
83
|
+
}
|
|
84
|
+
function updateGeometryUniforms() {
|
|
85
|
+
const angleVal = readScalar(uniforms.angle);
|
|
86
|
+
if (angleVal !== null) angleU.value = angleVal;
|
|
87
|
+
const centerXVal = uniforms.center.uniform.value?.x ?? uniforms.center.uniform.x?.value;
|
|
88
|
+
if (typeof centerXVal === "number") centerXU.value = centerXVal;
|
|
89
|
+
const centerYVal = uniforms.center.uniform.value?.y ?? uniforms.center.uniform.y?.value;
|
|
90
|
+
if (typeof centerYVal === "number") centerYU.value = centerYVal;
|
|
91
|
+
const falloffVal = readScalar(uniforms.falloff);
|
|
92
|
+
if (falloffVal !== null) falloffU.value = falloffVal;
|
|
93
|
+
aspectU.value = dimensions.width / dimensions.height;
|
|
94
|
+
}
|
|
95
|
+
const intensityMapInfo = uniforms.intensity.mapComputeInfo;
|
|
96
|
+
if (intensityMapInfo) {
|
|
97
|
+
const { sourceTexture, channel, inputMin, inputMax, outputMin, outputMax, curve } = intensityMapInfo;
|
|
98
|
+
const fillBlurMap$1 = Fn(() => {
|
|
99
|
+
const idx = instanceIndex;
|
|
100
|
+
const x = idx.mod(w);
|
|
101
|
+
const y = idx.div(w);
|
|
102
|
+
If(y.lessThan(h), () => {
|
|
103
|
+
const u = x.toFloat().add(float(.5)).div(float(texWidth));
|
|
104
|
+
const v = y.toFloat().add(float(.5)).div(float(texHeight));
|
|
105
|
+
const angleRad = angleU.mul(float(Math.PI / 180));
|
|
106
|
+
const direction = vec2(angleRad.cos().div(aspectU), angleRad.sin());
|
|
107
|
+
const centerPos = vec2(centerXU, float(1).sub(centerYU));
|
|
108
|
+
const centeredUV = vec2(u, v).sub(centerPos);
|
|
109
|
+
const directionalDist = max(float(0), centeredUV.dot(direction));
|
|
110
|
+
const blurAmount = smoothstep(float(0), falloffU, directionalDist);
|
|
111
|
+
const mapSample = textureLoad(sourceTexture, uvec2(x, y), int(0));
|
|
112
|
+
let raw;
|
|
113
|
+
if (channel === "alpha") raw = mapSample.a;
|
|
114
|
+
else if (channel === "alphaInverted") raw = mapSample.a.oneMinus();
|
|
115
|
+
else if (channel === "luminanceInverted") raw = dot(mapSample.rgb, vec3(.2126, .7152, .0722)).oneMinus();
|
|
116
|
+
else raw = dot(mapSample.rgb, vec3(.2126, .7152, .0722));
|
|
117
|
+
const inputRange = inputMax.sub(inputMin).max(float(1e-4));
|
|
118
|
+
const maxRadius = 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));
|
|
119
|
+
const radius = blurAmount.mul(maxRadius);
|
|
120
|
+
textureStore(blurMapWriteNode, uvec2(x, y), vec4(radius, float(0), float(0), float(1))).toWriteOnly();
|
|
121
|
+
});
|
|
122
|
+
})().compute(texWidth * texHeight, [256]);
|
|
123
|
+
return {
|
|
124
|
+
outputs: {
|
|
125
|
+
childTexture,
|
|
126
|
+
blurredTexture: outputTexture
|
|
127
|
+
},
|
|
128
|
+
getComputeNodes: () => {
|
|
129
|
+
updateGeometryUniforms();
|
|
130
|
+
return [fillBlurMap$1, ...blurNodes];
|
|
131
|
+
}
|
|
132
|
+
};
|
|
133
|
+
}
|
|
134
|
+
const maxRadiusU = uniform(18);
|
|
135
|
+
const fillBlurMap = Fn(() => {
|
|
136
|
+
const idx = instanceIndex;
|
|
137
|
+
const x = idx.mod(w);
|
|
138
|
+
const y = idx.div(w);
|
|
139
|
+
If(y.lessThan(h), () => {
|
|
140
|
+
const u = x.toFloat().add(float(.5)).div(float(texWidth));
|
|
141
|
+
const v = y.toFloat().add(float(.5)).div(float(texHeight));
|
|
142
|
+
const angleRad = angleU.mul(float(Math.PI / 180));
|
|
143
|
+
const direction = vec2(angleRad.cos().div(aspectU), angleRad.sin());
|
|
144
|
+
const centerPos = vec2(centerXU, float(1).sub(centerYU));
|
|
145
|
+
const centeredUV = vec2(u, v).sub(centerPos);
|
|
146
|
+
const directionalDist = max(float(0), centeredUV.dot(direction));
|
|
147
|
+
const radius = smoothstep(float(0), falloffU, directionalDist).mul(maxRadiusU);
|
|
148
|
+
textureStore(blurMapWriteNode, uvec2(x, y), vec4(radius, float(0), float(0), float(1))).toWriteOnly();
|
|
149
|
+
});
|
|
150
|
+
})().compute(texWidth * texHeight, [256]);
|
|
151
|
+
return {
|
|
152
|
+
outputs: {
|
|
153
|
+
childTexture,
|
|
154
|
+
blurredTexture: outputTexture
|
|
155
|
+
},
|
|
156
|
+
getComputeNodes: () => {
|
|
157
|
+
updateGeometryUniforms();
|
|
158
|
+
const intensityVal = readScalar(uniforms.intensity);
|
|
159
|
+
if (intensityVal !== null) maxRadiusU.value = intensityVal * .36;
|
|
160
|
+
return [fillBlurMap, ...blurNodes];
|
|
161
|
+
}
|
|
162
|
+
};
|
|
163
|
+
},
|
|
164
|
+
fragmentNode: ({ uniforms, childNode, onCleanup, computeOutputs }) => {
|
|
165
|
+
if (!childNode) return vec4(0, 0, 0, 0);
|
|
166
|
+
if (computeOutputs?.blurredTexture) {
|
|
167
|
+
const sharp = computeOutputs.childTexture.sample(screenUV);
|
|
168
|
+
const blurred = texture(computeOutputs.blurredTexture).sample(screenUV);
|
|
169
|
+
const propsPin = uniforms.intensity.uniform.mul(float(0)).add(uniforms.angle.uniform.mul(float(0))).add(uniforms.falloff.uniform.mul(float(0)));
|
|
170
|
+
return unpremultiplyAlpha(vec4(blurred.rgb.add(propsPin), sharp.a));
|
|
171
|
+
}
|
|
172
|
+
const childTexture = convertToTexture(childNode);
|
|
173
|
+
onCleanup(() => {
|
|
174
|
+
if (childTexture?.renderTarget?.dispose) childTexture.renderTarget.dispose();
|
|
175
|
+
});
|
|
176
|
+
const aspect = viewportSize.x.div(viewportSize.y);
|
|
177
|
+
const angleRad = radians(uniforms.angle.uniform);
|
|
178
|
+
const cosAngle = cos(angleRad);
|
|
179
|
+
const sinAngle = sin(angleRad);
|
|
180
|
+
const direction = vec2(cosAngle.div(aspect), sinAngle);
|
|
181
|
+
const centerPosition = vec2(uniforms.center.uniform[0], uniforms.center.uniform[1].oneMinus());
|
|
182
|
+
const centeredUV = screenUV.sub(centerPosition);
|
|
183
|
+
const directionalDist = max(float(0), centeredUV.dot(direction));
|
|
184
|
+
const falloff = max(float(.001), uniforms.falloff.uniform);
|
|
185
|
+
const blurAmount = smoothstep(float(0), falloff, directionalDist);
|
|
186
|
+
const scaledIntensity = uniforms.intensity.uniform.mul(.06);
|
|
187
|
+
const blurRadius = blurAmount.mul(scaledIntensity);
|
|
188
|
+
const weights = [
|
|
189
|
+
.056,
|
|
190
|
+
.135,
|
|
191
|
+
.278,
|
|
192
|
+
.487,
|
|
193
|
+
.726,
|
|
194
|
+
.923,
|
|
195
|
+
1,
|
|
196
|
+
.923,
|
|
197
|
+
.726,
|
|
198
|
+
.487,
|
|
199
|
+
.278,
|
|
200
|
+
.135,
|
|
201
|
+
.056
|
|
202
|
+
];
|
|
203
|
+
const weightSum = 6.214;
|
|
204
|
+
const horizontalTexture = convertToTexture(Fn(() => {
|
|
205
|
+
const uv$1 = screenUV;
|
|
206
|
+
const pixelSize = vec2(1).div(viewportSize);
|
|
207
|
+
const total = vec4(0).toVar();
|
|
208
|
+
for (let x = -6; x <= 6; x++) {
|
|
209
|
+
const weight = float(weights[x + 6] / weightSum);
|
|
210
|
+
const offset = vec2(float(x), float(0)).mul(blurRadius).mul(pixelSize);
|
|
211
|
+
const sampleCoord = uv$1.add(offset);
|
|
212
|
+
const sample = childTexture.sample(sampleCoord).mul(weight);
|
|
213
|
+
total.assign(total.add(sample));
|
|
214
|
+
}
|
|
215
|
+
return total;
|
|
216
|
+
})());
|
|
217
|
+
onCleanup(() => {
|
|
218
|
+
if (horizontalTexture?.renderTarget?.dispose) horizontalTexture.renderTarget.dispose();
|
|
219
|
+
});
|
|
220
|
+
return Fn(() => {
|
|
221
|
+
const uv$1 = screenUV;
|
|
222
|
+
const pixelSize = vec2(1).div(viewportSize);
|
|
223
|
+
const total = vec4(0).toVar();
|
|
224
|
+
for (let y = -6; y <= 6; y++) {
|
|
225
|
+
const weight = float(weights[y + 6] / weightSum);
|
|
226
|
+
const offset = vec2(float(0), float(y)).mul(blurRadius).mul(pixelSize);
|
|
227
|
+
const sampleCoord = uv$1.add(offset);
|
|
228
|
+
const sample = horizontalTexture.sample(sampleCoord).mul(weight);
|
|
229
|
+
total.assign(total.add(sample));
|
|
230
|
+
}
|
|
231
|
+
return unpremultiplyAlpha(total);
|
|
232
|
+
})();
|
|
233
|
+
}
|
|
234
|
+
};
|
|
235
|
+
var ProgressiveBlur_default = componentDefinition;
|
|
236
|
+
export { componentDefinition as n, ProgressiveBlur_default as t };
|
|
@@ -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 { l as ringSdf } from "./sdf-
|
|
3
|
+
import { l as ringSdf } from "./sdf-DyC2H_qS.js";
|
|
4
4
|
import { float, screenUV, 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 { u as roundedRectSdf } from "./sdf-
|
|
3
|
+
import { u as roundedRectSdf } 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,12 +1,15 @@
|
|
|
1
1
|
import { t as applyEdgeHandling } from "./edges-CfGcQniB.js";
|
|
2
2
|
import { c as transformEdges } from "./transformations-B5lM6fYX.js";
|
|
3
3
|
import { t as unpremultiplyAlpha } from "./alpha-C4ptedXe.js";
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
4
|
+
import { StorageTexture } from "three/webgpu";
|
|
5
|
+
import { DataTexture, FloatType, LinearFilter as LinearFilter$1, NearestFilter, RGBAFormat } from "three";
|
|
6
|
+
import { Fn, If, convertToTexture, float, instanceIndex, int, screenUV, smoothstep, storageTexture, texture, textureStore, uint, uniformArray, uvec2, vec2, vec4 } from "three/tsl";
|
|
6
7
|
var seededRandom = (seed) => {
|
|
7
8
|
const x = Math.sin(seed) * 1e4;
|
|
8
9
|
return x - Math.floor(x);
|
|
9
10
|
};
|
|
11
|
+
var SHARD_COUNT = 16;
|
|
12
|
+
var VORONOI_SIZE = 1024;
|
|
10
13
|
const componentDefinition = {
|
|
11
14
|
name: "Shatter",
|
|
12
15
|
category: "Interactive",
|
|
@@ -140,23 +143,148 @@ const componentDefinition = {
|
|
|
140
143
|
}
|
|
141
144
|
}
|
|
142
145
|
},
|
|
143
|
-
|
|
144
|
-
const
|
|
146
|
+
computeNode: ({ uniforms, onCleanup }) => {
|
|
147
|
+
const cellPositions = uniformArray(new Array(SHARD_COUNT * 2).fill(0), "float");
|
|
148
|
+
const voronoiTex = new StorageTexture(VORONOI_SIZE, VORONOI_SIZE);
|
|
149
|
+
voronoiTex.type = FloatType;
|
|
150
|
+
voronoiTex.magFilter = NearestFilter;
|
|
151
|
+
voronoiTex.minFilter = NearestFilter;
|
|
152
|
+
voronoiTex.generateMipmaps = false;
|
|
153
|
+
const voronoiTexNode = storageTexture(voronoiTex);
|
|
154
|
+
onCleanup(() => {
|
|
155
|
+
voronoiTex.dispose();
|
|
156
|
+
});
|
|
157
|
+
const vs = uint(VORONOI_SIZE);
|
|
158
|
+
const invVS = float(1 / VORONOI_SIZE);
|
|
159
|
+
const voronoiKernel = Fn(() => {
|
|
160
|
+
const idx = instanceIndex;
|
|
161
|
+
const x = idx.mod(vs);
|
|
162
|
+
const y = idx.div(vs);
|
|
163
|
+
If(y.lessThan(vs), () => {
|
|
164
|
+
const u = x.toFloat().add(float(.5)).mul(invVS);
|
|
165
|
+
const v = y.toFloat().add(float(.5)).mul(invVS);
|
|
166
|
+
const d1 = float(99999).toVar();
|
|
167
|
+
const d2 = float(99999).toVar();
|
|
168
|
+
const idx1 = float(0).toVar();
|
|
169
|
+
const idx2 = float(0).toVar();
|
|
170
|
+
for (let i = 0; i < SHARD_COUNT; i++) {
|
|
171
|
+
const cellX = cellPositions.element(int(i * 2));
|
|
172
|
+
const cellY = cellPositions.element(int(i * 2 + 1));
|
|
173
|
+
const ddx = u.sub(cellX);
|
|
174
|
+
const ddy = v.sub(cellY);
|
|
175
|
+
const distSq = ddx.mul(ddx).add(ddy.mul(ddy));
|
|
176
|
+
If(distSq.lessThan(d1), () => {
|
|
177
|
+
d2.assign(d1);
|
|
178
|
+
idx2.assign(idx1);
|
|
179
|
+
d1.assign(distSq);
|
|
180
|
+
idx1.assign(float(i));
|
|
181
|
+
}).Else(() => {
|
|
182
|
+
If(distSq.lessThan(d2), () => {
|
|
183
|
+
d2.assign(distSq);
|
|
184
|
+
idx2.assign(float(i));
|
|
185
|
+
});
|
|
186
|
+
});
|
|
187
|
+
}
|
|
188
|
+
textureStore(voronoiTexNode, uvec2(x, y), vec4(idx1, idx2, float(0), float(0))).toWriteOnly();
|
|
189
|
+
});
|
|
190
|
+
})().compute(VORONOI_SIZE * VORONOI_SIZE, [256]);
|
|
191
|
+
let currentSeed = uniforms.seed.uniform.value;
|
|
192
|
+
let needsDispatch = true;
|
|
193
|
+
const generateCells = (seed) => {
|
|
194
|
+
const positions = new Array(SHARD_COUNT * 2);
|
|
195
|
+
for (let i = 0; i < SHARD_COUNT; i++) {
|
|
196
|
+
positions[i * 2] = seededRandom(seed + i * 2);
|
|
197
|
+
positions[i * 2 + 1] = seededRandom(seed + i * 2 + 1);
|
|
198
|
+
}
|
|
199
|
+
cellPositions.array = positions;
|
|
200
|
+
};
|
|
201
|
+
generateCells(currentSeed);
|
|
202
|
+
return {
|
|
203
|
+
outputs: { voronoiTexture: voronoiTex },
|
|
204
|
+
getComputeNodes: () => {
|
|
205
|
+
const newSeed = uniforms.seed.uniform.value;
|
|
206
|
+
if (newSeed !== currentSeed) {
|
|
207
|
+
currentSeed = newSeed;
|
|
208
|
+
generateCells(currentSeed);
|
|
209
|
+
needsDispatch = true;
|
|
210
|
+
}
|
|
211
|
+
if (needsDispatch) {
|
|
212
|
+
needsDispatch = false;
|
|
213
|
+
return [voronoiKernel];
|
|
214
|
+
}
|
|
215
|
+
return null;
|
|
216
|
+
}
|
|
217
|
+
};
|
|
218
|
+
},
|
|
219
|
+
fragmentNode: ({ uniforms, onBeforeRender, childNode, onCleanup, dimensions, computeOutputs }) => {
|
|
145
220
|
const FRICTION = 1;
|
|
146
221
|
const cellData = new Float32Array(SHARD_COUNT * 4);
|
|
147
222
|
const cellTexture = new DataTexture(cellData, 4, 4, RGBAFormat, FloatType);
|
|
148
|
-
cellTexture.magFilter = LinearFilter;
|
|
149
|
-
cellTexture.minFilter = LinearFilter;
|
|
223
|
+
cellTexture.magFilter = LinearFilter$1;
|
|
224
|
+
cellTexture.minFilter = LinearFilter$1;
|
|
150
225
|
const displacementData = new Float32Array(SHARD_COUNT * 4);
|
|
151
226
|
const displacementTexture = new DataTexture(displacementData, 4, 4, RGBAFormat, FloatType);
|
|
152
|
-
displacementTexture.magFilter = LinearFilter;
|
|
153
|
-
displacementTexture.minFilter = LinearFilter;
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
227
|
+
displacementTexture.magFilter = LinearFilter$1;
|
|
228
|
+
displacementTexture.minFilter = LinearFilter$1;
|
|
229
|
+
let voronoiField;
|
|
230
|
+
if (computeOutputs?.voronoiTexture) voronoiField = texture(computeOutputs.voronoiTexture);
|
|
231
|
+
else {
|
|
232
|
+
const voronoiData = new Float32Array(VORONOI_SIZE * VORONOI_SIZE * 4);
|
|
233
|
+
const voronoiTexture = new DataTexture(voronoiData, VORONOI_SIZE, VORONOI_SIZE, RGBAFormat, FloatType);
|
|
234
|
+
voronoiTexture.magFilter = NearestFilter;
|
|
235
|
+
voronoiTexture.minFilter = NearestFilter;
|
|
236
|
+
voronoiField = texture(voronoiTexture);
|
|
237
|
+
const generateVoronoi = () => {
|
|
238
|
+
for (let y = 0; y < VORONOI_SIZE; y++) for (let x = 0; x < VORONOI_SIZE; x++) {
|
|
239
|
+
const u = (x + .5) / VORONOI_SIZE;
|
|
240
|
+
const v = (y + .5) / VORONOI_SIZE;
|
|
241
|
+
let d1 = Infinity, d2 = Infinity, i1 = 0, i2 = 0;
|
|
242
|
+
for (let i = 0; i < SHARD_COUNT; i++) {
|
|
243
|
+
const dx = u - cellData[i * 4];
|
|
244
|
+
const dy = v - cellData[i * 4 + 1];
|
|
245
|
+
const distSq = dx * dx + dy * dy;
|
|
246
|
+
if (distSq < d1) {
|
|
247
|
+
d2 = d1;
|
|
248
|
+
i2 = i1;
|
|
249
|
+
d1 = distSq;
|
|
250
|
+
i1 = i;
|
|
251
|
+
} else if (distSq < d2) {
|
|
252
|
+
d2 = distSq;
|
|
253
|
+
i2 = i;
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
const offset = (y * VORONOI_SIZE + x) * 4;
|
|
257
|
+
voronoiData[offset] = i1;
|
|
258
|
+
voronoiData[offset + 1] = i2;
|
|
259
|
+
}
|
|
260
|
+
voronoiTexture.needsUpdate = true;
|
|
261
|
+
};
|
|
262
|
+
let currentSeed = uniforms.seed.uniform.value;
|
|
263
|
+
const generateCells = (seed) => {
|
|
264
|
+
for (let i = 0; i < SHARD_COUNT; i++) {
|
|
265
|
+
cellData[i * 4] = seededRandom(seed + i * 2);
|
|
266
|
+
cellData[i * 4 + 1] = seededRandom(seed + i * 2 + 1);
|
|
267
|
+
cellData[i * 4 + 2] = seededRandom(seed + i * 3);
|
|
268
|
+
cellData[i * 4 + 3] = seededRandom(seed + i * 3 + 1);
|
|
269
|
+
}
|
|
270
|
+
cellTexture.needsUpdate = true;
|
|
271
|
+
};
|
|
272
|
+
generateCells(currentSeed);
|
|
273
|
+
generateVoronoi();
|
|
274
|
+
onBeforeRender(() => {
|
|
275
|
+
const newSeed = uniforms.seed.uniform.value;
|
|
276
|
+
if (newSeed !== currentSeed) {
|
|
277
|
+
currentSeed = newSeed;
|
|
278
|
+
generateCells(currentSeed);
|
|
279
|
+
generateVoronoi();
|
|
280
|
+
displacementData.fill(0);
|
|
281
|
+
}
|
|
282
|
+
});
|
|
283
|
+
onCleanup(() => {
|
|
284
|
+
voronoiTexture.dispose();
|
|
285
|
+
});
|
|
286
|
+
}
|
|
287
|
+
const generateCellsFull = (seed) => {
|
|
160
288
|
for (let i = 0; i < SHARD_COUNT; i++) {
|
|
161
289
|
cellData[i * 4] = seededRandom(seed + i * 2);
|
|
162
290
|
cellData[i * 4 + 1] = seededRandom(seed + i * 2 + 1);
|
|
@@ -165,60 +293,25 @@ const componentDefinition = {
|
|
|
165
293
|
}
|
|
166
294
|
cellTexture.needsUpdate = true;
|
|
167
295
|
};
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
const u = (x + .5) / VORONOI_SIZE;
|
|
171
|
-
const v = (y + .5) / VORONOI_SIZE;
|
|
172
|
-
let d1 = Infinity;
|
|
173
|
-
let d2 = Infinity;
|
|
174
|
-
let idx1 = 0;
|
|
175
|
-
let idx2 = 0;
|
|
176
|
-
for (let i = 0; i < SHARD_COUNT; i++) {
|
|
177
|
-
const dx = u - cellData[i * 4];
|
|
178
|
-
const dy = v - cellData[i * 4 + 1];
|
|
179
|
-
const distSq = dx * dx + dy * dy;
|
|
180
|
-
if (distSq < d1) {
|
|
181
|
-
d2 = d1;
|
|
182
|
-
idx2 = idx1;
|
|
183
|
-
d1 = distSq;
|
|
184
|
-
idx1 = i;
|
|
185
|
-
} else if (distSq < d2) {
|
|
186
|
-
d2 = distSq;
|
|
187
|
-
idx2 = i;
|
|
188
|
-
}
|
|
189
|
-
}
|
|
190
|
-
const offset = (y * VORONOI_SIZE + x) * 4;
|
|
191
|
-
voronoiData[offset] = idx1;
|
|
192
|
-
voronoiData[offset + 1] = idx2;
|
|
193
|
-
voronoiData[offset + 2] = 0;
|
|
194
|
-
voronoiData[offset + 3] = 0;
|
|
195
|
-
}
|
|
196
|
-
voronoiTexture.needsUpdate = true;
|
|
197
|
-
};
|
|
198
|
-
let currentSeed = uniforms.seed.uniform.value;
|
|
199
|
-
generateCells(currentSeed);
|
|
200
|
-
generateVoronoi();
|
|
296
|
+
let currentSeedForDisp = uniforms.seed.uniform.value;
|
|
297
|
+
generateCellsFull(currentSeedForDisp);
|
|
201
298
|
displacementData.fill(0);
|
|
202
299
|
displacementTexture.needsUpdate = true;
|
|
203
|
-
let prevX = .5;
|
|
204
|
-
let prevY = .5;
|
|
205
|
-
let lastTime = Date.now();
|
|
300
|
+
let prevX = .5, prevY = .5, lastTime = Date.now();
|
|
206
301
|
onBeforeRender(({ pointer }) => {
|
|
207
302
|
const currentTime = Date.now();
|
|
208
303
|
const dt = Math.min((currentTime - lastTime) / 1e3, .016);
|
|
209
304
|
lastTime = currentTime;
|
|
210
305
|
const aspect = dimensions.width / dimensions.height;
|
|
211
306
|
const newSeed = uniforms.seed.uniform.value;
|
|
212
|
-
if (newSeed !==
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
generateVoronoi();
|
|
307
|
+
if (newSeed !== currentSeedForDisp) {
|
|
308
|
+
currentSeedForDisp = newSeed;
|
|
309
|
+
generateCellsFull(currentSeedForDisp);
|
|
216
310
|
displacementData.fill(0);
|
|
217
311
|
}
|
|
218
312
|
const intensity = uniforms.intensity.uniform.value;
|
|
219
313
|
const radius = uniforms.radius.uniform.value;
|
|
220
314
|
const decay = uniforms.decay.uniform.value;
|
|
221
|
-
const friction = FRICTION;
|
|
222
315
|
let velX = dt > 0 ? (pointer.x - prevX) / dt : 0;
|
|
223
316
|
let velY = dt > 0 ? (pointer.y - prevY) / dt : 0;
|
|
224
317
|
let speed = Math.sqrt(velX * velX + velY * velY);
|
|
@@ -243,8 +336,7 @@ const componentDefinition = {
|
|
|
243
336
|
const decayFactor = Math.exp(-dt / decayTime);
|
|
244
337
|
currentDx *= decayFactor;
|
|
245
338
|
currentDy *= decayFactor;
|
|
246
|
-
let velocityDx = 0;
|
|
247
|
-
let velocityDy = 0;
|
|
339
|
+
let velocityDx = 0, velocityDy = 0;
|
|
248
340
|
if (dist < radius && speed > .01) {
|
|
249
341
|
const influence = Math.max(0, 1 - dist / radius);
|
|
250
342
|
const influenceCurve = influence * influence;
|
|
@@ -255,7 +347,7 @@ const componentDefinition = {
|
|
|
255
347
|
velocityDx += randomDirX * jitterForce;
|
|
256
348
|
velocityDy += randomDirY * jitterForce;
|
|
257
349
|
}
|
|
258
|
-
const lerpFactor = Math.min(1,
|
|
350
|
+
const lerpFactor = Math.min(1, FRICTION * dt);
|
|
259
351
|
displacementData[i * 4] = currentDx + velocityDx * lerpFactor;
|
|
260
352
|
displacementData[i * 4 + 1] = currentDy + velocityDy * lerpFactor;
|
|
261
353
|
displacementData[i * 4 + 2] = 0;
|
|
@@ -268,7 +360,6 @@ const componentDefinition = {
|
|
|
268
360
|
onCleanup(() => {
|
|
269
361
|
cellTexture.dispose();
|
|
270
362
|
displacementTexture.dispose();
|
|
271
|
-
voronoiTexture.dispose();
|
|
272
363
|
});
|
|
273
364
|
if (!childNode) return vec4(0, 0, 0, 0);
|
|
274
365
|
const childTexture = convertToTexture(childNode);
|
|
@@ -277,7 +368,7 @@ const componentDefinition = {
|
|
|
277
368
|
});
|
|
278
369
|
const cellField = texture(cellTexture);
|
|
279
370
|
const dispField = texture(displacementTexture);
|
|
280
|
-
const voronoiSample =
|
|
371
|
+
const voronoiSample = voronoiField.sample(screenUV);
|
|
281
372
|
const nearestIdx = voronoiSample.r;
|
|
282
373
|
const secondIdx = voronoiSample.g;
|
|
283
374
|
const nearestUV = vec2(nearestIdx.mod(float(4)).add(.5).div(4), nearestIdx.div(float(4)).floor().add(.5).div(4));
|
|
@@ -304,12 +395,9 @@ const componentDefinition = {
|
|
|
304
395
|
const rUV = displacedUV.add(rOffset.mul(crackIntensity));
|
|
305
396
|
const gUV = displacedUV.add(gOffset.mul(crackIntensity));
|
|
306
397
|
const bUV = displacedUV.add(bOffset.mul(crackIntensity));
|
|
307
|
-
const
|
|
308
|
-
const
|
|
309
|
-
const
|
|
310
|
-
const rFinal = applyEdgeHandling(rUV, rSample, childTexture, uniforms.edges.uniform.value);
|
|
311
|
-
const gFinal = applyEdgeHandling(gUV, gSample, childTexture, uniforms.edges.uniform.value);
|
|
312
|
-
const bFinal = applyEdgeHandling(bUV, bSample, childTexture, uniforms.edges.uniform.value);
|
|
398
|
+
const rFinal = applyEdgeHandling(rUV, childTexture.sample(rUV), childTexture, uniforms.edges.uniform.value);
|
|
399
|
+
const gFinal = applyEdgeHandling(gUV, childTexture.sample(gUV), childTexture, uniforms.edges.uniform.value);
|
|
400
|
+
const bFinal = applyEdgeHandling(bUV, childTexture.sample(bUV), childTexture, uniforms.edges.uniform.value);
|
|
313
401
|
const refractedColor = vec4(rFinal.r, gFinal.g, bFinal.b, gFinal.a);
|
|
314
402
|
const normalColor = applyEdgeHandling(displacedUV, childTexture.sample(displacedUV), childTexture, uniforms.edges.uniform.value);
|
|
315
403
|
let shadedRGB = normalColor.rgb.mul(float(1).sub(crackIntensity)).add(refractedColor.rgb.mul(crackIntensity));
|
|
@@ -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 { d as starSdf } from "./sdf-
|
|
3
|
+
import { d as starSdf } 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 {
|