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,141 @@
|
|
|
1
|
+
import { StorageTexture } from "three/webgpu";
|
|
2
|
+
import { FloatType } from "three";
|
|
3
|
+
import { Fn, If, float, instanceIndex, int, storageTexture, textureLoad, textureStore, uint, uniformArray, uvec2, vec4 } from "three/tsl";
|
|
4
|
+
var HALF_KERNEL = 48;
|
|
5
|
+
var KERNEL_SIZE = HALF_KERNEL * 2 + 1;
|
|
6
|
+
var VAR_SIGMA = HALF_KERNEL / 3;
|
|
7
|
+
var FIXED_WEIGHTS = [];
|
|
8
|
+
var fixedWeightSum = 0;
|
|
9
|
+
for (let i = -HALF_KERNEL; i <= HALF_KERNEL; i++) {
|
|
10
|
+
const w = Math.exp(-(i * i) / (2 * VAR_SIGMA * VAR_SIGMA));
|
|
11
|
+
FIXED_WEIGHTS.push(w);
|
|
12
|
+
fixedWeightSum += w;
|
|
13
|
+
}
|
|
14
|
+
for (let i = 0; i < KERNEL_SIZE; i++) FIXED_WEIGHTS[i] /= fixedWeightSum;
|
|
15
|
+
function createGaussianBlurCompute(inputTexture, width, height, onCleanup) {
|
|
16
|
+
const intermediateTex = new StorageTexture(width, height);
|
|
17
|
+
intermediateTex.type = FloatType;
|
|
18
|
+
const outputTex = new StorageTexture(width, height);
|
|
19
|
+
outputTex.type = FloatType;
|
|
20
|
+
onCleanup(() => {
|
|
21
|
+
intermediateTex.dispose();
|
|
22
|
+
outputTex.dispose();
|
|
23
|
+
});
|
|
24
|
+
const intermediateWriteNode = storageTexture(intermediateTex);
|
|
25
|
+
const intermediateReadNode = storageTexture(intermediateTex).toReadOnly();
|
|
26
|
+
const outputNode = storageTexture(outputTex);
|
|
27
|
+
const weights = uniformArray(new Array(KERNEL_SIZE).fill(0), "float");
|
|
28
|
+
let lastRadius = -1;
|
|
29
|
+
const w = uint(width);
|
|
30
|
+
const h = uint(height);
|
|
31
|
+
const wm1 = int(width - 1);
|
|
32
|
+
const hm1 = int(height - 1);
|
|
33
|
+
const horizontalPass = Fn(() => {
|
|
34
|
+
const idx = instanceIndex;
|
|
35
|
+
const x = idx.mod(w);
|
|
36
|
+
const y = idx.div(w);
|
|
37
|
+
If(y.lessThan(h), () => {
|
|
38
|
+
const sum = vec4(0).toVar();
|
|
39
|
+
const xi = x.toInt();
|
|
40
|
+
for (let i = -HALF_KERNEL; i <= HALF_KERNEL; i++) {
|
|
41
|
+
const texel = textureLoad(inputTexture, uvec2(xi.add(int(i)).clamp(int(0), wm1).toUint(), y), int(0));
|
|
42
|
+
sum.assign(sum.add(texel.mul(weights.element(int(i + HALF_KERNEL)))));
|
|
43
|
+
}
|
|
44
|
+
textureStore(intermediateWriteNode, uvec2(x, y), sum).toWriteOnly();
|
|
45
|
+
});
|
|
46
|
+
})().compute(width * height, [256]);
|
|
47
|
+
const verticalPass = Fn(() => {
|
|
48
|
+
const idx = instanceIndex;
|
|
49
|
+
const x = idx.mod(w);
|
|
50
|
+
const y = idx.div(w);
|
|
51
|
+
If(y.lessThan(h), () => {
|
|
52
|
+
const sum = vec4(0).toVar();
|
|
53
|
+
for (let i = -HALF_KERNEL; i <= HALF_KERNEL; i++) {
|
|
54
|
+
const texel = textureLoad(intermediateReadNode, uvec2(x, y.toInt().add(int(i)).clamp(int(0), hm1).toUint()), int(0));
|
|
55
|
+
sum.assign(sum.add(texel.mul(weights.element(int(i + HALF_KERNEL)))));
|
|
56
|
+
}
|
|
57
|
+
textureStore(outputNode, uvec2(x, y), sum).toWriteOnly();
|
|
58
|
+
});
|
|
59
|
+
})().compute(width * height, [256]);
|
|
60
|
+
function updateRadius(pixelRadius) {
|
|
61
|
+
if (Math.abs(pixelRadius - lastRadius) < .01) return;
|
|
62
|
+
lastRadius = pixelRadius;
|
|
63
|
+
const sigma = Math.max(pixelRadius * .5, .001);
|
|
64
|
+
const newWeights = new Array(KERNEL_SIZE);
|
|
65
|
+
let total = 0;
|
|
66
|
+
for (let i = -HALF_KERNEL; i <= HALF_KERNEL; i++) {
|
|
67
|
+
const w$1 = Math.exp(-(i * i) / (2 * sigma * sigma));
|
|
68
|
+
newWeights[i + HALF_KERNEL] = w$1;
|
|
69
|
+
total += w$1;
|
|
70
|
+
}
|
|
71
|
+
for (let i = 0; i < KERNEL_SIZE; i++) newWeights[i] /= total;
|
|
72
|
+
weights.array = newWeights;
|
|
73
|
+
}
|
|
74
|
+
updateRadius(4);
|
|
75
|
+
return {
|
|
76
|
+
computeNodes: [horizontalPass, verticalPass],
|
|
77
|
+
outputTexture: outputTex,
|
|
78
|
+
updateRadius
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
function createVariableGaussianBlurCompute(inputTexture, width, height, onCleanup) {
|
|
82
|
+
const blurMapTex = new StorageTexture(width, height);
|
|
83
|
+
blurMapTex.type = FloatType;
|
|
84
|
+
const blurMapWriteNode = storageTexture(blurMapTex);
|
|
85
|
+
const blurMapReadNode = storageTexture(blurMapTex).toReadOnly();
|
|
86
|
+
const intermediateTex = new StorageTexture(width, height);
|
|
87
|
+
intermediateTex.type = FloatType;
|
|
88
|
+
const outputTex = new StorageTexture(width, height);
|
|
89
|
+
outputTex.type = FloatType;
|
|
90
|
+
onCleanup(() => {
|
|
91
|
+
blurMapTex.dispose();
|
|
92
|
+
intermediateTex.dispose();
|
|
93
|
+
outputTex.dispose();
|
|
94
|
+
});
|
|
95
|
+
const intermediateWriteNode = storageTexture(intermediateTex);
|
|
96
|
+
const intermediateReadNode = storageTexture(intermediateTex).toReadOnly();
|
|
97
|
+
const outputNode = storageTexture(outputTex);
|
|
98
|
+
const weights = uniformArray(FIXED_WEIGHTS, "float");
|
|
99
|
+
const w = uint(width);
|
|
100
|
+
const h = uint(height);
|
|
101
|
+
const wm1 = int(width - 1);
|
|
102
|
+
const hm1 = int(height - 1);
|
|
103
|
+
const invHalf = float(1 / HALF_KERNEL);
|
|
104
|
+
return {
|
|
105
|
+
computeNodes: [Fn(() => {
|
|
106
|
+
const idx = instanceIndex;
|
|
107
|
+
const x = idx.mod(w);
|
|
108
|
+
const y = idx.div(w);
|
|
109
|
+
If(y.lessThan(h), () => {
|
|
110
|
+
const blurRadius = textureLoad(blurMapReadNode, uvec2(x, y), int(0)).r;
|
|
111
|
+
const sum = vec4(0).toVar();
|
|
112
|
+
const xi = x.toInt();
|
|
113
|
+
for (let i = -HALF_KERNEL; i <= HALF_KERNEL; i++) {
|
|
114
|
+
const offset = float(i).mul(invHalf).mul(blurRadius);
|
|
115
|
+
const texel = textureLoad(inputTexture, uvec2(xi.add(offset.round().toInt()).clamp(int(0), wm1).toUint(), y), int(0));
|
|
116
|
+
sum.assign(sum.add(texel.mul(weights.element(int(i + HALF_KERNEL)))));
|
|
117
|
+
}
|
|
118
|
+
textureStore(intermediateWriteNode, uvec2(x, y), sum).toWriteOnly();
|
|
119
|
+
});
|
|
120
|
+
})().compute(width * height, [256]), Fn(() => {
|
|
121
|
+
const idx = instanceIndex;
|
|
122
|
+
const x = idx.mod(w);
|
|
123
|
+
const y = idx.div(w);
|
|
124
|
+
If(y.lessThan(h), () => {
|
|
125
|
+
const blurRadius = textureLoad(blurMapReadNode, uvec2(x, y), int(0)).r;
|
|
126
|
+
const sum = vec4(0).toVar();
|
|
127
|
+
const yi = y.toInt();
|
|
128
|
+
for (let i = -HALF_KERNEL; i <= HALF_KERNEL; i++) {
|
|
129
|
+
const offset = float(i).mul(invHalf).mul(blurRadius);
|
|
130
|
+
const texel = textureLoad(intermediateReadNode, uvec2(x, yi.add(offset.round().toInt()).clamp(int(0), hm1).toUint()), int(0));
|
|
131
|
+
sum.assign(sum.add(texel.mul(weights.element(int(i + HALF_KERNEL)))));
|
|
132
|
+
}
|
|
133
|
+
textureStore(outputNode, uvec2(x, y), sum).toWriteOnly();
|
|
134
|
+
});
|
|
135
|
+
})().compute(width * height, [256])],
|
|
136
|
+
outputTexture: outputTex,
|
|
137
|
+
blurMapTexture: blurMapTex,
|
|
138
|
+
blurMapWriteNode
|
|
139
|
+
};
|
|
140
|
+
}
|
|
141
|
+
export { createVariableGaussianBlurCompute as n, createGaussianBlurCompute as t };
|
|
@@ -61,5 +61,5 @@ export interface GlassEffectUniforms {
|
|
|
61
61
|
uniform: any;
|
|
62
62
|
};
|
|
63
63
|
}
|
|
64
|
-
export declare function applyGlassEffect(childTexture: any, sdfSampler: (uv: any) => any, uniforms: GlassEffectUniforms & UniformsMap): Node;
|
|
64
|
+
export declare function applyGlassEffect(childTexture: any, sdfSampler: (uv: any) => any, uniforms: GlassEffectUniforms & UniformsMap, onBeforeRender?: (callback: () => void) => void, blurredTexture?: any): Node;
|
|
65
65
|
//# sourceMappingURL=glass.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"glass.d.ts","sourceRoot":"","sources":["../../src/effects/glass.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAC,IAAI,EAAC,MAAM,cAAc,CAAA;AACtC,OAAO,KAAK,EAAC,WAAW,EAAC,MAAM,UAAU,CAAA;AAMzC,eAAO,MAAM,SAAS,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,EAAO,CAAA;AAO/C,MAAM,WAAW,mBAAmB;IAChC,MAAM,EAAE;QAAE,OAAO,EAAE,GAAG,CAAA;KAAE,CAAA;IACxB,KAAK,EAAE;QAAE,OAAO,EAAE,GAAG,CAAA;KAAE,CAAA;IACvB,YAAY,EAAE;QAAE,OAAO,EAAE,GAAG,CAAA;KAAE,CAAA;IAC9B,UAAU,EAAE;QAAE,OAAO,EAAE,GAAG,CAAA;KAAE,CAAA;IAC5B,SAAS,EAAE;QAAE,OAAO,EAAE,GAAG,CAAA;KAAE,CAAA;IAC3B,UAAU,EAAE;QAAE,OAAO,EAAE,GAAG,CAAA;KAAE,CAAA;IAC5B,IAAI,EAAE;QAAE,OAAO,EAAE,GAAG,CAAA;KAAE,CAAA;IACtB,SAAS,EAAE;QAAE,OAAO,EAAE,GAAG,CAAA;KAAE,CAAA;IAC3B,aAAa,EAAE;QAAE,OAAO,EAAE,GAAG,CAAA;KAAE,CAAA;IAC/B,sBAAsB,EAAE;QAAE,OAAO,EAAE,GAAG,CAAA;KAAE,CAAA;IACxC,UAAU,EAAE;QAAE,OAAO,EAAE,GAAG,CAAA;KAAE,CAAA;IAC5B,SAAS,EAAE;QAAE,OAAO,EAAE,GAAG,CAAA;KAAE,CAAA;IAC3B,cAAc,EAAE;QAAE,OAAO,EAAE,GAAG,CAAA;KAAE,CAAA;IAChC,iBAAiB,EAAE;QAAE,OAAO,EAAE,GAAG,CAAA;KAAE,CAAA;IACnC,OAAO,EAAE;QAAE,OAAO,EAAE,GAAG,CAAA;KAAE,CAAA;IACzB,YAAY,EAAE;QAAE,OAAO,EAAE,GAAG,CAAA;KAAE,CAAA;IAC9B,eAAe,EAAE;QAAE,OAAO,EAAE,GAAG,CAAA;KAAE,CAAA;IACjC,MAAM,EAAE;QAAE,OAAO,EAAE,GAAG,CAAA;KAAE,CAAA;IACxB,SAAS,EAAE;QAAE,OAAO,EAAE,GAAG,CAAA;KAAE,CAAA;CAC9B;AAgBD,wBAAgB,gBAAgB,CAC5B,YAAY,EAAE,GAAG,EACjB,UAAU,EAAE,CAAC,EAAE,EAAE,GAAG,KAAK,GAAG,EAC5B,QAAQ,EAAE,mBAAmB,GAAG,WAAW,
|
|
1
|
+
{"version":3,"file":"glass.d.ts","sourceRoot":"","sources":["../../src/effects/glass.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAC,IAAI,EAAC,MAAM,cAAc,CAAA;AACtC,OAAO,KAAK,EAAC,WAAW,EAAC,MAAM,UAAU,CAAA;AAMzC,eAAO,MAAM,SAAS,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,EAAO,CAAA;AAO/C,MAAM,WAAW,mBAAmB;IAChC,MAAM,EAAE;QAAE,OAAO,EAAE,GAAG,CAAA;KAAE,CAAA;IACxB,KAAK,EAAE;QAAE,OAAO,EAAE,GAAG,CAAA;KAAE,CAAA;IACvB,YAAY,EAAE;QAAE,OAAO,EAAE,GAAG,CAAA;KAAE,CAAA;IAC9B,UAAU,EAAE;QAAE,OAAO,EAAE,GAAG,CAAA;KAAE,CAAA;IAC5B,SAAS,EAAE;QAAE,OAAO,EAAE,GAAG,CAAA;KAAE,CAAA;IAC3B,UAAU,EAAE;QAAE,OAAO,EAAE,GAAG,CAAA;KAAE,CAAA;IAC5B,IAAI,EAAE;QAAE,OAAO,EAAE,GAAG,CAAA;KAAE,CAAA;IACtB,SAAS,EAAE;QAAE,OAAO,EAAE,GAAG,CAAA;KAAE,CAAA;IAC3B,aAAa,EAAE;QAAE,OAAO,EAAE,GAAG,CAAA;KAAE,CAAA;IAC/B,sBAAsB,EAAE;QAAE,OAAO,EAAE,GAAG,CAAA;KAAE,CAAA;IACxC,UAAU,EAAE;QAAE,OAAO,EAAE,GAAG,CAAA;KAAE,CAAA;IAC5B,SAAS,EAAE;QAAE,OAAO,EAAE,GAAG,CAAA;KAAE,CAAA;IAC3B,cAAc,EAAE;QAAE,OAAO,EAAE,GAAG,CAAA;KAAE,CAAA;IAChC,iBAAiB,EAAE;QAAE,OAAO,EAAE,GAAG,CAAA;KAAE,CAAA;IACnC,OAAO,EAAE;QAAE,OAAO,EAAE,GAAG,CAAA;KAAE,CAAA;IACzB,YAAY,EAAE;QAAE,OAAO,EAAE,GAAG,CAAA;KAAE,CAAA;IAC9B,eAAe,EAAE;QAAE,OAAO,EAAE,GAAG,CAAA;KAAE,CAAA;IACjC,MAAM,EAAE;QAAE,OAAO,EAAE,GAAG,CAAA;KAAE,CAAA;IACxB,SAAS,EAAE;QAAE,OAAO,EAAE,GAAG,CAAA;KAAE,CAAA;CAC9B;AAgBD,wBAAgB,gBAAgB,CAC5B,YAAY,EAAE,GAAG,EACjB,UAAU,EAAE,CAAC,EAAE,EAAE,GAAG,KAAK,GAAG,EAC5B,QAAQ,EAAE,mBAAmB,GAAG,WAAW,EAC3C,cAAc,CAAC,EAAE,CAAC,QAAQ,EAAE,MAAM,IAAI,KAAK,IAAI,EAC/C,cAAc,CAAC,EAAE,GAAG,GACrB,IAAI,CAqMN"}
|
package/dist/core/index.js
CHANGED
|
@@ -7,108 +7,109 @@ import "./colorMixing-BPpDnR5I.js";
|
|
|
7
7
|
import { t as createAnimatedTime } from "./time-DUqSFWvT.js";
|
|
8
8
|
import "./Aurora-BPHeGEZ_.js";
|
|
9
9
|
import "./Beam-CAnoOWgt.js";
|
|
10
|
-
import "./Blob-
|
|
11
|
-
import "./
|
|
12
|
-
import "./
|
|
13
|
-
import "./
|
|
14
|
-
import "./
|
|
15
|
-
import "./
|
|
16
|
-
import "./
|
|
17
|
-
import "./
|
|
18
|
-
import "./
|
|
19
|
-
import "./
|
|
20
|
-
import "./
|
|
21
|
-
import "./
|
|
22
|
-
import "./
|
|
23
|
-
import "./
|
|
24
|
-
import "./
|
|
25
|
-
import "./
|
|
26
|
-
import "./
|
|
27
|
-
import "./
|
|
28
|
-
import "./
|
|
29
|
-
import "./
|
|
30
|
-
import "./
|
|
31
|
-
import "./
|
|
32
|
-
import "./
|
|
33
|
-
import "./
|
|
34
|
-
import "./
|
|
35
|
-
import "./
|
|
36
|
-
import "./
|
|
37
|
-
import "./
|
|
38
|
-
import "./
|
|
39
|
-
import "./
|
|
40
|
-
import "./
|
|
41
|
-
import "./
|
|
42
|
-
import "./
|
|
43
|
-
import "./
|
|
44
|
-
import "./
|
|
45
|
-
import "./
|
|
46
|
-
import "./
|
|
47
|
-
import "./
|
|
48
|
-
import "./
|
|
49
|
-
import "./
|
|
50
|
-
import "./
|
|
51
|
-
import "./
|
|
52
|
-
import "./
|
|
53
|
-
import "./
|
|
54
|
-
import "./
|
|
55
|
-
import "./
|
|
56
|
-
import "./
|
|
57
|
-
import "./
|
|
58
|
-
import "./
|
|
59
|
-
import "./
|
|
60
|
-
import "./
|
|
61
|
-
import "./
|
|
62
|
-
import "./
|
|
63
|
-
import "./
|
|
64
|
-
import "./
|
|
65
|
-
import "./
|
|
66
|
-
import "./
|
|
67
|
-
import "./
|
|
68
|
-
import "./
|
|
69
|
-
import "./
|
|
70
|
-
import "./
|
|
71
|
-
import "./
|
|
72
|
-
import "./
|
|
73
|
-
import "./
|
|
74
|
-
import "./
|
|
75
|
-
import "./
|
|
76
|
-
import "./
|
|
77
|
-
import "./
|
|
78
|
-
import "./
|
|
79
|
-
import "./
|
|
80
|
-
import "./
|
|
81
|
-
import "./
|
|
82
|
-
import "./
|
|
83
|
-
import "./
|
|
84
|
-
import "./
|
|
85
|
-
import "./
|
|
86
|
-
import "./
|
|
87
|
-
import "./
|
|
88
|
-
import "./
|
|
89
|
-
import "./
|
|
90
|
-
import "./
|
|
91
|
-
import "./
|
|
92
|
-
import "./
|
|
93
|
-
import "./
|
|
94
|
-
import "./
|
|
95
|
-
import "./
|
|
96
|
-
import "./
|
|
97
|
-
import "./
|
|
98
|
-
import "./
|
|
99
|
-
import "./
|
|
100
|
-
import "./
|
|
101
|
-
import "./
|
|
102
|
-
import "./
|
|
103
|
-
import "./
|
|
104
|
-
import "./
|
|
105
|
-
import "./
|
|
106
|
-
import "./
|
|
107
|
-
import "./
|
|
108
|
-
import "./
|
|
109
|
-
import "./
|
|
110
|
-
import "./
|
|
111
|
-
import
|
|
10
|
+
import "./Blob-CuRSRXmA.js";
|
|
11
|
+
import "./computeBlur-B0KA4n89.js";
|
|
12
|
+
import "./Blur-CC8fo0C5.js";
|
|
13
|
+
import "./BrightnessContrast-CJTOpQCn.js";
|
|
14
|
+
import "./Bulge-Chpbxxzj.js";
|
|
15
|
+
import "./ChannelBlur-CN_Zyiur.js";
|
|
16
|
+
import "./Checkerboard-ucave4-a.js";
|
|
17
|
+
import "./ChromaFlow-BZXyVHtK.js";
|
|
18
|
+
import "./ChromaticAberration-DsMj-vBw.js";
|
|
19
|
+
import "./Circle-QgCuVo44.js";
|
|
20
|
+
import "./ConcentricSpin-Crfxti93.js";
|
|
21
|
+
import "./ConicGradient-CQAPYlQg.js";
|
|
22
|
+
import "./ContourLines-KTHC32hd.js";
|
|
23
|
+
import "./sdf-DyC2H_qS.js";
|
|
24
|
+
import "./Crescent-BkRt-XWy.js";
|
|
25
|
+
import "./Cross-kkY7feuC.js";
|
|
26
|
+
import "./CRTScreen-CTwXU-NX.js";
|
|
27
|
+
import "./Crystal-xVyUhVD-.js";
|
|
28
|
+
import "./CursorRipples-Cgm7N0Bp.js";
|
|
29
|
+
import "./CursorTrail-CCRbdwHJ.js";
|
|
30
|
+
import "./DiamondGradient-BC3ugP8a.js";
|
|
31
|
+
import "./DiffuseBlur-eyM1v3ad.js";
|
|
32
|
+
import "./Dither-CDfDotR6.js";
|
|
33
|
+
import "./DOMTexture-D-RkeyMs.js";
|
|
34
|
+
import "./DotGrid-T9YbgC3V.js";
|
|
35
|
+
import "./DropShadow-jMhnYPXZ.js";
|
|
36
|
+
import "./Duotone-Bl02WcA2.js";
|
|
37
|
+
import "./Ellipse-CXxGqTYI.js";
|
|
38
|
+
import "./Emboss-ClQV27Mt.js";
|
|
39
|
+
import "./FallingLines-CArEXajJ.js";
|
|
40
|
+
import "./FilmGrain-Ph73aoC_.js";
|
|
41
|
+
import "./FloatingParticles-BtwGRl_d.js";
|
|
42
|
+
import "./Flower-MAwlZEv8.js";
|
|
43
|
+
import "./FlowField-RyqiRxyI.js";
|
|
44
|
+
import "./FlowingGradient-C0Zoyfd6.js";
|
|
45
|
+
import "./Form3D-rKpxb9t3.js";
|
|
46
|
+
import "./Glass-gQCmJlsQ.js";
|
|
47
|
+
import "./GlassTiles-k1C4a4u8.js";
|
|
48
|
+
import "./Glitch-DzPMkBu4.js";
|
|
49
|
+
import "./Glow-DvN-WnB4.js";
|
|
50
|
+
import "./Godrays-DAYmq-BP.js";
|
|
51
|
+
import "./Grayscale-lYKBBkGY.js";
|
|
52
|
+
import "./Grid-BJ-nxN3i.js";
|
|
53
|
+
import "./GridDistortion-DtaRNrTZ.js";
|
|
54
|
+
import "./Group-DpozigtX.js";
|
|
55
|
+
import "./Halftone-BVL2oy37.js";
|
|
56
|
+
import "./HexGrid-D-EmQ4kI.js";
|
|
57
|
+
import "./HueShift-D9K0ynaS.js";
|
|
58
|
+
import "./ImageTexture-CArkZMfh.js";
|
|
59
|
+
import "./Invert-DCnwo_Xq.js";
|
|
60
|
+
import "./Kaleidoscope-BytHro3k.js";
|
|
61
|
+
import "./LensFlare-B0vv4x97.js";
|
|
62
|
+
import "./LinearBlur-BFewxPjV.js";
|
|
63
|
+
import "./LinearGradient-BKUf_u7r.js";
|
|
64
|
+
import "./Liquify-cE5dxrfh.js";
|
|
65
|
+
import "./Mirror-DIle92J8.js";
|
|
66
|
+
import "./MultiPointGradient-DDwac_mm.js";
|
|
67
|
+
import "./Neon-Dg8UfC7P.js";
|
|
68
|
+
import "./Paper-bMSMCeYK.js";
|
|
69
|
+
import "./Perspective-BmfvQV6W.js";
|
|
70
|
+
import "./Pixelate-Dl26r6IT.js";
|
|
71
|
+
import "./Plasma-CJWS1TvX.js";
|
|
72
|
+
import "./PolarCoordinates-lq6K4WBm.js";
|
|
73
|
+
import "./Polygon-DRCs3CYs.js";
|
|
74
|
+
import "./Posterize-BjH7Zscm.js";
|
|
75
|
+
import "./ProgressiveBlur-Dm530r0z.js";
|
|
76
|
+
import "./RadialGradient-DiGFPgrn.js";
|
|
77
|
+
import "./RectangularCoordinates-COkNDxi0.js";
|
|
78
|
+
import "./Ring-QApyKPzE.js";
|
|
79
|
+
import "./Ripples-C8Q17Hvz.js";
|
|
80
|
+
import "./RoundedRect-Ca9af9xe.js";
|
|
81
|
+
import "./Saturation-CgDaiq6n.js";
|
|
82
|
+
import "./Sharpness-CRXT0D30.js";
|
|
83
|
+
import "./Shatter-BssZTRYJ.js";
|
|
84
|
+
import "./SimplexNoise-KfTCAfpL.js";
|
|
85
|
+
import "./SineWave-Ckeap_YM.js";
|
|
86
|
+
import "./Solarize-DhtQYYpW.js";
|
|
87
|
+
import "./SolidColor-6yUkGybH.js";
|
|
88
|
+
import "./Spherize-8LXrGGG_.js";
|
|
89
|
+
import "./Spiral-Bs7uZrBr.js";
|
|
90
|
+
import "./Star-DiXwnPGP.js";
|
|
91
|
+
import "./Strands-DsAAVemq.js";
|
|
92
|
+
import "./Stretch-D7P2R5lV.js";
|
|
93
|
+
import "./Stripes-DF8agIiJ.js";
|
|
94
|
+
import "./StudioBackground-BFeNfwEu.js";
|
|
95
|
+
import "./Swirl-BwezrSAA.js";
|
|
96
|
+
import "./TiltShift-BqKaU3TM.js";
|
|
97
|
+
import "./Tint-BdXlqlzz.js";
|
|
98
|
+
import "./Trapezoid-BX_hmeZJ.js";
|
|
99
|
+
import "./Tritone-BlJ7cchN.js";
|
|
100
|
+
import "./Truchet-Bnn0fwbF.js";
|
|
101
|
+
import "./Twirl-C5ijhqz1.js";
|
|
102
|
+
import "./Vesica-DU0f85NG.js";
|
|
103
|
+
import "./Vibrance-dqIV6GBe.js";
|
|
104
|
+
import "./browser-ClWxLlIB.js";
|
|
105
|
+
import "./VideoTexture-DJrkry82.js";
|
|
106
|
+
import "./Vignette-DB1wO1dm.js";
|
|
107
|
+
import "./Voronoi-C3WIJFWc.js";
|
|
108
|
+
import "./WaveDistortion-BKma8-Ju.js";
|
|
109
|
+
import "./Weave-xuu_vQ5e.js";
|
|
110
|
+
import "./WebcamTexture-Cf8J7JB1.js";
|
|
111
|
+
import "./ZoomBlur-UcS2iFT2.js";
|
|
112
|
+
import { t as getAllShaders } from "./shaderRegistry-DriE1ikS.js";
|
|
112
113
|
import { Material, Mesh, MeshBasicNodeMaterial, OrthographicCamera, PlaneGeometry, SRGBColorSpace, Scene, Vector2, WebGPURenderer } from "three/webgpu";
|
|
113
114
|
import { WebGLRenderer } from "three";
|
|
114
115
|
import { PI, abs, add, atan, clamp, convertToTexture, cos, div, dot, float, fract, max, min, mix, mul, pow, screenUV, sign, sin, smoothstep, sqrt, step, sub, time, uniform, uv, vec2, vec3, vec4 } from "three/tsl";
|
|
@@ -809,6 +810,15 @@ function shaderRenderer() {
|
|
|
809
810
|
}
|
|
810
811
|
});
|
|
811
812
|
});
|
|
813
|
+
let hasComputeNodes = false;
|
|
814
|
+
for (const ni of nodeRegistry.nodes.values()) if (ni.computeGetNodes) {
|
|
815
|
+
hasComputeNodes = true;
|
|
816
|
+
break;
|
|
817
|
+
}
|
|
818
|
+
if (hasComputeNodes && materialUpdateBatchRAF === null) materialUpdateBatchRAF = requestAnimationFrame(() => {
|
|
819
|
+
materialUpdateBatchRAF = null;
|
|
820
|
+
updateMaterial();
|
|
821
|
+
});
|
|
812
822
|
lastRenderTime = 0;
|
|
813
823
|
renderFrame();
|
|
814
824
|
});
|
|
@@ -1089,6 +1099,20 @@ function shaderRenderer() {
|
|
|
1089
1099
|
const transformedUV = applyUVTransform(screenUV, nodeInfo.transformUniforms.offsetX, nodeInfo.transformUniforms.offsetY, nodeInfo.transformUniforms.rotation, nodeInfo.transformUniforms.scale, nodeInfo.transformUniforms.anchorX, nodeInfo.transformUniforms.anchorY, nodeInfo.transformUniforms.aspectRatio);
|
|
1090
1100
|
return applyEdgeHandling(transformedUV, texture$1.sample(transformedUV), texture$1, nodeInfo.transformUniforms.edges.value);
|
|
1091
1101
|
};
|
|
1102
|
+
const initNodeCompute = (nodeInfo, params) => {
|
|
1103
|
+
nodeInfo.computeOutputs = void 0;
|
|
1104
|
+
nodeInfo.computeGetNodes = void 0;
|
|
1105
|
+
if (nodeInfo.computeNodeFunc && renderer.backend?.isWebGPUBackend === true) try {
|
|
1106
|
+
const result = nodeInfo.computeNodeFunc(params);
|
|
1107
|
+
if (result) {
|
|
1108
|
+
nodeInfo.computeOutputs = result.outputs;
|
|
1109
|
+
nodeInfo.computeGetNodes = result.getComputeNodes;
|
|
1110
|
+
return result.outputs;
|
|
1111
|
+
}
|
|
1112
|
+
} catch (e) {
|
|
1113
|
+
console.error(`Error initializing compute for node ${nodeInfo.id}:`, e);
|
|
1114
|
+
}
|
|
1115
|
+
};
|
|
1092
1116
|
const composeNodeTree = (nodeId, processedMasks = /* @__PURE__ */ new Set(), currentlyComposedNodes) => {
|
|
1093
1117
|
if (currentWidth === 0 || currentHeight === 0) return vec4(0, 0, 0, 0);
|
|
1094
1118
|
const nodeInfo = nodeRegistry.nodes.get(nodeId);
|
|
@@ -1118,9 +1142,8 @@ function shaderRenderer() {
|
|
|
1118
1142
|
nodeInfo.beforeRenderCallbacks = [];
|
|
1119
1143
|
nodeInfo.afterRenderCallbacks = [];
|
|
1120
1144
|
nodeInfo.resizeCallbacks = [];
|
|
1121
|
-
const
|
|
1122
|
-
|
|
1123
|
-
uniforms: effectiveUniforms0,
|
|
1145
|
+
const baseParams0 = {
|
|
1146
|
+
uniforms: buildEffectiveUniforms(nodeInfo.uniforms ?? {}, nodeInfo.metadata.maps, nodeId, processedMasks),
|
|
1124
1147
|
childNode: void 0,
|
|
1125
1148
|
onCleanup: nodeSpecificOnCleanup,
|
|
1126
1149
|
onBeforeRender: nodeSpecificOnBeforeRender,
|
|
@@ -1133,7 +1156,9 @@ function shaderRenderer() {
|
|
|
1133
1156
|
},
|
|
1134
1157
|
renderer,
|
|
1135
1158
|
domCanvas: nodeInfo.domCanvas
|
|
1136
|
-
}
|
|
1159
|
+
};
|
|
1160
|
+
baseParams0.computeOutputs = initNodeCompute(nodeInfo, baseParams0);
|
|
1161
|
+
return applyMaskIfNeeded(applyNodeTransformation(nodeInfo.fragmentNodeFunc(baseParams0), nodeInfo), nodeInfo, nodeId, processedMasks);
|
|
1137
1162
|
} else {
|
|
1138
1163
|
const sortedChildren = [...childNodes].sort((a, b) => a.metadata.renderOrder - b.metadata.renderOrder);
|
|
1139
1164
|
if (nodeInfo.parentId === null) {
|
|
@@ -1179,9 +1204,8 @@ function shaderRenderer() {
|
|
|
1179
1204
|
childInfo.beforeRenderCallbacks = [];
|
|
1180
1205
|
childInfo.afterRenderCallbacks = [];
|
|
1181
1206
|
childInfo.resizeCallbacks = [];
|
|
1182
|
-
const
|
|
1183
|
-
|
|
1184
|
-
uniforms: effectiveUniforms1,
|
|
1207
|
+
const baseParams1 = {
|
|
1208
|
+
uniforms: buildEffectiveUniforms(childInfo.uniforms ?? {}, childInfo.metadata.maps, childInfo.id, processedMasks),
|
|
1185
1209
|
childNode: effectiveChildNode,
|
|
1186
1210
|
onCleanup: childSpecificOnCleanup,
|
|
1187
1211
|
onBeforeRender: childSpecificOnBeforeRender,
|
|
@@ -1194,7 +1218,9 @@ function shaderRenderer() {
|
|
|
1194
1218
|
},
|
|
1195
1219
|
renderer,
|
|
1196
1220
|
domCanvas: childInfo.domCanvas
|
|
1197
|
-
}
|
|
1221
|
+
};
|
|
1222
|
+
baseParams1.computeOutputs = initNodeCompute(childInfo, baseParams1);
|
|
1223
|
+
childResult = applyMaskIfNeeded(applyNodeTransformation(childInfo.fragmentNodeFunc(baseParams1), childInfo), childInfo, childInfo.id, processedMasks);
|
|
1198
1224
|
}
|
|
1199
1225
|
if (childInfo.requiresChild && childInfo.metadata.blendMode === "normal" && !childHasChildren) composedChildren = mix(composedChildren || vec4(0, 0, 0, 0), childResult, childInfo.opacityUniform);
|
|
1200
1226
|
else if (composedChildren === void 0) if (nodeInfo.requiresRTT || effectiveOpacity !== 1) composedChildren = applyBlendMode(vec4(1, 1, 1, 0), childResult, childInfo.metadata.blendMode, childInfo.opacityUniform);
|
|
@@ -1212,9 +1238,8 @@ function shaderRenderer() {
|
|
|
1212
1238
|
nodeInfo.beforeRenderCallbacks = [];
|
|
1213
1239
|
nodeInfo.afterRenderCallbacks = [];
|
|
1214
1240
|
nodeInfo.resizeCallbacks = [];
|
|
1215
|
-
const
|
|
1216
|
-
|
|
1217
|
-
uniforms: effectiveUniforms2,
|
|
1241
|
+
const baseParams2 = {
|
|
1242
|
+
uniforms: buildEffectiveUniforms(nodeInfo.uniforms ?? {}, nodeInfo.metadata.maps, nodeId, processedMasks),
|
|
1218
1243
|
childNode: composedChildren,
|
|
1219
1244
|
onCleanup: nodeSpecificOnCleanup,
|
|
1220
1245
|
onBeforeRender: nodeSpecificOnBeforeRender,
|
|
@@ -1227,7 +1252,9 @@ function shaderRenderer() {
|
|
|
1227
1252
|
},
|
|
1228
1253
|
renderer,
|
|
1229
1254
|
domCanvas: nodeInfo.domCanvas
|
|
1230
|
-
}
|
|
1255
|
+
};
|
|
1256
|
+
baseParams2.computeOutputs = initNodeCompute(nodeInfo, baseParams2);
|
|
1257
|
+
return applyMaskIfNeeded(applyNodeTransformation(nodeInfo.fragmentNodeFunc(baseParams2), nodeInfo), nodeInfo, nodeId, processedMasks);
|
|
1231
1258
|
} else {
|
|
1232
1259
|
let composedChildrenResult = void 0;
|
|
1233
1260
|
for (let i = 0; i < sortedChildren.length; i++) {
|
|
@@ -1264,9 +1291,8 @@ function shaderRenderer() {
|
|
|
1264
1291
|
childInfo.beforeRenderCallbacks = [];
|
|
1265
1292
|
childInfo.afterRenderCallbacks = [];
|
|
1266
1293
|
childInfo.resizeCallbacks = [];
|
|
1267
|
-
const
|
|
1268
|
-
|
|
1269
|
-
uniforms: effectiveUniforms3,
|
|
1294
|
+
const baseParams3 = {
|
|
1295
|
+
uniforms: buildEffectiveUniforms(childInfo.uniforms ?? {}, childInfo.metadata.maps, childInfo.id, processedMasks),
|
|
1270
1296
|
childNode: effectiveChildNode,
|
|
1271
1297
|
onCleanup: childSpecificOnCleanup,
|
|
1272
1298
|
onBeforeRender: childSpecificOnBeforeRender,
|
|
@@ -1279,7 +1305,9 @@ function shaderRenderer() {
|
|
|
1279
1305
|
},
|
|
1280
1306
|
renderer,
|
|
1281
1307
|
domCanvas: childInfo.domCanvas
|
|
1282
|
-
}
|
|
1308
|
+
};
|
|
1309
|
+
baseParams3.computeOutputs = initNodeCompute(childInfo, baseParams3);
|
|
1310
|
+
childResult = applyMaskIfNeeded(applyNodeTransformation(childInfo.fragmentNodeFunc(baseParams3), childInfo), childInfo, childInfo.id, processedMasks);
|
|
1283
1311
|
}
|
|
1284
1312
|
if (childInfo.requiresChild && childInfo.metadata.blendMode === "normal" && !childHasChildren) composedChildrenResult = mix(composedChildrenResult || vec4(0, 0, 0, 0), childResult, childInfo.opacityUniform);
|
|
1285
1313
|
else if (composedChildrenResult === void 0) if (nodeInfo.requiresRTT || effectiveOpacity !== 1) composedChildrenResult = applyBlendMode(vec4(1, 1, 1, 0), childResult, childInfo.metadata.blendMode, childInfo.opacityUniform);
|
|
@@ -1297,9 +1325,8 @@ function shaderRenderer() {
|
|
|
1297
1325
|
nodeInfo.beforeRenderCallbacks = [];
|
|
1298
1326
|
nodeInfo.afterRenderCallbacks = [];
|
|
1299
1327
|
nodeInfo.resizeCallbacks = [];
|
|
1300
|
-
const
|
|
1301
|
-
|
|
1302
|
-
uniforms: effectiveUniforms4,
|
|
1328
|
+
const baseParams4 = {
|
|
1329
|
+
uniforms: buildEffectiveUniforms(nodeInfo.uniforms ?? {}, nodeInfo.metadata.maps, nodeId, processedMasks),
|
|
1303
1330
|
childNode: composedChildrenResult,
|
|
1304
1331
|
onCleanup: nodeSpecificOnCleanup,
|
|
1305
1332
|
onBeforeRender: nodeSpecificOnBeforeRender,
|
|
@@ -1312,7 +1339,9 @@ function shaderRenderer() {
|
|
|
1312
1339
|
},
|
|
1313
1340
|
renderer,
|
|
1314
1341
|
domCanvas: nodeInfo.domCanvas
|
|
1315
|
-
}
|
|
1342
|
+
};
|
|
1343
|
+
baseParams4.computeOutputs = initNodeCompute(nodeInfo, baseParams4);
|
|
1344
|
+
return applyMaskIfNeeded(applyNodeTransformation(nodeInfo.fragmentNodeFunc(baseParams4), nodeInfo), nodeInfo, nodeId, processedMasks);
|
|
1316
1345
|
}
|
|
1317
1346
|
}
|
|
1318
1347
|
};
|
|
@@ -1402,6 +1431,7 @@ function shaderRenderer() {
|
|
|
1402
1431
|
transformUniforms,
|
|
1403
1432
|
transformRTTActive: false,
|
|
1404
1433
|
mapSampleUVsFunc: componentDefinition?.mapSampleUVs,
|
|
1434
|
+
computeNodeFunc: componentDefinition?.computeNode,
|
|
1405
1435
|
domCanvas
|
|
1406
1436
|
};
|
|
1407
1437
|
nodeRegistry.nodes.set(id, nodeInfo);
|
|
@@ -1735,6 +1765,26 @@ function shaderRenderer() {
|
|
|
1735
1765
|
}
|
|
1736
1766
|
}
|
|
1737
1767
|
};
|
|
1768
|
+
const executeComputeDispatches = (deltaTime) => {
|
|
1769
|
+
const params = {
|
|
1770
|
+
deltaTime,
|
|
1771
|
+
pointer: {
|
|
1772
|
+
x: pointerX,
|
|
1773
|
+
y: pointerY
|
|
1774
|
+
},
|
|
1775
|
+
pointerActive,
|
|
1776
|
+
dimensions: {
|
|
1777
|
+
width: currentWidth,
|
|
1778
|
+
height: currentHeight
|
|
1779
|
+
}
|
|
1780
|
+
};
|
|
1781
|
+
for (const nodeInfo of nodeRegistry.nodes.values()) if (nodeInfo.computeGetNodes) try {
|
|
1782
|
+
const nodes = nodeInfo.computeGetNodes(params);
|
|
1783
|
+
if (nodes) for (const node of nodes) renderer.compute(node);
|
|
1784
|
+
} catch (e) {
|
|
1785
|
+
console.error(`Error dispatching compute for node ${nodeInfo.id}:`, e);
|
|
1786
|
+
}
|
|
1787
|
+
};
|
|
1738
1788
|
const executeBeforeRenderCallbacks = (deltaTime) => {
|
|
1739
1789
|
const params = {
|
|
1740
1790
|
deltaTime,
|
|
@@ -1804,6 +1854,7 @@ function shaderRenderer() {
|
|
|
1804
1854
|
lastRenderTime = currentTime;
|
|
1805
1855
|
if (enablePerformanceTracking) performance.mark("shader-cpu-start");
|
|
1806
1856
|
updateMouseDrivers(cappedDeltaTime);
|
|
1857
|
+
executeComputeDispatches(cappedDeltaTime);
|
|
1807
1858
|
executeBeforeRenderCallbacks(cappedDeltaTime);
|
|
1808
1859
|
try {
|
|
1809
1860
|
if (isUpdatingMaterial) return;
|