@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,110 @@
1
+ /* * * * * * * * * * * * * * * * * * * * * * * * * * * *
2
+ * Paper Shaders *
3
+ * https://github.com/paper-design/shaders *
4
+ * * * * * * * * * * * * * * * * * * * * * * * * * * * */
5
+
6
+ import { sizingVariablesDeclaration } from "../shader-sizing.js";
7
+ import { declarePI, simplexNoise } from "../shader-utils.js";
8
+ const dotGridFragmentShader = `#version 300 es
9
+ precision mediump float;
10
+
11
+ uniform vec4 u_colorBack;
12
+ uniform vec4 u_colorFill;
13
+ uniform vec4 u_colorStroke;
14
+ uniform float u_dotSize;
15
+ uniform float u_gapX;
16
+ uniform float u_gapY;
17
+ uniform float u_strokeWidth;
18
+ uniform float u_sizeRange;
19
+ uniform float u_opacityRange;
20
+ uniform float u_shape;
21
+
22
+ ${sizingVariablesDeclaration}
23
+
24
+ out vec4 fragColor;
25
+
26
+ ${declarePI}
27
+ ${simplexNoise}
28
+
29
+ float polygon(vec2 p, float N, float rot) {
30
+ float a = atan(p.x, p.y) + rot;
31
+ float r = TWO_PI / float(N);
32
+
33
+ return cos(floor(.5 + a / r) * r - a) * length(p);
34
+ }
35
+
36
+ void main() {
37
+
38
+ // x100 is a default multiplier between vertex and fragmant shaders
39
+ // we use it to avoid UV presision issues
40
+ vec2 shape_uv = 100. * v_patternUV;
41
+
42
+ vec2 gap = max(abs(vec2(u_gapX, u_gapY)), vec2(1e-6));
43
+ vec2 grid = fract(shape_uv / gap) + 1e-4;
44
+ vec2 grid_idx = floor(shape_uv / gap);
45
+ float sizeRandomizer = .5 + .8 * snoise(2. * vec2(grid_idx.x * 100., grid_idx.y));
46
+ float opacity_randomizer = .5 + .7 * snoise(2. * vec2(grid_idx.y, grid_idx.x));
47
+
48
+ vec2 center = vec2(0.5) - 1e-3;
49
+ vec2 p = (grid - center) * vec2(u_gapX, u_gapY);
50
+
51
+ float baseSize = u_dotSize * (1. - sizeRandomizer * u_sizeRange);
52
+ float strokeWidth = u_strokeWidth * (1. - sizeRandomizer * u_sizeRange);
53
+
54
+ float dist;
55
+ if (u_shape < 0.5) {
56
+ // Circle
57
+ dist = length(p);
58
+ } else if (u_shape < 1.5) {
59
+ // Diamond
60
+ strokeWidth *= 1.5;
61
+ dist = polygon(1.5 * p, 4., .25 * PI);
62
+ } else if (u_shape < 2.5) {
63
+ // Square
64
+ dist = polygon(1.03 * p, 4., 1e-3);
65
+ } else {
66
+ // Triangle
67
+ strokeWidth *= 1.5;
68
+ p = p * 2. - 1.;
69
+ p *= .9;
70
+ p.y = 1. - p.y;
71
+ p.y -= .75 * baseSize;
72
+ dist = polygon(p, 3., 1e-3);
73
+ }
74
+
75
+ float edgeWidth = fwidth(dist);
76
+ float shapeOuter = 1. - smoothstep(baseSize - edgeWidth, baseSize + edgeWidth, dist - strokeWidth);
77
+ float shapeInner = 1. - smoothstep(baseSize - edgeWidth, baseSize + edgeWidth, dist);
78
+ float stroke = shapeOuter - shapeInner;
79
+
80
+ float dotOpacity = max(0., 1. - opacity_randomizer * u_opacityRange);
81
+ stroke *= dotOpacity;
82
+ shapeInner *= dotOpacity;
83
+
84
+ stroke *= u_colorStroke.a;
85
+ shapeInner *= u_colorFill.a;
86
+
87
+ vec3 color = vec3(0.);
88
+ color += stroke * u_colorStroke.rgb;
89
+ color += shapeInner * u_colorFill.rgb;
90
+ color += (1. - shapeInner - stroke) * u_colorBack.rgb * u_colorBack.a;
91
+
92
+ float opacity = 0.;
93
+ opacity += stroke;
94
+ opacity += shapeInner;
95
+ opacity += (1. - opacity) * u_colorBack.a;
96
+
97
+ fragColor = vec4(color, opacity);
98
+ }
99
+ `;
100
+ const DotGridShapes = {
101
+ circle: 0,
102
+ diamond: 1,
103
+ square: 2,
104
+ triangle: 3
105
+ };
106
+ export {
107
+ DotGridShapes,
108
+ dotGridFragmentShader
109
+ };
110
+ //# sourceMappingURL=dot-grid.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/shaders/dot-grid.ts"],
4
+ "sourcesContent": ["import { sizingVariablesDeclaration, type ShaderSizingParams, type ShaderSizingUniforms } from '../shader-sizing.js';\nimport { declarePI, simplexNoise } from '../shader-utils.js';\n\n/**\n * Static grid pattern\n *\n * Uniforms:\n * - u_colorBack, u_colorFill, u_colorStroke (vec4 RGBA)\n * - u_dotSize (px): base shape size\n * - u_sizeRange (0..1): randomizes the size of shape between 0 and u_dotSize\n * - u_strokeWidth (px): the stroke (to be added to u_dotSize)\n * - u_gapX, u_gapY (px): pattern spacing\n * - u_opacityRange (0..1): variety of shape opacity\n * - u_shape (float used as integer):\n * ---- 1: circle\n * ---- 2: square\n * ---- 3: triangle\n * ---- 4: diamond\n * ---- 5: cross\n *\n */\n\n// language=GLSL\nexport const dotGridFragmentShader: string = `#version 300 es\nprecision mediump float;\n\nuniform vec4 u_colorBack;\nuniform vec4 u_colorFill;\nuniform vec4 u_colorStroke;\nuniform float u_dotSize;\nuniform float u_gapX;\nuniform float u_gapY;\nuniform float u_strokeWidth;\nuniform float u_sizeRange;\nuniform float u_opacityRange;\nuniform float u_shape;\n\n${sizingVariablesDeclaration}\n\nout vec4 fragColor;\n\n${declarePI}\n${simplexNoise}\n\nfloat polygon(vec2 p, float N, float rot) {\n float a = atan(p.x, p.y) + rot;\n float r = TWO_PI / float(N);\n\n return cos(floor(.5 + a / r) * r - a) * length(p);\n}\n\nvoid main() {\n\n // x100 is a default multiplier between vertex and fragmant shaders\n // we use it to avoid UV presision issues\n vec2 shape_uv = 100. * v_patternUV;\n\n vec2 gap = max(abs(vec2(u_gapX, u_gapY)), vec2(1e-6));\n vec2 grid = fract(shape_uv / gap) + 1e-4;\n vec2 grid_idx = floor(shape_uv / gap);\n float sizeRandomizer = .5 + .8 * snoise(2. * vec2(grid_idx.x * 100., grid_idx.y));\n float opacity_randomizer = .5 + .7 * snoise(2. * vec2(grid_idx.y, grid_idx.x));\n\n vec2 center = vec2(0.5) - 1e-3;\n vec2 p = (grid - center) * vec2(u_gapX, u_gapY);\n\n float baseSize = u_dotSize * (1. - sizeRandomizer * u_sizeRange);\n float strokeWidth = u_strokeWidth * (1. - sizeRandomizer * u_sizeRange);\n\n float dist;\n if (u_shape < 0.5) {\n // Circle\n dist = length(p);\n } else if (u_shape < 1.5) {\n // Diamond\n strokeWidth *= 1.5;\n dist = polygon(1.5 * p, 4., .25 * PI);\n } else if (u_shape < 2.5) {\n // Square\n dist = polygon(1.03 * p, 4., 1e-3);\n } else {\n // Triangle\n strokeWidth *= 1.5;\n p = p * 2. - 1.;\n p *= .9;\n p.y = 1. - p.y;\n p.y -= .75 * baseSize;\n dist = polygon(p, 3., 1e-3);\n }\n\n float edgeWidth = fwidth(dist);\n float shapeOuter = 1. - smoothstep(baseSize - edgeWidth, baseSize + edgeWidth, dist - strokeWidth);\n float shapeInner = 1. - smoothstep(baseSize - edgeWidth, baseSize + edgeWidth, dist);\n float stroke = shapeOuter - shapeInner;\n\n float dotOpacity = max(0., 1. - opacity_randomizer * u_opacityRange);\n stroke *= dotOpacity;\n shapeInner *= dotOpacity;\n\n stroke *= u_colorStroke.a;\n shapeInner *= u_colorFill.a;\n\n vec3 color = vec3(0.);\n color += stroke * u_colorStroke.rgb;\n color += shapeInner * u_colorFill.rgb;\n color += (1. - shapeInner - stroke) * u_colorBack.rgb * u_colorBack.a;\n\n float opacity = 0.;\n opacity += stroke;\n opacity += shapeInner;\n opacity += (1. - opacity) * u_colorBack.a;\n\n fragColor = vec4(color, opacity);\n}\n`;\n\nexport interface DotGridUniforms extends ShaderSizingUniforms {\n u_colorBack: [number, number, number, number];\n u_colorFill: [number, number, number, number];\n u_colorStroke: [number, number, number, number];\n u_dotSize: number;\n u_gapX: number;\n u_gapY: number;\n u_strokeWidth: number;\n u_sizeRange: number;\n u_opacityRange: number;\n u_shape: (typeof DotGridShapes)[DotGridShape];\n}\n\nexport interface DotGridParams extends ShaderSizingParams {\n colorBack?: string;\n colorFill?: string;\n colorStroke?: string;\n size?: number;\n gapX?: number;\n gapY?: number;\n strokeWidth?: number;\n sizeRange?: number;\n opacityRange?: number;\n shape?: DotGridShape;\n}\n\nexport const DotGridShapes = {\n circle: 0,\n diamond: 1,\n square: 2,\n triangle: 3,\n} as const;\n\nexport type DotGridShape = keyof typeof DotGridShapes;\n"],
5
+ "mappings": ";;;;;AAAA,SAAS,kCAAsF;AAC/F,SAAS,WAAW,oBAAoB;AAsBjC,MAAM,wBAAgC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAc3C,0BAA0B;AAAA;AAAA;AAAA;AAAA,EAI1B,SAAS;AAAA,EACT,YAAY;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;AAoGP,MAAM,gBAAgB;AAAA,EAC3B,QAAQ;AAAA,EACR,SAAS;AAAA,EACT,QAAQ;AAAA,EACR,UAAU;AACZ;",
6
+ "names": []
7
+ }
@@ -0,0 +1,39 @@
1
+ import type { vec4 } from '../types.js';
2
+ import type { ShaderMotionParams } from '../shader-mount.js';
3
+ import { type ShaderSizingParams, type ShaderSizingUniforms } from '../shader-sizing.js';
4
+ export declare const dotOrbitMeta: {
5
+ readonly maxColorCount: 10;
6
+ };
7
+ /**
8
+ * Animated dot pattern with dots orbiting around their grid positions
9
+ *
10
+ * Uniforms:
11
+ * - u_colorBack (RGBA)
12
+ * - u_colors (vec4[]), u_colorsCount (float used as integer)
13
+ * - u_stepsPerColor: discrete color steps between u_colors
14
+ * - u_size (0..1): dot radius (relative to cell size)
15
+ * - u_sizeRange (0..1): randomizes dot radius between 0 and u_size
16
+ * - u_spreading (0..1): max orbit distance of each dot around the cell center
17
+ *
18
+ * - u_noiseTexture (sampler2D): pre-computed randomizer source
19
+ *
20
+ */
21
+ export declare const dotOrbitFragmentShader: string;
22
+ export interface DotOrbitUniforms extends ShaderSizingUniforms {
23
+ u_colorBack: [number, number, number, number];
24
+ u_colors: vec4[];
25
+ u_colorsCount: number;
26
+ u_size: number;
27
+ u_sizeRange: number;
28
+ u_spreading: number;
29
+ u_stepsPerColor: number;
30
+ u_noiseTexture?: HTMLImageElement;
31
+ }
32
+ export interface DotOrbitParams extends ShaderSizingParams, ShaderMotionParams {
33
+ colorBack?: string;
34
+ colors?: string[];
35
+ size?: number;
36
+ sizeRange?: number;
37
+ spreading?: number;
38
+ stepsPerColor?: number;
39
+ }
@@ -0,0 +1,124 @@
1
+ /* * * * * * * * * * * * * * * * * * * * * * * * * * * *
2
+ * Paper Shaders *
3
+ * https://github.com/paper-design/shaders *
4
+ * * * * * * * * * * * * * * * * * * * * * * * * * * * */
5
+
6
+ import { sizingVariablesDeclaration } from "../shader-sizing.js";
7
+ import { declarePI, rotation2, textureRandomizerR, textureRandomizerGB } from "../shader-utils.js";
8
+ const dotOrbitMeta = {
9
+ maxColorCount: 10
10
+ };
11
+ const dotOrbitFragmentShader = `#version 300 es
12
+ precision mediump float;
13
+
14
+ uniform float u_time;
15
+
16
+ uniform sampler2D u_noiseTexture;
17
+
18
+ uniform vec4 u_colorBack;
19
+ uniform vec4 u_colors[${dotOrbitMeta.maxColorCount}];
20
+ uniform float u_colorsCount;
21
+ uniform float u_stepsPerColor;
22
+ uniform float u_size;
23
+ uniform float u_sizeRange;
24
+ uniform float u_spreading;
25
+
26
+ ${sizingVariablesDeclaration}
27
+
28
+ out vec4 fragColor;
29
+
30
+ ${declarePI}
31
+ ${rotation2}
32
+ ${textureRandomizerR}
33
+ ${textureRandomizerGB}
34
+
35
+
36
+ vec3 voronoiShape(vec2 uv, float time) {
37
+ vec2 i_uv = floor(uv);
38
+ vec2 f_uv = fract(uv);
39
+
40
+ float spreading = .25 * clamp(u_spreading, 0., 1.);
41
+
42
+ float minDist = 1.;
43
+ vec2 randomizer = vec2(0.);
44
+ for (int y = -1; y <= 1; y++) {
45
+ for (int x = -1; x <= 1; x++) {
46
+ vec2 tileOffset = vec2(float(x), float(y));
47
+ vec2 rand = randomGB(i_uv + tileOffset);
48
+ vec2 cellCenter = vec2(.5 + 1e-4);
49
+ cellCenter += spreading * cos(time + TWO_PI * rand);
50
+ cellCenter -= .5;
51
+ cellCenter = rotate(cellCenter, randomR(vec2(rand.x, rand.y)) + .1 * time);
52
+ cellCenter += .5;
53
+ float dist = length(tileOffset + cellCenter - f_uv);
54
+ if (dist < minDist) {
55
+ minDist = dist;
56
+ randomizer = rand;
57
+ }
58
+ minDist = min(minDist, dist);
59
+ }
60
+ }
61
+
62
+ return vec3(minDist, randomizer);
63
+ }
64
+
65
+ void main() {
66
+
67
+ vec2 shape_uv = v_patternUV;
68
+ shape_uv *= 1.5;
69
+
70
+ const float firstFrameOffset = -10.;
71
+ float t = u_time + firstFrameOffset;
72
+
73
+ vec3 voronoi = voronoiShape(shape_uv, t) + 1e-4;
74
+
75
+ float radius = .25 * clamp(u_size, 0., 1.) - .5 * clamp(u_sizeRange, 0., 1.) * voronoi[2];
76
+ float dist = voronoi[0];
77
+ float edgeWidth = fwidth(dist);
78
+ float dots = 1. - smoothstep(radius - edgeWidth, radius + edgeWidth, dist);
79
+
80
+ float shape = voronoi[1];
81
+
82
+ float mixer = shape * (u_colorsCount - 1.);
83
+ mixer = (shape - .5 / u_colorsCount) * u_colorsCount;
84
+ float steps = max(1., u_stepsPerColor);
85
+
86
+ vec4 gradient = u_colors[0];
87
+ gradient.rgb *= gradient.a;
88
+ for (int i = 1; i < ${dotOrbitMeta.maxColorCount}; i++) {
89
+ if (i >= int(u_colorsCount)) break;
90
+ float localT = clamp(mixer - float(i - 1), 0.0, 1.0);
91
+ localT = round(localT * steps) / steps;
92
+ vec4 c = u_colors[i];
93
+ c.rgb *= c.a;
94
+ gradient = mix(gradient, c, localT);
95
+ }
96
+
97
+ if ((mixer < 0.) || (mixer > (u_colorsCount - 1.))) {
98
+ float localT = mixer + 1.;
99
+ if (mixer > (u_colorsCount - 1.)) {
100
+ localT = mixer - (u_colorsCount - 1.);
101
+ }
102
+ localT = round(localT * steps) / steps;
103
+ vec4 cFst = u_colors[0];
104
+ cFst.rgb *= cFst.a;
105
+ vec4 cLast = u_colors[int(u_colorsCount - 1.)];
106
+ cLast.rgb *= cLast.a;
107
+ gradient = mix(cLast, cFst, localT);
108
+ }
109
+
110
+ vec3 color = gradient.rgb * dots;
111
+ float opacity = gradient.a * dots;
112
+
113
+ vec3 bgColor = u_colorBack.rgb * u_colorBack.a;
114
+ color = color + bgColor * (1. - opacity);
115
+ opacity = opacity + u_colorBack.a * (1. - opacity);
116
+
117
+ fragColor = vec4(color, opacity);
118
+ }
119
+ `;
120
+ export {
121
+ dotOrbitFragmentShader,
122
+ dotOrbitMeta
123
+ };
124
+ //# sourceMappingURL=dot-orbit.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/shaders/dot-orbit.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, rotation2, textureRandomizerR, textureRandomizerGB } from '../shader-utils.js';\n\nexport const dotOrbitMeta = {\n maxColorCount: 10,\n} as const;\n\n/**\n * Animated dot pattern with dots orbiting around their grid positions\n *\n * Uniforms:\n * - u_colorBack (RGBA)\n * - u_colors (vec4[]), u_colorsCount (float used as integer)\n * - u_stepsPerColor: discrete color steps between u_colors\n * - u_size (0..1): dot radius (relative to cell size)\n * - u_sizeRange (0..1): randomizes dot radius between 0 and u_size\n * - u_spreading (0..1): max orbit distance of each dot around the cell center\n *\n * - u_noiseTexture (sampler2D): pre-computed randomizer source\n *\n */\n\n// language=GLSL\nexport const dotOrbitFragmentShader: string = `#version 300 es\nprecision mediump float;\n\nuniform float u_time;\n\nuniform sampler2D u_noiseTexture;\n\nuniform vec4 u_colorBack;\nuniform vec4 u_colors[${dotOrbitMeta.maxColorCount}];\nuniform float u_colorsCount;\nuniform float u_stepsPerColor;\nuniform float u_size;\nuniform float u_sizeRange;\nuniform float u_spreading;\n\n${sizingVariablesDeclaration}\n\nout vec4 fragColor;\n\n${declarePI}\n${rotation2}\n${textureRandomizerR}\n${textureRandomizerGB}\n\n\nvec3 voronoiShape(vec2 uv, float time) {\n vec2 i_uv = floor(uv);\n vec2 f_uv = fract(uv);\n\n float spreading = .25 * clamp(u_spreading, 0., 1.);\n\n float minDist = 1.;\n vec2 randomizer = vec2(0.);\n for (int y = -1; y <= 1; y++) {\n for (int x = -1; x <= 1; x++) {\n vec2 tileOffset = vec2(float(x), float(y));\n vec2 rand = randomGB(i_uv + tileOffset);\n vec2 cellCenter = vec2(.5 + 1e-4);\n cellCenter += spreading * cos(time + TWO_PI * rand);\n cellCenter -= .5;\n cellCenter = rotate(cellCenter, randomR(vec2(rand.x, rand.y)) + .1 * time);\n cellCenter += .5;\n float dist = length(tileOffset + cellCenter - f_uv);\n if (dist < minDist) {\n minDist = dist;\n randomizer = rand;\n }\n minDist = min(minDist, dist);\n }\n }\n\n return vec3(minDist, randomizer);\n}\n\nvoid main() {\n\n vec2 shape_uv = v_patternUV;\n shape_uv *= 1.5;\n\n const float firstFrameOffset = -10.;\n float t = u_time + firstFrameOffset;\n\n vec3 voronoi = voronoiShape(shape_uv, t) + 1e-4;\n\n float radius = .25 * clamp(u_size, 0., 1.) - .5 * clamp(u_sizeRange, 0., 1.) * voronoi[2];\n float dist = voronoi[0];\n float edgeWidth = fwidth(dist);\n float dots = 1. - smoothstep(radius - edgeWidth, radius + edgeWidth, dist);\n\n float shape = voronoi[1];\n\n float mixer = shape * (u_colorsCount - 1.);\n mixer = (shape - .5 / u_colorsCount) * u_colorsCount;\n float steps = max(1., u_stepsPerColor);\n\n vec4 gradient = u_colors[0];\n gradient.rgb *= gradient.a;\n for (int i = 1; i < ${dotOrbitMeta.maxColorCount}; i++) {\n if (i >= int(u_colorsCount)) break;\n float localT = clamp(mixer - float(i - 1), 0.0, 1.0);\n localT = round(localT * steps) / steps;\n vec4 c = u_colors[i];\n c.rgb *= c.a;\n gradient = mix(gradient, c, localT);\n }\n\n if ((mixer < 0.) || (mixer > (u_colorsCount - 1.))) {\n float localT = mixer + 1.;\n if (mixer > (u_colorsCount - 1.)) {\n localT = mixer - (u_colorsCount - 1.);\n }\n localT = round(localT * steps) / steps;\n vec4 cFst = u_colors[0];\n cFst.rgb *= cFst.a;\n vec4 cLast = u_colors[int(u_colorsCount - 1.)];\n cLast.rgb *= cLast.a;\n gradient = mix(cLast, cFst, localT);\n }\n\n vec3 color = gradient.rgb * dots;\n float opacity = gradient.a * dots;\n\n vec3 bgColor = u_colorBack.rgb * u_colorBack.a;\n color = color + bgColor * (1. - opacity);\n opacity = opacity + u_colorBack.a * (1. - opacity);\n\n fragColor = vec4(color, opacity);\n}\n`;\n\nexport interface DotOrbitUniforms extends ShaderSizingUniforms {\n u_colorBack: [number, number, number, number];\n u_colors: vec4[];\n u_colorsCount: number;\n u_size: number;\n u_sizeRange: number;\n u_spreading: number;\n u_stepsPerColor: number;\n u_noiseTexture?: HTMLImageElement;\n}\n\nexport interface DotOrbitParams extends ShaderSizingParams, ShaderMotionParams {\n colorBack?: string;\n colors?: string[];\n size?: number;\n sizeRange?: number;\n spreading?: number;\n stepsPerColor?: number;\n}\n"],
5
+ "mappings": ";;;;;AAEA,SAAS,kCAAsF;AAC/F,SAAS,WAAW,WAAW,oBAAoB,2BAA2B;AAEvE,MAAM,eAAe;AAAA,EAC1B,eAAe;AACjB;AAkBO,MAAM,yBAAiC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,wBAQtB,aAAa,aAAa;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOhD,0BAA0B;AAAA;AAAA;AAAA;AAAA,EAI1B,SAAS;AAAA,EACT,SAAS;AAAA,EACT,kBAAkB;AAAA,EAClB,mBAAmB;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,wBAuDG,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;",
6
+ "names": []
7
+ }
@@ -0,0 +1,73 @@
1
+ import type { ShaderMotionParams } from '../shader-mount.js';
2
+ import { type ShaderSizingParams, type ShaderSizingUniforms } from '../shader-sizing.js';
3
+ /**
4
+ * Mimicking glass surface distortion over the image by distorting the texture
5
+ * coordinates within line patterns
6
+ *
7
+ * Uniforms:
8
+ * - u_size, u_angle - size and direction of grid relative to the image
9
+ * - u_shape (float used as integer):
10
+ * ---- 1: uniformly spaced stripes
11
+ * ---- 2: randomly spaced stripes
12
+ * ---- 3: sine wave stripes
13
+ * ---- 4: zigzag stripes
14
+ * ---- 5: wave-based pattern
15
+ * - u_distortion - the power of distortion applied along within each stripe
16
+ * - u_distortionShape (float used as integer):
17
+ * ---- 5 shapes available
18
+ * - u_shift - texture shift in direction opposite to the grid
19
+ * - u_blur - one-directional blur applied over the main distortion
20
+ * - u_edges - thin color lines along the grid (independent from distortion)
21
+ * - u_marginLeft, u_marginRight, u_marginTop, u_marginBottom - paddings
22
+ * within picture to be shown without any distortion
23
+ *
24
+ */
25
+ export declare const flutedGlassFragmentShader: string;
26
+ export interface FlutedGlassUniforms extends ShaderSizingUniforms {
27
+ u_image: HTMLImageElement | string;
28
+ u_size: number;
29
+ u_angle: number;
30
+ u_distortion: number;
31
+ u_shift: number;
32
+ u_blur: number;
33
+ u_marginLeft: number;
34
+ u_marginRight: number;
35
+ u_marginTop: number;
36
+ u_marginBottom: number;
37
+ u_edges: number;
38
+ u_distortionShape: (typeof GlassDistortionShapes)[GlassDistortionShape];
39
+ u_shape: (typeof GlassGridShapes)[GlassGridShape];
40
+ u_noiseTexture?: HTMLImageElement;
41
+ }
42
+ export interface FlutedGlassParams extends ShaderSizingParams, ShaderMotionParams {
43
+ image: HTMLImageElement | string;
44
+ size?: number;
45
+ angle?: number;
46
+ distortion?: number;
47
+ shift?: number;
48
+ blur?: number;
49
+ margin?: number;
50
+ marginLeft?: number;
51
+ marginRight?: number;
52
+ marginTop?: number;
53
+ marginBottom?: number;
54
+ edges?: number;
55
+ distortionShape?: GlassDistortionShape;
56
+ shape?: GlassGridShape;
57
+ }
58
+ export declare const GlassGridShapes: {
59
+ readonly lines: 1;
60
+ readonly linesIrregular: 2;
61
+ readonly wave: 3;
62
+ readonly zigzag: 4;
63
+ readonly pattern: 5;
64
+ };
65
+ export declare const GlassDistortionShapes: {
66
+ readonly prism: 1;
67
+ readonly lens: 2;
68
+ readonly contour: 3;
69
+ readonly cascade: 4;
70
+ readonly facete: 5;
71
+ };
72
+ export type GlassDistortionShape = keyof typeof GlassDistortionShapes;
73
+ export type GlassGridShape = keyof typeof GlassGridShapes;
@@ -0,0 +1,187 @@
1
+ /* * * * * * * * * * * * * * * * * * * * * * * * * * * *
2
+ * Paper Shaders *
3
+ * https://github.com/paper-design/shaders *
4
+ * * * * * * * * * * * * * * * * * * * * * * * * * * * */
5
+
6
+ import { sizingVariablesDeclaration } from "../shader-sizing.js";
7
+ import { declarePI, rotation2 } from "../shader-utils.js";
8
+ const flutedGlassFragmentShader = `#version 300 es
9
+ precision mediump float;
10
+
11
+ uniform vec2 u_resolution;
12
+ uniform float u_pixelRatio;
13
+
14
+ uniform sampler2D u_image;
15
+ uniform float u_imageAspectRatio;
16
+
17
+ uniform float u_size;
18
+ uniform float u_angle;
19
+ uniform float u_edges;
20
+ uniform float u_shape;
21
+ uniform float u_distortion;
22
+ uniform float u_distortionShape;
23
+ uniform float u_shift;
24
+ uniform float u_blur;
25
+ uniform float u_marginLeft;
26
+ uniform float u_marginRight;
27
+ uniform float u_marginTop;
28
+ uniform float u_marginBottom;
29
+
30
+ ${sizingVariablesDeclaration}
31
+
32
+ out vec4 fragColor;
33
+
34
+ ${declarePI}
35
+ ${rotation2}
36
+
37
+ float getUvFrame(vec2 uv) {
38
+ float aax = 2. * fwidth(uv.x);
39
+ float aay = 2. * fwidth(uv.y);
40
+
41
+ float left = smoothstep(0., aax, uv.x);
42
+ float right = 1. - smoothstep(1. - aax, 1., uv.x);
43
+ float bottom = smoothstep(0., aay, uv.y);
44
+ float top = 1. - smoothstep(1. - aay, 1., uv.y);
45
+
46
+
47
+ return left * right * bottom * top;
48
+ }
49
+
50
+ const int MAX_RADIUS = 50;
51
+
52
+ vec4 getBlur(sampler2D tex, vec2 uv, vec2 texelSize, vec2 dir, float sigma) {
53
+ if (sigma <= .5) return texture(tex, uv);
54
+ int radius = int(min(float(MAX_RADIUS), ceil(3.0 * sigma)));
55
+
56
+ float twoSigma2 = 2.0 * sigma * sigma;
57
+ float gaussianNorm = 1.0 / sqrt(TWO_PI * sigma * sigma);
58
+
59
+ vec4 sum = texture(tex, uv) * gaussianNorm;
60
+ float weightSum = gaussianNorm;
61
+
62
+ for (int i = 1; i <= MAX_RADIUS; i++) {
63
+ if (i > radius) break;
64
+
65
+ float x = float(i);
66
+ float w = exp(-(x * x) / twoSigma2) * gaussianNorm;
67
+
68
+ vec2 offset = dir * texelSize * x;
69
+ vec4 s1 = texture(tex, uv + offset);
70
+ vec4 s2 = texture(tex, uv - offset);
71
+
72
+ sum += (s1 + s2) * w;
73
+ weightSum += 2.0 * w;
74
+ }
75
+
76
+ return sum / weightSum;
77
+ }
78
+
79
+ void main() {
80
+ vec2 imageUV = v_imageUV;
81
+
82
+ vec2 uv = imageUV;
83
+ float frame = getUvFrame(imageUV);
84
+ if (frame < .05) discard;
85
+
86
+ float effectSize = 1. / pow(.7 * (u_size + .5), 6.);
87
+
88
+ vec2 sw = vec2(.005 * u_distortion) * vec2(1., u_imageAspectRatio);
89
+ float maskOuter =
90
+ smoothstep(u_marginLeft - sw.x, u_marginLeft, imageUV.x + sw.x) *
91
+ smoothstep(u_marginRight - sw.x, u_marginRight, 1.0 - imageUV.x + sw.x) *
92
+ smoothstep(u_marginTop - sw.y, u_marginTop, imageUV.y + sw.y) *
93
+ smoothstep(u_marginBottom - sw.y, u_marginBottom, 1.0 - imageUV.y + sw.y);
94
+ float mask =
95
+ smoothstep(u_marginLeft, u_marginLeft + sw.x, imageUV.x + sw.x) *
96
+ smoothstep(u_marginRight, u_marginRight + sw.x, 1.0 - imageUV.x + sw.x) *
97
+ smoothstep(u_marginTop, u_marginTop + sw.y, imageUV.y + sw.y) *
98
+ smoothstep(u_marginBottom, u_marginBottom + sw.y, 1.0 - imageUV.y + sw.y);
99
+ float stroke = (1. - mask) * maskOuter;
100
+
101
+ float patternRotation = u_angle * PI / 180.;
102
+ uv = rotate(uv - vec2(.5), patternRotation);
103
+ uv *= effectSize;
104
+
105
+ float curve = 0.;
106
+ if (u_shape > 4.5) {
107
+ // pattern
108
+ curve = .5 + .5 * sin(1.5 * uv.x) * cos(1.5 * uv.y);
109
+ } else if (u_shape > 3.5) {
110
+ // zigzag
111
+ curve = 10. * abs(fract(.1 * uv.y) - .5);
112
+ } else if (u_shape > 2.5) {
113
+ // wave
114
+ curve = 4. * sin(.23 * uv.y);
115
+ } else if (u_shape > 1.5) {
116
+ // lines irregular
117
+ curve = .5 + .5 * sin(.5 * uv.x) * sin(1.7 * uv.x);
118
+ } else {
119
+ // lines
120
+ }
121
+
122
+ vec2 uvOrig = uv;
123
+ uv += curve;
124
+
125
+ vec2 fractUV = fract(uv);
126
+ vec2 floorUV = floor(uv);
127
+
128
+ vec2 fractOrigUV = fract(uvOrig);
129
+ vec2 floorOrigUV = floor(uvOrig);
130
+
131
+ float edges = smoothstep(.85, .95, fractUV.x);
132
+ edges *= mask;
133
+
134
+ float xDistortion = 0.;
135
+ if (u_distortionShape == 1.) {
136
+ xDistortion = -pow(1.5 * fractUV.x, 3.) + (.5 + u_shift);
137
+ } else if (u_distortionShape == 2.) {
138
+ xDistortion = 2. * pow(fractUV.x, 2.) - (.5 + u_shift);
139
+ } else if (u_distortionShape == 3.) {
140
+ xDistortion = pow(2. * (fractUV.x - .5), 6.) + .5 - .5 + u_shift;
141
+ } else if (u_distortionShape == 4.) {
142
+ xDistortion = sin((fractUV.x + .25 + u_shift) * TWO_PI);
143
+ xDistortion *= .5;
144
+ } else if (u_distortionShape == 5.) {
145
+ xDistortion += (.5 + u_shift);
146
+ xDistortion -= pow(abs(fractUV.x), .2) * fractUV.x;
147
+ xDistortion *= .33;
148
+ }
149
+
150
+ xDistortion *= 3. * u_distortion;
151
+
152
+ uv = (floorOrigUV + fractOrigUV) / effectSize;
153
+ uv.x += xDistortion / effectSize;
154
+ uv += pow(stroke, 4.);
155
+ uv.y = mix(uv.y, .0, .4 * u_edges * edges);
156
+
157
+ uv = rotate(uv, -patternRotation) + vec2(.5);
158
+
159
+ uv = mix(imageUV, uv, mask);
160
+ float blur = mix(0., u_blur, mask);
161
+
162
+ vec4 color = getBlur(u_image, uv, 1. / u_resolution / u_pixelRatio, vec2(0., 1.), blur);
163
+
164
+ float opacity = color.a;
165
+ fragColor = vec4(color.rgb, opacity);
166
+ }
167
+ `;
168
+ const GlassGridShapes = {
169
+ lines: 1,
170
+ linesIrregular: 2,
171
+ wave: 3,
172
+ zigzag: 4,
173
+ pattern: 5
174
+ };
175
+ const GlassDistortionShapes = {
176
+ prism: 1,
177
+ lens: 2,
178
+ contour: 3,
179
+ cascade: 4,
180
+ facete: 5
181
+ };
182
+ export {
183
+ GlassDistortionShapes,
184
+ GlassGridShapes,
185
+ flutedGlassFragmentShader
186
+ };
187
+ //# sourceMappingURL=fluted-glass.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/shaders/fluted-glass.ts"],
4
+ "sourcesContent": ["import type { ShaderMotionParams } from '../shader-mount.js';\nimport { sizingVariablesDeclaration, type ShaderSizingParams, type ShaderSizingUniforms } from '../shader-sizing.js';\nimport { declarePI, rotation2 } from '../shader-utils.js';\n\n/**\n * Mimicking glass surface distortion over the image by distorting the texture\n * coordinates within line patterns\n *\n * Uniforms:\n * - u_size, u_angle - size and direction of grid relative to the image\n * - u_shape (float used as integer):\n * ---- 1: uniformly spaced stripes\n * ---- 2: randomly spaced stripes\n * ---- 3: sine wave stripes\n * ---- 4: zigzag stripes\n * ---- 5: wave-based pattern\n * - u_distortion - the power of distortion applied along within each stripe\n * - u_distortionShape (float used as integer):\n * ---- 5 shapes available\n * - u_shift - texture shift in direction opposite to the grid\n * - u_blur - one-directional blur applied over the main distortion\n * - u_edges - thin color lines along the grid (independent from distortion)\n * - u_marginLeft, u_marginRight, u_marginTop, u_marginBottom - paddings\n * within picture to be shown without any distortion\n *\n */\n\n// language=GLSL\nexport const flutedGlassFragmentShader: string = `#version 300 es\nprecision mediump float;\n\nuniform vec2 u_resolution;\nuniform float u_pixelRatio;\n\nuniform sampler2D u_image;\nuniform float u_imageAspectRatio;\n\nuniform float u_size;\nuniform float u_angle;\nuniform float u_edges;\nuniform float u_shape;\nuniform float u_distortion;\nuniform float u_distortionShape;\nuniform float u_shift;\nuniform float u_blur;\nuniform float u_marginLeft;\nuniform float u_marginRight;\nuniform float u_marginTop;\nuniform float u_marginBottom;\n\n${sizingVariablesDeclaration}\n\nout vec4 fragColor;\n\n${declarePI}\n${rotation2}\n\nfloat getUvFrame(vec2 uv) {\n float aax = 2. * fwidth(uv.x);\n float aay = 2. * fwidth(uv.y);\n\n float left = smoothstep(0., aax, uv.x);\n float right = 1. - smoothstep(1. - aax, 1., uv.x);\n float bottom = smoothstep(0., aay, uv.y);\n float top = 1. - smoothstep(1. - aay, 1., uv.y);\n\n\n return left * right * bottom * top;\n}\n\nconst int MAX_RADIUS = 50;\n\nvec4 getBlur(sampler2D tex, vec2 uv, vec2 texelSize, vec2 dir, float sigma) {\n if (sigma <= .5) return texture(tex, uv);\n int radius = int(min(float(MAX_RADIUS), ceil(3.0 * sigma)));\n\n float twoSigma2 = 2.0 * sigma * sigma;\n float gaussianNorm = 1.0 / sqrt(TWO_PI * sigma * sigma);\n\n vec4 sum = texture(tex, uv) * gaussianNorm;\n float weightSum = gaussianNorm;\n\n for (int i = 1; i <= MAX_RADIUS; i++) {\n if (i > radius) break;\n\n float x = float(i);\n float w = exp(-(x * x) / twoSigma2) * gaussianNorm;\n\n vec2 offset = dir * texelSize * x;\n vec4 s1 = texture(tex, uv + offset);\n vec4 s2 = texture(tex, uv - offset);\n\n sum += (s1 + s2) * w;\n weightSum += 2.0 * w;\n }\n\n return sum / weightSum;\n}\n\nvoid main() {\n vec2 imageUV = v_imageUV;\n\n vec2 uv = imageUV;\n float frame = getUvFrame(imageUV);\n if (frame < .05) discard;\n\n float effectSize = 1. / pow(.7 * (u_size + .5), 6.);\n\n vec2 sw = vec2(.005 * u_distortion) * vec2(1., u_imageAspectRatio);\n float maskOuter =\n smoothstep(u_marginLeft - sw.x, u_marginLeft, imageUV.x + sw.x) *\n smoothstep(u_marginRight - sw.x, u_marginRight, 1.0 - imageUV.x + sw.x) *\n smoothstep(u_marginTop - sw.y, u_marginTop, imageUV.y + sw.y) *\n smoothstep(u_marginBottom - sw.y, u_marginBottom, 1.0 - imageUV.y + sw.y);\n float mask =\n smoothstep(u_marginLeft, u_marginLeft + sw.x, imageUV.x + sw.x) *\n smoothstep(u_marginRight, u_marginRight + sw.x, 1.0 - imageUV.x + sw.x) *\n smoothstep(u_marginTop, u_marginTop + sw.y, imageUV.y + sw.y) *\n smoothstep(u_marginBottom, u_marginBottom + sw.y, 1.0 - imageUV.y + sw.y);\n float stroke = (1. - mask) * maskOuter;\n\n float patternRotation = u_angle * PI / 180.;\n uv = rotate(uv - vec2(.5), patternRotation);\n uv *= effectSize;\n\n float curve = 0.;\n if (u_shape > 4.5) {\n // pattern\n curve = .5 + .5 * sin(1.5 * uv.x) * cos(1.5 * uv.y);\n } else if (u_shape > 3.5) {\n // zigzag\n curve = 10. * abs(fract(.1 * uv.y) - .5);\n } else if (u_shape > 2.5) {\n // wave\n curve = 4. * sin(.23 * uv.y);\n } else if (u_shape > 1.5) {\n // lines irregular\n curve = .5 + .5 * sin(.5 * uv.x) * sin(1.7 * uv.x);\n } else {\n // lines\n }\n\n vec2 uvOrig = uv;\n uv += curve;\n\n vec2 fractUV = fract(uv);\n vec2 floorUV = floor(uv);\n\n vec2 fractOrigUV = fract(uvOrig);\n vec2 floorOrigUV = floor(uvOrig);\n\n float edges = smoothstep(.85, .95, fractUV.x);\n edges *= mask;\n\n float xDistortion = 0.;\n if (u_distortionShape == 1.) {\n xDistortion = -pow(1.5 * fractUV.x, 3.) + (.5 + u_shift);\n } else if (u_distortionShape == 2.) {\n xDistortion = 2. * pow(fractUV.x, 2.) - (.5 + u_shift);\n } else if (u_distortionShape == 3.) {\n xDistortion = pow(2. * (fractUV.x - .5), 6.) + .5 - .5 + u_shift;\n } else if (u_distortionShape == 4.) {\n xDistortion = sin((fractUV.x + .25 + u_shift) * TWO_PI);\n xDistortion *= .5;\n } else if (u_distortionShape == 5.) {\n xDistortion += (.5 + u_shift);\n xDistortion -= pow(abs(fractUV.x), .2) * fractUV.x;\n xDistortion *= .33;\n }\n\n xDistortion *= 3. * u_distortion;\n\n uv = (floorOrigUV + fractOrigUV) / effectSize;\n uv.x += xDistortion / effectSize;\n uv += pow(stroke, 4.);\n uv.y = mix(uv.y, .0, .4 * u_edges * edges);\n\n uv = rotate(uv, -patternRotation) + vec2(.5);\n\n uv = mix(imageUV, uv, mask);\n float blur = mix(0., u_blur, mask);\n\n vec4 color = getBlur(u_image, uv, 1. / u_resolution / u_pixelRatio, vec2(0., 1.), blur);\n\n float opacity = color.a;\n fragColor = vec4(color.rgb, opacity);\n}\n`;\n\nexport interface FlutedGlassUniforms extends ShaderSizingUniforms {\n u_image: HTMLImageElement | string;\n u_size: number;\n u_angle: number;\n u_distortion: number;\n u_shift: number;\n u_blur: number;\n u_marginLeft: number;\n u_marginRight: number;\n u_marginTop: number;\n u_marginBottom: number;\n u_edges: number;\n u_distortionShape: (typeof GlassDistortionShapes)[GlassDistortionShape];\n u_shape: (typeof GlassGridShapes)[GlassGridShape];\n u_noiseTexture?: HTMLImageElement;\n}\n\nexport interface FlutedGlassParams extends ShaderSizingParams, ShaderMotionParams {\n image: HTMLImageElement | string;\n size?: number;\n angle?: number;\n distortion?: number;\n shift?: number;\n blur?: number;\n margin?: number;\n marginLeft?: number;\n marginRight?: number;\n marginTop?: number;\n marginBottom?: number;\n edges?: number;\n distortionShape?: GlassDistortionShape;\n shape?: GlassGridShape;\n}\n\nexport const GlassGridShapes = {\n lines: 1,\n linesIrregular: 2,\n wave: 3,\n zigzag: 4,\n pattern: 5,\n} as const;\n\nexport const GlassDistortionShapes = {\n prism: 1,\n lens: 2,\n contour: 3,\n cascade: 4,\n facete: 5,\n} as const;\n\nexport type GlassDistortionShape = keyof typeof GlassDistortionShapes;\nexport type GlassGridShape = keyof typeof GlassGridShapes;\n"],
5
+ "mappings": ";;;;;AACA,SAAS,kCAAsF;AAC/F,SAAS,WAAW,iBAAiB;AA0B9B,MAAM,4BAAoC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAsB/C,0BAA0B;AAAA;AAAA;AAAA;AAAA,EAI1B,SAAS;AAAA,EACT,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;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;AAwKJ,MAAM,kBAAkB;AAAA,EAC7B,OAAO;AAAA,EACP,gBAAgB;AAAA,EAChB,MAAM;AAAA,EACN,QAAQ;AAAA,EACR,SAAS;AACX;AAEO,MAAM,wBAAwB;AAAA,EACnC,OAAO;AAAA,EACP,MAAM;AAAA,EACN,SAAS;AAAA,EACT,SAAS;AAAA,EACT,QAAQ;AACV;",
6
+ "names": []
7
+ }
@@ -0,0 +1,45 @@
1
+ import type { vec4 } from '../types.js';
2
+ import type { ShaderMotionParams } from '../shader-mount.js';
3
+ import { type ShaderSizingParams, type ShaderSizingUniforms } from '../shader-sizing.js';
4
+ export declare const godRaysMeta: {
5
+ readonly maxColorCount: 5;
6
+ };
7
+ /**
8
+ * Radial rays animated from center
9
+ *
10
+ * Uniforms:
11
+ * - u_colorBack, u_colorBloom (RGBA)
12
+ * - u_colors (vec4[]), u_colorsCount (float used as integer)
13
+ * - u_density: frequency of sector shapes
14
+ * - u_intensity: rays visibility within sectors
15
+ * - u_spotty: density of spots on the ray (higher = more spots)
16
+ * - u_midSize, u_midIntensity: central shape over the rays
17
+ * - u_bloom (0..1): normal to additive blending mix
18
+ *
19
+ * - u_noiseTexture (sampler2D): pre-computed randomizer source
20
+ */
21
+ export declare const godRaysFragmentShader: string;
22
+ export interface GodRaysUniforms extends ShaderSizingUniforms {
23
+ u_colorBack: [number, number, number, number];
24
+ u_colorBloom: [number, number, number, number];
25
+ u_colors: vec4[];
26
+ u_colorsCount: number;
27
+ u_spotty: number;
28
+ u_midSize: number;
29
+ u_midIntensity: number;
30
+ u_density: number;
31
+ u_intensity: number;
32
+ u_bloom: number;
33
+ u_noiseTexture?: HTMLImageElement;
34
+ }
35
+ export interface GodRaysParams extends ShaderSizingParams, ShaderMotionParams {
36
+ colorBack?: string;
37
+ colorBloom?: string;
38
+ colors?: string[];
39
+ spotty?: number;
40
+ midSize?: number;
41
+ midIntensity?: number;
42
+ density?: number;
43
+ intensity?: number;
44
+ bloom?: number;
45
+ }