shaders 2.2.23 → 2.2.25
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/core/AngularBlur-Dl2gwk68.js +64 -0
- package/dist/core/Ascii-Dha_QpT3.js +286 -0
- package/dist/core/Beam-CTN9Ni43.js +139 -0
- package/dist/core/Blob-CxFDZovO.js +218 -0
- package/dist/core/Blur-Y2FsmFk_.js +77 -0
- package/dist/core/Bulge-Cb-t0xqI.js +132 -0
- package/dist/core/CRTScreen-CtERsenz.js +112 -0
- package/dist/core/ChannelBlur-CvM6GJgZ.js +118 -0
- package/dist/core/Checkerboard-CgB-egNY.js +83 -0
- package/dist/core/ChromaFlow-vRCwhQpN.js +222 -0
- package/dist/core/ChromaticAberration-FTquTQIL.js +88 -0
- package/dist/core/Circle-Daziv5d7.js +67 -0
- package/dist/core/CursorTrail-Bsz9e6Fn.js +145 -0
- package/dist/core/DiffuseBlur-Cj2PtRNd.js +83 -0
- package/dist/core/Dither-D2Nf4p3w.js +66 -0
- package/dist/core/DotGrid-CzOwquo4.js +75 -0
- package/dist/core/Duotone-XuTN9tI7.js +65 -0
- package/dist/core/FilmGrain-D3-nbi12.js +28 -0
- package/dist/core/FloatingParticles-D9Nnu1qg.js +217 -0
- package/dist/core/GlassTiles-CnjCvajI.js +69 -0
- package/dist/core/Glow-BluFc9be.js +75 -0
- package/dist/core/Godrays-ChLh_vGl.js +144 -0
- package/dist/core/Grayscale-DRny75A9.js +20 -0
- package/dist/core/Grid-DgyDa4H1.js +58 -0
- package/dist/core/GridDistortion-BAspCYvp.js +188 -0
- package/dist/core/Group-Dul7PUBl.js +14 -0
- package/dist/core/Halftone-Ifv5F_FT.js +65 -0
- package/dist/core/HueShift-De8ukMWs.js +31 -0
- package/dist/core/ImageTexture-DvYcQgJB.js +143 -0
- package/dist/core/Invert-Fz0NtIJc.js +21 -0
- package/dist/core/LinearBlur-LmhnQoA4.js +62 -0
- package/dist/core/LinearGradient-xbloQjzt.js +133 -0
- package/dist/core/Liquify-DMe1V5-O.js +175 -0
- package/dist/core/Pixelate-Cv8537Pj.js +37 -0
- package/dist/core/PolarCoordinates-DDvDhBE-.js +112 -0
- package/dist/core/Posterize-3m3xkWOz.js +29 -0
- package/dist/core/ProgressiveBlur-EGkevObV.js +121 -0
- package/dist/core/RadialGradient-B7ZZB_VJ.js +71 -0
- package/dist/core/RectangularCoordinates-muWR8mZS.js +101 -0
- package/dist/core/Ripples-8XaZaXQF.js +117 -0
- package/dist/core/Saturation-CYFI1jzN.js +30 -0
- package/dist/core/SimplexNoise-DJUe0wz_.js +99 -0
- package/dist/core/SineWave-Dl3nFO1W.js +120 -0
- package/dist/core/SolidColor-CWGq_Bjq.js +21 -0
- package/dist/core/Spherize-C-jZEUsN.js +128 -0
- package/dist/core/Spiral-BSB_R39p.js +132 -0
- package/dist/core/Strands-0stO5BMy.js +161 -0
- package/dist/core/Stretch-B645paha.js +133 -0
- package/dist/core/Swirl-CVnbawit.js +173 -0
- package/dist/core/TiltShift-0CxNRI6L.js +134 -0
- package/dist/core/Tritone-Daa-I5UD.js +76 -0
- package/dist/core/Twirl-2CJVZEtk.js +96 -0
- package/dist/core/Vibrance-DRtecEvb.js +30 -0
- package/dist/core/WaveDistortion-BscXN2rs.js +173 -0
- package/dist/core/ZoomBlur-CAqK0Kju.js +62 -0
- package/dist/core/colorMixing-BXiTAqJU.js +69 -0
- package/dist/core/edges-Bn_OIa_h.js +26 -0
- package/dist/core/index.js +2257 -1604
- package/dist/core/shaderRegistry.d.ts.map +1 -1
- package/dist/core/shaders/AngularBlur/index.js +3 -7
- package/dist/core/shaders/Ascii/index.js +2 -6
- package/dist/core/shaders/Beam/index.d.ts +71 -0
- package/dist/core/shaders/Beam/index.d.ts.map +1 -0
- package/dist/core/shaders/Beam/index.js +4 -0
- package/dist/core/shaders/Blob/index.js +5 -9
- package/dist/core/shaders/Blur/index.js +2 -6
- package/dist/core/shaders/Bulge/index.js +4 -8
- package/dist/core/shaders/CRTScreen/index.js +2 -6
- package/dist/core/shaders/ChannelBlur/index.js +2 -6
- package/dist/core/shaders/Checkerboard/index.js +4 -8
- package/dist/core/shaders/ChromaFlow/index.js +3 -7
- package/dist/core/shaders/ChromaticAberration/index.js +3 -7
- package/dist/core/shaders/Circle/index.js +3 -7
- package/dist/core/shaders/CursorTrail/index.js +4 -8
- package/dist/core/shaders/DiffuseBlur/index.js +4 -8
- package/dist/core/shaders/Dither/index.js +3 -7
- package/dist/core/shaders/DotGrid/index.js +3 -7
- package/dist/core/shaders/Duotone/index.js +4 -8
- package/dist/core/shaders/FilmGrain/index.js +2 -6
- package/dist/core/shaders/FloatingParticles/index.js +3 -7
- package/dist/core/shaders/GlassTiles/index.js +2 -6
- package/dist/core/shaders/Glow/index.js +2 -6
- package/dist/core/shaders/Godrays/index.js +3 -7
- package/dist/core/shaders/Grayscale/index.js +2 -8
- package/dist/core/shaders/Grid/index.js +3 -7
- package/dist/core/shaders/GridDistortion/index.js +4 -8
- package/dist/core/shaders/Group/index.js +2 -6
- package/dist/core/shaders/Halftone/index.js +3 -7
- package/dist/core/shaders/HueShift/index.js +2 -8
- package/dist/core/shaders/ImageTexture/index.js +2 -6
- package/dist/core/shaders/Invert/index.js +2 -6
- package/dist/core/shaders/LinearBlur/index.js +3 -7
- package/dist/core/shaders/LinearGradient/index.js +4 -8
- package/dist/core/shaders/Liquify/index.js +4 -8
- package/dist/core/shaders/Pixelate/index.js +2 -6
- package/dist/core/shaders/PolarCoordinates/index.js +4 -8
- package/dist/core/shaders/Posterize/index.js +2 -7
- package/dist/core/shaders/ProgressiveBlur/index.js +3 -7
- package/dist/core/shaders/RadialGradient/index.js +4 -8
- package/dist/core/shaders/RectangularCoordinates/index.js +4 -8
- package/dist/core/shaders/Ripples/index.js +5 -9
- package/dist/core/shaders/Saturation/index.js +2 -8
- package/dist/core/shaders/SimplexNoise/index.js +5 -9
- package/dist/core/shaders/SineWave/index.js +3 -7
- package/dist/core/shaders/SolidColor/index.js +3 -7
- package/dist/core/shaders/Spherize/index.js +3 -7
- package/dist/core/shaders/Spiral/index.js +4 -8
- package/dist/core/shaders/Strands/index.js +4 -8
- package/dist/core/shaders/Stretch/index.js +4 -8
- package/dist/core/shaders/Swirl/index.js +5 -9
- package/dist/core/shaders/TiltShift/index.js +3 -7
- package/dist/core/shaders/Tritone/index.js +4 -8
- package/dist/core/shaders/Twirl/index.js +4 -8
- package/dist/core/shaders/Vibrance/index.js +2 -8
- package/dist/core/shaders/WaveDistortion/index.js +4 -8
- package/dist/core/shaders/ZoomBlur/index.js +3 -7
- package/dist/core/telemetry/index.js +189 -157
- package/dist/core/time-CTJvRUZ4.js +10 -0
- package/dist/core/transformations-DxfQXZWi.js +4715 -0
- package/dist/react/components/Beam.d.ts +31 -0
- package/dist/react/components/Beam.d.ts.map +1 -0
- package/dist/react/generatePresetCode-CCibXbtZ.js +645 -0
- package/dist/react/index.d.ts +1 -0
- package/dist/react/index.d.ts.map +1 -1
- package/dist/react/index.js +7649 -104600
- package/dist/react/utils/generatePresetCode.d.ts.map +1 -1
- package/dist/react/utils/generatePresetCode.js +2 -5
- package/dist/registry.js +224 -0
- package/dist/solid/components/Beam.d.ts +28 -0
- package/dist/solid/components/Beam.d.ts.map +1 -0
- package/dist/solid/index.d.ts +1 -0
- package/dist/solid/index.d.ts.map +1 -1
- package/dist/solid/index.js +6691 -102524
- package/dist/solid/utils/generatePresetCode.d.ts.map +1 -1
- package/dist/solid/utils/generatePresetCode.js +586 -537
- package/dist/svelte/components/Beam.svelte.d.ts +19 -0
- package/dist/svelte/generatePresetCode-CymgoDq_.js +645 -0
- package/dist/svelte/index.d.ts +1 -0
- package/dist/svelte/index.js +6175 -102455
- package/dist/svelte/utils/generatePresetCode.js +2 -5
- package/dist/vue/components/Beam.vue.d.ts +57 -0
- package/dist/vue/components/Beam.vue.d.ts.map +1 -0
- package/dist/vue/generatePresetCode-CRJmU8iF.js +649 -0
- package/dist/vue/index.d.ts +1 -0
- package/dist/vue/index.d.ts.map +1 -1
- package/dist/vue/index.js +6929 -103492
- package/dist/vue/utils/generatePresetCode.d.ts.map +1 -1
- package/dist/vue/utils/generatePresetCode.js +2 -5
- package/package.json +12 -1
- package/dist/core/AngularBlur-ClvtyURQ.js +0 -56
- package/dist/core/Ascii-BT0-K_vw.js +0 -196
- package/dist/core/Blob-BlQ_1T_8.js +0 -169
- package/dist/core/Blur-421AjWLH.js +0 -64
- package/dist/core/Bulge-CZRVoR6C.js +0 -103
- package/dist/core/CRTScreen-C_U9g_IR.js +0 -91
- package/dist/core/ChannelBlur-5pzcB6Zv.js +0 -89
- package/dist/core/Checkerboard-CrQkqXhD.js +0 -75
- package/dist/core/ChromaFlow-CNrQdL8f.js +0 -134
- package/dist/core/ChromaticAberration-D9H7O17Y.js +0 -82
- package/dist/core/Circle-DnLaDn8V.js +0 -62
- package/dist/core/ColorAdjustment-CKwpE_4M.js +0 -14
- package/dist/core/CursorTrail-NY6n97VG.js +0 -105
- package/dist/core/DiffuseBlur-C_n01ABk.js +0 -69
- package/dist/core/Dither-4s-c4zh4.js +0 -61
- package/dist/core/DotGrid-BYl8XdMi.js +0 -61
- package/dist/core/Duotone-DbewOoB4.js +0 -66
- package/dist/core/FilmGrain-zA_-knOw.js +0 -28
- package/dist/core/FloatingParticles-BhVnqMsE.js +0 -160
- package/dist/core/GlassTiles-CFI57glh.js +0 -52
- package/dist/core/Glow-CQgl3IoS.js +0 -66
- package/dist/core/Godrays-BHMix_Bh.js +0 -105
- package/dist/core/Grayscale-CAEFLteL.js +0 -21
- package/dist/core/Grid-DlM-rVbZ.js +0 -50
- package/dist/core/GridDistortion-ZOZphSAT.js +0 -147
- package/dist/core/Group-BQAs3RiH.js +0 -17
- package/dist/core/Halftone-ci4ga-_J.js +0 -55
- package/dist/core/HueShift-CyxzPcJV.js +0 -32
- package/dist/core/ImageTexture-CdAGsPuH.js +0 -105
- package/dist/core/Invert-iPsiIqNZ.js +0 -20
- package/dist/core/LinearBlur-BEaaoIk-.js +0 -56
- package/dist/core/LinearGradient-DR_7RxLX.js +0 -111
- package/dist/core/Liquify-Bi02_ugh.js +0 -139
- package/dist/core/Pixelate-CSsdT1rr.js +0 -38
- package/dist/core/PolarCoordinates-D626ml58.js +0 -103
- package/dist/core/Posterize-DhZkMaC7.js +0 -46
- package/dist/core/ProgressiveBlur-CGtCfLF8.js +0 -102
- package/dist/core/RadialGradient-C0_WzmbH.js +0 -71
- package/dist/core/RectangularCoordinates-DfXw7fhI.js +0 -92
- package/dist/core/Ripples-DkemN3eh.js +0 -106
- package/dist/core/Saturation-Dup81Pnq.js +0 -31
- package/dist/core/SimplexNoise-BYEiCjDj.js +0 -94
- package/dist/core/SineWave-C6MRPtsy.js +0 -107
- package/dist/core/SolidColor-BZHRczgb.js +0 -22
- package/dist/core/Spherize-DOAnDx2l.js +0 -103
- package/dist/core/Spiral-BMjnWXh1.js +0 -115
- package/dist/core/Strands-BOVsuJLe.js +0 -125
- package/dist/core/Stretch-D6bHc6yp.js +0 -103
- package/dist/core/Swirl-BFoc0ImG.js +0 -148
- package/dist/core/TSLBase-BFMvTOak.js +0 -8053
- package/dist/core/TiltShift-BiNvvhzj.js +0 -114
- package/dist/core/Tritone-gdx2AA0m.js +0 -75
- package/dist/core/Twirl-BsV8YbqC.js +0 -82
- package/dist/core/Vibrance-C182fbSw.js +0 -31
- package/dist/core/WaveDistortion-CmaS2zDB.js +0 -132
- package/dist/core/ZoomBlur-DLf5xQ16.js +0 -56
- package/dist/core/colorMixing--dhzx0ch.js +0 -21
- package/dist/core/edges-CDzKsauJ.js +0 -15
- package/dist/core/three.tsl-Btj1hLsf.js +0 -43845
- package/dist/core/time-DbRMw6Jm.js +0 -10
- package/dist/core/transformations-CsrIJXh-.js +0 -3992
- package/dist/react/generatePresetCode-DaS7jkcT.js +0 -626
- package/dist/svelte/generatePresetCode-DaS7jkcT.js +0 -626
- package/dist/vue/generatePresetCode-Cd1B-Y9j.js +0 -632
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { r as transformColor } from "./transformations-DxfQXZWi.js";
|
|
2
|
+
import * as TSL from "three/tsl";
|
|
3
|
+
const componentDefinition = {
|
|
4
|
+
name: "Dither",
|
|
5
|
+
category: "Stylize",
|
|
6
|
+
description: "Bayer matrix dithering to reduce colors",
|
|
7
|
+
requiresChild: true,
|
|
8
|
+
props: {
|
|
9
|
+
pixelSize: {
|
|
10
|
+
default: 4,
|
|
11
|
+
description: "Size of dithering pixels",
|
|
12
|
+
ui: {
|
|
13
|
+
type: "range",
|
|
14
|
+
min: 1,
|
|
15
|
+
max: 20,
|
|
16
|
+
step: 1,
|
|
17
|
+
label: "Pixel Size"
|
|
18
|
+
}
|
|
19
|
+
},
|
|
20
|
+
threshold: {
|
|
21
|
+
default: .5,
|
|
22
|
+
description: "Luminance threshold for dithering",
|
|
23
|
+
ui: {
|
|
24
|
+
type: "range",
|
|
25
|
+
min: 0,
|
|
26
|
+
max: 1,
|
|
27
|
+
step: .01,
|
|
28
|
+
label: "Threshold"
|
|
29
|
+
}
|
|
30
|
+
},
|
|
31
|
+
colorA: {
|
|
32
|
+
default: "transparent",
|
|
33
|
+
transform: transformColor,
|
|
34
|
+
description: "Dark color for dithering",
|
|
35
|
+
ui: {
|
|
36
|
+
type: "color",
|
|
37
|
+
label: "Dark Color"
|
|
38
|
+
}
|
|
39
|
+
},
|
|
40
|
+
colorB: {
|
|
41
|
+
default: "#ffffff",
|
|
42
|
+
transform: transformColor,
|
|
43
|
+
description: "Light color for dithering",
|
|
44
|
+
ui: {
|
|
45
|
+
type: "color",
|
|
46
|
+
label: "Light Color"
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
},
|
|
50
|
+
fragmentNode: ({ uniforms, childNode }) => {
|
|
51
|
+
const { vec2: vec2$1, vec3: vec3$1, vec4: vec4$1, floor, screenUV: screenUV$1, viewportSize: viewportSize$1, dot: dot$1, step: step$1, mix: mix$1 } = TSL;
|
|
52
|
+
if (!childNode) return vec4$1(0, 0, 0, 0);
|
|
53
|
+
const sourceColor = childNode;
|
|
54
|
+
const luminance = dot$1(sourceColor.rgb, vec3$1(.299, .587, .114)).mul(sourceColor.a);
|
|
55
|
+
const pixelSize = uniforms.pixelSize.uniform;
|
|
56
|
+
const bayerPos = floor(screenUV$1.mul(viewportSize$1).div(pixelSize)).mod(vec2$1(4));
|
|
57
|
+
const x = bayerPos.x;
|
|
58
|
+
const y = bayerPos.y;
|
|
59
|
+
const bayerValue = y.equal(0).select(x.equal(0).select(0 / 16, x.equal(1).select(8 / 16, x.equal(2).select(2 / 16, 10 / 16))), y.equal(1).select(x.equal(0).select(12 / 16, x.equal(1).select(4 / 16, x.equal(2).select(14 / 16, 6 / 16))), y.equal(2).select(x.equal(0).select(3 / 16, x.equal(1).select(11 / 16, x.equal(2).select(1 / 16, 9 / 16))), x.equal(0).select(15 / 16, x.equal(1).select(7 / 16, x.equal(2).select(13 / 16, 5 / 16))))));
|
|
60
|
+
const threshold = uniforms.threshold.uniform;
|
|
61
|
+
const ditherResult = step$1(bayerValue, luminance.add(threshold.sub(.5)));
|
|
62
|
+
return vec4$1(mix$1(uniforms.colorA.uniform.rgb, uniforms.colorB.uniform.rgb, ditherResult), mix$1(uniforms.colorA.uniform.a, uniforms.colorB.uniform.a, ditherResult));
|
|
63
|
+
}
|
|
64
|
+
};
|
|
65
|
+
var Dither_default = componentDefinition;
|
|
66
|
+
export { componentDefinition as n, Dither_default as t };
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import { r as transformColor } from "./transformations-DxfQXZWi.js";
|
|
2
|
+
import * as TSL from "three/tsl";
|
|
3
|
+
const componentDefinition = {
|
|
4
|
+
name: "DotGrid",
|
|
5
|
+
category: "Base Layers",
|
|
6
|
+
description: "Grid of dots with optional twinkling animation",
|
|
7
|
+
acceptsUVContext: true,
|
|
8
|
+
props: {
|
|
9
|
+
color: {
|
|
10
|
+
default: "#ffffff",
|
|
11
|
+
description: "The color of the dot",
|
|
12
|
+
transform: transformColor,
|
|
13
|
+
ui: {
|
|
14
|
+
type: "color",
|
|
15
|
+
label: "Color"
|
|
16
|
+
}
|
|
17
|
+
},
|
|
18
|
+
density: {
|
|
19
|
+
default: 100,
|
|
20
|
+
description: "The number of dots on the longest canvas edge",
|
|
21
|
+
ui: {
|
|
22
|
+
type: "range",
|
|
23
|
+
min: 10,
|
|
24
|
+
max: 500,
|
|
25
|
+
step: 10,
|
|
26
|
+
label: "Density"
|
|
27
|
+
}
|
|
28
|
+
},
|
|
29
|
+
dotSize: {
|
|
30
|
+
default: .3,
|
|
31
|
+
description: "The size of each dot, zero (0) being invisible, one (1) filled the grid with no gaps",
|
|
32
|
+
ui: {
|
|
33
|
+
type: "range",
|
|
34
|
+
min: 0,
|
|
35
|
+
max: 1,
|
|
36
|
+
step: .01,
|
|
37
|
+
label: "Dot Size"
|
|
38
|
+
}
|
|
39
|
+
},
|
|
40
|
+
twinkle: {
|
|
41
|
+
default: 0,
|
|
42
|
+
description: "Intensity of the twinkle effect (0 = off, 1 = full twinkle)",
|
|
43
|
+
ui: {
|
|
44
|
+
type: "range",
|
|
45
|
+
min: 0,
|
|
46
|
+
max: 1,
|
|
47
|
+
step: .01,
|
|
48
|
+
label: "Twinkle"
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
},
|
|
52
|
+
fragmentNode: ({ uniforms, uvContext }) => {
|
|
53
|
+
const { screenUV: screenUV$1, vec4: vec4$1, vec2: vec2$1, smoothstep, length, floor, float: float$1, viewportSize: viewportSize$1, time, sin: sin$1, mix: mix$1 } = TSL;
|
|
54
|
+
const uvCoords = uvContext ?? screenUV$1;
|
|
55
|
+
const density = uniforms.density.uniform;
|
|
56
|
+
const dotSize = uniforms.dotSize.uniform;
|
|
57
|
+
const dotColor = uniforms.color.uniform;
|
|
58
|
+
const twinkleIntensity = uniforms.twinkle.uniform;
|
|
59
|
+
const resolution = viewportSize$1;
|
|
60
|
+
const aspect = resolution.x.div(resolution.y);
|
|
61
|
+
const correctedUV = vec2$1(uvCoords.x.mul(aspect), uvCoords.y.oneMinus());
|
|
62
|
+
const gridUV = correctedUV.mul(density);
|
|
63
|
+
const centerDistance = length(gridUV.sub(floor(gridUV)).sub(.5));
|
|
64
|
+
const pixelSize = length(TSL.fwidth(correctedUV.mul(density)));
|
|
65
|
+
const dot$1 = float$1(1).sub(smoothstep(dotSize.mul(.5), dotSize.mul(.5).add(pixelSize.mul(.5)), centerDistance));
|
|
66
|
+
const gridPosition = floor(gridUV);
|
|
67
|
+
const dotPhase = gridPosition.x.mul(12.9898).add(gridPosition.y.mul(78.233)).sin().mul(43758.5453).fract();
|
|
68
|
+
const twinkleValue = sin$1(time.mul(2).add(dotPhase.mul(6.28318))).mul(.5).add(.5);
|
|
69
|
+
const twinkleModifier = mix$1(float$1(1), twinkleValue, twinkleIntensity);
|
|
70
|
+
const twinkledAlpha = dot$1.mul(twinkleModifier);
|
|
71
|
+
return vec4$1(dotColor.rgb, twinkledAlpha);
|
|
72
|
+
}
|
|
73
|
+
};
|
|
74
|
+
var DotGrid_default = componentDefinition;
|
|
75
|
+
export { componentDefinition as n, DotGrid_default as t };
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { i as transformColorSpace, r as transformColor, t as colorSpaceOptions } from "./transformations-DxfQXZWi.js";
|
|
2
|
+
import { t as mixColors } from "./colorMixing-BXiTAqJU.js";
|
|
3
|
+
import * as TSL from "three/tsl";
|
|
4
|
+
const componentDefinition = {
|
|
5
|
+
name: "Duotone",
|
|
6
|
+
category: "Adjustments",
|
|
7
|
+
description: "Map colors to two tones based on luminance",
|
|
8
|
+
requiresRTT: true,
|
|
9
|
+
requiresChild: true,
|
|
10
|
+
props: {
|
|
11
|
+
colorA: {
|
|
12
|
+
default: "#ff0000",
|
|
13
|
+
transform: transformColor,
|
|
14
|
+
description: "First color (used for darker areas)",
|
|
15
|
+
ui: {
|
|
16
|
+
type: "color",
|
|
17
|
+
label: "Color A"
|
|
18
|
+
}
|
|
19
|
+
},
|
|
20
|
+
colorB: {
|
|
21
|
+
default: "#023af4",
|
|
22
|
+
transform: transformColor,
|
|
23
|
+
description: "Second color (used for brighter areas)",
|
|
24
|
+
ui: {
|
|
25
|
+
type: "color",
|
|
26
|
+
label: "Color B"
|
|
27
|
+
}
|
|
28
|
+
},
|
|
29
|
+
blend: {
|
|
30
|
+
default: .5,
|
|
31
|
+
description: "Blend point between the two colors",
|
|
32
|
+
ui: {
|
|
33
|
+
type: "range",
|
|
34
|
+
min: 0,
|
|
35
|
+
max: 1,
|
|
36
|
+
step: .01,
|
|
37
|
+
label: "Blend"
|
|
38
|
+
}
|
|
39
|
+
},
|
|
40
|
+
colorSpace: {
|
|
41
|
+
default: "linear",
|
|
42
|
+
transform: transformColorSpace,
|
|
43
|
+
description: "Color space for color interpolation",
|
|
44
|
+
ui: {
|
|
45
|
+
type: "select",
|
|
46
|
+
options: colorSpaceOptions,
|
|
47
|
+
label: "Color Space"
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
},
|
|
51
|
+
fragmentNode: ({ uniforms, childNode, onCleanup }) => {
|
|
52
|
+
const { vec3: vec3$1, vec4: vec4$1, dot: dot$1, smoothstep, screenUV: screenUV$1, convertToTexture: convertToTexture$1 } = TSL;
|
|
53
|
+
if (!childNode) return vec4$1(0, 0, 0, 0);
|
|
54
|
+
const childTexture = convertToTexture$1(childNode);
|
|
55
|
+
onCleanup(() => {
|
|
56
|
+
if (childTexture?.renderTarget?.dispose) childTexture.renderTarget.dispose();
|
|
57
|
+
});
|
|
58
|
+
const inputColor = childTexture.sample(screenUV$1);
|
|
59
|
+
const luminance = dot$1(inputColor.rgb, vec3$1(.299, .587, .114));
|
|
60
|
+
const adjustedLuminance = smoothstep(uniforms.blend.uniform.sub(.5), uniforms.blend.uniform.add(.5), luminance);
|
|
61
|
+
return vec4$1(mixColors(uniforms.colorA.uniform, uniforms.colorB.uniform, adjustedLuminance, uniforms.colorSpace.uniform).rgb, inputColor.a);
|
|
62
|
+
}
|
|
63
|
+
};
|
|
64
|
+
var Duotone_default = componentDefinition;
|
|
65
|
+
export { componentDefinition as n, Duotone_default as t };
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import * as TSL from "three/tsl";
|
|
2
|
+
const componentDefinition = {
|
|
3
|
+
name: "FilmGrain",
|
|
4
|
+
category: "Stylize",
|
|
5
|
+
description: "Analog film grain texture overlay",
|
|
6
|
+
requiresChild: true,
|
|
7
|
+
acceptsUVContext: true,
|
|
8
|
+
props: { strength: {
|
|
9
|
+
default: .5,
|
|
10
|
+
description: "Intensity of the film grain noise",
|
|
11
|
+
ui: {
|
|
12
|
+
type: "range",
|
|
13
|
+
min: 0,
|
|
14
|
+
max: 1,
|
|
15
|
+
step: .01,
|
|
16
|
+
label: "Strength"
|
|
17
|
+
}
|
|
18
|
+
} },
|
|
19
|
+
fragmentNode: ({ uniforms, childNode, uvContext }) => {
|
|
20
|
+
const { vec2: vec2$1, vec4: vec4$1, float: float$1, screenUV: screenUV$1, sin: sin$1, dot: dot$1, fract } = TSL;
|
|
21
|
+
const strength = uniforms.strength.uniform;
|
|
22
|
+
const sourceColor = childNode || vec4$1(0, 0, 0, 0);
|
|
23
|
+
const grainIntensity = fract(sin$1(dot$1(uvContext ?? screenUV$1, vec2$1(float$1(12.9898), float$1(78.233)).mul(float$1(2)))).mul(float$1(43758.5453))).mul(float$1(2)).sub(float$1(1)).mul(strength.mul(float$1(.1)));
|
|
24
|
+
return vec4$1(sourceColor.rgb.add(grainIntensity), sourceColor.a);
|
|
25
|
+
}
|
|
26
|
+
};
|
|
27
|
+
var FilmGrain_default = componentDefinition;
|
|
28
|
+
export { componentDefinition as n, FilmGrain_default as t };
|
|
@@ -0,0 +1,217 @@
|
|
|
1
|
+
import { r as transformColor } from "./transformations-DxfQXZWi.js";
|
|
2
|
+
import * as TSL from "three/tsl";
|
|
3
|
+
var { vec2: vec2$1, vec3: vec3$1, vec4: vec4$1, float: float$1, sin: sin$1, cos: cos$1, smoothstep, mix: mix$1, min: min$1, floor, fract, length, dot: dot$1, screenUV: screenUV$1, viewportSize: viewportSize$1, time, Fn } = TSL;
|
|
4
|
+
var hash1_2 = Fn(([p]) => {
|
|
5
|
+
return fract(sin$1(dot$1(p, vec2$1(127.1, 311.7))).mul(43758.5453123));
|
|
6
|
+
});
|
|
7
|
+
var hash2_2 = Fn(([p]) => {
|
|
8
|
+
return fract(sin$1(vec2$1(dot$1(p, vec2$1(127.1, 311.7)), dot$1(p, vec2$1(269.5, 183.3)))).mul(43758.5453));
|
|
9
|
+
});
|
|
10
|
+
var voronoiPointFromRoot = Fn(([root, deg]) => {
|
|
11
|
+
const point = hash2_2(root).sub(.5);
|
|
12
|
+
const s = sin$1(deg);
|
|
13
|
+
const c = cos$1(deg);
|
|
14
|
+
return vec2$1(c.mul(point.x).sub(s.mul(point.y)).mul(.66), s.mul(point.x).add(c.mul(point.y)).mul(.66)).add(root).add(.5);
|
|
15
|
+
});
|
|
16
|
+
var degFromRootUV = Fn(([uv, randomness]) => {
|
|
17
|
+
return time.mul(randomness).mul(hash1_2(uv).sub(.5)).mul(2);
|
|
18
|
+
});
|
|
19
|
+
var getParticleDistance = Fn(([uv, cellUV, randomness]) => {
|
|
20
|
+
const pointUV = voronoiPointFromRoot(cellUV, degFromRootUV(cellUV, randomness));
|
|
21
|
+
return length(uv.sub(pointUV));
|
|
22
|
+
});
|
|
23
|
+
const componentDefinition = {
|
|
24
|
+
name: "FloatingParticles",
|
|
25
|
+
category: "Base Layers",
|
|
26
|
+
description: "Animated floating particles with twinkle effects",
|
|
27
|
+
requiresRTT: false,
|
|
28
|
+
acceptsUVContext: true,
|
|
29
|
+
props: {
|
|
30
|
+
randomness: {
|
|
31
|
+
default: .25,
|
|
32
|
+
description: "Randomness of particle animation",
|
|
33
|
+
ui: {
|
|
34
|
+
type: "range",
|
|
35
|
+
min: 0,
|
|
36
|
+
max: 1,
|
|
37
|
+
step: .01,
|
|
38
|
+
label: "Randomness"
|
|
39
|
+
}
|
|
40
|
+
},
|
|
41
|
+
speed: {
|
|
42
|
+
default: .25,
|
|
43
|
+
description: "Speed of particle movement",
|
|
44
|
+
ui: {
|
|
45
|
+
type: "range",
|
|
46
|
+
min: 0,
|
|
47
|
+
max: 1,
|
|
48
|
+
step: .01,
|
|
49
|
+
label: "Speed"
|
|
50
|
+
}
|
|
51
|
+
},
|
|
52
|
+
angle: {
|
|
53
|
+
default: 90,
|
|
54
|
+
description: "Movement angle in degrees (0=right, 90=down, 180=left, 270=up)",
|
|
55
|
+
ui: {
|
|
56
|
+
type: "range",
|
|
57
|
+
min: 0,
|
|
58
|
+
max: 360,
|
|
59
|
+
step: 1,
|
|
60
|
+
label: "Angle"
|
|
61
|
+
}
|
|
62
|
+
},
|
|
63
|
+
particleSize: {
|
|
64
|
+
default: 1,
|
|
65
|
+
description: "Size of particles",
|
|
66
|
+
ui: {
|
|
67
|
+
type: "range",
|
|
68
|
+
min: .1,
|
|
69
|
+
max: 20,
|
|
70
|
+
step: .1,
|
|
71
|
+
label: "Particle Size"
|
|
72
|
+
}
|
|
73
|
+
},
|
|
74
|
+
particleSoftness: {
|
|
75
|
+
default: 0,
|
|
76
|
+
description: "Edge softness of particles (0 = sharp, 1 = very soft)",
|
|
77
|
+
ui: {
|
|
78
|
+
type: "range",
|
|
79
|
+
min: 0,
|
|
80
|
+
max: 5,
|
|
81
|
+
step: .01,
|
|
82
|
+
label: "Particle Softness"
|
|
83
|
+
}
|
|
84
|
+
},
|
|
85
|
+
twinkle: {
|
|
86
|
+
default: .5,
|
|
87
|
+
description: "Intensity of the twinkle effect (0 = off, 1 = full twinkle)",
|
|
88
|
+
ui: {
|
|
89
|
+
type: "range",
|
|
90
|
+
min: 0,
|
|
91
|
+
max: 1,
|
|
92
|
+
step: .01,
|
|
93
|
+
label: "Twinkle"
|
|
94
|
+
}
|
|
95
|
+
},
|
|
96
|
+
count: {
|
|
97
|
+
default: 5,
|
|
98
|
+
description: "Number of particle layers",
|
|
99
|
+
ui: {
|
|
100
|
+
type: "range",
|
|
101
|
+
min: 1,
|
|
102
|
+
max: 5,
|
|
103
|
+
step: 1,
|
|
104
|
+
label: "Count"
|
|
105
|
+
}
|
|
106
|
+
},
|
|
107
|
+
particleColor: {
|
|
108
|
+
default: "#ffffff",
|
|
109
|
+
transform: transformColor,
|
|
110
|
+
description: "Color of the particles",
|
|
111
|
+
ui: {
|
|
112
|
+
type: "color",
|
|
113
|
+
label: "Particle Color"
|
|
114
|
+
}
|
|
115
|
+
},
|
|
116
|
+
speedVariance: {
|
|
117
|
+
default: .3,
|
|
118
|
+
description: "Per-layer speed variance (0 = all layers same speed, 1 = high variance)",
|
|
119
|
+
ui: {
|
|
120
|
+
type: "range",
|
|
121
|
+
min: 0,
|
|
122
|
+
max: 1,
|
|
123
|
+
step: .01,
|
|
124
|
+
label: "Speed Variance"
|
|
125
|
+
}
|
|
126
|
+
},
|
|
127
|
+
angleVariance: {
|
|
128
|
+
default: 30,
|
|
129
|
+
description: "Per-layer angle variance in degrees (0 = all layers same angle, 180 = full variance)",
|
|
130
|
+
ui: {
|
|
131
|
+
type: "range",
|
|
132
|
+
min: 0,
|
|
133
|
+
max: 180,
|
|
134
|
+
step: 1,
|
|
135
|
+
label: "Angle Variance"
|
|
136
|
+
}
|
|
137
|
+
},
|
|
138
|
+
particleDensity: {
|
|
139
|
+
default: 3,
|
|
140
|
+
description: "Particle density (lower = more spread out, higher = more dense)",
|
|
141
|
+
ui: {
|
|
142
|
+
type: "range",
|
|
143
|
+
min: .5,
|
|
144
|
+
max: 3,
|
|
145
|
+
step: .1,
|
|
146
|
+
label: "Particle Density"
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
},
|
|
150
|
+
fragmentNode: ({ uniforms, childNode, uvContext }) => {
|
|
151
|
+
const baseUV = uvContext ?? screenUV$1;
|
|
152
|
+
const renderParticle = Fn(([uv$1]) => {
|
|
153
|
+
const rootUV = floor(uv$1);
|
|
154
|
+
const localPos = fract(uv$1);
|
|
155
|
+
let minDist = getParticleDistance(uv$1, rootUV, uniforms.randomness.uniform);
|
|
156
|
+
const softness = uniforms.particleSoftness.uniform;
|
|
157
|
+
const scaledSize = uniforms.particleSize.uniform.mul(.01);
|
|
158
|
+
const outerRadius = scaledSize.mul(.6).add(softness.mul(scaledSize.mul(2.4)));
|
|
159
|
+
const needsNeighbors = outerRadius.greaterThan(.35);
|
|
160
|
+
const nearLeft = localPos.x.lessThan(.4);
|
|
161
|
+
const nearRight = localPos.x.greaterThan(.6);
|
|
162
|
+
const nearTop = localPos.y.lessThan(.4);
|
|
163
|
+
const nearBottom = localPos.y.greaterThan(.6);
|
|
164
|
+
const checkLeft = needsNeighbors.and(nearLeft);
|
|
165
|
+
const checkRight = needsNeighbors.and(nearRight);
|
|
166
|
+
const checkTop = needsNeighbors.and(nearTop);
|
|
167
|
+
const checkBottom = needsNeighbors.and(nearBottom);
|
|
168
|
+
minDist = checkLeft.select(min$1(minDist, getParticleDistance(uv$1, rootUV.add(vec2$1(-1, 0)), uniforms.randomness.uniform)), minDist);
|
|
169
|
+
minDist = checkRight.select(min$1(minDist, getParticleDistance(uv$1, rootUV.add(vec2$1(1, 0)), uniforms.randomness.uniform)), minDist);
|
|
170
|
+
minDist = checkTop.select(min$1(minDist, getParticleDistance(uv$1, rootUV.add(vec2$1(0, -1)), uniforms.randomness.uniform)), minDist);
|
|
171
|
+
minDist = checkBottom.select(min$1(minDist, getParticleDistance(uv$1, rootUV.add(vec2$1(0, 1)), uniforms.randomness.uniform)), minDist);
|
|
172
|
+
const baseIntensity = smoothstep(outerRadius, scaledSize.mul(.6), minDist);
|
|
173
|
+
const twinkleIntensity = uniforms.twinkle.uniform;
|
|
174
|
+
const particlePhase = rootUV.x.mul(12.9898).add(rootUV.y.mul(78.233)).sin().mul(43758.5453).fract();
|
|
175
|
+
const twinkleValue = sin$1(time.mul(2).add(particlePhase.mul(6.28318))).mul(.5).add(.5);
|
|
176
|
+
const twinkleModifier = mix$1(float$1(1), twinkleValue, twinkleIntensity);
|
|
177
|
+
return baseIntensity.mul(twinkleModifier).mul(uniforms.particleColor.uniform.rgb);
|
|
178
|
+
});
|
|
179
|
+
const layeredParticles = Fn(([uv$1]) => {
|
|
180
|
+
const sizeMod = float$1(1.05);
|
|
181
|
+
const alphaMod = float$1(.9);
|
|
182
|
+
const layers = uniforms.count.uniform;
|
|
183
|
+
const particles$1 = vec3$1(0).toVar();
|
|
184
|
+
const size = float$1(1).toVar();
|
|
185
|
+
const alpha = float$1(1).toVar();
|
|
186
|
+
const offset = vec2$1(0).toVar();
|
|
187
|
+
const angleRad = uniforms.angle.uniform.mul(3.14159).div(180);
|
|
188
|
+
const baseMovementDir = vec2$1(cos$1(angleRad), sin$1(angleRad));
|
|
189
|
+
const baseMovement = time.mul(baseMovementDir).mul(uniforms.speed.uniform);
|
|
190
|
+
const speedVar = uniforms.speedVariance.uniform;
|
|
191
|
+
const angleVar = uniforms.angleVariance.uniform.mul(3.14159).div(180);
|
|
192
|
+
for (let i = 0; i < 4; i++) {
|
|
193
|
+
const layerActive = float$1(i).lessThan(layers).and(alpha.greaterThan(.02));
|
|
194
|
+
const layerHash = hash2_2(vec2$1(alpha, float$1(i).mul(7.919)));
|
|
195
|
+
const speedMod = float$1(1).add(layerHash.x.sub(.5).mul(speedVar));
|
|
196
|
+
const angleDelta = layerHash.y.sub(.5).mul(angleVar).mul(2);
|
|
197
|
+
const variedAngle = angleRad.add(angleDelta);
|
|
198
|
+
const variedDir = vec2$1(cos$1(variedAngle), sin$1(variedAngle));
|
|
199
|
+
const movement = baseMovement.mul(speedMod).add(variedDir.sub(baseMovementDir).mul(time).mul(uniforms.speed.uniform));
|
|
200
|
+
const layerParticles = renderParticle(uv$1.mul(size).add(movement).add(offset)).mul(alpha);
|
|
201
|
+
particles$1.assign(particles$1.add(layerActive.select(layerParticles, vec3$1(0))));
|
|
202
|
+
offset.assign(offset.add(layerHash.mul(10)));
|
|
203
|
+
alpha.assign(alpha.mul(alphaMod));
|
|
204
|
+
size.assign(size.mul(sizeMod));
|
|
205
|
+
}
|
|
206
|
+
return particles$1;
|
|
207
|
+
});
|
|
208
|
+
const uv = baseUV.mul(2).sub(1);
|
|
209
|
+
const aspectRatio = viewportSize$1.x.div(viewportSize$1.y);
|
|
210
|
+
const particles = layeredParticles(vec2$1(uv.x.mul(aspectRatio), uv.y).mul(uniforms.particleDensity.uniform));
|
|
211
|
+
const particleAlpha = length(particles);
|
|
212
|
+
if (childNode) return vec4$1(mix$1(childNode.xyz, particles, particleAlpha.greaterThan(.01).select(particleAlpha, 0)), childNode.w);
|
|
213
|
+
return vec4$1(particles, particleAlpha);
|
|
214
|
+
}
|
|
215
|
+
};
|
|
216
|
+
var FloatingParticles_default = componentDefinition;
|
|
217
|
+
export { componentDefinition as n, FloatingParticles_default as t };
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import * as TSL from "three/tsl";
|
|
2
|
+
const componentDefinition = {
|
|
3
|
+
name: "GlassTiles",
|
|
4
|
+
category: "Distortions",
|
|
5
|
+
description: "Refraction-like distortion in a tile grid pattern",
|
|
6
|
+
requiresRTT: true,
|
|
7
|
+
requiresChild: true,
|
|
8
|
+
props: {
|
|
9
|
+
intensity: {
|
|
10
|
+
default: 1,
|
|
11
|
+
description: "The intensity of the glass tiles effect",
|
|
12
|
+
ui: {
|
|
13
|
+
type: "range",
|
|
14
|
+
min: 0,
|
|
15
|
+
max: 5,
|
|
16
|
+
step: .1,
|
|
17
|
+
label: "Intensity"
|
|
18
|
+
}
|
|
19
|
+
},
|
|
20
|
+
tileCount: {
|
|
21
|
+
default: 100,
|
|
22
|
+
description: "Number of tiles across the shortest dimension",
|
|
23
|
+
ui: {
|
|
24
|
+
type: "range",
|
|
25
|
+
min: 1,
|
|
26
|
+
max: 200,
|
|
27
|
+
step: 1,
|
|
28
|
+
label: "Tile Count"
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
},
|
|
32
|
+
uvTransformNode: ({ uv, uniforms, viewportSize: viewportSize$1 }) => {
|
|
33
|
+
const { vec2: vec2$1, floor, select } = TSL;
|
|
34
|
+
const intensity = uniforms.intensity.uniform;
|
|
35
|
+
const baseTileCount = uniforms.tileCount.uniform;
|
|
36
|
+
const aspectRatio = viewportSize$1.x.div(viewportSize$1.y);
|
|
37
|
+
const tileCount = vec2$1(select(aspectRatio.greaterThanEqual(1), baseTileCount.mul(aspectRatio), baseTileCount), select(aspectRatio.lessThan(1), baseTileCount.div(aspectRatio), baseTileCount));
|
|
38
|
+
const cellCoord = floor(uv.mul(tileCount)).div(tileCount);
|
|
39
|
+
const localUV = uv.sub(cellCoord);
|
|
40
|
+
const distortionCenter = vec2$1(.5, .5);
|
|
41
|
+
const distortionFactor = intensity.mul(.025);
|
|
42
|
+
const distortion = localUV.div(vec2$1(1, 1).div(tileCount)).sub(distortionCenter).mul(distortionFactor);
|
|
43
|
+
return localUV.add(distortion).add(cellCoord);
|
|
44
|
+
},
|
|
45
|
+
fragmentNode: ({ uniforms, childNode, dimensions, onCleanup }) => {
|
|
46
|
+
const { vec2: vec2$1, vec4: vec4$1, floor, mul: mul$1, div: div$1, sub: sub$1, add: add$1, screenUV: screenUV$1, uniform: uniform$1, convertToTexture: convertToTexture$1 } = TSL;
|
|
47
|
+
if (!childNode) {
|
|
48
|
+
console.error("You must pass a child component into the Glass Tiles shader.");
|
|
49
|
+
return vec4$1(0);
|
|
50
|
+
}
|
|
51
|
+
const texture = convertToTexture$1(childNode);
|
|
52
|
+
onCleanup(() => {
|
|
53
|
+
if (texture?.renderTarget?.dispose) texture.renderTarget.dispose();
|
|
54
|
+
});
|
|
55
|
+
const aspectRatioUniform = uniform$1(dimensions.width / dimensions.height);
|
|
56
|
+
const uvNode = screenUV$1;
|
|
57
|
+
const intensity = uniforms.intensity.uniform;
|
|
58
|
+
const baseTileCount = uniforms.tileCount.uniform;
|
|
59
|
+
const tileCount = vec2$1(aspectRatioUniform.greaterThanEqual(1).select(mul$1(baseTileCount, aspectRatioUniform), baseTileCount), aspectRatioUniform.lessThan(1).select(div$1(baseTileCount, aspectRatioUniform), baseTileCount));
|
|
60
|
+
const cellCoord = div$1(floor(mul$1(uvNode, tileCount)), tileCount);
|
|
61
|
+
const localUV = sub$1(uvNode, cellCoord);
|
|
62
|
+
const distortionCenter = vec2$1(.5, .5);
|
|
63
|
+
const distortionFactor = mul$1(intensity, .025);
|
|
64
|
+
const finalUV = add$1(add$1(localUV, mul$1(sub$1(div$1(localUV, div$1(vec2$1(1), tileCount)), distortionCenter), distortionFactor)), cellCoord);
|
|
65
|
+
return vec4$1(texture.sample(finalUV));
|
|
66
|
+
}
|
|
67
|
+
};
|
|
68
|
+
var GlassTiles_default = componentDefinition;
|
|
69
|
+
export { componentDefinition as n, GlassTiles_default as t };
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import * as TSL from "three/tsl";
|
|
2
|
+
const componentDefinition = {
|
|
3
|
+
name: "Glow",
|
|
4
|
+
category: "Stylize",
|
|
5
|
+
description: "Soft glow effect with adjustable intensity",
|
|
6
|
+
requiresRTT: true,
|
|
7
|
+
requiresChild: true,
|
|
8
|
+
props: {
|
|
9
|
+
intensity: {
|
|
10
|
+
default: 1,
|
|
11
|
+
description: "Glow intensity (brightness of the glow effect)",
|
|
12
|
+
ui: {
|
|
13
|
+
type: "range",
|
|
14
|
+
min: 0,
|
|
15
|
+
max: 10,
|
|
16
|
+
step: .01,
|
|
17
|
+
label: "Intensity"
|
|
18
|
+
}
|
|
19
|
+
},
|
|
20
|
+
threshold: {
|
|
21
|
+
default: .5,
|
|
22
|
+
description: "Brightness threshold for glow extraction (lower = more glow)",
|
|
23
|
+
ui: {
|
|
24
|
+
type: "range",
|
|
25
|
+
min: 0,
|
|
26
|
+
max: 1,
|
|
27
|
+
step: .01,
|
|
28
|
+
label: "Threshold"
|
|
29
|
+
}
|
|
30
|
+
},
|
|
31
|
+
size: {
|
|
32
|
+
default: 10,
|
|
33
|
+
description: "Size/spread of the glow effect",
|
|
34
|
+
ui: {
|
|
35
|
+
type: "range",
|
|
36
|
+
min: 1,
|
|
37
|
+
max: 20,
|
|
38
|
+
step: .01,
|
|
39
|
+
label: "Glow Size"
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
},
|
|
43
|
+
fragmentNode: ({ uniforms, childNode, onCleanup }) => {
|
|
44
|
+
const { vec2: vec2$1, vec3: vec3$1, vec4: vec4$1, float: float$1, max: max$1, dot: dot$1, screenUV: screenUV$1, convertToTexture: convertToTexture$1, viewportSize: viewportSize$1, Fn } = TSL;
|
|
45
|
+
if (!childNode) return vec4$1(0, 0, 0, 0);
|
|
46
|
+
const childTexture = convertToTexture$1(childNode);
|
|
47
|
+
onCleanup(() => {
|
|
48
|
+
if (childTexture?.renderTarget?.dispose) childTexture.renderTarget.dispose();
|
|
49
|
+
});
|
|
50
|
+
const originalColor = childTexture.sample(screenUV$1);
|
|
51
|
+
const glowEffect = Fn(() => {
|
|
52
|
+
const blurRadius = uniforms.size.uniform;
|
|
53
|
+
const threshold = uniforms.threshold.uniform;
|
|
54
|
+
const pixelSize = vec2$1(1).div(viewportSize$1);
|
|
55
|
+
const blurredGlow = vec4$1(0, 0, 0, 0).toVar();
|
|
56
|
+
const radius = 5;
|
|
57
|
+
for (let dx = -radius; dx <= radius; dx++) for (let dy = -radius; dy <= radius; dy++) {
|
|
58
|
+
const offset = vec2$1(float$1(dx), float$1(dy)).mul(pixelSize).mul(blurRadius);
|
|
59
|
+
const sampleUV = screenUV$1.add(offset);
|
|
60
|
+
const sampleColor = childTexture.sample(sampleUV);
|
|
61
|
+
const luminance = dot$1(sampleColor.rgb, vec3$1(.299, .587, .114));
|
|
62
|
+
const brightnessMask = max$1(float$1(0), luminance.sub(threshold));
|
|
63
|
+
const brightColor = sampleColor.mul(brightnessMask);
|
|
64
|
+
blurredGlow.assign(blurredGlow.add(brightColor));
|
|
65
|
+
}
|
|
66
|
+
const totalSamples = float$1((radius * 2 + 1) * (radius * 2 + 1));
|
|
67
|
+
return blurredGlow.div(totalSamples);
|
|
68
|
+
})();
|
|
69
|
+
const intensity = uniforms.intensity.uniform;
|
|
70
|
+
const intensifiedGlow = glowEffect.mul(intensity);
|
|
71
|
+
return vec4$1(originalColor.rgb.add(intensifiedGlow.rgb), max$1(originalColor.a, intensifiedGlow.a));
|
|
72
|
+
}
|
|
73
|
+
};
|
|
74
|
+
var Glow_default = componentDefinition;
|
|
75
|
+
export { componentDefinition as n, Glow_default as t };
|