@paper-design/shaders 0.0.0-canary.390a3d9

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 (114) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +7 -0
  3. package/dist/get-empty-pixel.d.ts +1 -0
  4. package/dist/get-empty-pixel.js +19 -0
  5. package/dist/get-empty-pixel.js.map +7 -0
  6. package/dist/get-shader-color-from-string.d.ts +3 -0
  7. package/dist/get-shader-color-from-string.js +93 -0
  8. package/dist/get-shader-color-from-string.js.map +7 -0
  9. package/dist/get-shader-noise-texture.d.ts +1 -0
  10. package/dist/get-shader-noise-texture.js +19 -0
  11. package/dist/get-shader-noise-texture.js.map +7 -0
  12. package/dist/index.d.ts +53 -0
  13. package/dist/index.js +168 -0
  14. package/dist/index.js.map +7 -0
  15. package/dist/shader-color-spaces.d.ts +6 -0
  16. package/dist/shader-color-spaces.js +96 -0
  17. package/dist/shader-color-spaces.js.map +7 -0
  18. package/dist/shader-mount.d.ts +130 -0
  19. package/dist/shader-mount.js +483 -0
  20. package/dist/shader-mount.js.map +7 -0
  21. package/dist/shader-sizing.d.ts +35 -0
  22. package/dist/shader-sizing.js +230 -0
  23. package/dist/shader-sizing.js.map +7 -0
  24. package/dist/shader-utils.d.ts +10 -0
  25. package/dist/shader-utils.js +131 -0
  26. package/dist/shader-utils.js.map +7 -0
  27. package/dist/shaders/color-panels.d.ts +50 -0
  28. package/dist/shaders/color-panels.js +224 -0
  29. package/dist/shaders/color-panels.js.map +7 -0
  30. package/dist/shaders/dithering.d.ts +56 -0
  31. package/dist/shaders/dithering.js +223 -0
  32. package/dist/shaders/dithering.js.map +7 -0
  33. package/dist/shaders/dot-grid.d.ts +51 -0
  34. package/dist/shaders/dot-grid.js +110 -0
  35. package/dist/shaders/dot-grid.js.map +7 -0
  36. package/dist/shaders/dot-orbit.d.ts +39 -0
  37. package/dist/shaders/dot-orbit.js +124 -0
  38. package/dist/shaders/dot-orbit.js.map +7 -0
  39. package/dist/shaders/fluted-glass.d.ts +73 -0
  40. package/dist/shaders/fluted-glass.js +187 -0
  41. package/dist/shaders/fluted-glass.js.map +7 -0
  42. package/dist/shaders/god-rays.d.ts +45 -0
  43. package/dist/shaders/god-rays.js +133 -0
  44. package/dist/shaders/god-rays.js.map +7 -0
  45. package/dist/shaders/grain-gradient.d.ts +58 -0
  46. package/dist/shaders/grain-gradient.js +289 -0
  47. package/dist/shaders/grain-gradient.js.map +7 -0
  48. package/dist/shaders/heatmap.d.ts +31 -0
  49. package/dist/shaders/heatmap.js +303 -0
  50. package/dist/shaders/heatmap.js.map +7 -0
  51. package/dist/shaders/image-dithering.d.ts +49 -0
  52. package/dist/shaders/image-dithering.js +163 -0
  53. package/dist/shaders/image-dithering.js.map +7 -0
  54. package/dist/shaders/image-halftone-dots.d.ts +46 -0
  55. package/dist/shaders/image-halftone-dots.js +337 -0
  56. package/dist/shaders/image-halftone-dots.js.map +7 -0
  57. package/dist/shaders/liquid-metal.d.ts +66 -0
  58. package/dist/shaders/liquid-metal.js +627 -0
  59. package/dist/shaders/liquid-metal.js.map +7 -0
  60. package/dist/shaders/mesh-gradient.d.ts +33 -0
  61. package/dist/shaders/mesh-gradient.js +136 -0
  62. package/dist/shaders/mesh-gradient.js.map +7 -0
  63. package/dist/shaders/metaballs.d.ts +35 -0
  64. package/dist/shaders/metaballs.js +112 -0
  65. package/dist/shaders/metaballs.js.map +7 -0
  66. package/dist/shaders/neuro-noise.d.ts +27 -0
  67. package/dist/shaders/neuro-noise.js +80 -0
  68. package/dist/shaders/neuro-noise.js.map +7 -0
  69. package/dist/shaders/paper-texture.d.ts +53 -0
  70. package/dist/shaders/paper-texture.js +248 -0
  71. package/dist/shaders/paper-texture.js.map +7 -0
  72. package/dist/shaders/perlin-noise.d.ts +33 -0
  73. package/dist/shaders/perlin-noise.js +195 -0
  74. package/dist/shaders/perlin-noise.js.map +7 -0
  75. package/dist/shaders/pulsing-border.d.ts +72 -0
  76. package/dist/shaders/pulsing-border.js +237 -0
  77. package/dist/shaders/pulsing-border.js.map +7 -0
  78. package/dist/shaders/simplex-noise.d.ts +27 -0
  79. package/dist/shaders/simplex-noise.js +100 -0
  80. package/dist/shaders/simplex-noise.js.map +7 -0
  81. package/dist/shaders/smoke-ring.d.ts +39 -0
  82. package/dist/shaders/smoke-ring.js +130 -0
  83. package/dist/shaders/smoke-ring.js.map +7 -0
  84. package/dist/shaders/spiral.d.ts +41 -0
  85. package/dist/shaders/spiral.js +81 -0
  86. package/dist/shaders/spiral.js.map +7 -0
  87. package/dist/shaders/static-mesh-gradient.d.ts +42 -0
  88. package/dist/shaders/static-mesh-gradient.js +139 -0
  89. package/dist/shaders/static-mesh-gradient.js.map +7 -0
  90. package/dist/shaders/static-radial-gradient.d.ts +50 -0
  91. package/dist/shaders/static-radial-gradient.js +195 -0
  92. package/dist/shaders/static-radial-gradient.js.map +7 -0
  93. package/dist/shaders/swirl.d.ts +42 -0
  94. package/dist/shaders/swirl.js +102 -0
  95. package/dist/shaders/swirl.js.map +7 -0
  96. package/dist/shaders/voronoi.d.ts +44 -0
  97. package/dist/shaders/voronoi.js +139 -0
  98. package/dist/shaders/voronoi.js.map +7 -0
  99. package/dist/shaders/warp.d.ts +54 -0
  100. package/dist/shaders/warp.js +132 -0
  101. package/dist/shaders/warp.js.map +7 -0
  102. package/dist/shaders/water.d.ts +39 -0
  103. package/dist/shaders/water.js +120 -0
  104. package/dist/shaders/water.js.map +7 -0
  105. package/dist/shaders/waves.d.ts +38 -0
  106. package/dist/shaders/waves.js +66 -0
  107. package/dist/shaders/waves.js.map +7 -0
  108. package/dist/types.d.ts +3 -0
  109. package/dist/types.js +6 -0
  110. package/dist/types.js.map +7 -0
  111. package/dist/vertex-shader.d.ts +2 -0
  112. package/dist/vertex-shader.js +211 -0
  113. package/dist/vertex-shader.js.map +7 -0
  114. package/package.json +27 -0
@@ -0,0 +1,224 @@
1
+ /* * * * * * * * * * * * * * * * * * * * * * * * * * * *
2
+ * Paper Shaders *
3
+ * https://github.com/paper-design/shaders *
4
+ * * * * * * * * * * * * * * * * * * * * * * * * * * * */
5
+
6
+ import { sizingVariablesDeclaration } from "../shader-sizing.js";
7
+ import { declarePI, colorBandingFix } from "../shader-utils.js";
8
+ const colorPanelsMeta = {
9
+ maxColorCount: 7
10
+ };
11
+ const colorPanelsFragmentShader = `#version 300 es
12
+ precision lowp float;
13
+
14
+ uniform float u_time;
15
+ uniform mediump float u_scale;
16
+
17
+ uniform vec4 u_colors[${colorPanelsMeta.maxColorCount}];
18
+ uniform float u_colorsCount;
19
+ uniform vec4 u_colorBack;
20
+ uniform float u_density;
21
+ uniform float u_angle1;
22
+ uniform float u_angle2;
23
+ uniform float u_length;
24
+ uniform bool u_edges;
25
+ uniform float u_blur;
26
+ uniform float u_fadeIn;
27
+ uniform float u_fadeOut;
28
+ uniform float u_gradient;
29
+
30
+ ${sizingVariablesDeclaration}
31
+
32
+ out vec4 fragColor;
33
+
34
+ ${declarePI}
35
+
36
+ const float zLimit = .5;
37
+
38
+ vec2 getPanel(float angle, vec2 uv, float invLength, float aa) {
39
+ float sinA = sin(angle);
40
+ float cosA = cos(angle);
41
+
42
+ float denom = sinA - uv.y * cosA;
43
+ if (abs(denom) < .01) return vec2(0.);
44
+
45
+ float z = uv.y / denom;
46
+
47
+ if (z <= 0. || z > zLimit) return vec2(0.);
48
+
49
+ float zRatio = z / zLimit;
50
+ float panelMap = 1. - zRatio;
51
+ float x = uv.x * (cosA * z + 1.) * invLength;
52
+
53
+ float zOffset = zRatio - .5;
54
+ float left = -.5 + zOffset * u_angle1;
55
+ float right = .5 - zOffset * u_angle2;
56
+ float blurX = aa + 2. * panelMap * u_blur;
57
+
58
+ float leftEdge1 = left - blurX;
59
+ float leftEdge2 = left + .25 * blurX;
60
+ float rightEdge1 = right - .25 * blurX;
61
+ float rightEdge2 = right + blurX;
62
+
63
+ float panel = smoothstep(leftEdge1, leftEdge2, x) * (1.0 - smoothstep(rightEdge1, rightEdge2, x));
64
+ panel *= mix(0., panel, smoothstep(0., .01 / max(u_scale, 1e-6), panelMap));
65
+
66
+ float midScreen = abs(sinA);
67
+ if (u_edges == true) {
68
+ panelMap = mix(.99, panelMap, panel * clamp(panelMap / (.15 * (1. - pow(midScreen, .1))), 0.0, 1.0));
69
+ } else if (midScreen < .07) {
70
+ panel *= (midScreen * 15.);
71
+ }
72
+
73
+ return vec2(panel, panelMap);
74
+ }
75
+
76
+ vec4 blendColor(vec4 colorA, float panelMask, float panelMap) {
77
+ float fade = 1. - smoothstep(.97 - .97 * u_fadeIn, 1., panelMap);
78
+
79
+ fade *= smoothstep(-.2 * (1. - u_fadeOut), u_fadeOut, panelMap);
80
+
81
+ vec3 blendedRGB = mix(vec3(0.), colorA.rgb, fade);
82
+ float blendedAlpha = mix(0., colorA.a, fade);
83
+
84
+ return vec4(blendedRGB, blendedAlpha) * panelMask;
85
+ }
86
+
87
+ void main() {
88
+ vec2 uv = v_objectUV;
89
+ uv *= 1.25;
90
+
91
+ float t = .02 * u_time;
92
+ t = fract(t);
93
+ bool reverseTime = (t < 0.5);
94
+
95
+ vec3 color = vec3(0.);
96
+ float opacity = 0.;
97
+
98
+ float aa = .005 / u_scale;
99
+ int colorsCount = int(u_colorsCount);
100
+
101
+ vec4 premultipliedColors[${colorPanelsMeta.maxColorCount}];
102
+ for (int i = 0; i < ${colorPanelsMeta.maxColorCount}; i++) {
103
+ if (i >= colorsCount) break;
104
+ vec4 c = u_colors[i];
105
+ c.rgb *= c.a;
106
+ premultipliedColors[i] = c;
107
+ }
108
+
109
+ float invLength = 1.5 / max(u_length, .001);
110
+
111
+ float totalColorWeight = 0.;
112
+ int panelsNumber = 12;
113
+
114
+ float densityNormalizer = 1.;
115
+ if (colorsCount == 4) {
116
+ panelsNumber = 16;
117
+ densityNormalizer = 1.34;
118
+ } else if (colorsCount == 5) {
119
+ panelsNumber = 20;
120
+ densityNormalizer = 1.67;
121
+ } else if (colorsCount == 7) {
122
+ panelsNumber = 14;
123
+ densityNormalizer = 1.17;
124
+ }
125
+
126
+ float fPanelsNumber = float(panelsNumber);
127
+
128
+ float totalPanelsShape = 0.;
129
+ float panelGrad = 1. - clamp(u_gradient, 0., 1.);
130
+
131
+ for (int set = 0; set < 2; set++) {
132
+ bool isForward = (set == 0 && !reverseTime) || (set == 1 && reverseTime);
133
+ if (!isForward) continue;
134
+
135
+ for (int i = 0; i <= 20; i++) {
136
+ if (i >= panelsNumber) break;
137
+
138
+ int idx = panelsNumber - 1 - i;
139
+
140
+ float offset = float(idx) / fPanelsNumber;
141
+ if (set == 1) {
142
+ offset += .5;
143
+ }
144
+
145
+ float densityFract = densityNormalizer * fract(t + offset);
146
+ float angleNorm = densityFract / u_density;
147
+ if (densityFract >= .5 || angleNorm >= .3) continue;
148
+
149
+ float smoothDensity = clamp((.5 - densityFract) / .1, 0., 1.) * clamp(densityFract / .01, 0., 1.);
150
+ float smoothAngle = clamp((.3 - angleNorm) / .05, 0., 1.);
151
+ if (smoothDensity * smoothAngle < .001) continue;
152
+
153
+ if (angleNorm > .5) {
154
+ angleNorm = 0.5;
155
+ }
156
+ vec2 panel = getPanel(angleNorm * TWO_PI + PI, uv, invLength, aa);
157
+ if (panel[0] <= .001) continue;
158
+ float panelMask = panel[0] * smoothDensity * smoothAngle;
159
+ float panelMap = panel[1];
160
+
161
+ int colorIdx = idx % colorsCount;
162
+ int nextColorIdx = (idx + 1) % colorsCount;
163
+
164
+ vec4 colorA = premultipliedColors[colorIdx];
165
+ vec4 colorB = premultipliedColors[nextColorIdx];
166
+
167
+ colorA = mix(colorA, colorB, max(0., smoothstep(.0, .45, panelMap) - panelGrad));
168
+ vec4 blended = blendColor(colorA, panelMask, panelMap);
169
+ color = blended.rgb + color * (1. - blended.a);
170
+ opacity = blended.a + opacity * (1. - blended.a);
171
+ }
172
+
173
+
174
+ for (int i = 0; i <= 20; i++) {
175
+ if (i >= panelsNumber) break;
176
+
177
+ int idx = panelsNumber - 1 - i;
178
+
179
+ float offset = float(idx) / fPanelsNumber;
180
+ if (set == 0) {
181
+ offset += .5;
182
+ }
183
+
184
+ float densityFract = densityNormalizer * fract(-t + offset);
185
+ float angleNorm = -densityFract / u_density;
186
+ if (densityFract >= .5 || angleNorm < -.3) continue;
187
+
188
+ float smoothDensity = clamp((.5 - densityFract) / .1, 0., 1.) * clamp(densityFract / .01, 0., 1.);
189
+ float smoothAngle = clamp((angleNorm + .3) / .05, 0., 1.);
190
+ if (smoothDensity * smoothAngle < .001) continue;
191
+
192
+ vec2 panel = getPanel(angleNorm * TWO_PI + PI, uv, invLength, aa);
193
+ float panelMask = panel[0] * smoothDensity * smoothAngle;
194
+ if (panelMask <= .001) continue;
195
+ float panelMap = panel[1];
196
+
197
+ int colorIdx = (colorsCount - (idx % colorsCount)) % colorsCount;
198
+ if (colorIdx < 0) colorIdx += colorsCount;
199
+ int nextColorIdx = (colorIdx + 1) % colorsCount;
200
+
201
+ vec4 colorA = premultipliedColors[colorIdx];
202
+ vec4 colorB = premultipliedColors[nextColorIdx];
203
+
204
+ colorA = mix(colorA, colorB, max(0., smoothstep(.0, .45, panelMap) - panelGrad));
205
+ vec4 blended = blendColor(colorA, panelMask, panelMap);
206
+ color = blended.rgb + color * (1. - blended.a);
207
+ opacity = blended.a + opacity * (1. - blended.a);
208
+ }
209
+ }
210
+
211
+ vec3 bgColor = u_colorBack.rgb * u_colorBack.a;
212
+ color = color + bgColor * (1.0 - opacity);
213
+ opacity = opacity + u_colorBack.a * (1.0 - opacity);
214
+
215
+ ${colorBandingFix}
216
+
217
+ fragColor = vec4(color, opacity);
218
+ }
219
+ `;
220
+ export {
221
+ colorPanelsFragmentShader,
222
+ colorPanelsMeta
223
+ };
224
+ //# sourceMappingURL=color-panels.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/shaders/color-panels.ts"],
4
+ "sourcesContent": ["import type { vec4 } from '../types.js';\nimport type { ShaderMotionParams } from '../shader-mount.js';\nimport { sizingVariablesDeclaration, type ShaderSizingParams, type ShaderSizingUniforms } from '../shader-sizing.js';\nimport { declarePI, colorBandingFix } from '../shader-utils.js';\n\nexport const colorPanelsMeta = {\n maxColorCount: 7,\n} as const;\n\n/**\n * Pseudo-3D panels rotating around a central axis\n *\n * Uniforms include:\n * - u_colorBack (RGBA)\n * - u_colors (vec4[]), u_colorsCount (float used as integer)\n * - u_density: angle between every 2 panels\n * - u_angle1, u_angle2: skew angle applied to all panes\n * - u_length: panel length (relative to total height)\n * - u_edges: faking edges effect\n * - u_blur: side blur (0 for sharp edges)\n * - u_fadeIn: transparency near central axis\n * - u_fadeOut: transparency near viewer\n * - u_gradient: color mixing within panes (0 = single color, 1 = two colors)\n *\n */\n\n// language=GLSL\nexport const colorPanelsFragmentShader: string = `#version 300 es\nprecision lowp float;\n\nuniform float u_time;\nuniform mediump float u_scale;\n\nuniform vec4 u_colors[${colorPanelsMeta.maxColorCount}];\nuniform float u_colorsCount;\nuniform vec4 u_colorBack;\nuniform float u_density;\nuniform float u_angle1;\nuniform float u_angle2;\nuniform float u_length;\nuniform bool u_edges;\nuniform float u_blur;\nuniform float u_fadeIn;\nuniform float u_fadeOut;\nuniform float u_gradient;\n\n${sizingVariablesDeclaration}\n\nout vec4 fragColor;\n\n${declarePI}\n\nconst float zLimit = .5;\n\nvec2 getPanel(float angle, vec2 uv, float invLength, float aa) {\n float sinA = sin(angle);\n float cosA = cos(angle);\n\n float denom = sinA - uv.y * cosA;\n if (abs(denom) < .01) return vec2(0.);\n \n float z = uv.y / denom;\n\n if (z <= 0. || z > zLimit) return vec2(0.);\n\n float zRatio = z / zLimit;\n float panelMap = 1. - zRatio;\n float x = uv.x * (cosA * z + 1.) * invLength;\n\n float zOffset = zRatio - .5;\n float left = -.5 + zOffset * u_angle1;\n float right = .5 - zOffset * u_angle2;\n float blurX = aa + 2. * panelMap * u_blur;\n\n float leftEdge1 = left - blurX;\n float leftEdge2 = left + .25 * blurX;\n float rightEdge1 = right - .25 * blurX;\n float rightEdge2 = right + blurX;\n\n float panel = smoothstep(leftEdge1, leftEdge2, x) * (1.0 - smoothstep(rightEdge1, rightEdge2, x));\n panel *= mix(0., panel, smoothstep(0., .01 / max(u_scale, 1e-6), panelMap));\n\n float midScreen = abs(sinA);\n if (u_edges == true) {\n panelMap = mix(.99, panelMap, panel * clamp(panelMap / (.15 * (1. - pow(midScreen, .1))), 0.0, 1.0));\n } else if (midScreen < .07) {\n panel *= (midScreen * 15.);\n }\n \n return vec2(panel, panelMap);\n}\n\nvec4 blendColor(vec4 colorA, float panelMask, float panelMap) {\n float fade = 1. - smoothstep(.97 - .97 * u_fadeIn, 1., panelMap);\n \n fade *= smoothstep(-.2 * (1. - u_fadeOut), u_fadeOut, panelMap);\n\n vec3 blendedRGB = mix(vec3(0.), colorA.rgb, fade);\n float blendedAlpha = mix(0., colorA.a, fade);\n\n return vec4(blendedRGB, blendedAlpha) * panelMask;\n}\n\nvoid main() {\n vec2 uv = v_objectUV;\n uv *= 1.25;\n\n float t = .02 * u_time;\n t = fract(t);\n bool reverseTime = (t < 0.5);\n\n vec3 color = vec3(0.);\n float opacity = 0.;\n\n float aa = .005 / u_scale;\n int colorsCount = int(u_colorsCount);\n\n vec4 premultipliedColors[${colorPanelsMeta.maxColorCount}];\n for (int i = 0; i < ${colorPanelsMeta.maxColorCount}; i++) {\n if (i >= colorsCount) break;\n vec4 c = u_colors[i];\n c.rgb *= c.a;\n premultipliedColors[i] = c;\n }\n\n float invLength = 1.5 / max(u_length, .001);\n\n float totalColorWeight = 0.;\n int panelsNumber = 12;\n\n float densityNormalizer = 1.;\n if (colorsCount == 4) {\n panelsNumber = 16;\n densityNormalizer = 1.34;\n } else if (colorsCount == 5) {\n panelsNumber = 20;\n densityNormalizer = 1.67;\n } else if (colorsCount == 7) {\n panelsNumber = 14;\n densityNormalizer = 1.17;\n }\n\n float fPanelsNumber = float(panelsNumber);\n\n float totalPanelsShape = 0.;\n float panelGrad = 1. - clamp(u_gradient, 0., 1.);\n\n for (int set = 0; set < 2; set++) {\n bool isForward = (set == 0 && !reverseTime) || (set == 1 && reverseTime);\n if (!isForward) continue;\n\n for (int i = 0; i <= 20; i++) {\n if (i >= panelsNumber) break;\n\n int idx = panelsNumber - 1 - i;\n\n float offset = float(idx) / fPanelsNumber;\n if (set == 1) {\n offset += .5;\n }\n\n float densityFract = densityNormalizer * fract(t + offset);\n float angleNorm = densityFract / u_density;\n if (densityFract >= .5 || angleNorm >= .3) continue;\n\n float smoothDensity = clamp((.5 - densityFract) / .1, 0., 1.) * clamp(densityFract / .01, 0., 1.);\n float smoothAngle = clamp((.3 - angleNorm) / .05, 0., 1.);\n if (smoothDensity * smoothAngle < .001) continue;\n\n if (angleNorm > .5) {\n angleNorm = 0.5;\n }\n vec2 panel = getPanel(angleNorm * TWO_PI + PI, uv, invLength, aa);\n if (panel[0] <= .001) continue;\n float panelMask = panel[0] * smoothDensity * smoothAngle;\n float panelMap = panel[1];\n\n int colorIdx = idx % colorsCount;\n int nextColorIdx = (idx + 1) % colorsCount;\n\n vec4 colorA = premultipliedColors[colorIdx];\n vec4 colorB = premultipliedColors[nextColorIdx];\n\n colorA = mix(colorA, colorB, max(0., smoothstep(.0, .45, panelMap) - panelGrad));\n vec4 blended = blendColor(colorA, panelMask, panelMap);\n color = blended.rgb + color * (1. - blended.a);\n opacity = blended.a + opacity * (1. - blended.a);\n }\n\n\n for (int i = 0; i <= 20; i++) {\n if (i >= panelsNumber) break;\n\n int idx = panelsNumber - 1 - i;\n\n float offset = float(idx) / fPanelsNumber;\n if (set == 0) {\n offset += .5;\n }\n\n float densityFract = densityNormalizer * fract(-t + offset);\n float angleNorm = -densityFract / u_density;\n if (densityFract >= .5 || angleNorm < -.3) continue;\n\n float smoothDensity = clamp((.5 - densityFract) / .1, 0., 1.) * clamp(densityFract / .01, 0., 1.);\n float smoothAngle = clamp((angleNorm + .3) / .05, 0., 1.);\n if (smoothDensity * smoothAngle < .001) continue;\n\n vec2 panel = getPanel(angleNorm * TWO_PI + PI, uv, invLength, aa);\n float panelMask = panel[0] * smoothDensity * smoothAngle;\n if (panelMask <= .001) continue;\n float panelMap = panel[1];\n\n int colorIdx = (colorsCount - (idx % colorsCount)) % colorsCount;\n if (colorIdx < 0) colorIdx += colorsCount;\n int nextColorIdx = (colorIdx + 1) % colorsCount;\n\n vec4 colorA = premultipliedColors[colorIdx];\n vec4 colorB = premultipliedColors[nextColorIdx];\n\n colorA = mix(colorA, colorB, max(0., smoothstep(.0, .45, panelMap) - panelGrad));\n vec4 blended = blendColor(colorA, panelMask, panelMap);\n color = blended.rgb + color * (1. - blended.a);\n opacity = blended.a + opacity * (1. - blended.a);\n }\n }\n\n vec3 bgColor = u_colorBack.rgb * u_colorBack.a;\n color = color + bgColor * (1.0 - opacity);\n opacity = opacity + u_colorBack.a * (1.0 - opacity);\n\n ${colorBandingFix}\n\n fragColor = vec4(color, opacity);\n}\n`;\n\nexport interface ColorPanelsUniforms extends ShaderSizingUniforms {\n u_colors: vec4[];\n u_colorsCount: number;\n u_colorBack: [number, number, number, number];\n u_angle1: number;\n u_angle2: number;\n u_length: number;\n u_edges: boolean;\n u_blur: number;\n u_fadeIn: number;\n u_fadeOut: number;\n u_density: number;\n u_gradient: number;\n}\n\nexport interface ColorPanelsParams extends ShaderSizingParams, ShaderMotionParams {\n colors?: string[];\n colorBack?: string;\n angle1?: number;\n angle2?: number;\n length?: number;\n edges?: boolean;\n blur?: number;\n fadeIn?: number;\n fadeOut?: number;\n density?: number;\n gradient?: number;\n}\n"],
5
+ "mappings": ";;;;;AAEA,SAAS,kCAAsF;AAC/F,SAAS,WAAW,uBAAuB;AAEpC,MAAM,kBAAkB;AAAA,EAC7B,eAAe;AACjB;AAoBO,MAAM,4BAAoC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,wBAMzB,gBAAgB,aAAa;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAanD,0BAA0B;AAAA;AAAA;AAAA;AAAA,EAI1B,SAAS;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,6BAmEkB,gBAAgB,aAAa;AAAA,wBAClC,gBAAgB,aAAa;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAiHjD,eAAe;AAAA;AAAA;AAAA;AAAA;",
6
+ "names": []
7
+ }
@@ -0,0 +1,56 @@
1
+ import type { ShaderMotionParams } from '../shader-mount.js';
2
+ import { type ShaderSizingParams, type ShaderSizingUniforms } from '../shader-sizing.js';
3
+ /**
4
+ * 2-color dithering effect over animated abstract shapes
5
+ *
6
+ * Uniforms:
7
+ * - u_colorBack, u_colorFront (RGBA)
8
+ * - pxSize: px size relative to canvas resolution
9
+ * - u_shape (float used as integer):
10
+ * ---- 1: simplex noise pattern
11
+ * ---- 2: warp noise pattern
12
+ * ---- 3: columns of dots moving vertically
13
+ * ---- 4: sine wave
14
+ * ---- 5: ripple effect
15
+ * ---- 6: swirl animation
16
+ * ---- 7: rotating sphere
17
+ * - u_type (float used as integer)
18
+ * ---- 1: random dithering
19
+ * ---- 2: 2x2 Bayer matrix
20
+ * ---- 3: 4x4 Bayer matrix
21
+ * ---- 4: 8x8 Bayer matrix
22
+ *
23
+ * Note: pixelization is applied to the shapes BEFORE dithering, meaning pixels don't react to scaling and fit
24
+ */
25
+ export declare const ditheringFragmentShader: string;
26
+ export interface DitheringUniforms extends ShaderSizingUniforms {
27
+ u_colorBack: [number, number, number, number];
28
+ u_colorFront: [number, number, number, number];
29
+ u_shape: (typeof DitheringShapes)[DitheringShape];
30
+ u_type: (typeof DitheringTypes)[DitheringType];
31
+ u_pxSize: number;
32
+ }
33
+ export interface DitheringParams extends ShaderSizingParams, ShaderMotionParams {
34
+ colorBack?: string;
35
+ colorFront?: string;
36
+ shape?: DitheringShape;
37
+ type?: DitheringType;
38
+ size?: number;
39
+ }
40
+ export declare const DitheringShapes: {
41
+ readonly simplex: 1;
42
+ readonly warp: 2;
43
+ readonly dots: 3;
44
+ readonly wave: 4;
45
+ readonly ripple: 5;
46
+ readonly swirl: 6;
47
+ readonly sphere: 7;
48
+ };
49
+ export type DitheringShape = keyof typeof DitheringShapes;
50
+ export declare const DitheringTypes: {
51
+ readonly random: 1;
52
+ readonly '2x2': 2;
53
+ readonly '4x4': 3;
54
+ readonly '8x8': 4;
55
+ };
56
+ export type DitheringType = keyof typeof DitheringTypes;
@@ -0,0 +1,223 @@
1
+ /* * * * * * * * * * * * * * * * * * * * * * * * * * * *
2
+ * Paper Shaders *
3
+ * https://github.com/paper-design/shaders *
4
+ * * * * * * * * * * * * * * * * * * * * * * * * * * * */
5
+
6
+ import {
7
+ sizingUniformsDeclaration,
8
+ sizingUV,
9
+ drawSizingHelpers
10
+ } from "../shader-sizing.js";
11
+ import { simplexNoise, declarePI, proceduralHash11, proceduralHash21 } from "../shader-utils.js";
12
+ const ditheringFragmentShader = `#version 300 es
13
+ precision mediump float;
14
+
15
+ uniform float u_time;
16
+ uniform vec2 u_resolution;
17
+ uniform float u_pixelRatio;
18
+
19
+ ${sizingUniformsDeclaration}
20
+
21
+ uniform vec4 u_colorBack;
22
+ uniform vec4 u_colorFront;
23
+ uniform float u_shape;
24
+ uniform float u_type;
25
+ uniform float u_pxSize;
26
+
27
+ out vec4 fragColor;
28
+
29
+ ${simplexNoise}
30
+ ${declarePI}
31
+ ${proceduralHash11}
32
+ ${proceduralHash21}
33
+
34
+ float getSimplexNoise(vec2 uv, float t) {
35
+ float noise = .5 * snoise(uv - vec2(0., .3 * t));
36
+ noise += .5 * snoise(2. * uv + vec2(0., .32 * t));
37
+
38
+ return noise;
39
+ }
40
+
41
+ const int bayer2x2[4] = int[4](0, 2, 3, 1);
42
+ const int bayer4x4[16] = int[16](
43
+ 0, 8, 2, 10,
44
+ 12, 4, 14, 6,
45
+ 3, 11, 1, 9,
46
+ 15, 7, 13, 5
47
+ );
48
+
49
+ const int bayer8x8[64] = int[64](
50
+ 0, 32, 8, 40, 2, 34, 10, 42,
51
+ 48, 16, 56, 24, 50, 18, 58, 26,
52
+ 12, 44, 4, 36, 14, 46, 6, 38,
53
+ 60, 28, 52, 20, 62, 30, 54, 22,
54
+ 3, 35, 11, 43, 1, 33, 9, 41,
55
+ 51, 19, 59, 27, 49, 17, 57, 25,
56
+ 15, 47, 7, 39, 13, 45, 5, 37,
57
+ 63, 31, 55, 23, 61, 29, 53, 21
58
+ );
59
+
60
+ float getBayerValue(vec2 uv, int size) {
61
+ ivec2 pos = ivec2(fract(uv / float(size)) * float(size));
62
+ int index = pos.y * size + pos.x;
63
+
64
+ if (size == 2) {
65
+ return float(bayer2x2[index]) / 4.0;
66
+ } else if (size == 4) {
67
+ return float(bayer4x4[index]) / 16.0;
68
+ } else if (size == 8) {
69
+ return float(bayer8x8[index]) / 64.0;
70
+ }
71
+ return 0.0;
72
+ }
73
+
74
+
75
+ void main() {
76
+ float t = .5 * u_time;
77
+
78
+ #define USE_PATTERN_SIZING
79
+ #define USE_OBJECT_SIZING
80
+ #define USE_PIXELIZATION
81
+ // #define ADD_HELPERS
82
+
83
+ ${sizingUV}
84
+
85
+ vec2 dithering_uv = pxSizeUv;
86
+ vec2 ditheringNoise_uv = uv * u_resolution;
87
+ vec2 shape_uv = objectUV;
88
+ if (u_shape < 3.5) {
89
+ shape_uv = patternUV;
90
+ }
91
+
92
+ float shape = 0.;
93
+ if (u_shape < 1.5) {
94
+ // Simplex noise
95
+ shape_uv *= .001;
96
+
97
+ shape = 0.5 + 0.5 * getSimplexNoise(shape_uv, t);
98
+ shape = smoothstep(0.3, 0.9, shape);
99
+
100
+ } else if (u_shape < 2.5) {
101
+ // Warp
102
+ shape_uv *= .003;
103
+
104
+ for (float i = 1.0; i < 6.0; i++) {
105
+ shape_uv.x += 0.6 / i * cos(i * 2.5 * shape_uv.y + t);
106
+ shape_uv.y += 0.6 / i * cos(i * 1.5 * shape_uv.x + t);
107
+ }
108
+
109
+ shape = .15 / max(0.001, abs(sin(t - shape_uv.y - shape_uv.x)));
110
+ shape = smoothstep(0.02, 1., shape);
111
+
112
+ } else if (u_shape < 3.5) {
113
+ // Dots
114
+ shape_uv *= .05;
115
+
116
+ float stripeIdx = floor(2. * shape_uv.x / TWO_PI);
117
+ float rand = hash11(stripeIdx * 10.);
118
+ rand = sign(rand - .5) * pow(.1 + abs(rand), .4);
119
+ shape = sin(shape_uv.x) * cos(shape_uv.y - 5. * rand * t);
120
+ shape = pow(abs(shape), 6.);
121
+
122
+ } else if (u_shape < 4.5) {
123
+ // Sine wave
124
+ shape_uv *= 4.;
125
+
126
+ float wave = cos(.5 * shape_uv.x - 2. * t) * sin(1.5 * shape_uv.x + t) * (.75 + .25 * cos(3. * t));
127
+ shape = 1. - smoothstep(-1., 1., shape_uv.y + wave);
128
+
129
+ } else if (u_shape < 5.5) {
130
+ // Ripple
131
+
132
+ float dist = length(shape_uv);
133
+ float waves = sin(pow(dist, 1.7) * 7. - 3. * t) * .5 + .5;
134
+ shape = waves;
135
+
136
+ } else if (u_shape < 6.5) {
137
+ // Swirl
138
+
139
+ float l = length(shape_uv);
140
+ float angle = 6. * atan(shape_uv.y, shape_uv.x) + 4. * t;
141
+ float twist = 1.2;
142
+ float offset = 1. / pow(max(l, 1e-6), twist) + angle / TWO_PI;
143
+ float mid = smoothstep(0., 1., pow(l, twist));
144
+ shape = mix(0., fract(offset), mid);
145
+
146
+ } else {
147
+ // Sphere
148
+ shape_uv *= 2.;
149
+
150
+ float d = 1. - pow(length(shape_uv), 2.);
151
+ vec3 pos = vec3(shape_uv, sqrt(max(0., d)));
152
+ vec3 lightPos = normalize(vec3(cos(1.5 * t), .8, sin(1.25 * t)));
153
+ shape = .5 + .5 * dot(lightPos, pos);
154
+ shape *= step(0., d);
155
+ }
156
+
157
+
158
+ int type = int(floor(u_type));
159
+ float dithering = 0.0;
160
+
161
+ switch (type) {
162
+ case 1: {
163
+ dithering = step(hash21(ditheringNoise_uv), shape);
164
+ } break;
165
+ case 2:
166
+ dithering = getBayerValue(dithering_uv, 2);
167
+ break;
168
+ case 3:
169
+ dithering = getBayerValue(dithering_uv, 4);
170
+ break;
171
+ default:
172
+ dithering = getBayerValue(dithering_uv, 8);
173
+ break;
174
+ }
175
+
176
+ dithering -= .5;
177
+ float res = step(.5, shape + dithering);
178
+
179
+ vec3 fgColor = u_colorFront.rgb * u_colorFront.a;
180
+ float fgOpacity = u_colorFront.a;
181
+ vec3 bgColor = u_colorBack.rgb * u_colorBack.a;
182
+ float bgOpacity = u_colorBack.a;
183
+
184
+ vec3 color = fgColor * res;
185
+ float opacity = fgOpacity * res;
186
+
187
+ color += bgColor * (1. - opacity);
188
+ opacity += bgOpacity * (1. - opacity);
189
+
190
+ #ifdef ADD_HELPERS
191
+ vec2 helperBox = objectHelperBox;
192
+ vec2 boxSize = objectBoxSize;
193
+ if (u_shape < 3.5) {
194
+ helperBox = patternHelperBox;
195
+ boxSize = patternBoxSize;
196
+ }
197
+ ${drawSizingHelpers}
198
+ #endif
199
+
200
+ fragColor = vec4(color, opacity);
201
+ }
202
+ `;
203
+ const DitheringShapes = {
204
+ simplex: 1,
205
+ warp: 2,
206
+ dots: 3,
207
+ wave: 4,
208
+ ripple: 5,
209
+ swirl: 6,
210
+ sphere: 7
211
+ };
212
+ const DitheringTypes = {
213
+ "random": 1,
214
+ "2x2": 2,
215
+ "4x4": 3,
216
+ "8x8": 4
217
+ };
218
+ export {
219
+ DitheringShapes,
220
+ DitheringTypes,
221
+ ditheringFragmentShader
222
+ };
223
+ //# sourceMappingURL=dithering.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/shaders/dithering.ts"],
4
+ "sourcesContent": ["import type { ShaderMotionParams } from '../shader-mount.js';\nimport {\n sizingUniformsDeclaration,\n type ShaderSizingParams,\n type ShaderSizingUniforms,\n sizingUV,\n drawSizingHelpers,\n} from '../shader-sizing.js';\nimport { simplexNoise, declarePI, proceduralHash11, proceduralHash21 } from '../shader-utils.js';\n\n/**\n * 2-color dithering effect over animated abstract shapes\n *\n * Uniforms:\n * - u_colorBack, u_colorFront (RGBA)\n * - pxSize: px size relative to canvas resolution\n * - u_shape (float used as integer):\n * ---- 1: simplex noise pattern\n * ---- 2: warp noise pattern\n * ---- 3: columns of dots moving vertically\n * ---- 4: sine wave\n * ---- 5: ripple effect\n * ---- 6: swirl animation\n * ---- 7: rotating sphere\n * - u_type (float used as integer)\n * ---- 1: random dithering\n * ---- 2: 2x2 Bayer matrix\n * ---- 3: 4x4 Bayer matrix\n * ---- 4: 8x8 Bayer matrix\n *\n * Note: pixelization is applied to the shapes BEFORE dithering, meaning pixels don't react to scaling and fit\n */\n\n// language=GLSL\nexport const ditheringFragmentShader: string = `#version 300 es\nprecision mediump float;\n\nuniform float u_time;\nuniform vec2 u_resolution;\nuniform float u_pixelRatio;\n\n${sizingUniformsDeclaration}\n\nuniform vec4 u_colorBack;\nuniform vec4 u_colorFront;\nuniform float u_shape;\nuniform float u_type;\nuniform float u_pxSize;\n\nout vec4 fragColor;\n\n${simplexNoise}\n${declarePI}\n${proceduralHash11}\n${proceduralHash21}\n\nfloat getSimplexNoise(vec2 uv, float t) {\n float noise = .5 * snoise(uv - vec2(0., .3 * t));\n noise += .5 * snoise(2. * uv + vec2(0., .32 * t));\n\n return noise;\n}\n\nconst int bayer2x2[4] = int[4](0, 2, 3, 1);\nconst int bayer4x4[16] = int[16](\n 0, 8, 2, 10,\n 12, 4, 14, 6,\n 3, 11, 1, 9,\n 15, 7, 13, 5\n);\n\nconst int bayer8x8[64] = int[64](\n 0, 32, 8, 40, 2, 34, 10, 42,\n 48, 16, 56, 24, 50, 18, 58, 26,\n 12, 44, 4, 36, 14, 46, 6, 38,\n 60, 28, 52, 20, 62, 30, 54, 22,\n 3, 35, 11, 43, 1, 33, 9, 41,\n 51, 19, 59, 27, 49, 17, 57, 25,\n 15, 47, 7, 39, 13, 45, 5, 37,\n 63, 31, 55, 23, 61, 29, 53, 21\n);\n\nfloat getBayerValue(vec2 uv, int size) {\n ivec2 pos = ivec2(fract(uv / float(size)) * float(size));\n int index = pos.y * size + pos.x;\n\n if (size == 2) {\n return float(bayer2x2[index]) / 4.0;\n } else if (size == 4) {\n return float(bayer4x4[index]) / 16.0;\n } else if (size == 8) {\n return float(bayer8x8[index]) / 64.0;\n }\n return 0.0;\n}\n\n\nvoid main() {\n float t = .5 * u_time;\n\n #define USE_PATTERN_SIZING\n #define USE_OBJECT_SIZING\n #define USE_PIXELIZATION\n // #define ADD_HELPERS\n\n ${sizingUV}\n\n vec2 dithering_uv = pxSizeUv;\n vec2 ditheringNoise_uv = uv * u_resolution;\n vec2 shape_uv = objectUV;\n if (u_shape < 3.5) {\n shape_uv = patternUV;\n }\n\n float shape = 0.;\n if (u_shape < 1.5) {\n // Simplex noise\n shape_uv *= .001;\n\n shape = 0.5 + 0.5 * getSimplexNoise(shape_uv, t);\n shape = smoothstep(0.3, 0.9, shape);\n\n } else if (u_shape < 2.5) {\n // Warp\n shape_uv *= .003;\n\n for (float i = 1.0; i < 6.0; i++) {\n shape_uv.x += 0.6 / i * cos(i * 2.5 * shape_uv.y + t);\n shape_uv.y += 0.6 / i * cos(i * 1.5 * shape_uv.x + t);\n }\n\n shape = .15 / max(0.001, abs(sin(t - shape_uv.y - shape_uv.x)));\n shape = smoothstep(0.02, 1., shape);\n\n } else if (u_shape < 3.5) {\n // Dots\n shape_uv *= .05;\n\n float stripeIdx = floor(2. * shape_uv.x / TWO_PI);\n float rand = hash11(stripeIdx * 10.);\n rand = sign(rand - .5) * pow(.1 + abs(rand), .4);\n shape = sin(shape_uv.x) * cos(shape_uv.y - 5. * rand * t);\n shape = pow(abs(shape), 6.);\n\n } else if (u_shape < 4.5) {\n // Sine wave\n shape_uv *= 4.;\n\n float wave = cos(.5 * shape_uv.x - 2. * t) * sin(1.5 * shape_uv.x + t) * (.75 + .25 * cos(3. * t));\n shape = 1. - smoothstep(-1., 1., shape_uv.y + wave);\n\n } else if (u_shape < 5.5) {\n // Ripple\n\n float dist = length(shape_uv);\n float waves = sin(pow(dist, 1.7) * 7. - 3. * t) * .5 + .5;\n shape = waves;\n\n } else if (u_shape < 6.5) {\n // Swirl\n\n float l = length(shape_uv);\n float angle = 6. * atan(shape_uv.y, shape_uv.x) + 4. * t;\n float twist = 1.2;\n float offset = 1. / pow(max(l, 1e-6), twist) + angle / TWO_PI;\n float mid = smoothstep(0., 1., pow(l, twist));\n shape = mix(0., fract(offset), mid);\n\n } else {\n // Sphere\n shape_uv *= 2.;\n\n float d = 1. - pow(length(shape_uv), 2.);\n vec3 pos = vec3(shape_uv, sqrt(max(0., d)));\n vec3 lightPos = normalize(vec3(cos(1.5 * t), .8, sin(1.25 * t)));\n shape = .5 + .5 * dot(lightPos, pos);\n shape *= step(0., d);\n }\n\n\n int type = int(floor(u_type));\n float dithering = 0.0;\n\n switch (type) {\n case 1: {\n dithering = step(hash21(ditheringNoise_uv), shape);\n } break;\n case 2:\n dithering = getBayerValue(dithering_uv, 2);\n break;\n case 3:\n dithering = getBayerValue(dithering_uv, 4);\n break;\n default:\n dithering = getBayerValue(dithering_uv, 8);\n break;\n }\n\n dithering -= .5;\n float res = step(.5, shape + dithering);\n\n vec3 fgColor = u_colorFront.rgb * u_colorFront.a;\n float fgOpacity = u_colorFront.a;\n vec3 bgColor = u_colorBack.rgb * u_colorBack.a;\n float bgOpacity = u_colorBack.a;\n\n vec3 color = fgColor * res;\n float opacity = fgOpacity * res;\n\n color += bgColor * (1. - opacity);\n opacity += bgOpacity * (1. - opacity);\n\n #ifdef ADD_HELPERS\n vec2 helperBox = objectHelperBox;\n vec2 boxSize = objectBoxSize;\n if (u_shape < 3.5) {\n helperBox = patternHelperBox;\n boxSize = patternBoxSize;\n }\n ${drawSizingHelpers}\n #endif\n\n fragColor = vec4(color, opacity);\n}\n`;\n\nexport interface DitheringUniforms extends ShaderSizingUniforms {\n u_colorBack: [number, number, number, number];\n u_colorFront: [number, number, number, number];\n u_shape: (typeof DitheringShapes)[DitheringShape];\n u_type: (typeof DitheringTypes)[DitheringType];\n u_pxSize: number;\n}\n\nexport interface DitheringParams extends ShaderSizingParams, ShaderMotionParams {\n colorBack?: string;\n colorFront?: string;\n shape?: DitheringShape;\n type?: DitheringType;\n size?: number;\n}\n\nexport const DitheringShapes = {\n simplex: 1,\n warp: 2,\n dots: 3,\n wave: 4,\n ripple: 5,\n swirl: 6,\n sphere: 7,\n} as const;\n\nexport type DitheringShape = keyof typeof DitheringShapes;\n\nexport const DitheringTypes = {\n 'random': 1,\n '2x2': 2,\n '4x4': 3,\n '8x8': 4,\n} as const;\n\nexport type DitheringType = keyof typeof DitheringTypes;\n"],
5
+ "mappings": ";;;;;AACA;AAAA,EACE;AAAA,EAGA;AAAA,EACA;AAAA,OACK;AACP,SAAS,cAAc,WAAW,kBAAkB,wBAAwB;AA0BrE,MAAM,0BAAkC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAO7C,yBAAyB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAUzB,YAAY;AAAA,EACZ,SAAS;AAAA,EACT,gBAAgB;AAAA,EAChB,gBAAgB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAmDd,QAAQ;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,MAkHN,iBAAiB;AAAA;AAAA;AAAA;AAAA;AAAA;AAuBhB,MAAM,kBAAkB;AAAA,EAC7B,SAAS;AAAA,EACT,MAAM;AAAA,EACN,MAAM;AAAA,EACN,MAAM;AAAA,EACN,QAAQ;AAAA,EACR,OAAO;AAAA,EACP,QAAQ;AACV;AAIO,MAAM,iBAAiB;AAAA,EAC5B,UAAU;AAAA,EACV,OAAO;AAAA,EACP,OAAO;AAAA,EACP,OAAO;AACT;",
6
+ "names": []
7
+ }
@@ -0,0 +1,51 @@
1
+ import { type ShaderSizingParams, type ShaderSizingUniforms } from '../shader-sizing.js';
2
+ /**
3
+ * Static grid pattern
4
+ *
5
+ * Uniforms:
6
+ * - u_colorBack, u_colorFill, u_colorStroke (vec4 RGBA)
7
+ * - u_dotSize (px): base shape size
8
+ * - u_sizeRange (0..1): randomizes the size of shape between 0 and u_dotSize
9
+ * - u_strokeWidth (px): the stroke (to be added to u_dotSize)
10
+ * - u_gapX, u_gapY (px): pattern spacing
11
+ * - u_opacityRange (0..1): variety of shape opacity
12
+ * - u_shape (float used as integer):
13
+ * ---- 1: circle
14
+ * ---- 2: square
15
+ * ---- 3: triangle
16
+ * ---- 4: diamond
17
+ * ---- 5: cross
18
+ *
19
+ */
20
+ export declare const dotGridFragmentShader: string;
21
+ export interface DotGridUniforms extends ShaderSizingUniforms {
22
+ u_colorBack: [number, number, number, number];
23
+ u_colorFill: [number, number, number, number];
24
+ u_colorStroke: [number, number, number, number];
25
+ u_dotSize: number;
26
+ u_gapX: number;
27
+ u_gapY: number;
28
+ u_strokeWidth: number;
29
+ u_sizeRange: number;
30
+ u_opacityRange: number;
31
+ u_shape: (typeof DotGridShapes)[DotGridShape];
32
+ }
33
+ export interface DotGridParams extends ShaderSizingParams {
34
+ colorBack?: string;
35
+ colorFill?: string;
36
+ colorStroke?: string;
37
+ size?: number;
38
+ gapX?: number;
39
+ gapY?: number;
40
+ strokeWidth?: number;
41
+ sizeRange?: number;
42
+ opacityRange?: number;
43
+ shape?: DotGridShape;
44
+ }
45
+ export declare const DotGridShapes: {
46
+ readonly circle: 0;
47
+ readonly diamond: 1;
48
+ readonly square: 2;
49
+ readonly triangle: 3;
50
+ };
51
+ export type DotGridShape = keyof typeof DotGridShapes;