@paper-design/shaders 0.0.29 → 0.0.31

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 (68) hide show
  1. package/README.md +7 -4
  2. package/dist/index.d.ts +25 -23
  3. package/dist/index.js +44 -23
  4. package/dist/index.js.map +2 -2
  5. package/dist/shader-mount.d.ts +5 -1
  6. package/dist/shader-mount.js +15 -2
  7. package/dist/shader-mount.js.map +2 -2
  8. package/dist/shader-sizing.d.ts +1 -1
  9. package/dist/shader-sizing.js +2 -5
  10. package/dist/shader-sizing.js.map +2 -2
  11. package/dist/shaders/color-panels.d.ts +48 -0
  12. package/dist/shaders/color-panels.js +213 -0
  13. package/dist/shaders/color-panels.js.map +7 -0
  14. package/dist/shaders/dithering.d.ts +29 -15
  15. package/dist/shaders/dithering.js +85 -61
  16. package/dist/shaders/dithering.js.map +2 -2
  17. package/dist/shaders/dot-grid.d.ts +1 -1
  18. package/dist/shaders/dot-grid.js +20 -13
  19. package/dist/shaders/dot-grid.js.map +2 -2
  20. package/dist/shaders/dot-orbit.d.ts +6 -3
  21. package/dist/shaders/dot-orbit.js +15 -11
  22. package/dist/shaders/dot-orbit.js.map +2 -2
  23. package/dist/shaders/god-rays.d.ts +9 -6
  24. package/dist/shaders/god-rays.js +15 -16
  25. package/dist/shaders/god-rays.js.map +2 -2
  26. package/dist/shaders/grain-gradient.d.ts +17 -5
  27. package/dist/shaders/grain-gradient.js +61 -37
  28. package/dist/shaders/grain-gradient.js.map +2 -2
  29. package/dist/shaders/liquid-metal.d.ts +27 -12
  30. package/dist/shaders/liquid-metal.js +64 -67
  31. package/dist/shaders/liquid-metal.js.map +2 -2
  32. package/dist/shaders/mesh-gradient.d.ts +3 -3
  33. package/dist/shaders/mesh-gradient.js +7 -7
  34. package/dist/shaders/mesh-gradient.js.map +1 -1
  35. package/dist/shaders/metaballs.d.ts +6 -3
  36. package/dist/shaders/metaballs.js +12 -11
  37. package/dist/shaders/metaballs.js.map +2 -2
  38. package/dist/shaders/neuro-noise.d.ts +12 -6
  39. package/dist/shaders/neuro-noise.js +27 -12
  40. package/dist/shaders/neuro-noise.js.map +2 -2
  41. package/dist/shaders/perlin-noise.d.ts +10 -10
  42. package/dist/shaders/perlin-noise.js +30 -22
  43. package/dist/shaders/perlin-noise.js.map +2 -2
  44. package/dist/shaders/pulsing-border.d.ts +3 -3
  45. package/dist/shaders/pulsing-border.js +25 -25
  46. package/dist/shaders/pulsing-border.js.map +1 -1
  47. package/dist/shaders/simplex-noise.d.ts +3 -3
  48. package/dist/shaders/simplex-noise.js +13 -13
  49. package/dist/shaders/simplex-noise.js.map +1 -1
  50. package/dist/shaders/smoke-ring.d.ts +3 -3
  51. package/dist/shaders/smoke-ring.js +7 -7
  52. package/dist/shaders/smoke-ring.js.map +1 -1
  53. package/dist/shaders/spiral.d.ts +8 -8
  54. package/dist/shaders/spiral.js +16 -8
  55. package/dist/shaders/spiral.js.map +2 -2
  56. package/dist/shaders/swirl.d.ts +5 -3
  57. package/dist/shaders/swirl.js +30 -19
  58. package/dist/shaders/swirl.js.map +2 -2
  59. package/dist/shaders/voronoi.d.ts +8 -8
  60. package/dist/shaders/voronoi.js +12 -12
  61. package/dist/shaders/voronoi.js.map +1 -1
  62. package/dist/shaders/warp.d.ts +3 -3
  63. package/dist/shaders/warp.js +32 -28
  64. package/dist/shaders/warp.js.map +2 -2
  65. package/dist/shaders/waves.d.ts +7 -7
  66. package/dist/shaders/waves.js +17 -9
  67. package/dist/shaders/waves.js.map +2 -2
  68. package/package.json +1 -1
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/shaders/mesh-gradient.ts"],
4
- "sourcesContent": ["import type { vec4 } from '../types';\nimport type { ShaderMotionParams } from '../shader-mount';\nimport { sizingVariablesDeclaration, type ShaderSizingParams, type ShaderSizingUniforms } from '../shader-sizing';\nimport { declarePI, declareRotate, colorBandingFix } from '../shader-utils';\n\nexport const meshGradientMeta = {\n maxColorCount: 10,\n} as const;\n\n/**\n * Mesh Gradient Ksenia Kondrashova\n * Smooth, animated mesh gradient using a dynamic list of colors\n *\n * Uniforms include:\n * - u_colors (vec4[]): Input RGBA colors\n * - u_colorsCount (float): Number of active colors (`u_colors` length)\n * - u_distortion (float): Amount of animated wavy distortion applied to UV coordinates\n * - u_swirl (float): Amount of radial swirl distortion applied to UV coordinates\n */\nexport const meshGradientFragmentShader: string = `#version 300 es\nprecision highp float;\n\nuniform float u_time;\n\nuniform vec4 u_colors[${meshGradientMeta.maxColorCount}];\nuniform float u_colorsCount;\n\nuniform float u_distortion;\nuniform float u_swirl;\n\n${sizingVariablesDeclaration}\n\nout vec4 fragColor;\n\n${declarePI}\n${declareRotate}\n\nvec2 getPosition(int i, float t) {\n float a = float(i) * .37;\n float b = .6 + mod(float(i), 3.) * .3;\n float c = .8 + mod(float(i + 1), 4.) * 0.25;\n\n float x = sin(t * b + a);\n float y = cos(t * c + a * 1.5);\n\n return .5 + .5 * vec2(x, y);\n}\n\nvoid main() {\n vec2 shape_uv = v_objectUV;\n\n shape_uv += .5;\n\n float t = .5 * u_time;\n\n float radius = smoothstep(0., 1., length(shape_uv - .5));\n float center = 1. - radius;\n for (float i = 1.; i <= 2.; i++) {\n shape_uv.x += u_distortion * center / i * sin(t + i * .4 * smoothstep(.0, 1., shape_uv.y)) * cos(.2 * t + i * 2.4 * smoothstep(.0, 1., shape_uv.y));\n shape_uv.y += u_distortion * center / i * cos(t + i * 2. * smoothstep(.0, 1., shape_uv.x));\n }\n\n vec2 uvRotated = shape_uv;\n uvRotated -= vec2(.5);\n float angle = 3. * u_swirl * radius;\n uvRotated = rotate(uvRotated, -angle);\n uvRotated += vec2(.5);\n\n vec3 color = vec3(0.);\n float opacity = 0.;\n float totalWeight = 0.;\n \n for (int i = 0; i < ${meshGradientMeta.maxColorCount}; i++) {\n if (i >= int(u_colorsCount)) break;\n \n vec2 pos = getPosition(i, t);\n vec3 colorFraction = u_colors[i].rgb * u_colors[i].a;\n float opacityFraction = u_colors[i].a;\n \n float dist = 0.;\n if (mod(float(i), 2.) > 1.) {\n dist = length(shape_uv - pos);\n } else {\n dist = length(uvRotated - pos);\n }\n\n dist = pow(dist, 3.5);\n float weight = 1. / (dist + 1e-3);\n color += colorFraction * weight;\n opacity += opacityFraction * weight;\n totalWeight += weight;\n }\n\n color /= totalWeight;\n opacity /= totalWeight;\n \n ${colorBandingFix}\n\n fragColor = vec4(color, opacity);\n}\n`;\n\nexport interface MeshGradientUniforms extends ShaderSizingUniforms {\n u_colors: vec4[];\n u_colorsCount: number;\n u_distortion: number;\n u_swirl: number;\n}\n\nexport interface MeshGradientParams extends ShaderSizingParams, ShaderMotionParams {\n colors?: string[];\n distortion?: number;\n swirl?: number;\n}\n"],
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, declareRotate, colorBandingFix } from '../shader-utils.js';\n\nexport const meshGradientMeta = {\n maxColorCount: 10,\n} as const;\n\n/**\n * Mesh Gradient Ksenia Kondrashova\n * Smooth, animated mesh gradient using a dynamic list of colors\n *\n * Uniforms include:\n * - u_colors (vec4[]): Input RGBA colors\n * - u_colorsCount (float): Number of active colors (`u_colors` length)\n * - u_distortion (float): Amount of animated wavy distortion applied to UV coordinates\n * - u_swirl (float): Amount of radial swirl distortion applied to UV coordinates\n */\nexport const meshGradientFragmentShader: string = `#version 300 es\nprecision mediump float;\n\nuniform float u_time;\n\nuniform vec4 u_colors[${meshGradientMeta.maxColorCount}];\nuniform float u_colorsCount;\n\nuniform float u_distortion;\nuniform float u_swirl;\n\n${sizingVariablesDeclaration}\n\nout vec4 fragColor;\n\n${declarePI}\n${declareRotate}\n\nvec2 getPosition(int i, float t) {\n float a = float(i) * .37;\n float b = .6 + mod(float(i), 3.) * .3;\n float c = .8 + mod(float(i + 1), 4.) * 0.25;\n\n float x = sin(t * b + a);\n float y = cos(t * c + a * 1.5);\n\n return .5 + .5 * vec2(x, y);\n}\n\nvoid main() {\n vec2 shape_uv = v_objectUV;\n\n shape_uv += .5;\n\n float t = .5 * u_time;\n\n float radius = smoothstep(0., 1., length(shape_uv - .5));\n float center = 1. - radius;\n for (float i = 1.; i <= 2.; i++) {\n shape_uv.x += u_distortion * center / i * sin(t + i * .4 * smoothstep(.0, 1., shape_uv.y)) * cos(.2 * t + i * 2.4 * smoothstep(.0, 1., shape_uv.y));\n shape_uv.y += u_distortion * center / i * cos(t + i * 2. * smoothstep(.0, 1., shape_uv.x));\n }\n\n vec2 uvRotated = shape_uv;\n uvRotated -= vec2(.5);\n float angle = 3. * u_swirl * radius;\n uvRotated = rotate(uvRotated, -angle);\n uvRotated += vec2(.5);\n\n vec3 color = vec3(0.);\n float opacity = 0.;\n float totalWeight = 0.;\n\n for (int i = 0; i < ${meshGradientMeta.maxColorCount}; i++) {\n if (i >= int(u_colorsCount)) break;\n\n vec2 pos = getPosition(i, t);\n vec3 colorFraction = u_colors[i].rgb * u_colors[i].a;\n float opacityFraction = u_colors[i].a;\n\n float dist = 0.;\n if (mod(float(i), 2.) > 1.) {\n dist = length(shape_uv - pos);\n } else {\n dist = length(uvRotated - pos);\n }\n\n dist = pow(dist, 3.5);\n float weight = 1. / (dist + 1e-3);\n color += colorFraction * weight;\n opacity += opacityFraction * weight;\n totalWeight += weight;\n }\n\n color /= totalWeight;\n opacity /= totalWeight;\n\n ${colorBandingFix}\n\n fragColor = vec4(color, opacity);\n}\n`;\n\nexport interface MeshGradientUniforms extends ShaderSizingUniforms {\n u_colors: vec4[];\n u_colorsCount: number;\n u_distortion: number;\n u_swirl: number;\n}\n\nexport interface MeshGradientParams extends ShaderSizingParams, ShaderMotionParams {\n colors?: string[];\n distortion?: number;\n swirl?: number;\n}\n"],
5
5
  "mappings": ";;;;;AAEA,SAAS,kCAAsF;AAC/F,SAAS,WAAW,eAAe,uBAAuB;AAEnD,MAAM,mBAAmB;AAAA,EAC9B,eAAe;AACjB;AAYO,MAAM,6BAAqC;AAAA;AAAA;AAAA;AAAA;AAAA,wBAK1B,iBAAiB,aAAa;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAMpD,0BAA0B;AAAA;AAAA;AAAA;AAAA,EAI1B,SAAS;AAAA,EACT,aAAa;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,wBAqCS,iBAAiB,aAAa;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAwBlD,eAAe;AAAA;AAAA;AAAA;AAAA;",
6
6
  "names": []
7
7
  }
@@ -1,6 +1,6 @@
1
- import type { vec4 } from '../types';
2
- import type { ShaderMotionParams } from '../shader-mount';
3
- import { type ShaderSizingParams, type ShaderSizingUniforms } from '../shader-sizing';
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
4
  export declare const metaballsMeta: {
5
5
  readonly maxColorCount: 8;
6
6
  readonly maxBallsCount: 20;
@@ -10,6 +10,7 @@ export declare const metaballsMeta: {
10
10
  * The artwork by Ksenia Kondrashova
11
11
  *
12
12
  * Uniforms include:
13
+ * - u_colorBack: the background color of the scene
13
14
  * - uColors (vec4[]): Input RGBA colors
14
15
  * - uColorsCount (float): Number of active colors (`uColors` length)
15
16
  * - u_count (float)
@@ -17,12 +18,14 @@ export declare const metaballsMeta: {
17
18
  */
18
19
  export declare const metaballsFragmentShader: string;
19
20
  export interface MetaballsUniforms extends ShaderSizingUniforms {
21
+ u_colorBack: [number, number, number, number];
20
22
  u_colors: vec4[];
21
23
  u_colorsCount: number;
22
24
  u_count: number;
23
25
  u_size: number;
24
26
  }
25
27
  export interface MetaballsParams extends ShaderSizingParams, ShaderMotionParams {
28
+ colorBack?: string;
26
29
  colors?: string[];
27
30
  count?: number;
28
31
  size?: number;
@@ -3,17 +3,18 @@
3
3
  * https://github.com/paper-design/shaders *
4
4
  * * * * * * * * * * * * * * * * * * * * * * * * * * * */
5
5
 
6
- import { sizingVariablesDeclaration } from "../shader-sizing";
7
- import { declarePI, colorBandingFix } from "../shader-utils";
6
+ import { sizingVariablesDeclaration } from "../shader-sizing.js";
7
+ import { declarePI, colorBandingFix } from "../shader-utils.js";
8
8
  const metaballsMeta = {
9
9
  maxColorCount: 8,
10
10
  maxBallsCount: 20
11
11
  };
12
12
  const metaballsFragmentShader = `#version 300 es
13
- precision highp float;
13
+ precision mediump float;
14
14
 
15
15
  uniform float u_time;
16
16
 
17
+ uniform vec4 u_colorBack;
17
18
  uniform vec4 u_colors[${metaballsMeta.maxColorCount}];
18
19
  uniform float u_colorsCount;
19
20
  uniform float u_size;
@@ -53,19 +54,19 @@ void main() {
53
54
  vec3 totalColor = vec3(0.);
54
55
  float totalShape = 0.;
55
56
  float totalOpacity = 0.;
56
-
57
+
57
58
  for (int i = 0; i < ${metaballsMeta.maxBallsCount}; i++) {
58
59
  if (i >= int(ceil(u_count))) break;
59
-
60
+
60
61
  float idxFract = float(i) / float(${metaballsMeta.maxBallsCount});
61
62
  float angle = TWO_PI * idxFract;
62
-
63
+
63
64
  float speed = 1. - .2 * idxFract;
64
65
  float noiseX = noise(angle * 10. + float(i) + t * speed);
65
66
  float noiseY = noise(angle * 20. + float(i) - t * speed);
66
-
67
+
67
68
  vec2 pos = vec2(.5) + 1e-4 + .9 * (vec2(noiseX, noiseY) - .5);
68
-
69
+
69
70
  int safeIndex = i % int(u_colorsCount + 0.5);
70
71
  vec4 ballColor = u_colors[safeIndex];
71
72
  ballColor.rgb *= ballColor.a;
@@ -93,9 +94,9 @@ void main() {
93
94
  vec3 color = totalColor * finalShape;
94
95
  float opacity = totalOpacity * finalShape;
95
96
 
96
- if (opacity < .005) {
97
- discard;
98
- }
97
+ vec3 bgColor = u_colorBack.rgb * u_colorBack.a;
98
+ color = color + bgColor * (1. - opacity);
99
+ opacity = opacity + u_colorBack.a * (1. - opacity);
99
100
 
100
101
  ${colorBandingFix}
101
102
 
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/shaders/metaballs.ts"],
4
- "sourcesContent": ["import type { vec4 } from '../types';\nimport type { ShaderMotionParams } from '../shader-mount';\nimport { sizingVariablesDeclaration, type ShaderSizingParams, type ShaderSizingUniforms } from '../shader-sizing';\nimport { declarePI, colorBandingFix } from '../shader-utils';\n\nexport const metaballsMeta = {\n maxColorCount: 8,\n maxBallsCount: 20,\n} as const;\n\n/**\n * Metaballs (circular shapes with gooey effect applied)\n * The artwork by Ksenia Kondrashova\n *\n * Uniforms include:\n * - uColors (vec4[]): Input RGBA colors\n * - uColorsCount (float): Number of active colors (`uColors` length)\n * - u_count (float)\n * - u_size (float)\n */\nexport const metaballsFragmentShader: string = `#version 300 es\nprecision highp float;\n\nuniform float u_time;\n\nuniform vec4 u_colors[${metaballsMeta.maxColorCount}];\nuniform float u_colorsCount;\nuniform float u_size;\nuniform float u_sizeRange;\nuniform float u_count;\n\n${sizingVariablesDeclaration}\n\nout vec4 fragColor;\n\n${declarePI}\n\nfloat hash(float x) {\n return fract(sin(x) * 43758.5453123);\n}\nfloat noise(float x) {\n float i = floor(x);\n float f = fract(x);\n float u = f * f * (3.0 - 2.0 * f);\n return mix(hash(i), hash(i + 1.0), u);\n}\n\nfloat getBallShape(vec2 uv, vec2 c, float p) {\n float s = .5 * length(uv - c);\n s = 1. - clamp(s, 0., 1.);\n s = pow(s, p);\n return s;\n}\n\nvoid main() {\n vec2 shape_uv = v_objectUV;\n\n shape_uv += .5;\n\n float t = .2 * u_time + 1.;\n\n vec3 totalColor = vec3(0.);\n float totalShape = 0.;\n float totalOpacity = 0.;\n \n for (int i = 0; i < ${metaballsMeta.maxBallsCount}; i++) {\n if (i >= int(ceil(u_count))) break;\n \n float idxFract = float(i) / float(${metaballsMeta.maxBallsCount});\n float angle = TWO_PI * idxFract;\n \n float speed = 1. - .2 * idxFract;\n float noiseX = noise(angle * 10. + float(i) + t * speed);\n float noiseY = noise(angle * 20. + float(i) - t * speed);\n \n vec2 pos = vec2(.5) + 1e-4 + .9 * (vec2(noiseX, noiseY) - .5);\n \n int safeIndex = i % int(u_colorsCount + 0.5);\n vec4 ballColor = u_colors[safeIndex];\n ballColor.rgb *= ballColor.a;\n\n float sizeFrac = 1.;\n if (float(i) > floor(u_count - 1.)) {\n sizeFrac *= fract(u_count);\n }\n\n float shape = getBallShape(shape_uv, pos, 45. - 30. * u_size * sizeFrac);\n shape *= pow(u_size, .2);\n shape = smoothstep(0., 1., shape);\n\n totalColor += ballColor.rgb * shape;\n totalShape += shape;\n totalOpacity += ballColor.a * shape;\n }\n\n totalColor /= max(totalShape, 1e-4);\n totalOpacity /= max(totalShape, 1e-4);\n\n float edge_width = fwidth(totalShape);\n float finalShape = smoothstep(.4, .4 + edge_width, totalShape);\n\n vec3 color = totalColor * finalShape;\n float opacity = totalOpacity * finalShape;\n\n if (opacity < .005) {\n discard;\n }\n\n ${colorBandingFix}\n\n fragColor = vec4(color, opacity);\n}\n`;\n\nexport interface MetaballsUniforms extends ShaderSizingUniforms {\n u_colors: vec4[];\n u_colorsCount: number;\n u_count: number;\n u_size: number;\n}\n\nexport interface MetaballsParams extends ShaderSizingParams, ShaderMotionParams {\n colors?: string[];\n count?: number;\n size?: number;\n}\n"],
5
- "mappings": ";;;;;AAEA,SAAS,kCAAsF;AAC/F,SAAS,WAAW,uBAAuB;AAEpC,MAAM,gBAAgB;AAAA,EAC3B,eAAe;AAAA,EACf,eAAe;AACjB;AAYO,MAAM,0BAAkC;AAAA;AAAA;AAAA;AAAA;AAAA,wBAKvB,cAAc,aAAa;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAMjD,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,wBA8Ba,cAAc,aAAa;AAAA;AAAA;AAAA,wCAGX,cAAc,aAAa;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAwC/D,eAAe;AAAA;AAAA;AAAA;AAAA;",
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 metaballsMeta = {\n maxColorCount: 8,\n maxBallsCount: 20,\n} as const;\n\n/**\n * Metaballs (circular shapes with gooey effect applied)\n * The artwork by Ksenia Kondrashova\n *\n * Uniforms include:\n * - u_colorBack: the background color of the scene\n * - uColors (vec4[]): Input RGBA colors\n * - uColorsCount (float): Number of active colors (`uColors` length)\n * - u_count (float)\n * - u_size (float)\n */\nexport const metaballsFragmentShader: string = `#version 300 es\nprecision mediump float;\n\nuniform float u_time;\n\nuniform vec4 u_colorBack;\nuniform vec4 u_colors[${metaballsMeta.maxColorCount}];\nuniform float u_colorsCount;\nuniform float u_size;\nuniform float u_sizeRange;\nuniform float u_count;\n\n${sizingVariablesDeclaration}\n\nout vec4 fragColor;\n\n${declarePI}\n\nfloat hash(float x) {\n return fract(sin(x) * 43758.5453123);\n}\nfloat noise(float x) {\n float i = floor(x);\n float f = fract(x);\n float u = f * f * (3.0 - 2.0 * f);\n return mix(hash(i), hash(i + 1.0), u);\n}\n\nfloat getBallShape(vec2 uv, vec2 c, float p) {\n float s = .5 * length(uv - c);\n s = 1. - clamp(s, 0., 1.);\n s = pow(s, p);\n return s;\n}\n\nvoid main() {\n vec2 shape_uv = v_objectUV;\n\n shape_uv += .5;\n\n float t = .2 * u_time + 1.;\n\n vec3 totalColor = vec3(0.);\n float totalShape = 0.;\n float totalOpacity = 0.;\n\n for (int i = 0; i < ${metaballsMeta.maxBallsCount}; i++) {\n if (i >= int(ceil(u_count))) break;\n\n float idxFract = float(i) / float(${metaballsMeta.maxBallsCount});\n float angle = TWO_PI * idxFract;\n\n float speed = 1. - .2 * idxFract;\n float noiseX = noise(angle * 10. + float(i) + t * speed);\n float noiseY = noise(angle * 20. + float(i) - t * speed);\n\n vec2 pos = vec2(.5) + 1e-4 + .9 * (vec2(noiseX, noiseY) - .5);\n\n int safeIndex = i % int(u_colorsCount + 0.5);\n vec4 ballColor = u_colors[safeIndex];\n ballColor.rgb *= ballColor.a;\n\n float sizeFrac = 1.;\n if (float(i) > floor(u_count - 1.)) {\n sizeFrac *= fract(u_count);\n }\n\n float shape = getBallShape(shape_uv, pos, 45. - 30. * u_size * sizeFrac);\n shape *= pow(u_size, .2);\n shape = smoothstep(0., 1., shape);\n\n totalColor += ballColor.rgb * shape;\n totalShape += shape;\n totalOpacity += ballColor.a * shape;\n }\n\n totalColor /= max(totalShape, 1e-4);\n totalOpacity /= max(totalShape, 1e-4);\n\n float edge_width = fwidth(totalShape);\n float finalShape = smoothstep(.4, .4 + edge_width, totalShape);\n\n vec3 color = totalColor * finalShape;\n float opacity = totalOpacity * finalShape;\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 ${colorBandingFix}\n\n fragColor = vec4(color, opacity);\n}\n`;\n\nexport interface MetaballsUniforms extends ShaderSizingUniforms {\n u_colorBack: [number, number, number, number];\n u_colors: vec4[];\n u_colorsCount: number;\n u_count: number;\n u_size: number;\n}\n\nexport interface MetaballsParams extends ShaderSizingParams, ShaderMotionParams {\n colorBack?: string;\n colors?: string[];\n count?: number;\n size?: number;\n}\n"],
5
+ "mappings": ";;;;;AAEA,SAAS,kCAAsF;AAC/F,SAAS,WAAW,uBAAuB;AAEpC,MAAM,gBAAgB;AAAA,EAC3B,eAAe;AAAA,EACf,eAAe;AACjB;AAaO,MAAM,0BAAkC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,wBAMvB,cAAc,aAAa;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAMjD,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,wBA8Ba,cAAc,aAAa;AAAA;AAAA;AAAA,wCAGX,cAAc,aAAa;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAwC/D,eAAe;AAAA;AAAA;AAAA;AAAA;",
6
6
  "names": []
7
7
  }
@@ -1,23 +1,29 @@
1
- import type { ShaderMotionParams } from '../shader-mount';
2
- import { type ShaderSizingParams, type ShaderSizingUniforms } from '../shader-sizing';
1
+ import type { ShaderMotionParams } from '../shader-mount.js';
2
+ import { type ShaderSizingParams, type ShaderSizingUniforms } from '../shader-sizing.js';
3
3
  /**
4
4
  * Neuro Noise Pattern
5
- * The original artwork: https://codepen.io/ksenia-k/full/vYwgrWv by Ksenia Kondrashova
5
+ * Original algo: https://x.com/zozuar/status/1625182758745128981/
6
6
  * Renders a fractal-like structure made of several layers of since-arches
7
7
  *
8
8
  * Uniforms include:
9
- * u_colorFront - the front color of pattern
10
- * u_colorBack - the back color of pattern
11
- * u_brightness - the power (brightness) of pattern lines
9
+ * u_colorFront - the highlights (overexposed noise areas)
10
+ * u_colorMid - the base color of pattern
11
+ * u_colorBack - the backgrond color of pattern
12
+ * u_brightness - increase/decrease the weight of strong lines
13
+ * u_contrast - show/hide the weak pattern lines
12
14
  */
13
15
  export declare const neuroNoiseFragmentShader: string;
14
16
  export interface NeuroNoiseUniforms extends ShaderSizingUniforms {
15
17
  u_colorFront: [number, number, number, number];
18
+ u_colorMid: [number, number, number, number];
16
19
  u_colorBack: [number, number, number, number];
17
20
  u_brightness: number;
21
+ u_contrast: number;
18
22
  }
19
23
  export interface NeuroNoiseParams extends ShaderSizingParams, ShaderMotionParams {
20
24
  colorFront?: string;
25
+ colorMid?: string;
21
26
  colorBack?: string;
22
27
  brightness?: number;
28
+ contrast?: number;
23
29
  }
@@ -3,18 +3,20 @@
3
3
  * https://github.com/paper-design/shaders *
4
4
  * * * * * * * * * * * * * * * * * * * * * * * * * * * */
5
5
 
6
- import { sizingVariablesDeclaration } from "../shader-sizing";
7
- import { declareRotate, colorBandingFix } from "../shader-utils";
6
+ import { sizingVariablesDeclaration } from "../shader-sizing.js";
7
+ import { declareRotate, colorBandingFix } from "../shader-utils.js";
8
8
  const neuroNoiseFragmentShader = `#version 300 es
9
- precision highp float;
9
+ precision mediump float;
10
10
 
11
11
  uniform float u_time;
12
12
  uniform vec2 u_resolution;
13
13
  uniform float u_pixelRatio;
14
14
 
15
15
  uniform vec4 u_colorFront;
16
+ uniform vec4 u_colorMid;
16
17
  uniform vec4 u_colorBack;
17
18
  uniform float u_brightness;
19
+ uniform float u_contrast;
18
20
 
19
21
 
20
22
  ${sizingVariablesDeclaration}
@@ -23,7 +25,7 @@ out vec4 fragColor;
23
25
 
24
26
  ${declareRotate}
25
27
 
26
- float neuro_shape(vec2 uv, float t) {
28
+ float neuroShape(vec2 uv, float t) {
27
29
  vec2 sine_acc = vec2(0.);
28
30
  vec2 res = vec2(0.);
29
31
  float scale = 8.;
@@ -42,19 +44,32 @@ float neuro_shape(vec2 uv, float t) {
42
44
  void main() {
43
45
  vec2 shape_uv = v_patternUV;
44
46
 
45
- shape_uv *= .002;
47
+ shape_uv *= .0013;
46
48
 
47
49
  float t = .5 * u_time;
48
50
 
49
- float noise = neuro_shape(shape_uv, t);
51
+ float noise = neuroShape(shape_uv, t);
50
52
 
51
- noise = u_brightness * pow(noise, 3.);
52
- noise += pow(noise, 12.);
53
- noise = max(.0, noise - .5);
53
+ noise = (1. + u_brightness) * pow(noise, 2.);
54
+ noise = pow(noise, .7 + 6. * u_contrast);
55
+ noise = min(1.4, noise);
56
+
57
+ float blend = smoothstep(0.7, 1.4, noise);
58
+
59
+ vec4 frontC = u_colorFront;
60
+ frontC.rgb *= frontC.a;
61
+ vec4 midC = u_colorMid;
62
+ midC.rgb *= midC.a;
63
+ vec4 blendFront = mix(midC, frontC, blend);
64
+
65
+ float safeNoise = max(noise, 0.0);
66
+ vec3 color = blendFront.rgb * safeNoise;
67
+ float opacity = clamp(blendFront.a * safeNoise, 0., 1.);
68
+
69
+ vec3 bgColor = u_colorBack.rgb * u_colorBack.a;
70
+ color = color + bgColor * (1. - opacity);
71
+ opacity = opacity + u_colorBack.a * (1. - opacity);
54
72
 
55
- vec3 color = mix(u_colorBack.rgb * u_colorBack.a, u_colorFront.rgb * u_colorFront.a, noise);
56
- float opacity = mix(u_colorBack.a, u_colorFront.a, noise);
57
-
58
73
  ${colorBandingFix}
59
74
 
60
75
  fragColor = vec4(color, opacity);
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/shaders/neuro-noise.ts"],
4
- "sourcesContent": ["import type { ShaderMotionParams } from '../shader-mount';\nimport { sizingVariablesDeclaration, type ShaderSizingParams, type ShaderSizingUniforms } from '../shader-sizing';\nimport { declareRotate, colorBandingFix } from '../shader-utils';\n\n/**\n * Neuro Noise Pattern\n * The original artwork: https://codepen.io/ksenia-k/full/vYwgrWv by Ksenia Kondrashova\n * Renders a fractal-like structure made of several layers of since-arches\n *\n * Uniforms include:\n * u_colorFront - the front color of pattern\n * u_colorBack - the back color of pattern\n * u_brightness - the power (brightness) of pattern lines\n */\nexport const neuroNoiseFragmentShader: string = `#version 300 es\nprecision highp float;\n\nuniform float u_time;\nuniform vec2 u_resolution;\nuniform float u_pixelRatio;\n\nuniform vec4 u_colorFront;\nuniform vec4 u_colorBack;\nuniform float u_brightness;\n\n\n${sizingVariablesDeclaration}\n\nout vec4 fragColor;\n\n${declareRotate}\n\nfloat neuro_shape(vec2 uv, float t) {\n vec2 sine_acc = vec2(0.);\n vec2 res = vec2(0.);\n float scale = 8.;\n\n for (int j = 0; j < 15; j++) {\n uv = rotate(uv, 1.);\n sine_acc = rotate(sine_acc, 1.);\n vec2 layer = uv * scale + float(j) + sine_acc - t;\n sine_acc += sin(layer);\n res += (.5 + .5 * cos(layer)) / scale;\n scale *= (1.2);\n }\n return res.x + res.y;\n}\n\nvoid main() {\n vec2 shape_uv = v_patternUV;\n\n shape_uv *= .002;\n\n float t = .5 * u_time;\n\n float noise = neuro_shape(shape_uv, t);\n\n noise = u_brightness * pow(noise, 3.);\n noise += pow(noise, 12.);\n noise = max(.0, noise - .5);\n\n vec3 color = mix(u_colorBack.rgb * u_colorBack.a, u_colorFront.rgb * u_colorFront.a, noise);\n float opacity = mix(u_colorBack.a, u_colorFront.a, noise);\n \n ${colorBandingFix}\n\n fragColor = vec4(color, opacity);\n}\n`;\n\nexport interface NeuroNoiseUniforms extends ShaderSizingUniforms {\n u_colorFront: [number, number, number, number];\n u_colorBack: [number, number, number, number];\n u_brightness: number;\n}\n\nexport interface NeuroNoiseParams extends ShaderSizingParams, ShaderMotionParams {\n colorFront?: string;\n colorBack?: string;\n brightness?: number;\n}\n"],
5
- "mappings": ";;;;;AACA,SAAS,kCAAsF;AAC/F,SAAS,eAAe,uBAAuB;AAYxC,MAAM,2BAAmC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAY9C,0BAA0B;AAAA;AAAA;AAAA;AAAA,EAI1B,aAAa;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAkCX,eAAe;AAAA;AAAA;AAAA;AAAA;",
4
+ "sourcesContent": ["import type { ShaderMotionParams } from '../shader-mount.js';\nimport { sizingVariablesDeclaration, type ShaderSizingParams, type ShaderSizingUniforms } from '../shader-sizing.js';\nimport { declareRotate, colorBandingFix } from '../shader-utils.js';\n\n/**\n * Neuro Noise Pattern\n * Original algo: https://x.com/zozuar/status/1625182758745128981/\n * Renders a fractal-like structure made of several layers of since-arches\n *\n * Uniforms include:\n * u_colorFront - the highlights (overexposed noise areas)\n * u_colorMid - the base color of pattern\n * u_colorBack - the backgrond color of pattern\n * u_brightness - increase/decrease the weight of strong lines\n * u_contrast - show/hide the weak pattern lines\n */\nexport const neuroNoiseFragmentShader: string = `#version 300 es\nprecision mediump float;\n\nuniform float u_time;\nuniform vec2 u_resolution;\nuniform float u_pixelRatio;\n\nuniform vec4 u_colorFront;\nuniform vec4 u_colorMid;\nuniform vec4 u_colorBack;\nuniform float u_brightness;\nuniform float u_contrast;\n\n\n${sizingVariablesDeclaration}\n\nout vec4 fragColor;\n\n${declareRotate}\n\nfloat neuroShape(vec2 uv, float t) {\n vec2 sine_acc = vec2(0.);\n vec2 res = vec2(0.);\n float scale = 8.;\n\n for (int j = 0; j < 15; j++) {\n uv = rotate(uv, 1.);\n sine_acc = rotate(sine_acc, 1.);\n vec2 layer = uv * scale + float(j) + sine_acc - t;\n sine_acc += sin(layer);\n res += (.5 + .5 * cos(layer)) / scale;\n scale *= (1.2);\n }\n return res.x + res.y;\n}\n\nvoid main() {\n vec2 shape_uv = v_patternUV;\n\n shape_uv *= .0013;\n\n float t = .5 * u_time;\n\n float noise = neuroShape(shape_uv, t);\n\n noise = (1. + u_brightness) * pow(noise, 2.);\n noise = pow(noise, .7 + 6. * u_contrast);\n noise = min(1.4, noise);\n\n float blend = smoothstep(0.7, 1.4, noise);\n\n vec4 frontC = u_colorFront;\n frontC.rgb *= frontC.a;\n vec4 midC = u_colorMid;\n midC.rgb *= midC.a;\n vec4 blendFront = mix(midC, frontC, blend);\n\n float safeNoise = max(noise, 0.0);\n vec3 color = blendFront.rgb * safeNoise;\n float opacity = clamp(blendFront.a * safeNoise, 0., 1.);\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 ${colorBandingFix}\n\n fragColor = vec4(color, opacity);\n}\n`;\n\nexport interface NeuroNoiseUniforms extends ShaderSizingUniforms {\n u_colorFront: [number, number, number, number];\n u_colorMid: [number, number, number, number];\n u_colorBack: [number, number, number, number];\n u_brightness: number;\n u_contrast: number;\n}\n\nexport interface NeuroNoiseParams extends ShaderSizingParams, ShaderMotionParams {\n colorFront?: string;\n colorMid?: string;\n colorBack?: string;\n brightness?: number;\n contrast?: number;\n}\n"],
5
+ "mappings": ";;;;;AACA,SAAS,kCAAsF;AAC/F,SAAS,eAAe,uBAAuB;AAcxC,MAAM,2BAAmC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAc9C,0BAA0B;AAAA;AAAA;AAAA;AAAA,EAI1B,aAAa;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IA+CX,eAAe;AAAA;AAAA;AAAA;AAAA;",
6
6
  "names": []
7
7
  }
@@ -1,14 +1,14 @@
1
- import type { ShaderMotionParams } from '../shader-mount';
2
- import { type ShaderSizingParams, type ShaderSizingUniforms } from '../shader-sizing';
1
+ import type { ShaderMotionParams } from '../shader-mount.js';
2
+ import { type ShaderSizingParams, type ShaderSizingUniforms } from '../shader-sizing.js';
3
3
  /**
4
4
  * 3d Perlin noise with exposed parameters
5
5
  * Based on https://www.shadertoy.com/view/NlSGDz
6
6
  *
7
7
  * Uniforms include:
8
- * u_color1 - the first mixed color
9
- * u_color2 - the second mixed color
10
- * u_proportion (0 .. 1) - the proportion between u_color1 and u_color2;
11
- * u_softness - the sharpness of the transition between u_color1 and u_color2 in the noise output
8
+ * u_colorFront - the first mixed color
9
+ * u_colorBack - the second mixed color
10
+ * u_proportion (0 .. 1) - the proportion between u_colorFront and u_colorBack;
11
+ * u_softness - the sharpness of the transition between u_colorFront and u_colorBack in the noise output
12
12
  * u_octaveCount - the number of octaves for Perlin noise;
13
13
  * higher values increase the complexity of the noise
14
14
  * u_persistence (0 .. 1) - the amplitude of each successive octave of the noise;
@@ -18,8 +18,8 @@ import { type ShaderSizingParams, type ShaderSizingUniforms } from '../shader-si
18
18
  */
19
19
  export declare const perlinNoiseFragmentShader: string;
20
20
  export interface PerlinNoiseUniforms extends ShaderSizingUniforms {
21
- u_color1: [number, number, number, number];
22
- u_color2: [number, number, number, number];
21
+ u_colorFront: [number, number, number, number];
22
+ u_colorBack: [number, number, number, number];
23
23
  u_proportion: number;
24
24
  u_softness: number;
25
25
  u_octaveCount: number;
@@ -27,8 +27,8 @@ export interface PerlinNoiseUniforms extends ShaderSizingUniforms {
27
27
  u_lacunarity: number;
28
28
  }
29
29
  export interface PerlinNoiseParams extends ShaderSizingParams, ShaderMotionParams {
30
- color1?: string;
31
- color2?: string;
30
+ colorFront?: string;
31
+ colorBack?: string;
32
32
  proportion?: number;
33
33
  softness?: number;
34
34
  octaveCount?: number;
@@ -3,15 +3,15 @@
3
3
  * https://github.com/paper-design/shaders *
4
4
  * * * * * * * * * * * * * * * * * * * * * * * * * * * */
5
5
 
6
- import { sizingVariablesDeclaration } from "../shader-sizing";
7
- import { declarePI, colorBandingFix } from "../shader-utils";
6
+ import { sizingVariablesDeclaration } from "../shader-sizing.js";
7
+ import { declarePI, colorBandingFix } from "../shader-utils.js";
8
8
  const perlinNoiseFragmentShader = `#version 300 es
9
- precision highp float;
9
+ precision mediump float;
10
10
 
11
11
  uniform float u_time;
12
12
 
13
- uniform vec4 u_color1;
14
- uniform vec4 u_color2;
13
+ uniform vec4 u_colorFront;
14
+ uniform vec4 u_colorBack;
15
15
  uniform float u_proportion;
16
16
  uniform float u_softness;
17
17
  uniform float u_octaveCount;
@@ -158,29 +158,37 @@ float get_max_amp(float persistence, float octaveCount) {
158
158
  }
159
159
 
160
160
  void main() {
161
- vec2 shape_uv = v_patternUV;
161
+ vec2 uv = v_patternUV;
162
162
 
163
- shape_uv *= .005;
163
+ uv *= .005;
164
164
  float t = .2 * u_time;
165
165
 
166
- vec3 p = vec3(shape_uv, t);
166
+ vec3 p = vec3(uv, t);
167
167
 
168
- float oct_count = max(0., floor(u_octaveCount));
169
- float persistence = clamp(u_persistence, 0., 1.);
170
- float noise = p_noise(p, int(oct_count), persistence, u_lacunarity);
168
+ float oct_count = max(0., floor(u_octaveCount));
169
+ float persistence = clamp(u_persistence, 0., 1.);
170
+ float noise = p_noise(p, int(oct_count), persistence, u_lacunarity);
171
171
 
172
- float max_amp = get_max_amp(persistence, oct_count);
173
- float noise_normalized = (noise + max_amp) / (2. * max_amp) + (u_proportion - .5);
174
- float sharpness = clamp(u_softness, 0., 1.);
175
- float smooth_w = 0.5 * fwidth(noise_normalized);
176
- float sharp_noise = smoothstep(
177
- .5 - .5 * sharpness - smooth_w,
178
- .5 + .5 * sharpness + smooth_w,
179
- noise_normalized
180
- );
172
+ float max_amp = get_max_amp(persistence, oct_count);
173
+ float noise_normalized = (noise + max_amp) / (2. * max_amp) + (u_proportion - .5);
174
+ float sharpness = clamp(u_softness, 0., 1.);
175
+ float smooth_w = 0.5 * fwidth(noise_normalized);
176
+ float res = smoothstep(
177
+ .5 - .5 * sharpness - smooth_w,
178
+ .5 + .5 * sharpness + smooth_w,
179
+ noise_normalized
180
+ );
181
+
182
+ vec3 fgColor = u_colorFront.rgb * u_colorFront.a;
183
+ float fgOpacity = u_colorFront.a;
184
+ vec3 bgColor = u_colorBack.rgb * u_colorBack.a;
185
+ float bgOpacity = u_colorBack.a;
186
+
187
+ vec3 color = fgColor * res;
188
+ float opacity = fgOpacity * res;
181
189
 
182
- vec3 color = mix(u_color1.rgb * u_color1.a, u_color2.rgb * u_color2.a, sharp_noise);
183
- float opacity = mix(u_color1.a, u_color2.a, sharp_noise);
190
+ color += bgColor * (1. - opacity);
191
+ opacity += bgOpacity * (1. - opacity);
184
192
 
185
193
  ${colorBandingFix}
186
194
 
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/shaders/perlin-noise.ts"],
4
- "sourcesContent": ["import type { ShaderMotionParams } from '../shader-mount';\nimport { sizingVariablesDeclaration, type ShaderSizingParams, type ShaderSizingUniforms } from '../shader-sizing';\nimport { declarePI, colorBandingFix } from '../shader-utils';\n\n/**\n * 3d Perlin noise with exposed parameters\n * Based on https://www.shadertoy.com/view/NlSGDz\n *\n * Uniforms include:\n * u_color1 - the first mixed color\n * u_color2 - the second mixed color\n * u_proportion (0 .. 1) - the proportion between u_color1 and u_color2;\n * u_softness - the sharpness of the transition between u_color1 and u_color2 in the noise output\n * u_octaveCount - the number of octaves for Perlin noise;\n * higher values increase the complexity of the noise\n * u_persistence (0 .. 1) - the amplitude of each successive octave of the noise;\n * lower values make higher octaves less pronounced\n * u_lacunarity - the frequency of each successive octave of the noise;\n * higher values increase the detail\n */\nexport const perlinNoiseFragmentShader: string = `#version 300 es\nprecision highp float;\n\nuniform float u_time;\n\nuniform vec4 u_color1;\nuniform vec4 u_color2;\nuniform float u_proportion;\nuniform float u_softness;\nuniform float u_octaveCount;\nuniform float u_persistence;\nuniform float u_lacunarity;\n\n${sizingVariablesDeclaration}\n\nout vec4 fragColor;\n\n${declarePI}\n\nuint hash(uint x, uint seed) {\n const uint m = 0x5bd1e995U;\n uint hash = seed;\n // process input\n uint k = x;\n k *= m;\n k ^= k >> 24;\n k *= m;\n hash *= m;\n hash ^= k;\n // some final mixing\n hash ^= hash >> 13;\n hash *= m;\n hash ^= hash >> 15;\n return hash;\n}\n\nuint hash(uvec3 x, uint seed){\n const uint m = 0x5bd1e995U;\n uint hash = seed;\n // process first vector element\n uint k = x.x;\n k *= m;\n k ^= k >> 24;\n k *= m;\n hash *= m;\n hash ^= k;\n // process second vector element\n k = x.y;\n k *= m;\n k ^= k >> 24;\n k *= m;\n hash *= m;\n hash ^= k;\n // process third vector element\n k = x.z;\n k *= m;\n k ^= k >> 24;\n k *= m;\n hash *= m;\n hash ^= k;\n // some final mixing\n hash ^= hash >> 13;\n hash *= m;\n hash ^= hash >> 15;\n return hash;\n}\n\n\nvec3 gradientdy(uint hash) {\n switch (int(hash) & 15) { // look at the last four bits to pick a gradient dy\n case 0:\n return vec3(1, 1, 0);\n case 1:\n return vec3(-1, 1, 0);\n case 2:\n return vec3(1, -1, 0);\n case 3:\n return vec3(-1, -1, 0);\n case 4:\n return vec3(1, 0, 1);\n case 5:\n return vec3(-1, 0, 1);\n case 6:\n return vec3(1, 0, -1);\n case 7:\n return vec3(-1, 0, -1);\n case 8:\n return vec3(0, 1, 1);\n case 9:\n return vec3(0, -1, 1);\n case 10:\n return vec3(0, 1, -1);\n case 11:\n return vec3(0, -1, -1);\n case 12:\n return vec3(1, 1, 0);\n case 13:\n return vec3(-1, 1, 0);\n case 14:\n return vec3(0, -1, 1);\n case 15:\n return vec3(0, -1, -1);\n }\n}\n\nfloat interpolate(float value1, float value2, float value3, float value4, float value5, float value6, float value7, float value8, vec3 t) {\n return mix(\n mix(mix(value1, value2, t.x), mix(value3, value4, t.x), t.y),\n mix(mix(value5, value6, t.x), mix(value7, value8, t.x), t.y),\n t.z\n );\n}\n\nvec3 fade(vec3 t) {\n return t * t * t * (t * (t * 6.0 - 15.0) + 10.0);\n}\n\nfloat perlinNoise(vec3 position, uint seed) {\n position += 1e+4;\n vec3 floorPosition = floor(position);\n vec3 fractPosition = fract(position);\n uvec3 cellCoordinates = uvec3(floorPosition);\n float value1 = dot(gradientdy(hash(cellCoordinates, seed)), fractPosition);\n float value2 = dot(gradientdy(hash((cellCoordinates + uvec3(1, 0, 0)), seed)), fractPosition - vec3(1, 0, 0));\n float value3 = dot(gradientdy(hash((cellCoordinates + uvec3(0, 1, 0)), seed)), fractPosition - vec3(0, 1, 0));\n float value4 = dot(gradientdy(hash((cellCoordinates + uvec3(1, 1, 0)), seed)), fractPosition - vec3(1, 1, 0));\n float value5 = dot(gradientdy(hash((cellCoordinates + uvec3(0, 0, 1)), seed)), fractPosition - vec3(0, 0, 1));\n float value6 = dot(gradientdy(hash((cellCoordinates + uvec3(1, 0, 1)), seed)), fractPosition - vec3(1, 0, 1));\n float value7 = dot(gradientdy(hash((cellCoordinates + uvec3(0, 1, 1)), seed)), fractPosition - vec3(0, 1, 1));\n float value8 = dot(gradientdy(hash((cellCoordinates + uvec3(1, 1, 1)), seed)), fractPosition - vec3(1, 1, 1));\n return interpolate(value1, value2, value3, value4, value5, value6, value7, value8, fade(fractPosition));\n}\n\nfloat p_noise(vec3 position, int octaveCount, float persistence, float lacunarity) {\n float value = 0.0;\n float amplitude = 1.0;\n float currentFrequency = 10.;\n uint currentSeed = uint(0);\n for (int i = 0; i < octaveCount; i++) {\n currentSeed = hash(currentSeed, 0x0U);\n value += perlinNoise(position * currentFrequency, currentSeed) * amplitude;\n amplitude *= persistence;\n currentFrequency *= lacunarity;\n }\n return value;\n}\n\nfloat get_max_amp(float persistence, float octaveCount) {\n persistence *= .999;\n return (1. - pow(persistence, octaveCount)) / (1. - persistence);\n}\n\nvoid main() {\n vec2 shape_uv = v_patternUV;\n\n shape_uv *= .005;\n float t = .2 * u_time;\n\n vec3 p = vec3(shape_uv, t);\n\n float oct_count = max(0., floor(u_octaveCount));\n float persistence = clamp(u_persistence, 0., 1.);\n float noise = p_noise(p, int(oct_count), persistence, u_lacunarity);\n\n float max_amp = get_max_amp(persistence, oct_count);\n float noise_normalized = (noise + max_amp) / (2. * max_amp) + (u_proportion - .5);\n float sharpness = clamp(u_softness, 0., 1.);\n float smooth_w = 0.5 * fwidth(noise_normalized);\n float sharp_noise = smoothstep(\n .5 - .5 * sharpness - smooth_w,\n .5 + .5 * sharpness + smooth_w,\n noise_normalized\n );\n\n vec3 color = mix(u_color1.rgb * u_color1.a, u_color2.rgb * u_color2.a, sharp_noise);\n float opacity = mix(u_color1.a, u_color2.a, sharp_noise);\n\n ${colorBandingFix}\n\n fragColor = vec4(color, opacity);\n}\n`;\n\nexport interface PerlinNoiseUniforms extends ShaderSizingUniforms {\n u_color1: [number, number, number, number];\n u_color2: [number, number, number, number];\n u_proportion: number;\n u_softness: number;\n u_octaveCount: number;\n u_persistence: number;\n u_lacunarity: number;\n}\n\nexport interface PerlinNoiseParams extends ShaderSizingParams, ShaderMotionParams {\n color1?: string;\n color2?: string;\n proportion?: number;\n softness?: number;\n octaveCount?: number;\n persistence?: number;\n lacunarity?: number;\n}\n"],
5
- "mappings": ";;;;;AACA,SAAS,kCAAsF;AAC/F,SAAS,WAAW,uBAAuB;AAkBpC,MAAM,4BAAoC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAa/C,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;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAgKP,eAAe;AAAA;AAAA;AAAA;AAAA;",
4
+ "sourcesContent": ["import type { ShaderMotionParams } from '../shader-mount.js';\nimport { sizingVariablesDeclaration, type ShaderSizingParams, type ShaderSizingUniforms } from '../shader-sizing.js';\nimport { declarePI, colorBandingFix } from '../shader-utils.js';\n\n/**\n * 3d Perlin noise with exposed parameters\n * Based on https://www.shadertoy.com/view/NlSGDz\n *\n * Uniforms include:\n * u_colorFront - the first mixed color\n * u_colorBack - the second mixed color\n * u_proportion (0 .. 1) - the proportion between u_colorFront and u_colorBack;\n * u_softness - the sharpness of the transition between u_colorFront and u_colorBack in the noise output\n * u_octaveCount - the number of octaves for Perlin noise;\n * higher values increase the complexity of the noise\n * u_persistence (0 .. 1) - the amplitude of each successive octave of the noise;\n * lower values make higher octaves less pronounced\n * u_lacunarity - the frequency of each successive octave of the noise;\n * higher values increase the detail\n */\nexport const perlinNoiseFragmentShader: string = `#version 300 es\nprecision mediump float;\n\nuniform float u_time;\n\nuniform vec4 u_colorFront;\nuniform vec4 u_colorBack;\nuniform float u_proportion;\nuniform float u_softness;\nuniform float u_octaveCount;\nuniform float u_persistence;\nuniform float u_lacunarity;\n\n${sizingVariablesDeclaration}\n\nout vec4 fragColor;\n\n${declarePI}\n\nuint hash(uint x, uint seed) {\n const uint m = 0x5bd1e995U;\n uint hash = seed;\n // process input\n uint k = x;\n k *= m;\n k ^= k >> 24;\n k *= m;\n hash *= m;\n hash ^= k;\n // some final mixing\n hash ^= hash >> 13;\n hash *= m;\n hash ^= hash >> 15;\n return hash;\n}\n\nuint hash(uvec3 x, uint seed){\n const uint m = 0x5bd1e995U;\n uint hash = seed;\n // process first vector element\n uint k = x.x;\n k *= m;\n k ^= k >> 24;\n k *= m;\n hash *= m;\n hash ^= k;\n // process second vector element\n k = x.y;\n k *= m;\n k ^= k >> 24;\n k *= m;\n hash *= m;\n hash ^= k;\n // process third vector element\n k = x.z;\n k *= m;\n k ^= k >> 24;\n k *= m;\n hash *= m;\n hash ^= k;\n // some final mixing\n hash ^= hash >> 13;\n hash *= m;\n hash ^= hash >> 15;\n return hash;\n}\n\n\nvec3 gradientdy(uint hash) {\n switch (int(hash) & 15) { // look at the last four bits to pick a gradient dy\n case 0:\n return vec3(1, 1, 0);\n case 1:\n return vec3(-1, 1, 0);\n case 2:\n return vec3(1, -1, 0);\n case 3:\n return vec3(-1, -1, 0);\n case 4:\n return vec3(1, 0, 1);\n case 5:\n return vec3(-1, 0, 1);\n case 6:\n return vec3(1, 0, -1);\n case 7:\n return vec3(-1, 0, -1);\n case 8:\n return vec3(0, 1, 1);\n case 9:\n return vec3(0, -1, 1);\n case 10:\n return vec3(0, 1, -1);\n case 11:\n return vec3(0, -1, -1);\n case 12:\n return vec3(1, 1, 0);\n case 13:\n return vec3(-1, 1, 0);\n case 14:\n return vec3(0, -1, 1);\n case 15:\n return vec3(0, -1, -1);\n }\n}\n\nfloat interpolate(float value1, float value2, float value3, float value4, float value5, float value6, float value7, float value8, vec3 t) {\n return mix(\n mix(mix(value1, value2, t.x), mix(value3, value4, t.x), t.y),\n mix(mix(value5, value6, t.x), mix(value7, value8, t.x), t.y),\n t.z\n );\n}\n\nvec3 fade(vec3 t) {\n return t * t * t * (t * (t * 6.0 - 15.0) + 10.0);\n}\n\nfloat perlinNoise(vec3 position, uint seed) {\n position += 1e+4;\n vec3 floorPosition = floor(position);\n vec3 fractPosition = fract(position);\n uvec3 cellCoordinates = uvec3(floorPosition);\n float value1 = dot(gradientdy(hash(cellCoordinates, seed)), fractPosition);\n float value2 = dot(gradientdy(hash((cellCoordinates + uvec3(1, 0, 0)), seed)), fractPosition - vec3(1, 0, 0));\n float value3 = dot(gradientdy(hash((cellCoordinates + uvec3(0, 1, 0)), seed)), fractPosition - vec3(0, 1, 0));\n float value4 = dot(gradientdy(hash((cellCoordinates + uvec3(1, 1, 0)), seed)), fractPosition - vec3(1, 1, 0));\n float value5 = dot(gradientdy(hash((cellCoordinates + uvec3(0, 0, 1)), seed)), fractPosition - vec3(0, 0, 1));\n float value6 = dot(gradientdy(hash((cellCoordinates + uvec3(1, 0, 1)), seed)), fractPosition - vec3(1, 0, 1));\n float value7 = dot(gradientdy(hash((cellCoordinates + uvec3(0, 1, 1)), seed)), fractPosition - vec3(0, 1, 1));\n float value8 = dot(gradientdy(hash((cellCoordinates + uvec3(1, 1, 1)), seed)), fractPosition - vec3(1, 1, 1));\n return interpolate(value1, value2, value3, value4, value5, value6, value7, value8, fade(fractPosition));\n}\n\nfloat p_noise(vec3 position, int octaveCount, float persistence, float lacunarity) {\n float value = 0.0;\n float amplitude = 1.0;\n float currentFrequency = 10.;\n uint currentSeed = uint(0);\n for (int i = 0; i < octaveCount; i++) {\n currentSeed = hash(currentSeed, 0x0U);\n value += perlinNoise(position * currentFrequency, currentSeed) * amplitude;\n amplitude *= persistence;\n currentFrequency *= lacunarity;\n }\n return value;\n}\n\nfloat get_max_amp(float persistence, float octaveCount) {\n persistence *= .999;\n return (1. - pow(persistence, octaveCount)) / (1. - persistence);\n}\n\nvoid main() {\n vec2 uv = v_patternUV;\n\n uv *= .005;\n float t = .2 * u_time;\n\n vec3 p = vec3(uv, t);\n\n float oct_count = max(0., floor(u_octaveCount));\n float persistence = clamp(u_persistence, 0., 1.);\n float noise = p_noise(p, int(oct_count), persistence, u_lacunarity);\n\n float max_amp = get_max_amp(persistence, oct_count);\n float noise_normalized = (noise + max_amp) / (2. * max_amp) + (u_proportion - .5);\n float sharpness = clamp(u_softness, 0., 1.);\n float smooth_w = 0.5 * fwidth(noise_normalized);\n float res = smoothstep(\n .5 - .5 * sharpness - smooth_w,\n .5 + .5 * sharpness + smooth_w,\n noise_normalized\n );\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 ${colorBandingFix}\n\n fragColor = vec4(color, opacity);\n}\n`;\n\nexport interface PerlinNoiseUniforms extends ShaderSizingUniforms {\n u_colorFront: [number, number, number, number];\n u_colorBack: [number, number, number, number];\n u_proportion: number;\n u_softness: number;\n u_octaveCount: number;\n u_persistence: number;\n u_lacunarity: number;\n}\n\nexport interface PerlinNoiseParams extends ShaderSizingParams, ShaderMotionParams {\n colorFront?: string;\n colorBack?: string;\n proportion?: number;\n softness?: number;\n octaveCount?: number;\n persistence?: number;\n lacunarity?: number;\n}\n"],
5
+ "mappings": ";;;;;AACA,SAAS,kCAAsF;AAC/F,SAAS,WAAW,uBAAuB;AAkBpC,MAAM,4BAAoC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAa/C,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;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAwKP,eAAe;AAAA;AAAA;AAAA;AAAA;",
6
6
  "names": []
7
7
  }
@@ -1,6 +1,6 @@
1
- import type { vec4 } from '../types';
2
- import type { ShaderMotionParams } from '../shader-mount';
3
- import { type ShaderSizingParams, type ShaderSizingUniforms } from '../shader-sizing';
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
4
  export declare const pulsingBorderMeta: {
5
5
  readonly maxColorCount: 5;
6
6
  readonly maxSpotsPerColor: 5;
@@ -3,8 +3,8 @@
3
3
  * https://github.com/paper-design/shaders *
4
4
  * * * * * * * * * * * * * * * * * * * * * * * * * * * */
5
5
 
6
- import { sizingVariablesDeclaration } from "../shader-sizing";
7
- import { declarePI, colorBandingFix } from "../shader-utils";
6
+ import { sizingVariablesDeclaration } from "../shader-sizing.js";
7
+ import { declarePI, colorBandingFix } from "../shader-utils.js";
8
8
  const pulsingBorderMeta = {
9
9
  maxColorCount: 5,
10
10
  maxSpotsPerColor: 5
@@ -37,7 +37,7 @@ out vec4 fragColor;
37
37
  ${declarePI}
38
38
 
39
39
  float roundedBox(vec2 uv, vec2 halfSize, float radius, float distance, float edgeSoftness) {
40
-
40
+
41
41
  float borderDistance = abs(distance) - .5 * u_thickness;
42
42
  float border = 1. - smoothstep(-.5 * edgeSoftness, .5 * edgeSoftness, borderDistance);
43
43
  border *= border;
@@ -46,24 +46,24 @@ float roundedBox(vec2 uv, vec2 halfSize, float radius, float distance, float edg
46
46
  vec2 v1 = uv - vec2(-halfSize.x, halfSize.y);
47
47
  vec2 v2 = uv - vec2(halfSize.x, -halfSize.y);
48
48
  vec2 v3 = uv - halfSize;
49
-
49
+
50
50
  float mult = (.07 - .25 * radius);
51
51
  float m0 = mult * clamp(pow(1. - abs(v0.x - v0.y), 20.), 0., 1.);
52
52
  float m1 = mult * clamp(pow(1. - abs(v1.x + v1.y), 20.), 0., 1.);
53
53
  float m2 = mult * clamp(pow(1. - abs(v2.x + v2.y), 20.), 0., 1.);
54
54
  float m3 = mult * clamp(pow(1. - abs(v3.x - v3.y), 20.), 0., 1.);
55
-
55
+
56
56
  float l = edgeSoftness * .5 + .75 * u_thickness;
57
57
  float fade0 = 1. - clamp(length(v0) / l, 0., 1.);
58
58
  float fade1 = 1. - clamp(length(v1) / l, 0., 1.);
59
59
  float fade2 = 1. - clamp(length(v2) / l, 0., 1.);
60
60
  float fade3 = 1. - clamp(length(v3) / l, 0., 1.);
61
-
61
+
62
62
  m0 *= fade0;
63
63
  m1 *= fade1;
64
64
  m2 *= fade2;
65
65
  m3 *= fade3;
66
-
66
+
67
67
  float fillFix = m0 + m1 + m2 + m3;
68
68
  fillFix *= step(distance, 0.);
69
69
  fillFix *= (1. + 3. * u_thickness);
@@ -82,7 +82,7 @@ float roundedBoxSmoke(vec2 uv, vec2 halfSize, float radius, float distance, floa
82
82
  vec2 v1 = uv - vec2(-halfSize.x, halfSize.y);
83
83
  vec2 v2 = uv - vec2(halfSize.x, -halfSize.y);
84
84
  vec2 v3 = uv - halfSize;
85
-
85
+
86
86
  float l_mask = .5;
87
87
  float mask = smoothstep(0., 1., length(v0) / l_mask);
88
88
  mask *= smoothstep(0., 1., length(v1) / l_mask);
@@ -121,12 +121,12 @@ float getWaveformValue(float time) {
121
121
  void main() {
122
122
 
123
123
  float t = .5 * u_time + 20.;
124
-
124
+
125
125
  vec2 borderUV = v_responsiveUV;
126
126
 
127
127
  float angle = atan(borderUV.y, borderUV.x) / TWO_PI;
128
-
129
-
128
+
129
+
130
130
  float borderRatio = v_responsiveBoxGivenSize.x / v_responsiveBoxGivenSize.y;
131
131
  borderUV.x *= borderRatio;
132
132
  vec2 halfSize = vec2(.5);
@@ -136,11 +136,11 @@ void main() {
136
136
  float outsideDistance = length(max(d, 0.)) - radius;
137
137
  float insideDistance = min(max(d.x, d.y), 0.0);
138
138
  float distance = outsideDistance + insideDistance;
139
-
139
+
140
140
  float border = roundedBox(borderUV, halfSize, radius, distance, .5 * u_softness);
141
141
 
142
142
  float pulse = u_pulse * getWaveformValue(.18 * u_time);
143
-
143
+
144
144
  border *= (1. + .1 * pulse);
145
145
  border *= (1. + u_intensity);
146
146
 
@@ -159,53 +159,53 @@ void main() {
159
159
 
160
160
  vec3 color = vec3(0.);
161
161
  float opacity = 0.;
162
-
162
+
163
163
  vec3 accumColor = vec3(0.);
164
164
  float accumAlpha = 0.;
165
-
165
+
166
166
  for (int i = 0; i < ${pulsingBorderMeta.maxSpotsPerColor}; i++) {
167
167
  if (i >= int(u_spotsPerColor)) break;
168
168
  float idx = float(i);
169
-
169
+
170
170
  for (int j = 0; j < ${pulsingBorderMeta.maxColorCount}; j++) {
171
171
  if (j >= int(u_colorsCount)) break;
172
172
  float colorIdx = float(j);
173
173
 
174
174
  vec2 randVal = rand(vec2(idx * 10. + 2., 40. + colorIdx));
175
-
175
+
176
176
  float time = (.1 + .15 * abs(sin(idx * (2. + colorIdx)) * cos(idx * (2. + 2.5 * colorIdx)))) * t + randVal.x * 3.;
177
177
  time *= mix(1., -1., step(.5, randVal.y));
178
-
178
+
179
179
  float mask = .2 + mix(
180
180
  sin(t + idx * (5. - 1.5 * colorIdx)),
181
181
  cos(t + idx * (3. + 1.3 * colorIdx)),
182
182
  step(mod(colorIdx, 2.), .5)
183
183
  );
184
-
184
+
185
185
  mask += pulse;
186
186
  if (mask < 0.) continue;
187
-
187
+
188
188
  float atg1 = fract(angle + time);
189
189
  float sector = smoothstep(.5 - u_spotSize, .5, atg1) * smoothstep(.5 + u_spotSize, .5, atg1);
190
190
  sector *= border;
191
191
  sector *= mask;
192
192
  sector = clamp(sector, 0., 1.);
193
-
193
+
194
194
  sectorsTotal += sector;
195
-
195
+
196
196
  float alpha = sector * u_colors[j].a;
197
197
  accumColor += u_colors[j].rgb * alpha;
198
198
  accumAlpha += alpha;
199
199
  }
200
200
  }
201
-
201
+
202
202
  color = accumColor;
203
203
  opacity = clamp(accumAlpha, 0., 1.);
204
-
204
+
205
205
  vec3 bgColor = u_colorBack.rgb * u_colorBack.a;
206
206
  color = color + bgColor * (1. - opacity);
207
207
  opacity = opacity + u_colorBack.a * (1. - opacity);
208
-
208
+
209
209
  ${colorBandingFix}
210
210
 
211
211
  fragColor = vec4(color, opacity);