shaders 2.2.24 → 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.
Files changed (193) hide show
  1. package/dist/core/AngularBlur-Dl2gwk68.js +64 -0
  2. package/dist/core/Ascii-Dha_QpT3.js +286 -0
  3. package/dist/core/Beam-CTN9Ni43.js +139 -0
  4. package/dist/core/Blob-CxFDZovO.js +218 -0
  5. package/dist/core/Blur-Y2FsmFk_.js +77 -0
  6. package/dist/core/Bulge-Cb-t0xqI.js +132 -0
  7. package/dist/core/CRTScreen-CtERsenz.js +112 -0
  8. package/dist/core/ChannelBlur-CvM6GJgZ.js +118 -0
  9. package/dist/core/Checkerboard-CgB-egNY.js +83 -0
  10. package/dist/core/ChromaFlow-vRCwhQpN.js +222 -0
  11. package/dist/core/ChromaticAberration-FTquTQIL.js +88 -0
  12. package/dist/core/Circle-Daziv5d7.js +67 -0
  13. package/dist/core/CursorTrail-Bsz9e6Fn.js +145 -0
  14. package/dist/core/DiffuseBlur-Cj2PtRNd.js +83 -0
  15. package/dist/core/Dither-D2Nf4p3w.js +66 -0
  16. package/dist/core/DotGrid-CzOwquo4.js +75 -0
  17. package/dist/core/Duotone-XuTN9tI7.js +65 -0
  18. package/dist/core/FilmGrain-D3-nbi12.js +28 -0
  19. package/dist/core/FloatingParticles-D9Nnu1qg.js +217 -0
  20. package/dist/core/GlassTiles-CnjCvajI.js +69 -0
  21. package/dist/core/Glow-BluFc9be.js +75 -0
  22. package/dist/core/Godrays-ChLh_vGl.js +144 -0
  23. package/dist/core/Grayscale-DRny75A9.js +20 -0
  24. package/dist/core/Grid-DgyDa4H1.js +58 -0
  25. package/dist/core/GridDistortion-BAspCYvp.js +188 -0
  26. package/dist/core/Group-Dul7PUBl.js +14 -0
  27. package/dist/core/Halftone-Ifv5F_FT.js +65 -0
  28. package/dist/core/HueShift-De8ukMWs.js +31 -0
  29. package/dist/core/ImageTexture-DvYcQgJB.js +143 -0
  30. package/dist/core/Invert-Fz0NtIJc.js +21 -0
  31. package/dist/core/LinearBlur-LmhnQoA4.js +62 -0
  32. package/dist/core/LinearGradient-xbloQjzt.js +133 -0
  33. package/dist/core/Liquify-DMe1V5-O.js +175 -0
  34. package/dist/core/Pixelate-Cv8537Pj.js +37 -0
  35. package/dist/core/PolarCoordinates-DDvDhBE-.js +112 -0
  36. package/dist/core/Posterize-3m3xkWOz.js +29 -0
  37. package/dist/core/ProgressiveBlur-EGkevObV.js +121 -0
  38. package/dist/core/RadialGradient-B7ZZB_VJ.js +71 -0
  39. package/dist/core/RectangularCoordinates-muWR8mZS.js +101 -0
  40. package/dist/core/Ripples-8XaZaXQF.js +117 -0
  41. package/dist/core/Saturation-CYFI1jzN.js +30 -0
  42. package/dist/core/SimplexNoise-DJUe0wz_.js +99 -0
  43. package/dist/core/SineWave-Dl3nFO1W.js +120 -0
  44. package/dist/core/SolidColor-CWGq_Bjq.js +21 -0
  45. package/dist/core/Spherize-C-jZEUsN.js +128 -0
  46. package/dist/core/Spiral-BSB_R39p.js +132 -0
  47. package/dist/core/Strands-0stO5BMy.js +161 -0
  48. package/dist/core/Stretch-B645paha.js +133 -0
  49. package/dist/core/Swirl-CVnbawit.js +173 -0
  50. package/dist/core/TiltShift-0CxNRI6L.js +134 -0
  51. package/dist/core/Tritone-Daa-I5UD.js +76 -0
  52. package/dist/core/Twirl-2CJVZEtk.js +96 -0
  53. package/dist/core/Vibrance-DRtecEvb.js +30 -0
  54. package/dist/core/WaveDistortion-BscXN2rs.js +173 -0
  55. package/dist/core/ZoomBlur-CAqK0Kju.js +62 -0
  56. package/dist/core/colorMixing-BXiTAqJU.js +69 -0
  57. package/dist/core/edges-Bn_OIa_h.js +26 -0
  58. package/dist/core/index.js +2257 -1606
  59. package/dist/core/shaders/AngularBlur/index.js +3 -7
  60. package/dist/core/shaders/Ascii/index.js +2 -6
  61. package/dist/core/shaders/Beam/index.js +4 -8
  62. package/dist/core/shaders/Blob/index.js +5 -9
  63. package/dist/core/shaders/Blur/index.js +2 -6
  64. package/dist/core/shaders/Bulge/index.js +4 -8
  65. package/dist/core/shaders/CRTScreen/index.js +2 -6
  66. package/dist/core/shaders/ChannelBlur/index.js +2 -6
  67. package/dist/core/shaders/Checkerboard/index.js +4 -8
  68. package/dist/core/shaders/ChromaFlow/index.js +3 -7
  69. package/dist/core/shaders/ChromaticAberration/index.js +3 -7
  70. package/dist/core/shaders/Circle/index.js +3 -7
  71. package/dist/core/shaders/CursorTrail/index.js +4 -8
  72. package/dist/core/shaders/DiffuseBlur/index.js +4 -8
  73. package/dist/core/shaders/Dither/index.js +3 -7
  74. package/dist/core/shaders/DotGrid/index.js +3 -7
  75. package/dist/core/shaders/Duotone/index.js +4 -8
  76. package/dist/core/shaders/FilmGrain/index.js +2 -6
  77. package/dist/core/shaders/FloatingParticles/index.js +3 -7
  78. package/dist/core/shaders/GlassTiles/index.js +2 -6
  79. package/dist/core/shaders/Glow/index.js +2 -6
  80. package/dist/core/shaders/Godrays/index.js +3 -7
  81. package/dist/core/shaders/Grayscale/index.js +2 -8
  82. package/dist/core/shaders/Grid/index.js +3 -7
  83. package/dist/core/shaders/GridDistortion/index.js +4 -8
  84. package/dist/core/shaders/Group/index.js +2 -6
  85. package/dist/core/shaders/Halftone/index.js +3 -7
  86. package/dist/core/shaders/HueShift/index.js +2 -8
  87. package/dist/core/shaders/ImageTexture/index.js +2 -6
  88. package/dist/core/shaders/Invert/index.js +2 -6
  89. package/dist/core/shaders/LinearBlur/index.js +3 -7
  90. package/dist/core/shaders/LinearGradient/index.js +4 -8
  91. package/dist/core/shaders/Liquify/index.js +4 -8
  92. package/dist/core/shaders/Pixelate/index.js +2 -6
  93. package/dist/core/shaders/PolarCoordinates/index.js +4 -8
  94. package/dist/core/shaders/Posterize/index.js +2 -7
  95. package/dist/core/shaders/ProgressiveBlur/index.js +3 -7
  96. package/dist/core/shaders/RadialGradient/index.js +4 -8
  97. package/dist/core/shaders/RectangularCoordinates/index.js +4 -8
  98. package/dist/core/shaders/Ripples/index.js +5 -9
  99. package/dist/core/shaders/Saturation/index.js +2 -8
  100. package/dist/core/shaders/SimplexNoise/index.js +5 -9
  101. package/dist/core/shaders/SineWave/index.js +3 -7
  102. package/dist/core/shaders/SolidColor/index.js +3 -7
  103. package/dist/core/shaders/Spherize/index.js +3 -7
  104. package/dist/core/shaders/Spiral/index.js +4 -8
  105. package/dist/core/shaders/Strands/index.js +4 -8
  106. package/dist/core/shaders/Stretch/index.js +4 -8
  107. package/dist/core/shaders/Swirl/index.js +5 -9
  108. package/dist/core/shaders/TiltShift/index.js +3 -7
  109. package/dist/core/shaders/Tritone/index.js +4 -8
  110. package/dist/core/shaders/Twirl/index.js +4 -8
  111. package/dist/core/shaders/Vibrance/index.js +2 -8
  112. package/dist/core/shaders/WaveDistortion/index.js +4 -8
  113. package/dist/core/shaders/ZoomBlur/index.js +3 -7
  114. package/dist/core/telemetry/index.js +189 -157
  115. package/dist/core/time-CTJvRUZ4.js +10 -0
  116. package/dist/core/transformations-DxfQXZWi.js +4715 -0
  117. package/dist/react/generatePresetCode-CCibXbtZ.js +645 -0
  118. package/dist/react/index.js +7645 -104827
  119. package/dist/react/utils/generatePresetCode.js +2 -5
  120. package/dist/solid/index.js +6670 -102727
  121. package/dist/solid/utils/generatePresetCode.js +583 -554
  122. package/dist/svelte/generatePresetCode-CymgoDq_.js +645 -0
  123. package/dist/svelte/index.js +6175 -102645
  124. package/dist/svelte/utils/generatePresetCode.js +2 -5
  125. package/dist/vue/generatePresetCode-CRJmU8iF.js +649 -0
  126. package/dist/vue/index.js +6929 -103706
  127. package/dist/vue/utils/generatePresetCode.js +2 -5
  128. package/package.json +4 -1
  129. package/dist/core/AngularBlur-ClvtyURQ.js +0 -56
  130. package/dist/core/Ascii-BT0-K_vw.js +0 -196
  131. package/dist/core/Beam-BAKql1AP.js +0 -116
  132. package/dist/core/Blob-CVSxhHJG.js +0 -169
  133. package/dist/core/Blur-C1TTBHCX.js +0 -64
  134. package/dist/core/Bulge-DV8tX-cw.js +0 -103
  135. package/dist/core/CRTScreen-VTJQoOeq.js +0 -91
  136. package/dist/core/ChannelBlur-BLZ9kBNA.js +0 -89
  137. package/dist/core/Checkerboard-DQ4Df3vm.js +0 -75
  138. package/dist/core/ChromaFlow-BggN1_Av.js +0 -134
  139. package/dist/core/ChromaticAberration-DlTaHNcp.js +0 -82
  140. package/dist/core/Circle-B9ObWlq5.js +0 -62
  141. package/dist/core/ColorAdjustment-FeXXpypd.js +0 -14
  142. package/dist/core/CursorTrail-C7QdUj8O.js +0 -105
  143. package/dist/core/DiffuseBlur-Mx6LBsqz.js +0 -69
  144. package/dist/core/Dither-CeIdV_9C.js +0 -61
  145. package/dist/core/DotGrid-D6xUvYrt.js +0 -61
  146. package/dist/core/Duotone-C2Pqt2gR.js +0 -66
  147. package/dist/core/FilmGrain-CJ9n_fgk.js +0 -28
  148. package/dist/core/FloatingParticles-iGtMs44K.js +0 -160
  149. package/dist/core/GlassTiles-D_lVyag2.js +0 -52
  150. package/dist/core/Glow-B0jj-6OC.js +0 -66
  151. package/dist/core/Godrays-DjLVuZa4.js +0 -105
  152. package/dist/core/Grayscale-BbsdDa_X.js +0 -21
  153. package/dist/core/Grid-ByjU-_ua.js +0 -50
  154. package/dist/core/GridDistortion-C_eIlhkW.js +0 -147
  155. package/dist/core/Group-CyaDLGpI.js +0 -17
  156. package/dist/core/Halftone-BvuAe_k-.js +0 -55
  157. package/dist/core/HueShift-B_qE9c08.js +0 -32
  158. package/dist/core/ImageTexture-h00TFC1l.js +0 -105
  159. package/dist/core/Invert-BEDDB0sm.js +0 -20
  160. package/dist/core/LinearBlur-CLKxuyeT.js +0 -56
  161. package/dist/core/LinearGradient-BPo8TX_M.js +0 -111
  162. package/dist/core/Liquify-DGkfeixZ.js +0 -139
  163. package/dist/core/Pixelate-Bzy_7LnJ.js +0 -38
  164. package/dist/core/PolarCoordinates-BUumPeTv.js +0 -103
  165. package/dist/core/Posterize-ggKIJlmm.js +0 -46
  166. package/dist/core/ProgressiveBlur-D6_6T7SS.js +0 -102
  167. package/dist/core/RadialGradient-DEY9fRqa.js +0 -71
  168. package/dist/core/RectangularCoordinates-CZ-cFrCh.js +0 -92
  169. package/dist/core/Ripples-BwNlcsnV.js +0 -106
  170. package/dist/core/Saturation-Dl3gCWuZ.js +0 -31
  171. package/dist/core/SimplexNoise-BhE_WyGt.js +0 -94
  172. package/dist/core/SineWave-Db_Y0Mcv.js +0 -107
  173. package/dist/core/SolidColor-CerOp4EQ.js +0 -22
  174. package/dist/core/Spherize-Dh8E5XwG.js +0 -103
  175. package/dist/core/Spiral-BvygQEfP.js +0 -115
  176. package/dist/core/Strands-maaPn4On.js +0 -125
  177. package/dist/core/Stretch-CnA0-nSz.js +0 -103
  178. package/dist/core/Swirl-CQBUahTB.js +0 -148
  179. package/dist/core/TSLBase-Bt7Z4hv_.js +0 -8053
  180. package/dist/core/TiltShift-qFj0oFzN.js +0 -114
  181. package/dist/core/Tritone-AiixmTg8.js +0 -75
  182. package/dist/core/Twirl-ooHQcV89.js +0 -82
  183. package/dist/core/Vibrance-C2FRlLkK.js +0 -31
  184. package/dist/core/WaveDistortion-CN8MjKlm.js +0 -132
  185. package/dist/core/ZoomBlur-CxWGx8PH.js +0 -56
  186. package/dist/core/colorMixing--dhzx0ch.js +0 -21
  187. package/dist/core/edges-CDzKsauJ.js +0 -15
  188. package/dist/core/three.tsl-Btj1hLsf.js +0 -43845
  189. package/dist/core/time-DbRMw6Jm.js +0 -10
  190. package/dist/core/transformations-CsrIJXh-.js +0 -3992
  191. package/dist/react/generatePresetCode-CVj6IV8Y.js +0 -646
  192. package/dist/svelte/generatePresetCode-CVj6IV8Y.js +0 -646
  193. package/dist/vue/generatePresetCode-DCaIsDhE.js +0 -652
@@ -0,0 +1,144 @@
1
+ import { o as transformPosition, r as transformColor } from "./transformations-DxfQXZWi.js";
2
+ import * as TSL from "three/tsl";
3
+ const componentDefinition = {
4
+ name: "Godrays",
5
+ category: "Base Layers",
6
+ description: "Volumetric light rays emanating from a point",
7
+ requiresRTT: false,
8
+ acceptsUVContext: true,
9
+ props: {
10
+ center: {
11
+ default: {
12
+ x: 0,
13
+ y: 0
14
+ },
15
+ transform: transformPosition,
16
+ description: "The center point of the god rays",
17
+ ui: {
18
+ type: "position",
19
+ label: "Center"
20
+ }
21
+ },
22
+ density: {
23
+ default: .3,
24
+ description: "Frequency of ray sectors",
25
+ ui: {
26
+ type: "range",
27
+ min: 0,
28
+ max: 1,
29
+ step: .01,
30
+ label: "Density"
31
+ }
32
+ },
33
+ intensity: {
34
+ default: .8,
35
+ description: "Ray visibility within sectors",
36
+ ui: {
37
+ type: "range",
38
+ min: 0,
39
+ max: 1,
40
+ step: .01,
41
+ label: "Intensity"
42
+ }
43
+ },
44
+ spotty: {
45
+ default: 1,
46
+ description: "Density of spots on rays (higher = more spots)",
47
+ ui: {
48
+ type: "range",
49
+ min: 0,
50
+ max: 1,
51
+ step: .01,
52
+ label: "Spotty"
53
+ }
54
+ },
55
+ speed: {
56
+ default: .5,
57
+ description: "Animation speed of the rays",
58
+ ui: {
59
+ type: "range",
60
+ min: 0,
61
+ max: 2,
62
+ step: .01,
63
+ label: "Speed"
64
+ }
65
+ },
66
+ rayColor: {
67
+ default: "#4283fb",
68
+ transform: transformColor,
69
+ description: "Color of the light rays",
70
+ ui: {
71
+ type: "color",
72
+ label: "Ray Color"
73
+ }
74
+ },
75
+ backgroundColor: {
76
+ default: "transparent",
77
+ transform: transformColor,
78
+ description: "Background color",
79
+ ui: {
80
+ type: "color",
81
+ label: "Background Color"
82
+ }
83
+ }
84
+ },
85
+ fragmentNode: ({ uniforms, uvContext }) => {
86
+ const { vec2: vec2$1, vec4: vec4$1, float: float$1, sin: sin$1, atan: atan$1, length, pow: pow$1, smoothstep, mix: mix$1, clamp: clamp$1, screenUV: screenUV$1, time, PI, Fn } = TSL;
87
+ const uv = uvContext ?? screenUV$1;
88
+ const centerPos = vec2$1(uniforms.center.uniform.x, uniforms.center.uniform.y.oneMinus());
89
+ const shapeUV = uv.sub(centerPos);
90
+ const valueNoise = Fn(([st]) => {
91
+ const i = st.floor();
92
+ const f = st.fract();
93
+ const hash = (p) => {
94
+ return sin$1(p.x.mul(127.1).add(p.y.mul(311.7))).mul(43758.5453).fract();
95
+ };
96
+ const a = hash(i);
97
+ const b = hash(i.add(vec2$1(1, 0)));
98
+ const c = hash(i.add(vec2$1(0, 1)));
99
+ const d = hash(i.add(vec2$1(1, 1)));
100
+ const u = f.mul(f).mul(f.mul(-2).add(3));
101
+ return mix$1(mix$1(a, b, u.x), mix$1(c, d, u.x), u.y);
102
+ });
103
+ const raysShape = Fn(([uv$1, r, freq, intensity]) => {
104
+ const a = atan$1(uv$1.y, uv$1.x);
105
+ const left = vec2$1(a.mul(freq), r);
106
+ const right = vec2$1(a.mod(PI.mul(2)).mul(freq), r);
107
+ const nLeft = pow$1(valueNoise(left), intensity);
108
+ return mix$1(pow$1(valueNoise(right), intensity), nLeft, smoothstep(-.15, .15, uv$1.x));
109
+ });
110
+ const rayEffect = Fn(() => {
111
+ const animTime = time.mul(uniforms.speed.uniform).mul(.2);
112
+ const radius = length(shapeUV);
113
+ const spots = float$1(6.5).mul(TSL.abs(uniforms.spotty.uniform));
114
+ const intensityCalc = float$1(4).sub(float$1(3).mul(clamp$1(uniforms.intensity.uniform, 0, 1)));
115
+ const density = float$1(6).mul(uniforms.density.uniform);
116
+ const accumRay = float$1(0).toVar();
117
+ const r1 = radius.mul(1).sub(animTime.mul(3));
118
+ const r2 = radius.mul(.5).mul(float$1(1).add(spots)).sub(animTime.mul(2));
119
+ const f1 = density.mul(5);
120
+ const ray = raysShape(shapeUV, r1, f1, intensityCalc).toVar();
121
+ ray.assign(ray.mul(raysShape(shapeUV, r2, f1.mul(4), intensityCalc)));
122
+ accumRay.assign(accumRay.add(ray));
123
+ const r3 = radius.mul(1.4).sub(animTime.mul(2.5));
124
+ const r4 = radius.mul(.7).mul(float$1(1).add(spots)).sub(animTime.mul(1.8));
125
+ const f2 = density.mul(4.5);
126
+ const ray2 = raysShape(shapeUV, r3, f2, intensityCalc).toVar();
127
+ ray2.assign(ray2.mul(raysShape(shapeUV, r4, f2.mul(3.5), intensityCalc)));
128
+ accumRay.assign(accumRay.add(ray2.mul(.7)));
129
+ return clamp$1(accumRay, 0, 1);
130
+ })();
131
+ const rayColorRGB = uniforms.rayColor.uniform.rgb;
132
+ const rayColorA = uniforms.rayColor.uniform.a;
133
+ const bgColorRGB = uniforms.backgroundColor.uniform.rgb;
134
+ const bgColorA = uniforms.backgroundColor.uniform.a;
135
+ const rayAlpha = rayEffect.mul(rayColorA);
136
+ const finalAlpha = rayAlpha.add(bgColorA.mul(float$1(1).sub(rayAlpha)));
137
+ const safeAlpha = clamp$1(finalAlpha, .001, 1);
138
+ const rayContribution = rayColorRGB.mul(rayAlpha);
139
+ const bgContribution = bgColorRGB.mul(bgColorA).mul(float$1(1).sub(rayAlpha));
140
+ return vec4$1(rayContribution.add(bgContribution).div(safeAlpha), finalAlpha);
141
+ }
142
+ };
143
+ var Godrays_default = componentDefinition;
144
+ export { componentDefinition as n, Godrays_default as t };
@@ -0,0 +1,20 @@
1
+ import * as TSL from "three/tsl";
2
+ import { grayscale } from "three/src/nodes/display/ColorAdjustment";
3
+ const componentDefinition = {
4
+ name: "Grayscale",
5
+ category: "Adjustments",
6
+ description: "Convert colors to black and white",
7
+ requiresChild: true,
8
+ props: {},
9
+ fragmentNode: ({ childNode }) => {
10
+ const { vec4: vec4$1 } = TSL;
11
+ if (!childNode) {
12
+ console.error("You must pass a child component into the Grayscale shader.");
13
+ return vec4$1(0);
14
+ }
15
+ const sourceColor = childNode || vec4$1(0, 0, 0, 0);
16
+ return vec4$1(grayscale(sourceColor.rgb).rgb, sourceColor.a);
17
+ }
18
+ };
19
+ var Grayscale_default = componentDefinition;
20
+ export { componentDefinition as n, Grayscale_default as t };
@@ -0,0 +1,58 @@
1
+ import { r as transformColor } from "./transformations-DxfQXZWi.js";
2
+ import * as TSL from "three/tsl";
3
+ const componentDefinition = {
4
+ name: "Grid",
5
+ category: "Base Layers",
6
+ description: "Simple grid lines pattern with adjustable thickness",
7
+ acceptsUVContext: true,
8
+ props: {
9
+ color: {
10
+ default: "#ffffff",
11
+ transform: transformColor,
12
+ description: "The color of the grid lines",
13
+ ui: {
14
+ type: "color",
15
+ label: "Color"
16
+ }
17
+ },
18
+ cells: {
19
+ default: 10,
20
+ description: "Number of cells along the shortest canvas edge (creates square cells)",
21
+ ui: {
22
+ type: "range",
23
+ min: 1,
24
+ max: 50,
25
+ step: 1,
26
+ label: "Cells"
27
+ }
28
+ },
29
+ thickness: {
30
+ default: 1,
31
+ description: "Thickness of grid lines (normalized, 0.0-1.0)",
32
+ ui: {
33
+ type: "range",
34
+ min: 0,
35
+ max: 5,
36
+ step: .1,
37
+ label: "Thickness"
38
+ }
39
+ }
40
+ },
41
+ fragmentNode: ({ uniforms, uvContext }) => {
42
+ const { vec2: vec2$1, vec4: vec4$1, fract, max: max$1, screenUV: screenUV$1, viewportSize: viewportSize$1, fwidth, smoothstep } = TSL;
43
+ const uv = uvContext ?? screenUV$1;
44
+ const aspect = viewportSize$1.x.div(viewportSize$1.y);
45
+ const correctedUV = vec2$1(uv.x.mul(aspect), uv.y.oneMinus());
46
+ const cells = uniforms.cells.uniform;
47
+ const gridUV = correctedUV.mul(cells);
48
+ const gridFract = fract(gridUV);
49
+ const lineWidth = uniforms.thickness.uniform.mul(.01);
50
+ const distToLineX = gridFract.x.min(gridFract.x.oneMinus());
51
+ const distToLineY = gridFract.y.min(gridFract.y.oneMinus());
52
+ const pixelSize = fwidth(gridUV);
53
+ const gridMask = max$1(smoothstep(lineWidth.add(pixelSize.x), lineWidth, distToLineX), smoothstep(lineWidth.add(pixelSize.y), lineWidth, distToLineY));
54
+ return vec4$1(uniforms.color.uniform.rgb, uniforms.color.uniform.a.mul(gridMask));
55
+ }
56
+ };
57
+ var Grid_default = componentDefinition;
58
+ export { componentDefinition as n, Grid_default as t };
@@ -0,0 +1,188 @@
1
+ import { t as applyEdgeHandling } from "./edges-Bn_OIa_h.js";
2
+ import { a as transformEdges } from "./transformations-DxfQXZWi.js";
3
+ import { DataTexture, FloatType, LinearFilter, RGFormat } from "three";
4
+ import * as TSL from "three/tsl";
5
+ var DEFAULT_GRID_SIZE = 20;
6
+ var displacementStateCache = /* @__PURE__ */ new WeakMap();
7
+ var getOrCreateDisplacementState = (uniforms) => {
8
+ let state = displacementStateCache.get(uniforms);
9
+ const gridSize = uniforms?.gridSize?.uniform?.value ? Math.max(8, Math.min(128, Math.floor(uniforms.gridSize.uniform.value))) : DEFAULT_GRID_SIZE;
10
+ if (state && state.gridSize !== gridSize) {
11
+ state.texture.dispose();
12
+ state = void 0;
13
+ displacementStateCache.delete(uniforms);
14
+ }
15
+ if (!state) {
16
+ const data = new Float32Array(gridSize * gridSize * 2);
17
+ const texture = new DataTexture(data, gridSize, gridSize, RGFormat, FloatType);
18
+ texture.magFilter = LinearFilter;
19
+ texture.minFilter = LinearFilter;
20
+ texture.needsUpdate = true;
21
+ state = {
22
+ texture,
23
+ data,
24
+ tslNode: TSL.texture(texture),
25
+ gridSize
26
+ };
27
+ displacementStateCache.set(uniforms, state);
28
+ }
29
+ return state;
30
+ };
31
+ const componentDefinition = {
32
+ name: "GridDistortion",
33
+ category: "Interactive",
34
+ description: "Interactive grid distortion controlled by mouse position",
35
+ requiresRTT: true,
36
+ requiresChild: true,
37
+ props: {
38
+ intensity: {
39
+ default: 1,
40
+ description: "Strength of the distortion effect",
41
+ ui: {
42
+ type: "range",
43
+ min: 0,
44
+ max: 5,
45
+ step: .1,
46
+ label: "Intensity"
47
+ }
48
+ },
49
+ swirl: {
50
+ default: 0,
51
+ description: "Amount of swirl motion",
52
+ ui: {
53
+ type: "range",
54
+ min: 0,
55
+ max: 2,
56
+ step: .1,
57
+ label: "Swirl"
58
+ }
59
+ },
60
+ decay: {
61
+ default: 3,
62
+ description: "Rate of distortion decay (higher = faster)",
63
+ ui: {
64
+ type: "range",
65
+ min: 0,
66
+ max: 10,
67
+ step: .1,
68
+ label: "Decay"
69
+ }
70
+ },
71
+ radius: {
72
+ default: 1,
73
+ description: "Radius of the distortion effect",
74
+ ui: {
75
+ type: "range",
76
+ min: 0,
77
+ max: 3,
78
+ step: .01,
79
+ label: "Radius"
80
+ }
81
+ },
82
+ gridSize: {
83
+ default: 20,
84
+ description: "Resolution of the distortion grid (higher = more detailed)",
85
+ ui: {
86
+ type: "range",
87
+ min: 8,
88
+ max: 128,
89
+ step: 1,
90
+ label: "Grid Size"
91
+ }
92
+ },
93
+ edges: {
94
+ default: "stretch",
95
+ description: "How to handle edges when distortion pushes content out of bounds",
96
+ transform: transformEdges,
97
+ ui: {
98
+ type: "select",
99
+ options: [
100
+ {
101
+ label: "Stretch",
102
+ value: "stretch"
103
+ },
104
+ {
105
+ label: "Transparent",
106
+ value: "transparent"
107
+ },
108
+ {
109
+ label: "Mirror",
110
+ value: "mirror"
111
+ },
112
+ {
113
+ label: "Wrap",
114
+ value: "wrap"
115
+ }
116
+ ],
117
+ label: "Edges"
118
+ }
119
+ }
120
+ },
121
+ fragmentNode: ({ uniforms, onBeforeRender, childNode, onCleanup }) => {
122
+ const { vec2: vec2$1, vec4: vec4$1, float: float$1, uniform: uniform$1, screenUV: screenUV$1, convertToTexture: convertToTexture$1 } = TSL;
123
+ const { texture: displacementTexture, data: displacementData, tslNode: displacementField, gridSize: GRID_SIZE } = getOrCreateDisplacementState(uniforms);
124
+ const mouseVelX = uniform$1(0);
125
+ const mouseVelY = uniform$1(0);
126
+ let prevX = .5;
127
+ let prevY = .5;
128
+ let lastTime = Date.now();
129
+ onBeforeRender(({ pointer }) => {
130
+ const currentTime = Date.now();
131
+ const dt = Math.min((currentTime - lastTime) / 1e3, .016);
132
+ lastTime = currentTime;
133
+ const velX = dt > 0 ? (pointer.x - prevX) / dt : 0;
134
+ const velY = dt > 0 ? (pointer.y - prevY) / dt : 0;
135
+ mouseVelX.value = mouseVelX.value * .85 + velX * .15;
136
+ mouseVelY.value = mouseVelY.value * .85 + velY * .15;
137
+ const decay = uniforms.decay.uniform.value;
138
+ const intensity = uniforms.intensity.uniform.value;
139
+ const radius = uniforms.radius.uniform.value * .05;
140
+ const swirl = uniforms.swirl.uniform.value;
141
+ for (let i = 0; i < GRID_SIZE; i++) for (let j = 0; j < GRID_SIZE; j++) {
142
+ const idx = (i * GRID_SIZE + j) * 2;
143
+ displacementData[idx] *= 1 - decay * dt;
144
+ displacementData[idx + 1] *= 1 - decay * dt;
145
+ const cellX = (j + .5) / GRID_SIZE;
146
+ const cellY = (i + .5) / GRID_SIZE;
147
+ const dx = cellX - pointer.x;
148
+ const dy = cellY - pointer.y;
149
+ const dist = Math.sqrt(dx * dx + dy * dy);
150
+ if (dist < radius * 2 && Math.abs(velX) + Math.abs(velY) > .01) {
151
+ const influence = Math.exp(-dist * dist / (radius * radius));
152
+ displacementData[idx] += mouseVelX.value * influence * intensity * dt * .5;
153
+ displacementData[idx + 1] += mouseVelY.value * influence * intensity * dt * .5;
154
+ if (swirl > 0) {
155
+ const angle = Math.atan2(dy, dx) + Math.PI * .5;
156
+ displacementData[idx] += Math.cos(angle) * swirl * influence * dt * 2;
157
+ displacementData[idx + 1] += Math.sin(angle) * swirl * influence * dt * 2;
158
+ }
159
+ }
160
+ displacementData[idx] = Math.max(-1, Math.min(1, displacementData[idx]));
161
+ displacementData[idx + 1] = Math.max(-1, Math.min(1, displacementData[idx + 1]));
162
+ }
163
+ displacementTexture.needsUpdate = true;
164
+ prevX = pointer.x;
165
+ prevY = pointer.y;
166
+ });
167
+ onCleanup(() => {
168
+ displacementTexture.dispose();
169
+ displacementStateCache.delete(uniforms);
170
+ });
171
+ if (!childNode) return vec4$1(0, 0, 0, 0);
172
+ const childTexture = convertToTexture$1(childNode);
173
+ onCleanup(() => {
174
+ if (childTexture?.renderTarget?.dispose) childTexture.renderTarget.dispose();
175
+ });
176
+ const gridSizeUniform = uniforms.gridSize.uniform;
177
+ const gridScale = float$1(1).div(gridSizeUniform);
178
+ const gridCellUV = screenUV$1.div(gridScale).floor().mul(gridScale).add(gridScale.mul(.5));
179
+ const displacement = displacementField.sample(gridCellUV).xy;
180
+ const maxDisplacement = float$1(.1);
181
+ const negMaxDisplacement = float$1(-.1);
182
+ const clampedDisplacement = displacement.clamp(vec2$1(negMaxDisplacement, negMaxDisplacement), vec2$1(maxDisplacement, maxDisplacement));
183
+ const distortedUV = screenUV$1.sub(clampedDisplacement);
184
+ return applyEdgeHandling(distortedUV, childTexture.sample(distortedUV), childTexture, uniforms.edges.uniform);
185
+ }
186
+ };
187
+ var GridDistortion_default = componentDefinition;
188
+ export { componentDefinition as n, GridDistortion_default as t };
@@ -0,0 +1,14 @@
1
+ import * as TSL from "three/tsl";
2
+ const componentDefinition = {
3
+ name: "Group",
4
+ category: "Utilities",
5
+ description: "Container for organizing and composing child effects",
6
+ requiresChild: true,
7
+ props: {},
8
+ fragmentNode: ({ childNode }) => {
9
+ const { vec4: vec4$1 } = TSL;
10
+ return childNode || vec4$1(0);
11
+ }
12
+ };
13
+ var Group_default = componentDefinition;
14
+ export { componentDefinition as n, Group_default as t };
@@ -0,0 +1,65 @@
1
+ import { n as transformAngle } from "./transformations-DxfQXZWi.js";
2
+ import * as TSL from "three/tsl";
3
+ const componentDefinition = {
4
+ name: "Halftone",
5
+ category: "Stylize",
6
+ description: "Halftone dot pattern effect for printing aesthetics",
7
+ requiresChild: true,
8
+ props: {
9
+ frequency: {
10
+ default: 100,
11
+ description: "Frequency of the halftone dots",
12
+ ui: {
13
+ type: "range",
14
+ min: 10,
15
+ max: 300,
16
+ step: 1,
17
+ label: "Frequency"
18
+ }
19
+ },
20
+ angle: {
21
+ default: 45,
22
+ transform: transformAngle,
23
+ description: "Rotation angle of the pattern (in degrees)",
24
+ ui: {
25
+ type: "range",
26
+ min: 0,
27
+ max: 360,
28
+ step: 1,
29
+ label: "Angle"
30
+ }
31
+ },
32
+ smoothness: {
33
+ default: .1,
34
+ description: "Edge smoothness of the dots",
35
+ ui: {
36
+ type: "range",
37
+ min: 0,
38
+ max: .3,
39
+ step: .01,
40
+ label: "Smoothness"
41
+ }
42
+ }
43
+ },
44
+ fragmentNode: ({ uniforms, childNode }) => {
45
+ const { vec2: vec2$1, vec3: vec3$1, vec4: vec4$1, sin: sin$1, cos: cos$1, fract, length, smoothstep, dot: dot$1, screenUV: screenUV$1, viewportSize: viewportSize$1, radians } = TSL;
46
+ if (!childNode) return vec4$1(0);
47
+ const _uv = screenUV$1;
48
+ const frequency = uniforms.frequency.uniform;
49
+ const angleDegrees = uniforms.angle.uniform;
50
+ const smoothness = uniforms.smoothness.uniform;
51
+ const angle = radians(angleDegrees);
52
+ const aspect = viewportSize$1.x.div(viewportSize$1.y);
53
+ const aspectCorrectedUV = vec2$1(_uv.x.mul(aspect), _uv.y);
54
+ const c = cos$1(angle);
55
+ const s = sin$1(angle);
56
+ const gridUV = fract(vec2$1(dot$1(aspectCorrectedUV, vec2$1(c, s.negate())), dot$1(aspectCorrectedUV, vec2$1(s, c))).mul(frequency)).sub(.5);
57
+ const originalColor = childNode;
58
+ const dotSize = dot$1(originalColor.rgb, vec3$1(.299, .587, .114)).mul(.7).add(.15);
59
+ const dist = length(gridUV);
60
+ const dotPattern = smoothstep(dotSize.add(smoothness), dotSize.sub(smoothness), dist);
61
+ return vec4$1(originalColor.rgb.mul(dotPattern), originalColor.a.mul(dotPattern));
62
+ }
63
+ };
64
+ var Halftone_default = componentDefinition;
65
+ export { componentDefinition as n, Halftone_default as t };
@@ -0,0 +1,31 @@
1
+ import * as TSL from "three/tsl";
2
+ import { hue } from "three/src/nodes/display/ColorAdjustment";
3
+ const componentDefinition = {
4
+ name: "HueShift",
5
+ category: "Adjustments",
6
+ description: "Rotate hue around the color wheel",
7
+ requiresChild: true,
8
+ props: { shift: {
9
+ default: 0,
10
+ description: "The amount to shift the hue by",
11
+ ui: {
12
+ type: "range",
13
+ min: -180,
14
+ max: 180,
15
+ step: 1,
16
+ label: "Shift"
17
+ },
18
+ transform: (value) => value * Math.PI / 180
19
+ } },
20
+ fragmentNode: ({ uniforms, childNode }) => {
21
+ const { vec4: vec4$1 } = TSL;
22
+ if (!childNode) {
23
+ console.error("You must pass a child component into the Hue Shift shader.");
24
+ return vec4$1(0);
25
+ }
26
+ const sourceColor = childNode || vec4$1(0, 0, 0, 0);
27
+ return vec4$1(hue(sourceColor.rgb, uniforms.shift.uniform).rgb, sourceColor.a);
28
+ }
29
+ };
30
+ var HueShift_default = componentDefinition;
31
+ export { componentDefinition as n, HueShift_default as t };
@@ -0,0 +1,143 @@
1
+ import { SRGBColorSpace, Texture, TextureLoader } from "three/webgpu";
2
+ import * as TSL from "three/tsl";
3
+ const componentDefinition = {
4
+ name: "ImageTexture",
5
+ category: "Base Layers",
6
+ description: "Display an image with customizable object-fit modes",
7
+ acceptsUVContext: true,
8
+ props: {
9
+ url: {
10
+ default: "https://shaders.com/sample.jpg",
11
+ description: "Upload an image or provide a URL",
12
+ ui: {
13
+ type: "image-upload",
14
+ label: "Image"
15
+ }
16
+ },
17
+ objectFit: {
18
+ default: "cover",
19
+ description: "How the image should be sized within the viewport",
20
+ transform: (value) => {
21
+ return {
22
+ "cover": 0,
23
+ "contain": 1,
24
+ "fill": 2,
25
+ "scale-down": 3,
26
+ "none": 4
27
+ }[value] ?? 0;
28
+ },
29
+ ui: {
30
+ type: "select",
31
+ options: [
32
+ {
33
+ label: "Cover",
34
+ value: "cover"
35
+ },
36
+ {
37
+ label: "Contain",
38
+ value: "contain"
39
+ },
40
+ {
41
+ label: "Fill",
42
+ value: "fill"
43
+ },
44
+ {
45
+ label: "Scale Down",
46
+ value: "scale-down"
47
+ },
48
+ {
49
+ label: "None",
50
+ value: "none"
51
+ }
52
+ ],
53
+ label: "Object Fit"
54
+ }
55
+ }
56
+ },
57
+ fragmentNode: ({ uniforms, onCleanup, onBeforeRender, uvContext }) => {
58
+ const { vec2: vec2$1, vec4: vec4$1, float: float$1, texture, screenUV: screenUV$1, viewportSize: viewportSize$1, step: step$1, min: min$1, max: max$1 } = TSL;
59
+ const baseUV = uvContext ?? screenUV$1;
60
+ const loader = new TextureLoader();
61
+ let currentUrl = "";
62
+ let isLoading = false;
63
+ const placeholderTexture = new Texture();
64
+ placeholderTexture.colorSpace = SRGBColorSpace;
65
+ const textureNode = texture(placeholderTexture);
66
+ const imageAspectUniform = TSL.uniform(1);
67
+ const imageWidthUniform = TSL.uniform(0);
68
+ const imageHeightUniform = TSL.uniform(0);
69
+ const loadImage = (url) => {
70
+ if (!url || url.trim() === "" || isLoading) return;
71
+ isLoading = true;
72
+ try {
73
+ let resolvedUrl = url;
74
+ try {
75
+ resolvedUrl = new URL(url, window.location.href).href;
76
+ } catch (e) {}
77
+ loader.load(url, (loadedTexture) => {
78
+ loadedTexture.colorSpace = SRGBColorSpace;
79
+ const img = loadedTexture.image;
80
+ const newWidth = img.width || 1;
81
+ const newHeight = img.height || 1;
82
+ const newAspect = newWidth / newHeight;
83
+ loadedTexture.dispose();
84
+ currentUrl = url;
85
+ requestAnimationFrame(() => {
86
+ const currentImage = placeholderTexture.image;
87
+ if (currentImage && typeof currentImage === "object" && (currentImage.width !== newWidth || currentImage.height !== newHeight)) placeholderTexture.dispose();
88
+ imageAspectUniform.value = newAspect;
89
+ imageWidthUniform.value = newWidth;
90
+ imageHeightUniform.value = newHeight;
91
+ placeholderTexture.image = img;
92
+ placeholderTexture.colorSpace = SRGBColorSpace;
93
+ placeholderTexture.needsUpdate = true;
94
+ });
95
+ isLoading = false;
96
+ }, void 0, (error) => {
97
+ const isRelative = !url.startsWith("http://") && !url.startsWith("https://") && !url.startsWith("data:");
98
+ console.error(`[ImageTexture] Failed to load image\n Requested URL: ${url}\n Resolved URL: ${resolvedUrl}\n Path type: ${isRelative ? "relative" : "absolute"}\n Error:`, error);
99
+ isLoading = false;
100
+ });
101
+ } catch (error) {
102
+ console.error(`[ImageTexture] Error initiating image load:`, error);
103
+ isLoading = false;
104
+ }
105
+ };
106
+ setTimeout(() => {
107
+ const initialUrl = uniforms?.url?.uniform?.value ?? "";
108
+ if (initialUrl && initialUrl.trim() !== "") loadImage(initialUrl);
109
+ }, 0);
110
+ onBeforeRender(() => {
111
+ const newUrl = uniforms?.url?.uniform?.value ?? "";
112
+ if (newUrl !== currentUrl && !isLoading) loadImage(newUrl);
113
+ });
114
+ onCleanup(() => {
115
+ placeholderTexture.dispose();
116
+ });
117
+ const uv = baseUV;
118
+ const viewportAspect = viewportSize$1.x.div(viewportSize$1.y);
119
+ const objectFitMode = uniforms.objectFit.uniform;
120
+ const coverScale = max$1(viewportAspect.div(imageAspectUniform), float$1(1));
121
+ const coverUVScale = vec2$1(imageAspectUniform.div(viewportAspect).mul(coverScale), coverScale);
122
+ const containScale = min$1(viewportAspect.div(imageAspectUniform), float$1(1));
123
+ const containUVScale = vec2$1(imageAspectUniform.div(viewportAspect).mul(containScale), containScale);
124
+ const fillUVScale = vec2$1(1, 1);
125
+ const scaleDownScale = min$1(min$1(viewportAspect.div(imageAspectUniform), float$1(1)), min$1(viewportSize$1.x.div(imageWidthUniform), viewportSize$1.y.div(imageHeightUniform)));
126
+ const scaleDownUVScale = vec2$1(imageAspectUniform.div(viewportAspect).mul(scaleDownScale), scaleDownScale);
127
+ const noneScale = min$1(viewportSize$1.x.div(imageWidthUniform), viewportSize$1.y.div(imageHeightUniform));
128
+ const noneUVScale = vec2$1(imageAspectUniform.div(viewportAspect).mul(noneScale), noneScale);
129
+ const isCover = step$1(objectFitMode, float$1(.5));
130
+ const isContain = step$1(float$1(.5), objectFitMode).mul(step$1(objectFitMode, float$1(1.5)));
131
+ const isFill = step$1(float$1(1.5), objectFitMode).mul(step$1(objectFitMode, float$1(2.5)));
132
+ const isScaleDown = step$1(float$1(2.5), objectFitMode).mul(step$1(objectFitMode, float$1(3.5)));
133
+ const isNone = step$1(float$1(3.5), objectFitMode);
134
+ const uvScale = vec2$1(0).add(coverUVScale.mul(isCover)).add(containUVScale.mul(isContain)).add(fillUVScale.mul(isFill)).add(scaleDownUVScale.mul(isScaleDown)).add(noneUVScale.mul(isNone));
135
+ const adjustedUV = uv.sub(vec2$1(.5)).div(uvScale).add(vec2$1(.5));
136
+ const finalUV = vec2$1(adjustedUV.x, float$1(1).sub(adjustedUV.y));
137
+ const sampledColor = textureNode.sample(finalUV);
138
+ const isOutOfBounds = TSL.or(TSL.or(finalUV.x.lessThan(0), finalUV.x.greaterThan(1)), TSL.or(finalUV.y.lessThan(0), finalUV.y.greaterThan(1)));
139
+ return vec4$1(sampledColor.rgb, TSL.select(isOutOfBounds, float$1(0), sampledColor.a));
140
+ }
141
+ };
142
+ var ImageTexture_default = componentDefinition;
143
+ export { componentDefinition as n, ImageTexture_default as t };
@@ -0,0 +1,21 @@
1
+ import * as TSL from "three/tsl";
2
+ const componentDefinition = {
3
+ name: "Invert",
4
+ category: "Adjustments",
5
+ description: "Invert RGB colors while preserving alpha",
6
+ requiresChild: true,
7
+ props: {},
8
+ fragmentNode: ({ childNode }) => {
9
+ const { vec4: vec4$1, vec3: vec3$1 } = TSL;
10
+ if (!childNode) {
11
+ console.error("You must pass a child component into the Invert shader.");
12
+ return vec4$1(0);
13
+ }
14
+ const sourceColor = childNode || vec4$1(0, 0, 0, 0);
15
+ const alpha = sourceColor.a;
16
+ const unpremultiplied = alpha.greaterThan(0).select(sourceColor.rgb.div(alpha), vec3$1(0, 0, 0));
17
+ return vec4$1(vec3$1(1, 1, 1).sub(unpremultiplied).mul(alpha), alpha);
18
+ }
19
+ };
20
+ var Invert_default = componentDefinition;
21
+ export { componentDefinition as n, Invert_default as t };