shaders 2.5.93 → 2.5.95
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/{Blob-56vuq_qL.js → Blob-CuRSRXmA.js} +22 -7
- package/dist/core/{Blur-DTyNQt1R.js → Blur-CC8fo0C5.js} +28 -3
- package/dist/core/{ChannelBlur-CCaPXjka.js → ChannelBlur-CN_Zyiur.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-CR9981-Z.js → Glass-gQCmJlsQ.js} +55 -11
- package/dist/core/{Glow-CKWIRcBt.js → Glow-DvN-WnB4.js} +32 -2
- 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-BcHBSVDo.js → ProgressiveBlur-Dm530r0z.js} +59 -2
- 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-BysRsV8v.js → TiltShift-BqKaU3TM.js} +60 -2
- 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/{WaveDistortion-BVT1KuLK.js → WaveDistortion-BKma8-Ju.js} +18 -5
- package/dist/core/{WebcamTexture-BXj7sqND.js → WebcamTexture-Cf8J7JB1.js} +1 -1
- package/dist/core/computeBlur-B0KA4n89.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 +173 -122
- package/dist/core/registry.js +103 -102
- package/dist/core/renderer.d.ts +14 -0
- package/dist/core/renderer.d.ts.map +1 -1
- package/dist/core/shaderRegistry-DriE1ikS.js +244 -0
- package/dist/core/shaders/Blob/index.d.ts.map +1 -1
- package/dist/core/shaders/Blob/index.js +1 -1
- 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.d.ts.map +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 +29 -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/CursorRipples-n_xEDr10.js +0 -179
- package/dist/core/CursorTrail-C-0lpOV1.js +0 -160
- package/dist/core/GridDistortion-DXM5MgSc.js +0 -183
- package/dist/core/Liquify-CqcAWBwZ.js +0 -228
- package/dist/core/shaderRegistry-BZ6QG12o.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/{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,263 @@
|
|
|
1
|
+
import { a as transformColor, o as transformColorSpace, t as colorSpaceOptions } from "./transformations-B5lM6fYX.js";
|
|
2
|
+
import { t as mixColors } from "./colorMixing-BPpDnR5I.js";
|
|
3
|
+
import { StorageTexture } from "three/webgpu";
|
|
4
|
+
import { DataTexture, FloatType, LinearFilter as LinearFilter$1, RGBAFormat } from "three";
|
|
5
|
+
import { Fn, If, attributeArray, float, instanceIndex, screenUV, step, storageTexture, texture, textureStore, uint, uniform, uvec2, vec2, vec4 } from "three/tsl";
|
|
6
|
+
var GRID_SIZE = 128;
|
|
7
|
+
const componentDefinition = {
|
|
8
|
+
name: "CursorTrail",
|
|
9
|
+
category: "Interactive",
|
|
10
|
+
description: "Animated trail effect that tracks cursor movement",
|
|
11
|
+
props: {
|
|
12
|
+
colorA: {
|
|
13
|
+
default: "#00aaff",
|
|
14
|
+
transform: transformColor,
|
|
15
|
+
description: "Color of fresh trails",
|
|
16
|
+
ui: {
|
|
17
|
+
type: "color",
|
|
18
|
+
label: "Start Color",
|
|
19
|
+
group: "Colors"
|
|
20
|
+
}
|
|
21
|
+
},
|
|
22
|
+
colorB: {
|
|
23
|
+
default: "#ff00aa",
|
|
24
|
+
transform: transformColor,
|
|
25
|
+
description: "Color trails transition to as they fade",
|
|
26
|
+
ui: {
|
|
27
|
+
type: "color",
|
|
28
|
+
label: "End Color",
|
|
29
|
+
group: "Colors"
|
|
30
|
+
}
|
|
31
|
+
},
|
|
32
|
+
radius: {
|
|
33
|
+
default: .5,
|
|
34
|
+
description: "Base radius of trail circles",
|
|
35
|
+
ui: {
|
|
36
|
+
type: "range",
|
|
37
|
+
min: .5,
|
|
38
|
+
max: 2,
|
|
39
|
+
step: .1,
|
|
40
|
+
label: "Radius",
|
|
41
|
+
group: "Effect"
|
|
42
|
+
}
|
|
43
|
+
},
|
|
44
|
+
length: {
|
|
45
|
+
default: .5,
|
|
46
|
+
description: "How long trail circles persist (in seconds)",
|
|
47
|
+
ui: {
|
|
48
|
+
type: "range",
|
|
49
|
+
min: .1,
|
|
50
|
+
max: 2,
|
|
51
|
+
step: .1,
|
|
52
|
+
label: "Trail Length",
|
|
53
|
+
group: "Animation"
|
|
54
|
+
}
|
|
55
|
+
},
|
|
56
|
+
shrink: {
|
|
57
|
+
default: 1,
|
|
58
|
+
description: "How much circles shrink as they fade out (0 = no shrink, 1 = full shrink)",
|
|
59
|
+
ui: {
|
|
60
|
+
type: "range",
|
|
61
|
+
min: 0,
|
|
62
|
+
max: 1,
|
|
63
|
+
step: .1,
|
|
64
|
+
label: "Shrink Amount",
|
|
65
|
+
group: "Effect"
|
|
66
|
+
}
|
|
67
|
+
},
|
|
68
|
+
colorSpace: {
|
|
69
|
+
default: "linear",
|
|
70
|
+
transform: transformColorSpace,
|
|
71
|
+
compileTime: true,
|
|
72
|
+
description: "Color space for color interpolation",
|
|
73
|
+
ui: {
|
|
74
|
+
type: "select",
|
|
75
|
+
options: colorSpaceOptions,
|
|
76
|
+
label: "Color Space",
|
|
77
|
+
group: "Colors"
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
},
|
|
81
|
+
computeNode: ({ uniforms, onCleanup, dimensions, renderer }) => {
|
|
82
|
+
const trailBuffer = attributeArray(GRID_SIZE * GRID_SIZE, "vec4");
|
|
83
|
+
const trailTex = new StorageTexture(GRID_SIZE, GRID_SIZE);
|
|
84
|
+
trailTex.type = FloatType;
|
|
85
|
+
const trailTexNode = storageTexture(trailTex);
|
|
86
|
+
onCleanup(() => {
|
|
87
|
+
trailTex.dispose();
|
|
88
|
+
});
|
|
89
|
+
const fadeRateU = uniform(.97);
|
|
90
|
+
const ageRateU = uniform(.03);
|
|
91
|
+
const shrinkU = uniform(1);
|
|
92
|
+
const cursorXU = uniform(.5);
|
|
93
|
+
const cursorYU = uniform(.5);
|
|
94
|
+
const radiusU = uniform(.05);
|
|
95
|
+
const amountU = uniform(0);
|
|
96
|
+
const aspectU = uniform(1);
|
|
97
|
+
const mouseActiveU = uniform(0);
|
|
98
|
+
const gs = uint(GRID_SIZE);
|
|
99
|
+
const decayPass = Fn(() => {
|
|
100
|
+
const idx = instanceIndex;
|
|
101
|
+
const cell = trailBuffer.element(idx);
|
|
102
|
+
const intensity = cell.x.mul(fadeRateU);
|
|
103
|
+
const size = float(1).sub(float(1).sub(intensity).mul(shrinkU));
|
|
104
|
+
const age = cell.z.add(ageRateU).min(float(1));
|
|
105
|
+
trailBuffer.element(idx).assign(vec4(intensity, size, age, float(0)));
|
|
106
|
+
})().compute(GRID_SIZE * GRID_SIZE, [256]);
|
|
107
|
+
const stampPass = Fn(() => {
|
|
108
|
+
const idx = instanceIndex;
|
|
109
|
+
const j = idx.mod(gs);
|
|
110
|
+
const i = idx.div(gs);
|
|
111
|
+
If(mouseActiveU.greaterThan(float(.5)), () => {
|
|
112
|
+
const cellX = j.toFloat().add(float(.5)).div(float(GRID_SIZE));
|
|
113
|
+
const cellY = i.toFloat().add(float(.5)).div(float(GRID_SIZE));
|
|
114
|
+
const ddx = aspectU.greaterThanEqual(float(1)).select(cellX.sub(cursorXU).mul(aspectU), cellX.sub(cursorXU));
|
|
115
|
+
const ddy = aspectU.greaterThanEqual(float(1)).select(cellY.sub(cursorYU), cellY.sub(cursorYU).div(aspectU));
|
|
116
|
+
const distSq = ddx.mul(ddx).add(ddy.mul(ddy));
|
|
117
|
+
const influenceRadius = radiusU.mul(float(3));
|
|
118
|
+
If(distSq.lessThan(influenceRadius.mul(influenceRadius)), () => {
|
|
119
|
+
const influence = distSq.negate().div(radiusU.mul(radiusU)).exp();
|
|
120
|
+
const newIntensity = trailBuffer.element(idx).x.add(influence.mul(amountU)).min(float(1));
|
|
121
|
+
trailBuffer.element(idx).assign(vec4(newIntensity, float(1), float(0), float(0)));
|
|
122
|
+
});
|
|
123
|
+
});
|
|
124
|
+
})().compute(GRID_SIZE * GRID_SIZE, [256]);
|
|
125
|
+
const outputPass = Fn(() => {
|
|
126
|
+
const idx = instanceIndex;
|
|
127
|
+
const j = idx.mod(gs);
|
|
128
|
+
const i = idx.div(gs);
|
|
129
|
+
const cell = trailBuffer.element(idx);
|
|
130
|
+
textureStore(trailTexNode, uvec2(j, i), cell).toWriteOnly();
|
|
131
|
+
})().compute(GRID_SIZE * GRID_SIZE, [256]);
|
|
132
|
+
let prevX = .5;
|
|
133
|
+
let prevY = .5;
|
|
134
|
+
let lastTime = Date.now();
|
|
135
|
+
let lastActiveTime = Date.now();
|
|
136
|
+
return {
|
|
137
|
+
outputs: { trailTexture: trailTex },
|
|
138
|
+
getComputeNodes: (params) => {
|
|
139
|
+
const currentTime = Date.now();
|
|
140
|
+
const dt = Math.min((currentTime - lastTime) / 1e3, .016);
|
|
141
|
+
lastTime = currentTime;
|
|
142
|
+
const aspect = dimensions.width / dimensions.height;
|
|
143
|
+
const radius = uniforms.radius.uniform.value * .1;
|
|
144
|
+
const length$1 = uniforms.length.uniform.value;
|
|
145
|
+
const shrink = uniforms.shrink.uniform.value;
|
|
146
|
+
const dx = params.pointer.x - prevX;
|
|
147
|
+
const dy = params.pointer.y - prevY;
|
|
148
|
+
const speed = Math.sqrt(dx * dx + dy * dy);
|
|
149
|
+
const oldX = prevX;
|
|
150
|
+
const oldY = prevY;
|
|
151
|
+
prevX = params.pointer.x;
|
|
152
|
+
prevY = params.pointer.y;
|
|
153
|
+
if (speed > .001) lastActiveTime = currentTime;
|
|
154
|
+
const settleMs = Math.min(3e4, Math.max(3e3, length$1 * 5e3));
|
|
155
|
+
if (currentTime - lastActiveTime > settleMs) return null;
|
|
156
|
+
fadeRateU.value = 1 - dt / Math.max(.1, length$1);
|
|
157
|
+
ageRateU.value = dt / Math.max(.1, length$1);
|
|
158
|
+
shrinkU.value = shrink;
|
|
159
|
+
radiusU.value = radius;
|
|
160
|
+
aspectU.value = aspect;
|
|
161
|
+
renderer.compute(decayPass);
|
|
162
|
+
if (speed > .001) {
|
|
163
|
+
const stepSize = Math.max(.005, radius * .5);
|
|
164
|
+
const numSteps = Math.min(20, Math.max(1, Math.ceil(speed / stepSize)));
|
|
165
|
+
const amountPerStep = speed / numSteps * 50 * dt;
|
|
166
|
+
mouseActiveU.value = 1;
|
|
167
|
+
amountU.value = amountPerStep;
|
|
168
|
+
for (let s = 0; s < numSteps; s++) {
|
|
169
|
+
const t = (s + .5) / numSteps;
|
|
170
|
+
cursorXU.value = oldX + dx * t;
|
|
171
|
+
cursorYU.value = oldY + dy * t;
|
|
172
|
+
renderer.compute(stampPass);
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
return [outputPass];
|
|
176
|
+
}
|
|
177
|
+
};
|
|
178
|
+
},
|
|
179
|
+
fragmentNode: ({ uniforms, onBeforeRender, onCleanup, dimensions, computeOutputs }) => {
|
|
180
|
+
let trailField;
|
|
181
|
+
if (computeOutputs?.trailTexture) trailField = texture(computeOutputs.trailTexture);
|
|
182
|
+
else {
|
|
183
|
+
const trailData = new Float32Array(GRID_SIZE * GRID_SIZE * 4);
|
|
184
|
+
const trailTexture = new DataTexture(trailData, GRID_SIZE, GRID_SIZE, RGBAFormat, FloatType);
|
|
185
|
+
trailTexture.magFilter = LinearFilter$1;
|
|
186
|
+
trailTexture.minFilter = LinearFilter$1;
|
|
187
|
+
trailTexture.needsUpdate = true;
|
|
188
|
+
trailField = texture(trailTexture);
|
|
189
|
+
let prevX = .5;
|
|
190
|
+
let prevY = .5;
|
|
191
|
+
let lastTime = Date.now();
|
|
192
|
+
onBeforeRender(({ pointer }) => {
|
|
193
|
+
const currentTime = Date.now();
|
|
194
|
+
const dt = Math.min((currentTime - lastTime) / 1e3, .016);
|
|
195
|
+
lastTime = currentTime;
|
|
196
|
+
const aspect = dimensions.width / dimensions.height;
|
|
197
|
+
const radius = uniforms.radius.uniform.value * .1;
|
|
198
|
+
const length$1 = uniforms.length.uniform.value;
|
|
199
|
+
const shrink = uniforms.shrink.uniform.value;
|
|
200
|
+
const dx = pointer.x - prevX;
|
|
201
|
+
const dy = pointer.y - prevY;
|
|
202
|
+
const speed = Math.sqrt(dx * dx + dy * dy);
|
|
203
|
+
const fadeRate = 1 - dt / Math.max(.1, length$1);
|
|
204
|
+
const ageRate = dt / Math.max(.1, length$1);
|
|
205
|
+
for (let i = 0; i < GRID_SIZE * GRID_SIZE * 4; i += 4) {
|
|
206
|
+
trailData[i] *= fadeRate;
|
|
207
|
+
trailData[i + 1] = 1 - (1 - trailData[i]) * shrink;
|
|
208
|
+
trailData[i + 2] = Math.min(1, trailData[i + 2] + ageRate);
|
|
209
|
+
}
|
|
210
|
+
if (speed > .001) {
|
|
211
|
+
const influenceRadius = radius * 3;
|
|
212
|
+
const stepSize = Math.max(.005, radius * .5);
|
|
213
|
+
const numSteps = Math.min(20, Math.max(1, Math.ceil(speed / stepSize)));
|
|
214
|
+
const amountPerStep = speed / numSteps * 50 * dt;
|
|
215
|
+
for (let s = 0; s < numSteps; s++) {
|
|
216
|
+
const t = (s + .5) / numSteps;
|
|
217
|
+
const px = prevX + dx * t;
|
|
218
|
+
const py = prevY + dy * t;
|
|
219
|
+
const minJ = Math.max(0, Math.floor((px - influenceRadius) * GRID_SIZE));
|
|
220
|
+
const maxJ = Math.min(GRID_SIZE - 1, Math.ceil((px + influenceRadius) * GRID_SIZE));
|
|
221
|
+
const minI = Math.max(0, Math.floor((py - influenceRadius) * GRID_SIZE));
|
|
222
|
+
const maxI = Math.min(GRID_SIZE - 1, Math.ceil((py + influenceRadius) * GRID_SIZE));
|
|
223
|
+
for (let i = minI; i <= maxI; i++) for (let j = minJ; j <= maxJ; j++) {
|
|
224
|
+
const idx = (i * GRID_SIZE + j) * 4;
|
|
225
|
+
const cellX = (j + .5) / GRID_SIZE;
|
|
226
|
+
const cellY = (i + .5) / GRID_SIZE;
|
|
227
|
+
const cellDx = aspect >= 1 ? (cellX - px) * aspect : cellX - px;
|
|
228
|
+
const cellDy = aspect >= 1 ? cellY - py : (cellY - py) / aspect;
|
|
229
|
+
const dist = Math.sqrt(cellDx * cellDx + cellDy * cellDy);
|
|
230
|
+
if (dist < influenceRadius) {
|
|
231
|
+
const influence = Math.exp(-dist * dist / (radius * radius));
|
|
232
|
+
trailData[idx] = Math.min(1, trailData[idx] + influence * amountPerStep);
|
|
233
|
+
trailData[idx + 1] = 1;
|
|
234
|
+
trailData[idx + 2] = 0;
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
trailTexture.needsUpdate = true;
|
|
240
|
+
prevX = pointer.x;
|
|
241
|
+
prevY = pointer.y;
|
|
242
|
+
});
|
|
243
|
+
onCleanup(() => {
|
|
244
|
+
trailTexture.dispose();
|
|
245
|
+
});
|
|
246
|
+
}
|
|
247
|
+
const pixelSize = float(1 / GRID_SIZE);
|
|
248
|
+
const centerSample = trailField.sample(screenUV);
|
|
249
|
+
const sample1 = trailField.sample(screenUV.add(vec2(pixelSize, float(0))));
|
|
250
|
+
const sample2 = trailField.sample(screenUV.add(vec2(float(0), pixelSize)));
|
|
251
|
+
const sample3 = trailField.sample(screenUV.add(vec2(pixelSize.negate(), float(0))));
|
|
252
|
+
const sample4 = trailField.sample(screenUV.add(vec2(float(0), pixelSize.negate())));
|
|
253
|
+
const trailIntensity = centerSample.x.mul(float(.5)).add(sample1.x.mul(float(.125))).add(sample2.x.mul(float(.125))).add(sample3.x.mul(float(.125))).add(sample4.x.mul(float(.125)));
|
|
254
|
+
const trailAge = centerSample.z.mul(float(.5)).add(sample1.z.mul(float(.125))).add(sample2.z.mul(float(.125))).add(sample3.z.mul(float(.125))).add(sample4.z.mul(float(.125)));
|
|
255
|
+
const circleMask = step(float(.01), trailIntensity);
|
|
256
|
+
const colorA = uniforms.colorA.uniform;
|
|
257
|
+
const colorB = uniforms.colorB.uniform;
|
|
258
|
+
const trailColor = mixColors(colorA, colorB, trailAge, uniforms.colorSpace.uniform.value);
|
|
259
|
+
return vec4(trailColor.rgb, trailColor.a.mul(circleMask));
|
|
260
|
+
}
|
|
261
|
+
};
|
|
262
|
+
var CursorTrail_default = componentDefinition;
|
|
263
|
+
export { componentDefinition as n, CursorTrail_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 { o as ellipseSdf } from "./sdf-
|
|
3
|
+
import { o as ellipseSdf } 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 { 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, abs, clamp, convertToTexture, cos, float, max, screenUV, sin, smoothstep, sqrt, vec2, vec3, vec4, viewportSize } from "three/tsl";
|
|
4
4
|
var _INV_LIGHT_LEN = 1 / Math.sqrt(1.49);
|
|
5
5
|
var _LZN = .7 * _INV_LIGHT_LEN;
|
|
@@ -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 { s as flowerSdf } from "./sdf-
|
|
3
|
+
import { s as flowerSdf } 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,7 @@
|
|
|
1
1
|
import { a as transformColor, l as transformPosition } from "./transformations-B5lM6fYX.js";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
2
|
+
import { t as createGaussianBlurCompute } from "./computeBlur-B0KA4n89.js";
|
|
3
|
+
import { n as createAnalyticSdfSampler, r as createSvgSdfSampler } from "./sdf-DyC2H_qS.js";
|
|
4
|
+
import { Fn, clamp, convertToTexture, dot, exp2, float, max, mix, pow, screenUV, smoothstep, sqrt, texture, uniform, vec2, vec3, vec4, viewportSize } from "three/tsl";
|
|
4
5
|
var GOLDEN_ANGLE = 2.3999632297286535;
|
|
5
6
|
var BLUR_SAMPLE_COUNT = 9;
|
|
6
7
|
const BLUR_DISK = [];
|
|
@@ -10,7 +11,16 @@ for (let i = 0; i < BLUR_SAMPLE_COUNT; i++) {
|
|
|
10
11
|
BLUR_DISK.push([Math.cos(angle) * r, Math.sin(angle) * r]);
|
|
11
12
|
}
|
|
12
13
|
var INV_HLEN_GLASS = 1 / Math.sqrt(5);
|
|
13
|
-
function applyGlassEffect(childTexture, sdfSampler, uniforms) {
|
|
14
|
+
function applyGlassEffect(childTexture, sdfSampler, uniforms, onBeforeRender, blurredTexture) {
|
|
15
|
+
const lx = uniform(0);
|
|
16
|
+
const ly = uniform(0);
|
|
17
|
+
const updateLightAngle = () => {
|
|
18
|
+
const rad = uniforms.lightAngle.uniform.value * Math.PI / 180;
|
|
19
|
+
lx.value = Math.cos(rad);
|
|
20
|
+
ly.value = Math.sin(rad);
|
|
21
|
+
};
|
|
22
|
+
updateLightAngle();
|
|
23
|
+
onBeforeRender?.(updateLightAngle);
|
|
14
24
|
return Fn(() => {
|
|
15
25
|
const uv$1 = screenUV;
|
|
16
26
|
const aspect = viewportSize.x.div(viewportSize.y);
|
|
@@ -27,9 +37,6 @@ function applyGlassEffect(childTexture, sdfSampler, uniforms) {
|
|
|
27
37
|
const gradY = sdfSampler(sdfUV.add(vec2(float(0), EPS))).r.sub(sdfRaw).div(EPS);
|
|
28
38
|
const rb1 = clamp(sdf.negate().div(sharp).mul(float(32)), float(0), float(1));
|
|
29
39
|
const rb2base = clamp(sdf.sub(pxH).negate().div(sharp).mul(float(16)), float(0), float(1)).sub(clamp(sdf.negate().div(sharp).mul(float(16)), float(0), float(1)));
|
|
30
|
-
const lightRad = uniforms.lightAngle.uniform.mul(float(Math.PI / 180));
|
|
31
|
-
const lx = cos(lightRad);
|
|
32
|
-
const ly = sin(lightRad);
|
|
33
40
|
const lightFacing = gradX.mul(lx).add(gradY.mul(ly)).mul(float(.5)).add(float(.5));
|
|
34
41
|
const rb2 = rb2base.mul(lightFacing).mul(uniforms.highlight.uniform);
|
|
35
42
|
const thicknessRange = uniforms.thickness.uniform.mul(float(.3)).max(float(.005));
|
|
@@ -42,7 +49,21 @@ function applyGlassEffect(childTexture, sdfSampler, uniforms) {
|
|
|
42
49
|
const blurEnabled = typeof uniforms.blur.uniform.value === "number" ? uniforms.blur.uniform.value > 0 : true;
|
|
43
50
|
const aberrationEnabled = typeof uniforms.aberration.uniform.value === "number" ? uniforms.aberration.uniform.value > 0 : true;
|
|
44
51
|
let blurred;
|
|
45
|
-
if (
|
|
52
|
+
if (blurredTexture && blurEnabled) {
|
|
53
|
+
const blurTex = texture(blurredTexture);
|
|
54
|
+
if (!aberrationEnabled) blurred = blurTex.sample(lensUV);
|
|
55
|
+
else {
|
|
56
|
+
const chrScale = uniforms.aberration.uniform.mul(float(.06));
|
|
57
|
+
const chrOffX = offsetX.mul(chrScale);
|
|
58
|
+
const chrOffY = offsetY.mul(chrScale);
|
|
59
|
+
const rUV = lensUV.add(vec2(chrOffX, chrOffY));
|
|
60
|
+
const bUV = lensUV.sub(vec2(chrOffX, chrOffY));
|
|
61
|
+
const rSample = blurTex.sample(rUV);
|
|
62
|
+
const gSample = blurTex.sample(lensUV);
|
|
63
|
+
const bSample = blurTex.sample(bUV);
|
|
64
|
+
blurred = vec4(rSample.r, gSample.g, bSample.b, gSample.a);
|
|
65
|
+
}
|
|
66
|
+
} else if (!blurEnabled && !aberrationEnabled) blurred = childTexture.sample(lensUV);
|
|
46
67
|
else if (!blurEnabled && aberrationEnabled) {
|
|
47
68
|
const chrScale = uniforms.aberration.uniform.mul(float(.06));
|
|
48
69
|
const chrOffX = offsetX.mul(chrScale);
|
|
@@ -362,12 +383,35 @@ const componentDefinition = {
|
|
|
362
383
|
description: "Active SDF shape type — triggers recompile when shape is switched. When empty, derived from shape JSON at mount time."
|
|
363
384
|
}
|
|
364
385
|
},
|
|
365
|
-
|
|
366
|
-
if (!childNode) return
|
|
386
|
+
computeNode: ({ uniforms, childNode, onCleanup, dimensions, renderer }) => {
|
|
387
|
+
if (!childNode) return null;
|
|
388
|
+
const blurValue = uniforms.blur.uniform.value;
|
|
389
|
+
if (typeof blurValue === "number" && blurValue <= 0) return null;
|
|
367
390
|
const childTexture = convertToTexture(childNode);
|
|
368
391
|
onCleanup(() => {
|
|
369
392
|
if (childTexture?.renderTarget?.dispose) childTexture.renderTarget.dispose();
|
|
370
393
|
});
|
|
394
|
+
const dpr = renderer?.getPixelRatio?.() ?? 1;
|
|
395
|
+
const { computeNodes, outputTexture, updateRadius } = createGaussianBlurCompute(childTexture, Math.round(dimensions.width * dpr), Math.round(dimensions.height * dpr), onCleanup);
|
|
396
|
+
return {
|
|
397
|
+
outputs: {
|
|
398
|
+
childTexture,
|
|
399
|
+
blurredTexture: outputTexture
|
|
400
|
+
},
|
|
401
|
+
getComputeNodes: () => {
|
|
402
|
+
const currentBlur = uniforms.blur.uniform.value;
|
|
403
|
+
updateRadius(currentBlur * 2);
|
|
404
|
+
return computeNodes;
|
|
405
|
+
}
|
|
406
|
+
};
|
|
407
|
+
},
|
|
408
|
+
fragmentNode: ({ uniforms, childNode, onCleanup, onBeforeRender, computeOutputs }) => {
|
|
409
|
+
if (!childNode) return vec4(0);
|
|
410
|
+
const childTexture = computeOutputs?.childTexture ?? convertToTexture(childNode);
|
|
411
|
+
if (!computeOutputs) onCleanup(() => {
|
|
412
|
+
if (childTexture?.renderTarget?.dispose) childTexture.renderTarget.dispose();
|
|
413
|
+
});
|
|
414
|
+
const blurredTexture = computeOutputs?.blurredTexture;
|
|
371
415
|
const shapeSdfUrl = uniforms.shapeSdfUrl.uniform.value;
|
|
372
416
|
const initialConfig = (() => {
|
|
373
417
|
const val = uniforms.shape.uniform.value;
|
|
@@ -383,8 +427,8 @@ const componentDefinition = {
|
|
|
383
427
|
};
|
|
384
428
|
}
|
|
385
429
|
})();
|
|
386
|
-
if (shapeSdfUrl) return applyGlassEffect(childTexture, createSvgSdfSampler(shapeSdfUrl, onBeforeRender, onCleanup), uniforms);
|
|
387
|
-
else return applyGlassEffect(childTexture, createAnalyticSdfSampler(uniforms.shapeType.uniform.value || initialConfig.type || "circleSDF", initialConfig, uniforms.shape, onBeforeRender), uniforms);
|
|
430
|
+
if (shapeSdfUrl) return applyGlassEffect(childTexture, createSvgSdfSampler(shapeSdfUrl, onBeforeRender, onCleanup), uniforms, onBeforeRender, blurredTexture);
|
|
431
|
+
else return applyGlassEffect(childTexture, createAnalyticSdfSampler(uniforms.shapeType.uniform.value || initialConfig.type || "circleSDF", initialConfig, uniforms.shape, onBeforeRender), uniforms, onBeforeRender, blurredTexture);
|
|
388
432
|
}
|
|
389
433
|
};
|
|
390
434
|
var Glass_default = componentDefinition;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { t as unpremultiplyAlpha } from "./alpha-C4ptedXe.js";
|
|
2
|
-
import {
|
|
2
|
+
import { t as createGaussianBlurCompute } from "./computeBlur-B0KA4n89.js";
|
|
3
|
+
import { Fn, convertToTexture, dot, float, max, screenUV, texture, vec2, vec3, vec4, viewportSize } from "three/tsl";
|
|
3
4
|
const componentDefinition = {
|
|
4
5
|
name: "Glow",
|
|
5
6
|
category: "Stylize",
|
|
@@ -44,8 +45,37 @@ 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 size = uniforms.size.uniform.value;
|
|
63
|
+
updateRadius(size);
|
|
64
|
+
return computeNodes;
|
|
65
|
+
}
|
|
66
|
+
};
|
|
67
|
+
},
|
|
68
|
+
fragmentNode: ({ uniforms, childNode, onCleanup, computeOutputs }) => {
|
|
48
69
|
if (!childNode) return vec4(0, 0, 0, 0);
|
|
70
|
+
if (computeOutputs?.blurredTexture) {
|
|
71
|
+
const originalColor$1 = computeOutputs.childTexture.sample(screenUV);
|
|
72
|
+
const blurredColor = texture(computeOutputs.blurredTexture).sample(screenUV);
|
|
73
|
+
const luminance = dot(originalColor$1.rgb, vec3(.299, .587, .114));
|
|
74
|
+
const brightnessMask = max(float(0), luminance.sub(uniforms.threshold.uniform));
|
|
75
|
+
const intensity$1 = uniforms.intensity.uniform;
|
|
76
|
+
const glow = blurredColor.mul(brightnessMask).mul(intensity$1);
|
|
77
|
+
return unpremultiplyAlpha(vec4(originalColor$1.rgb.add(glow.rgb), max(originalColor$1.a, glow.a)));
|
|
78
|
+
}
|
|
49
79
|
const childTexture = convertToTexture(childNode);
|
|
50
80
|
onCleanup(() => {
|
|
51
81
|
if (childTexture?.renderTarget?.dispose) childTexture.renderTarget.dispose();
|