@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,230 @@
1
+ /* * * * * * * * * * * * * * * * * * * * * * * * * * * *
2
+ * Paper Shaders *
3
+ * https://github.com/paper-design/shaders *
4
+ * * * * * * * * * * * * * * * * * * * * * * * * * * * */
5
+
6
+ const sizingVariablesDeclaration = `
7
+ in vec2 v_objectUV;
8
+ in vec2 v_responsiveUV;
9
+ in vec2 v_responsiveBoxGivenSize;
10
+ in vec2 v_patternUV;
11
+ in vec2 v_imageUV;`;
12
+ const sizingDebugVariablesDeclaration = `
13
+ in vec2 v_objectBoxSize;
14
+ in vec2 v_objectHelperBox;
15
+ in vec2 v_responsiveBoxSize;
16
+ in vec2 v_responsiveHelperBox;
17
+ in vec2 v_patternBoxSize;
18
+ in vec2 v_patternHelperBox;`;
19
+ const sizingUniformsDeclaration = `
20
+ uniform float u_originX;
21
+ uniform float u_originY;
22
+ uniform float u_worldWidth;
23
+ uniform float u_worldHeight;
24
+ uniform float u_fit;
25
+
26
+ uniform float u_scale;
27
+ uniform float u_rotation;
28
+ uniform float u_offsetX;
29
+ uniform float u_offsetY;`;
30
+ const sizingUV = `
31
+
32
+ vec2 uv = gl_FragCoord.xy / u_resolution.xy;
33
+ #ifdef USE_PIXELIZATION
34
+ float pxSize = u_pxSize * u_pixelRatio;
35
+ vec2 pxSizeUv = gl_FragCoord.xy;
36
+ pxSizeUv -= .5 * u_resolution;
37
+ pxSizeUv /= pxSize;
38
+ uv = floor(pxSizeUv) * pxSize / u_resolution.xy;
39
+ uv += .5;
40
+ #endif
41
+ uv -= .5;
42
+
43
+
44
+ // ===================================================
45
+ // sizing params shared between objects and patterns
46
+
47
+ vec2 boxOrigin = vec2(.5 - u_originX, u_originY - .5);
48
+ vec2 givenBoxSize = vec2(u_worldWidth, u_worldHeight);
49
+ givenBoxSize = max(givenBoxSize, vec2(1.)) * u_pixelRatio;
50
+ float r = u_rotation * 3.14159265358979323846 / 180.;
51
+ mat2 graphicRotation = mat2(cos(r), sin(r), -sin(r), cos(r));
52
+ vec2 graphicOffset = vec2(-u_offsetX, u_offsetY);
53
+
54
+
55
+ // ===================================================
56
+ // Sizing api for objects (graphics with fixed ratio)
57
+
58
+ #ifdef USE_OBJECT_SIZING
59
+ float fixedRatio = 1.;
60
+ vec2 fixedRatioBoxGivenSize = vec2(
61
+ (u_worldWidth == 0.) ? u_resolution.x : givenBoxSize.x,
62
+ (u_worldHeight == 0.) ? u_resolution.y : givenBoxSize.y
63
+ );
64
+ vec2 objectBoxSize = vec2(0.);
65
+ // fit = none
66
+ objectBoxSize.x = fixedRatio * min(fixedRatioBoxGivenSize.x / fixedRatio, fixedRatioBoxGivenSize.y);
67
+ if (u_fit == 1.) { // fit = contain
68
+ objectBoxSize.x = fixedRatio * min(u_resolution.x / fixedRatio, u_resolution.y);
69
+ } else if (u_fit == 2.) { // fit = cover
70
+ objectBoxSize.x = fixedRatio * max(u_resolution.x / fixedRatio, u_resolution.y);
71
+ }
72
+ objectBoxSize.y = objectBoxSize.x / fixedRatio;
73
+ vec2 objectWorldScale = u_resolution.xy / objectBoxSize;
74
+
75
+ #ifdef ADD_HELPERS
76
+ vec2 objectHelperBox = gl_FragCoord.xy / u_resolution.xy;
77
+ objectHelperBox -= .5;
78
+ objectHelperBox *= objectWorldScale;
79
+ objectHelperBox += boxOrigin * (objectWorldScale - 1.);
80
+ #endif
81
+
82
+ vec2 objectUV = uv;
83
+ objectUV *= objectWorldScale;
84
+ objectUV += boxOrigin * (objectWorldScale - 1.);
85
+ objectUV += vec2(-u_offsetX, u_offsetY);
86
+ objectUV /= u_scale;
87
+ objectUV = graphicRotation * objectUV;
88
+ #endif
89
+
90
+ // ===================================================
91
+
92
+ // ===================================================
93
+ // Sizing api for patterns (graphics respecting u_worldWidth / u_worldHeight ratio)
94
+
95
+ #ifdef USE_PATTERN_SIZING
96
+ float patternBoxRatio = givenBoxSize.x / givenBoxSize.y;
97
+ vec2 patternBoxGivenSize = vec2(
98
+ (u_worldWidth == 0.) ? u_resolution.x : givenBoxSize.x,
99
+ (u_worldHeight == 0.) ? u_resolution.y : givenBoxSize.y
100
+ );
101
+ vec2 patternBoxSize = vec2(0.);
102
+ // fit = none
103
+ patternBoxSize.x = patternBoxRatio * min(patternBoxGivenSize.x / patternBoxRatio, patternBoxGivenSize.y);
104
+ float patternWorldNoFitBoxWidth = patternBoxSize.x;
105
+ if (u_fit == 1.) { // fit = contain
106
+ patternBoxSize.x = patternBoxRatio * min(u_resolution.x / patternBoxRatio, u_resolution.y);
107
+ } else if (u_fit == 2.) { // fit = cover
108
+ patternBoxSize.x = patternBoxRatio * max(u_resolution.x / patternBoxRatio, u_resolution.y);
109
+ }
110
+ patternBoxSize.y = patternBoxSize.x / patternBoxRatio;
111
+ vec2 patternWorldScale = u_resolution.xy / patternBoxSize;
112
+
113
+ #ifdef ADD_HELPERS
114
+ vec2 patternHelperBox = gl_FragCoord.xy / u_resolution.xy;
115
+ patternHelperBox -= .5;
116
+ patternHelperBox *= patternWorldScale;
117
+ patternHelperBox += boxOrigin * (patternWorldScale - 1.);
118
+ #endif
119
+
120
+ vec2 patternUV = uv;
121
+ patternUV += vec2(-u_offsetX, u_offsetY) / patternWorldScale;
122
+ patternUV += boxOrigin;
123
+ patternUV -= boxOrigin / patternWorldScale;
124
+ patternUV *= u_resolution.xy;
125
+ patternUV /= u_pixelRatio;
126
+ if (u_fit > 0.) {
127
+ patternUV *= (patternWorldNoFitBoxWidth / patternBoxSize.x);
128
+ }
129
+ patternUV /= u_scale;
130
+ patternUV = graphicRotation * patternUV;
131
+ patternUV += boxOrigin / patternWorldScale;
132
+ patternUV -= boxOrigin;
133
+ patternUV += .5;
134
+ #endif
135
+
136
+ // ===================================================
137
+
138
+ // ===================================================
139
+ // Sizing api for image filters
140
+
141
+ #ifdef USE_IMAGE_SIZING
142
+
143
+ vec2 imageBoxSize;
144
+ if (u_fit == 1.) { // contain
145
+ imageBoxSize.x = min(u_resolution.x / u_imageAspectRatio, u_resolution.y) * u_imageAspectRatio;
146
+ } else if (u_fit == 2.) { // cover
147
+ imageBoxSize.x = max(u_resolution.x / u_imageAspectRatio, u_resolution.y) * u_imageAspectRatio;
148
+ } else {
149
+ imageBoxSize.x = min(10.0, 10.0 / u_imageAspectRatio * u_imageAspectRatio);
150
+ }
151
+ imageBoxSize.y = imageBoxSize.x / u_imageAspectRatio;
152
+ vec2 imageBoxScale = u_resolution.xy / imageBoxSize;
153
+
154
+ #ifdef ADD_HELPERS
155
+ vec2 imageHelperBox = uv;
156
+ imageHelperBox *= imageBoxScale;
157
+ imageHelperBox += boxOrigin * (imageBoxScale - 1.);
158
+ #endif
159
+
160
+ vec2 imageUV = uv;
161
+ imageUV *= imageBoxScale;
162
+ imageUV += boxOrigin * (imageBoxScale - 1.);
163
+ imageUV += graphicOffset;
164
+ imageUV /= u_scale;
165
+ imageUV.x *= u_imageAspectRatio;
166
+ imageUV = graphicRotation * imageUV;
167
+ imageUV.x /= u_imageAspectRatio;
168
+
169
+ imageUV += .5;
170
+ imageUV.y = 1. - imageUV.y;
171
+ #endif
172
+ `;
173
+ const drawSizingHelpers = `
174
+ vec2 worldBoxDist = abs(helperBox);
175
+ float boxStroke = (step(max(worldBoxDist.x, worldBoxDist.y), .5) - step(max(worldBoxDist.x, worldBoxDist.y), .495));
176
+ color.rgb = mix(color.rgb, vec3(1., 0., 0.), boxStroke);
177
+ opacity += boxStroke;
178
+
179
+ vec2 boxOriginCopy = vec2(.5 - u_originX, u_originY - .5);
180
+ vec2 boxOriginDist = helperBox + boxOriginCopy;
181
+ boxOriginDist.x *= (boxSize.x / boxSize.y);
182
+ float boxOriginPoint = 1. - smoothstep(0., .05, length(boxOriginDist));
183
+
184
+ vec2 graphicOriginPointDist = helperBox + vec2(-u_offsetX, u_offsetY);
185
+ graphicOriginPointDist.x *= (boxSize.x / boxSize.y);
186
+ float graphicOriginPoint = 1. - smoothstep(0., .05, length(graphicOriginPointDist));
187
+
188
+ color.rgb = mix(color.rgb, vec3(0., 1., 0.), boxOriginPoint);
189
+ opacity += boxOriginPoint;
190
+ color.rgb = mix(color.rgb, vec3(0., 0., 1.), graphicOriginPoint);
191
+ opacity += graphicOriginPoint;
192
+ `;
193
+ const defaultObjectSizing = {
194
+ fit: "contain",
195
+ scale: 1,
196
+ rotation: 0,
197
+ offsetX: 0,
198
+ offsetY: 0,
199
+ originX: 0.5,
200
+ originY: 0.5,
201
+ worldWidth: 0,
202
+ worldHeight: 0
203
+ };
204
+ const defaultPatternSizing = {
205
+ fit: "none",
206
+ scale: 1,
207
+ rotation: 0,
208
+ offsetX: 0,
209
+ offsetY: 0,
210
+ originX: 0.5,
211
+ originY: 0.5,
212
+ worldWidth: 0,
213
+ worldHeight: 0
214
+ };
215
+ const ShaderFitOptions = {
216
+ none: 0,
217
+ contain: 1,
218
+ cover: 2
219
+ };
220
+ export {
221
+ ShaderFitOptions,
222
+ defaultObjectSizing,
223
+ defaultPatternSizing,
224
+ drawSizingHelpers,
225
+ sizingDebugVariablesDeclaration,
226
+ sizingUV,
227
+ sizingUniformsDeclaration,
228
+ sizingVariablesDeclaration
229
+ };
230
+ //# sourceMappingURL=shader-sizing.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../src/shader-sizing.ts"],
4
+ "sourcesContent": ["/*\n ===================================================================\n The space coordinates passed from the vertex shader.\n\n `sizingVariablesDeclaration` must be included in every fragment\n shader\u2014unless we want to apply sizing to the coordinates directly\n in the fragment shader.\n\n So far, the only exception is when we need to apply pixelization\n before sizing (e.g., to make dithering pixels independent of sizing).\n*/\nexport const sizingVariablesDeclaration = `\nin vec2 v_objectUV;\nin vec2 v_responsiveUV;\nin vec2 v_responsiveBoxGivenSize;\nin vec2 v_patternUV;\nin vec2 v_imageUV;`;\n\n/*\n ===================================================================\n Additional variables used only for drawing a sizing overlay.\n*/\nexport const sizingDebugVariablesDeclaration = `\nin vec2 v_objectBoxSize;\nin vec2 v_objectHelperBox;\nin vec2 v_responsiveBoxSize;\nin vec2 v_responsiveHelperBox;\nin vec2 v_patternBoxSize;\nin vec2 v_patternHelperBox;`;\n\n/*\n ===================================================================\n In most cases, sizing UNIFORMS are used only in the vertex shader.\n But there are cases where we need to pass them to the fragment shader\n as well:\n - dithering pixelization where all the sizing happens in fragment\n - drawing the sizing helpers\n*/\nexport const sizingUniformsDeclaration = `\nuniform float u_originX;\nuniform float u_originY;\nuniform float u_worldWidth;\nuniform float u_worldHeight;\nuniform float u_fit;\n\nuniform float u_scale;\nuniform float u_rotation;\nuniform float u_offsetX;\nuniform float u_offsetY;`;\n\n/*\n ===================================================================\n In most cases, sizing TRANSFORMS are applied in the vertex shader.\n For exceptions (e.g., dithering pixelization), the operations below\n need to be included in the fragment shader instead.\n\n The transforms are identical to those in the vertex shader,\n except for the `USE_PIXELIZATION` part we insert at start.\n*/\n\n\nexport const sizingUV = `\n\n vec2 uv = gl_FragCoord.xy / u_resolution.xy;\n #ifdef USE_PIXELIZATION\n float pxSize = u_pxSize * u_pixelRatio;\n vec2 pxSizeUv = gl_FragCoord.xy;\n pxSizeUv -= .5 * u_resolution;\n pxSizeUv /= pxSize;\n uv = floor(pxSizeUv) * pxSize / u_resolution.xy; \n uv += .5;\n #endif\n uv -= .5;\n\n \n // ===================================================\n // sizing params shared between objects and patterns\n \n vec2 boxOrigin = vec2(.5 - u_originX, u_originY - .5);\n vec2 givenBoxSize = vec2(u_worldWidth, u_worldHeight);\n givenBoxSize = max(givenBoxSize, vec2(1.)) * u_pixelRatio;\n float r = u_rotation * 3.14159265358979323846 / 180.;\n mat2 graphicRotation = mat2(cos(r), sin(r), -sin(r), cos(r));\n vec2 graphicOffset = vec2(-u_offsetX, u_offsetY);\n\n \n // ===================================================\n // Sizing api for objects (graphics with fixed ratio)\n\n #ifdef USE_OBJECT_SIZING\n float fixedRatio = 1.;\n vec2 fixedRatioBoxGivenSize = vec2(\n (u_worldWidth == 0.) ? u_resolution.x : givenBoxSize.x,\n (u_worldHeight == 0.) ? u_resolution.y : givenBoxSize.y\n );\n vec2 objectBoxSize = vec2(0.);\n // fit = none\n objectBoxSize.x = fixedRatio * min(fixedRatioBoxGivenSize.x / fixedRatio, fixedRatioBoxGivenSize.y);\n if (u_fit == 1.) { // fit = contain\n objectBoxSize.x = fixedRatio * min(u_resolution.x / fixedRatio, u_resolution.y);\n } else if (u_fit == 2.) { // fit = cover\n objectBoxSize.x = fixedRatio * max(u_resolution.x / fixedRatio, u_resolution.y);\n }\n objectBoxSize.y = objectBoxSize.x / fixedRatio;\n vec2 objectWorldScale = u_resolution.xy / objectBoxSize;\n \n #ifdef ADD_HELPERS\n vec2 objectHelperBox = gl_FragCoord.xy / u_resolution.xy;\n objectHelperBox -= .5;\n objectHelperBox *= objectWorldScale;\n objectHelperBox += boxOrigin * (objectWorldScale - 1.); \n #endif\n \n vec2 objectUV = uv;\n objectUV *= objectWorldScale;\n objectUV += boxOrigin * (objectWorldScale - 1.);\n objectUV += vec2(-u_offsetX, u_offsetY);\n objectUV /= u_scale;\n objectUV = graphicRotation * objectUV;\n #endif\n \n // ===================================================\n \n // ===================================================\n // Sizing api for patterns (graphics respecting u_worldWidth / u_worldHeight ratio)\n \n #ifdef USE_PATTERN_SIZING\n float patternBoxRatio = givenBoxSize.x / givenBoxSize.y;\n vec2 patternBoxGivenSize = vec2(\n (u_worldWidth == 0.) ? u_resolution.x : givenBoxSize.x,\n (u_worldHeight == 0.) ? u_resolution.y : givenBoxSize.y\n );\n vec2 patternBoxSize = vec2(0.);\n // fit = none\n patternBoxSize.x = patternBoxRatio * min(patternBoxGivenSize.x / patternBoxRatio, patternBoxGivenSize.y);\n float patternWorldNoFitBoxWidth = patternBoxSize.x;\n if (u_fit == 1.) { // fit = contain\n patternBoxSize.x = patternBoxRatio * min(u_resolution.x / patternBoxRatio, u_resolution.y);\n } else if (u_fit == 2.) { // fit = cover\n patternBoxSize.x = patternBoxRatio * max(u_resolution.x / patternBoxRatio, u_resolution.y);\n }\n patternBoxSize.y = patternBoxSize.x / patternBoxRatio;\n vec2 patternWorldScale = u_resolution.xy / patternBoxSize;\n \n #ifdef ADD_HELPERS \n vec2 patternHelperBox = gl_FragCoord.xy / u_resolution.xy;\n patternHelperBox -= .5;\n patternHelperBox *= patternWorldScale;\n patternHelperBox += boxOrigin * (patternWorldScale - 1.); \n #endif\n \n vec2 patternUV = uv;\n patternUV += vec2(-u_offsetX, u_offsetY) / patternWorldScale;\n patternUV += boxOrigin;\n patternUV -= boxOrigin / patternWorldScale;\n patternUV *= u_resolution.xy;\n patternUV /= u_pixelRatio;\n if (u_fit > 0.) {\n patternUV *= (patternWorldNoFitBoxWidth / patternBoxSize.x);\n }\n patternUV /= u_scale;\n patternUV = graphicRotation * patternUV;\n patternUV += boxOrigin / patternWorldScale;\n patternUV -= boxOrigin;\n patternUV += .5;\n #endif\n \n // ===================================================\n \n // ===================================================\n // Sizing api for image filters\n \n #ifdef USE_IMAGE_SIZING\n\n vec2 imageBoxSize;\n if (u_fit == 1.) { // contain\n imageBoxSize.x = min(u_resolution.x / u_imageAspectRatio, u_resolution.y) * u_imageAspectRatio;\n } else if (u_fit == 2.) { // cover\n imageBoxSize.x = max(u_resolution.x / u_imageAspectRatio, u_resolution.y) * u_imageAspectRatio;\n } else {\n imageBoxSize.x = min(10.0, 10.0 / u_imageAspectRatio * u_imageAspectRatio);\n }\n imageBoxSize.y = imageBoxSize.x / u_imageAspectRatio;\n vec2 imageBoxScale = u_resolution.xy / imageBoxSize;\n\n #ifdef ADD_HELPERS\n vec2 imageHelperBox = uv;\n imageHelperBox *= imageBoxScale;\n imageHelperBox += boxOrigin * (imageBoxScale - 1.);\n #endif\n\n vec2 imageUV = uv;\n imageUV *= imageBoxScale;\n imageUV += boxOrigin * (imageBoxScale - 1.);\n imageUV += graphicOffset;\n imageUV /= u_scale;\n imageUV.x *= u_imageAspectRatio;\n imageUV = graphicRotation * imageUV;\n imageUV.x /= u_imageAspectRatio;\n \n imageUV += .5;\n imageUV.y = 1. - imageUV.y;\n #endif\n`;\n\n/*\n ===================================================================\n Helpers used to draw the sizing (box, box origin and graphic origin)\n over the shader. Can be used with both vertex sizing and vector sizing\n\n helperBox and boxSize should be defined before inserting the code\n*/\nexport const drawSizingHelpers = `\n vec2 worldBoxDist = abs(helperBox);\n float boxStroke = (step(max(worldBoxDist.x, worldBoxDist.y), .5) - step(max(worldBoxDist.x, worldBoxDist.y), .495));\n color.rgb = mix(color.rgb, vec3(1., 0., 0.), boxStroke);\n opacity += boxStroke;\n\n vec2 boxOriginCopy = vec2(.5 - u_originX, u_originY - .5);\n vec2 boxOriginDist = helperBox + boxOriginCopy;\n boxOriginDist.x *= (boxSize.x / boxSize.y);\n float boxOriginPoint = 1. - smoothstep(0., .05, length(boxOriginDist));\n \n vec2 graphicOriginPointDist = helperBox + vec2(-u_offsetX, u_offsetY);\n graphicOriginPointDist.x *= (boxSize.x / boxSize.y);\n float graphicOriginPoint = 1. - smoothstep(0., .05, length(graphicOriginPointDist));\n \n color.rgb = mix(color.rgb, vec3(0., 1., 0.), boxOriginPoint);\n opacity += boxOriginPoint;\n color.rgb = mix(color.rgb, vec3(0., 0., 1.), graphicOriginPoint);\n opacity += graphicOriginPoint;\n`;\n\nexport interface ShaderSizingUniforms {\n u_fit: (typeof ShaderFitOptions)[ShaderFit];\n u_scale: number;\n u_rotation: number;\n u_originX: number;\n u_originY: number;\n u_offsetX: number;\n u_offsetY: number;\n u_worldWidth: number;\n u_worldHeight: number;\n}\n\nexport interface ShaderSizingParams {\n fit?: 'none' | 'contain' | 'cover';\n scale?: number;\n rotation?: number;\n originX?: number;\n originY?: number;\n offsetX?: number;\n offsetY?: number;\n worldWidth?: number;\n worldHeight?: number;\n}\n\nexport const defaultObjectSizing: Required<ShaderSizingParams> = {\n fit: 'contain',\n scale: 1,\n rotation: 0,\n offsetX: 0,\n offsetY: 0,\n originX: 0.5,\n originY: 0.5,\n worldWidth: 0,\n worldHeight: 0,\n};\n\nexport const defaultPatternSizing: Required<ShaderSizingParams> = {\n fit: 'none',\n scale: 1,\n rotation: 0,\n offsetX: 0,\n offsetY: 0,\n originX: 0.5,\n originY: 0.5,\n worldWidth: 0,\n worldHeight: 0,\n};\n\nexport const ShaderFitOptions = {\n none: 0,\n contain: 1,\n cover: 2,\n} as const;\n\nexport type ShaderFit = keyof typeof ShaderFitOptions;\n"],
5
+ "mappings": ";;;;;AAWO,MAAM,6BAA6B;AAAA;AAAA;AAAA;AAAA;AAAA;AAWnC,MAAM,kCAAkC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAgBxC,MAAM,4BAA4B;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAuBlC,MAAM,WAAW;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAuJjB,MAAM,oBAAoB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AA6C1B,MAAM,sBAAoD;AAAA,EAC/D,KAAK;AAAA,EACL,OAAO;AAAA,EACP,UAAU;AAAA,EACV,SAAS;AAAA,EACT,SAAS;AAAA,EACT,SAAS;AAAA,EACT,SAAS;AAAA,EACT,YAAY;AAAA,EACZ,aAAa;AACf;AAEO,MAAM,uBAAqD;AAAA,EAChE,KAAK;AAAA,EACL,OAAO;AAAA,EACP,UAAU;AAAA,EACV,SAAS;AAAA,EACT,SAAS;AAAA,EACT,SAAS;AAAA,EACT,SAAS;AAAA,EACT,YAAY;AAAA,EACZ,aAAa;AACf;AAEO,MAAM,mBAAmB;AAAA,EAC9B,MAAM;AAAA,EACN,SAAS;AAAA,EACT,OAAO;AACT;",
6
+ "names": []
7
+ }
@@ -0,0 +1,10 @@
1
+ export declare const declarePI = "\n#define TWO_PI 6.28318530718\n#define PI 3.14159265358979323846\n";
2
+ export declare const rotation2 = "\nvec2 rotate(vec2 uv, float th) {\n return mat2(cos(th), sin(th), -sin(th), cos(th)) * uv;\n}\n";
3
+ export declare const proceduralHash11 = "\n float hash11(float p) {\n p = fract(p * 0.3183099) + 0.1;\n p *= p + 19.19;\n return fract(p * p);\n }\n";
4
+ export declare const proceduralHash21 = "\n float hash21(vec2 p) {\n p = fract(p * vec2(0.3183099, 0.3678794)) + 0.1;\n p += dot(p, p + 19.19);\n return fract(p.x * p.y);\n }\n";
5
+ export declare const proceduralHash22 = "\n vec2 hash22(vec2 p) {\n p = fract(p * vec2(0.3183099, 0.3678794)) + 0.1;\n p += dot(p, p.yx + 19.19);\n return fract(vec2(p.x * p.y, p.x + p.y));\n }\n";
6
+ export declare const textureRandomizerR = "\n float randomR(vec2 p) {\n vec2 uv = floor(p) / 100. + .5;\n return texture(u_noiseTexture, fract(uv)).r;\n }\n";
7
+ export declare const textureRandomizerGB = "\n vec2 randomGB(vec2 p) {\n vec2 uv = floor(p) / 100. + .5;\n return texture(u_noiseTexture, fract(uv)).gb;\n }\n";
8
+ export declare const colorBandingFix = "\n color += 1. / 256. * (fract(sin(dot(.014 * gl_FragCoord.xy, vec2(12.9898, 78.233))) * 43758.5453123) - .5);\n";
9
+ export declare const simplexNoise = "\nvec3 permute(vec3 x) { return mod(((x * 34.0) + 1.0) * x, 289.0); }\nfloat snoise(vec2 v) {\n const vec4 C = vec4(0.211324865405187, 0.366025403784439,\n -0.577350269189626, 0.024390243902439);\n vec2 i = floor(v + dot(v, C.yy));\n vec2 x0 = v - i + dot(i, C.xx);\n vec2 i1;\n i1 = (x0.x > x0.y) ? vec2(1.0, 0.0) : vec2(0.0, 1.0);\n vec4 x12 = x0.xyxy + C.xxzz;\n x12.xy -= i1;\n i = mod(i, 289.0);\n vec3 p = permute(permute(i.y + vec3(0.0, i1.y, 1.0))\n + i.x + vec3(0.0, i1.x, 1.0));\n vec3 m = max(0.5 - vec3(dot(x0, x0), dot(x12.xy, x12.xy),\n dot(x12.zw, x12.zw)), 0.0);\n m = m * m;\n m = m * m;\n vec3 x = 2.0 * fract(p * C.www) - 1.0;\n vec3 h = abs(x) - 0.5;\n vec3 ox = floor(x + 0.5);\n vec3 a0 = x - ox;\n m *= 1.79284291400159 - 0.85373472095314 * (a0 * a0 + h * h);\n vec3 g;\n g.x = a0.x * x0.x + h.x * x0.y;\n g.yz = a0.yz * x12.xz + h.yz * x12.yw;\n return 130.0 * dot(m, g);\n}\n";
10
+ export declare const fiberNoise = "\nfloat fiberRandom(vec2 p) {\n vec2 uv = floor(p) / 100.;\n return texture(u_noiseTexture, fract(uv)).b;\n}\n\nfloat fiberValueNoise(vec2 st) {\n vec2 i = floor(st);\n vec2 f = fract(st);\n float a = fiberRandom(i);\n float b = fiberRandom(i + vec2(1.0, 0.0));\n float c = fiberRandom(i + vec2(0.0, 1.0));\n float d = fiberRandom(i + vec2(1.0, 1.0));\n vec2 u = f * f * (3.0 - 2.0 * f);\n float x1 = mix(a, b, u.x);\n float x2 = mix(c, d, u.x);\n return mix(x1, x2, u.y);\n}\n\nfloat fiberNoiseFbm(in vec2 n, vec2 seedOffset) {\n float total = 0.0, amplitude = 1.;\n for (int i = 0; i < 4; i++) {\n n = rotate(n, .7);\n total += fiberValueNoise(n + seedOffset) * amplitude;\n n *= 2.;\n amplitude *= 0.6;\n }\n return total;\n}\n\nfloat fiberNoise(vec2 uv, vec2 seedOffset) {\n float epsilon = 0.001;\n float n1 = fiberNoiseFbm(uv + vec2(epsilon, 0.0), seedOffset);\n float n2 = fiberNoiseFbm(uv - vec2(epsilon, 0.0), seedOffset);\n float n3 = fiberNoiseFbm(uv + vec2(0.0, epsilon), seedOffset);\n float n4 = fiberNoiseFbm(uv - vec2(0.0, epsilon), seedOffset);\n return length(vec2(n1 - n2, n3 - n4)) / (2.0 * epsilon);\n}\n";
@@ -0,0 +1,131 @@
1
+ /* * * * * * * * * * * * * * * * * * * * * * * * * * * *
2
+ * Paper Shaders *
3
+ * https://github.com/paper-design/shaders *
4
+ * * * * * * * * * * * * * * * * * * * * * * * * * * * */
5
+
6
+ const declarePI = `
7
+ #define TWO_PI 6.28318530718
8
+ #define PI 3.14159265358979323846
9
+ `;
10
+ const rotation2 = `
11
+ vec2 rotate(vec2 uv, float th) {
12
+ return mat2(cos(th), sin(th), -sin(th), cos(th)) * uv;
13
+ }
14
+ `;
15
+ const proceduralHash11 = `
16
+ float hash11(float p) {
17
+ p = fract(p * 0.3183099) + 0.1;
18
+ p *= p + 19.19;
19
+ return fract(p * p);
20
+ }
21
+ `;
22
+ const proceduralHash21 = `
23
+ float hash21(vec2 p) {
24
+ p = fract(p * vec2(0.3183099, 0.3678794)) + 0.1;
25
+ p += dot(p, p + 19.19);
26
+ return fract(p.x * p.y);
27
+ }
28
+ `;
29
+ const proceduralHash22 = `
30
+ vec2 hash22(vec2 p) {
31
+ p = fract(p * vec2(0.3183099, 0.3678794)) + 0.1;
32
+ p += dot(p, p.yx + 19.19);
33
+ return fract(vec2(p.x * p.y, p.x + p.y));
34
+ }
35
+ `;
36
+ const textureRandomizerR = `
37
+ float randomR(vec2 p) {
38
+ vec2 uv = floor(p) / 100. + .5;
39
+ return texture(u_noiseTexture, fract(uv)).r;
40
+ }
41
+ `;
42
+ const textureRandomizerGB = `
43
+ vec2 randomGB(vec2 p) {
44
+ vec2 uv = floor(p) / 100. + .5;
45
+ return texture(u_noiseTexture, fract(uv)).gb;
46
+ }
47
+ `;
48
+ const colorBandingFix = `
49
+ color += 1. / 256. * (fract(sin(dot(.014 * gl_FragCoord.xy, vec2(12.9898, 78.233))) * 43758.5453123) - .5);
50
+ `;
51
+ const simplexNoise = `
52
+ vec3 permute(vec3 x) { return mod(((x * 34.0) + 1.0) * x, 289.0); }
53
+ float snoise(vec2 v) {
54
+ const vec4 C = vec4(0.211324865405187, 0.366025403784439,
55
+ -0.577350269189626, 0.024390243902439);
56
+ vec2 i = floor(v + dot(v, C.yy));
57
+ vec2 x0 = v - i + dot(i, C.xx);
58
+ vec2 i1;
59
+ i1 = (x0.x > x0.y) ? vec2(1.0, 0.0) : vec2(0.0, 1.0);
60
+ vec4 x12 = x0.xyxy + C.xxzz;
61
+ x12.xy -= i1;
62
+ i = mod(i, 289.0);
63
+ vec3 p = permute(permute(i.y + vec3(0.0, i1.y, 1.0))
64
+ + i.x + vec3(0.0, i1.x, 1.0));
65
+ vec3 m = max(0.5 - vec3(dot(x0, x0), dot(x12.xy, x12.xy),
66
+ dot(x12.zw, x12.zw)), 0.0);
67
+ m = m * m;
68
+ m = m * m;
69
+ vec3 x = 2.0 * fract(p * C.www) - 1.0;
70
+ vec3 h = abs(x) - 0.5;
71
+ vec3 ox = floor(x + 0.5);
72
+ vec3 a0 = x - ox;
73
+ m *= 1.79284291400159 - 0.85373472095314 * (a0 * a0 + h * h);
74
+ vec3 g;
75
+ g.x = a0.x * x0.x + h.x * x0.y;
76
+ g.yz = a0.yz * x12.xz + h.yz * x12.yw;
77
+ return 130.0 * dot(m, g);
78
+ }
79
+ `;
80
+ const fiberNoise = `
81
+ float fiberRandom(vec2 p) {
82
+ vec2 uv = floor(p) / 100.;
83
+ return texture(u_noiseTexture, fract(uv)).b;
84
+ }
85
+
86
+ float fiberValueNoise(vec2 st) {
87
+ vec2 i = floor(st);
88
+ vec2 f = fract(st);
89
+ float a = fiberRandom(i);
90
+ float b = fiberRandom(i + vec2(1.0, 0.0));
91
+ float c = fiberRandom(i + vec2(0.0, 1.0));
92
+ float d = fiberRandom(i + vec2(1.0, 1.0));
93
+ vec2 u = f * f * (3.0 - 2.0 * f);
94
+ float x1 = mix(a, b, u.x);
95
+ float x2 = mix(c, d, u.x);
96
+ return mix(x1, x2, u.y);
97
+ }
98
+
99
+ float fiberNoiseFbm(in vec2 n, vec2 seedOffset) {
100
+ float total = 0.0, amplitude = 1.;
101
+ for (int i = 0; i < 4; i++) {
102
+ n = rotate(n, .7);
103
+ total += fiberValueNoise(n + seedOffset) * amplitude;
104
+ n *= 2.;
105
+ amplitude *= 0.6;
106
+ }
107
+ return total;
108
+ }
109
+
110
+ float fiberNoise(vec2 uv, vec2 seedOffset) {
111
+ float epsilon = 0.001;
112
+ float n1 = fiberNoiseFbm(uv + vec2(epsilon, 0.0), seedOffset);
113
+ float n2 = fiberNoiseFbm(uv - vec2(epsilon, 0.0), seedOffset);
114
+ float n3 = fiberNoiseFbm(uv + vec2(0.0, epsilon), seedOffset);
115
+ float n4 = fiberNoiseFbm(uv - vec2(0.0, epsilon), seedOffset);
116
+ return length(vec2(n1 - n2, n3 - n4)) / (2.0 * epsilon);
117
+ }
118
+ `;
119
+ export {
120
+ colorBandingFix,
121
+ declarePI,
122
+ fiberNoise,
123
+ proceduralHash11,
124
+ proceduralHash21,
125
+ proceduralHash22,
126
+ rotation2,
127
+ simplexNoise,
128
+ textureRandomizerGB,
129
+ textureRandomizerR
130
+ };
131
+ //# sourceMappingURL=shader-utils.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../src/shader-utils.ts"],
4
+ "sourcesContent": ["// language=GLSL\nexport const declarePI = `\n#define TWO_PI 6.28318530718\n#define PI 3.14159265358979323846\n`;\n\n// language=GLSL\nexport const rotation2 = `\nvec2 rotate(vec2 uv, float th) {\n return mat2(cos(th), sin(th), -sin(th), cos(th)) * uv;\n}\n`;\n\n// language=GLSL\nexport const proceduralHash11 = `\n float hash11(float p) {\n p = fract(p * 0.3183099) + 0.1;\n p *= p + 19.19;\n return fract(p * p);\n }\n`;\n\n// language=GLSL\nexport const proceduralHash21 = `\n float hash21(vec2 p) {\n p = fract(p * vec2(0.3183099, 0.3678794)) + 0.1;\n p += dot(p, p + 19.19);\n return fract(p.x * p.y);\n }\n`;\n\n// language=GLSL\nexport const proceduralHash22 = `\n vec2 hash22(vec2 p) {\n p = fract(p * vec2(0.3183099, 0.3678794)) + 0.1;\n p += dot(p, p.yx + 19.19);\n return fract(vec2(p.x * p.y, p.x + p.y));\n }\n`;\n\n// language=GLSL\nexport const textureRandomizerR = `\n float randomR(vec2 p) {\n vec2 uv = floor(p) / 100. + .5;\n return texture(u_noiseTexture, fract(uv)).r;\n }\n`;\n\n// language=GLSL\nexport const textureRandomizerGB = `\n vec2 randomGB(vec2 p) {\n vec2 uv = floor(p) / 100. + .5;\n return texture(u_noiseTexture, fract(uv)).gb;\n }\n`;\n\n// language=GLSL\nexport const colorBandingFix = `\n color += 1. / 256. * (fract(sin(dot(.014 * gl_FragCoord.xy, vec2(12.9898, 78.233))) * 43758.5453123) - .5);\n`;\n\n// language=GLSL\nexport const simplexNoise = `\nvec3 permute(vec3 x) { return mod(((x * 34.0) + 1.0) * x, 289.0); }\nfloat snoise(vec2 v) {\n const vec4 C = vec4(0.211324865405187, 0.366025403784439,\n -0.577350269189626, 0.024390243902439);\n vec2 i = floor(v + dot(v, C.yy));\n vec2 x0 = v - i + dot(i, C.xx);\n vec2 i1;\n i1 = (x0.x > x0.y) ? vec2(1.0, 0.0) : vec2(0.0, 1.0);\n vec4 x12 = x0.xyxy + C.xxzz;\n x12.xy -= i1;\n i = mod(i, 289.0);\n vec3 p = permute(permute(i.y + vec3(0.0, i1.y, 1.0))\n + i.x + vec3(0.0, i1.x, 1.0));\n vec3 m = max(0.5 - vec3(dot(x0, x0), dot(x12.xy, x12.xy),\n dot(x12.zw, x12.zw)), 0.0);\n m = m * m;\n m = m * m;\n vec3 x = 2.0 * fract(p * C.www) - 1.0;\n vec3 h = abs(x) - 0.5;\n vec3 ox = floor(x + 0.5);\n vec3 a0 = x - ox;\n m *= 1.79284291400159 - 0.85373472095314 * (a0 * a0 + h * h);\n vec3 g;\n g.x = a0.x * x0.x + h.x * x0.y;\n g.yz = a0.yz * x12.xz + h.yz * x12.yw;\n return 130.0 * dot(m, g);\n}\n`;\n\n// language=GLSL\nexport const fiberNoise = `\nfloat fiberRandom(vec2 p) {\n vec2 uv = floor(p) / 100.;\n return texture(u_noiseTexture, fract(uv)).b;\n}\n\nfloat fiberValueNoise(vec2 st) {\n vec2 i = floor(st);\n vec2 f = fract(st);\n float a = fiberRandom(i);\n float b = fiberRandom(i + vec2(1.0, 0.0));\n float c = fiberRandom(i + vec2(0.0, 1.0));\n float d = fiberRandom(i + vec2(1.0, 1.0));\n vec2 u = f * f * (3.0 - 2.0 * f);\n float x1 = mix(a, b, u.x);\n float x2 = mix(c, d, u.x);\n return mix(x1, x2, u.y);\n}\n\nfloat fiberNoiseFbm(in vec2 n, vec2 seedOffset) {\n float total = 0.0, amplitude = 1.;\n for (int i = 0; i < 4; i++) {\n n = rotate(n, .7);\n total += fiberValueNoise(n + seedOffset) * amplitude;\n n *= 2.;\n amplitude *= 0.6;\n }\n return total;\n}\n\nfloat fiberNoise(vec2 uv, vec2 seedOffset) {\n float epsilon = 0.001;\n float n1 = fiberNoiseFbm(uv + vec2(epsilon, 0.0), seedOffset);\n float n2 = fiberNoiseFbm(uv - vec2(epsilon, 0.0), seedOffset);\n float n3 = fiberNoiseFbm(uv + vec2(0.0, epsilon), seedOffset);\n float n4 = fiberNoiseFbm(uv - vec2(0.0, epsilon), seedOffset);\n return length(vec2(n1 - n2, n3 - n4)) / (2.0 * epsilon);\n}\n`;\n"],
5
+ "mappings": ";;;;;AACO,MAAM,YAAY;AAAA;AAAA;AAAA;AAMlB,MAAM,YAAY;AAAA;AAAA;AAAA;AAAA;AAOlB,MAAM,mBAAmB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AASzB,MAAM,mBAAmB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AASzB,MAAM,mBAAmB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AASzB,MAAM,qBAAqB;AAAA;AAAA;AAAA;AAAA;AAAA;AAQ3B,MAAM,sBAAsB;AAAA;AAAA;AAAA;AAAA;AAAA;AAQ5B,MAAM,kBAAkB;AAAA;AAAA;AAKxB,MAAM,eAAe;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AA+BrB,MAAM,aAAa;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;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,50 @@
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 colorPanelsMeta: {
5
+ readonly maxColorCount: 7;
6
+ };
7
+ /**
8
+ * Pseudo-3D panels rotating around a central axis
9
+ *
10
+ * Uniforms include:
11
+ * - u_colorBack (RGBA)
12
+ * - u_colors (vec4[]), u_colorsCount (float used as integer)
13
+ * - u_density: angle between every 2 panels
14
+ * - u_angle1, u_angle2: skew angle applied to all panes
15
+ * - u_length: panel length (relative to total height)
16
+ * - u_edges: faking edges effect
17
+ * - u_blur: side blur (0 for sharp edges)
18
+ * - u_fadeIn: transparency near central axis
19
+ * - u_fadeOut: transparency near viewer
20
+ * - u_gradient: color mixing within panes (0 = single color, 1 = two colors)
21
+ *
22
+ */
23
+ export declare const colorPanelsFragmentShader: string;
24
+ export interface ColorPanelsUniforms extends ShaderSizingUniforms {
25
+ u_colors: vec4[];
26
+ u_colorsCount: number;
27
+ u_colorBack: [number, number, number, number];
28
+ u_angle1: number;
29
+ u_angle2: number;
30
+ u_length: number;
31
+ u_edges: boolean;
32
+ u_blur: number;
33
+ u_fadeIn: number;
34
+ u_fadeOut: number;
35
+ u_density: number;
36
+ u_gradient: number;
37
+ }
38
+ export interface ColorPanelsParams extends ShaderSizingParams, ShaderMotionParams {
39
+ colors?: string[];
40
+ colorBack?: string;
41
+ angle1?: number;
42
+ angle2?: number;
43
+ length?: number;
44
+ edges?: boolean;
45
+ blur?: number;
46
+ fadeIn?: number;
47
+ fadeOut?: number;
48
+ density?: number;
49
+ gradient?: number;
50
+ }