@paper-design/shaders 0.0.0-canary.0d8316e
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.
- package/LICENSE +201 -0
- package/NOTICE +5 -0
- package/README.md +7 -0
- package/dist/empty-pixel.d.ts +1 -0
- package/dist/empty-pixel.js +10 -0
- package/dist/empty-pixel.js.map +7 -0
- package/dist/get-shader-color-from-string.d.ts +3 -0
- package/dist/get-shader-color-from-string.js +101 -0
- package/dist/get-shader-color-from-string.js.map +7 -0
- package/dist/get-shader-noise-texture.d.ts +1 -0
- package/dist/get-shader-noise-texture.js +18 -0
- package/dist/get-shader-noise-texture.js.map +7 -0
- package/dist/html-in-canvas.d.ts +35 -0
- package/dist/html-in-canvas.js +79 -0
- package/dist/html-in-canvas.js.map +7 -0
- package/dist/index.d.ts +69 -0
- package/dist/index.js +196 -0
- package/dist/index.js.map +7 -0
- package/dist/shader-color-spaces.d.ts +6 -0
- package/dist/shader-color-spaces.js +96 -0
- package/dist/shader-color-spaces.js.map +7 -0
- package/dist/shader-mount.d.ts +151 -0
- package/dist/shader-mount.js +605 -0
- package/dist/shader-mount.js.map +7 -0
- package/dist/shader-sizing.d.ts +30 -0
- package/dist/shader-sizing.js +38 -0
- package/dist/shader-sizing.js.map +7 -0
- package/dist/shader-utils.d.ts +10 -0
- package/dist/shader-utils.js +131 -0
- package/dist/shader-utils.js.map +7 -0
- package/dist/shaders/color-panels.d.ts +70 -0
- package/dist/shaders/color-panels.js +224 -0
- package/dist/shaders/color-panels.js.map +7 -0
- package/dist/shaders/dithering.d.ts +62 -0
- package/dist/shaders/dithering.js +271 -0
- package/dist/shaders/dithering.js.map +7 -0
- package/dist/shaders/dot-grid.d.ts +65 -0
- package/dist/shaders/dot-grid.js +110 -0
- package/dist/shaders/dot-grid.js.map +7 -0
- package/dist/shaders/dot-orbit.d.ts +57 -0
- package/dist/shaders/dot-orbit.js +123 -0
- package/dist/shaders/dot-orbit.js.map +7 -0
- package/dist/shaders/fluted-glass.d.ts +115 -0
- package/dist/shaders/fluted-glass.js +361 -0
- package/dist/shaders/fluted-glass.js.map +7 -0
- package/dist/shaders/gem-smoke.d.ts +96 -0
- package/dist/shaders/gem-smoke.js +573 -0
- package/dist/shaders/gem-smoke.js.map +7 -0
- package/dist/shaders/god-rays.d.ts +67 -0
- package/dist/shaders/god-rays.js +133 -0
- package/dist/shaders/god-rays.js.map +7 -0
- package/dist/shaders/grain-gradient.d.ts +80 -0
- package/dist/shaders/grain-gradient.js +301 -0
- package/dist/shaders/grain-gradient.js.map +7 -0
- package/dist/shaders/halftone-cmyk.d.ts +107 -0
- package/dist/shaders/halftone-cmyk.js +319 -0
- package/dist/shaders/halftone-cmyk.js.map +7 -0
- package/dist/shaders/halftone-dots.d.ts +83 -0
- package/dist/shaders/halftone-dots.js +345 -0
- package/dist/shaders/halftone-dots.js.map +7 -0
- package/dist/shaders/heatmap.d.ts +66 -0
- package/dist/shaders/heatmap.js +384 -0
- package/dist/shaders/heatmap.js.map +7 -0
- package/dist/shaders/image-dithering.d.ts +66 -0
- package/dist/shaders/image-dithering.js +209 -0
- package/dist/shaders/image-dithering.js.map +7 -0
- package/dist/shaders/lens-distortion.d.ts +100 -0
- package/dist/shaders/lens-distortion.js +290 -0
- package/dist/shaders/lens-distortion.js.map +7 -0
- package/dist/shaders/liquid-metal.d.ts +89 -0
- package/dist/shaders/liquid-metal.js +633 -0
- package/dist/shaders/liquid-metal.js.map +7 -0
- package/dist/shaders/mesh-gradient.d.ts +52 -0
- package/dist/shaders/mesh-gradient.js +131 -0
- package/dist/shaders/mesh-gradient.js.map +7 -0
- package/dist/shaders/metaballs.d.ts +51 -0
- package/dist/shaders/metaballs.js +111 -0
- package/dist/shaders/metaballs.js.map +7 -0
- package/dist/shaders/neuro-noise.d.ts +47 -0
- package/dist/shaders/neuro-noise.js +77 -0
- package/dist/shaders/neuro-noise.js.map +7 -0
- package/dist/shaders/paper-texture.d.ts +113 -0
- package/dist/shaders/paper-texture.js +541 -0
- package/dist/shaders/paper-texture.js.map +7 -0
- package/dist/shaders/perlin-noise.d.ts +52 -0
- package/dist/shaders/perlin-noise.js +167 -0
- package/dist/shaders/perlin-noise.js.map +7 -0
- package/dist/shaders/pulsing-border.d.ts +98 -0
- package/dist/shaders/pulsing-border.js +239 -0
- package/dist/shaders/pulsing-border.js.map +7 -0
- package/dist/shaders/simplex-noise.d.ts +45 -0
- package/dist/shaders/simplex-noise.js +92 -0
- package/dist/shaders/simplex-noise.js.map +7 -0
- package/dist/shaders/smoke-ring.d.ts +61 -0
- package/dist/shaders/smoke-ring.js +133 -0
- package/dist/shaders/smoke-ring.js.map +7 -0
- package/dist/shaders/spiral.d.ts +61 -0
- package/dist/shaders/spiral.js +83 -0
- package/dist/shaders/spiral.js.map +7 -0
- package/dist/shaders/static-mesh-gradient.d.ts +63 -0
- package/dist/shaders/static-mesh-gradient.js +131 -0
- package/dist/shaders/static-mesh-gradient.js.map +7 -0
- package/dist/shaders/static-radial-gradient.d.ts +72 -0
- package/dist/shaders/static-radial-gradient.js +188 -0
- package/dist/shaders/static-radial-gradient.js.map +7 -0
- package/dist/shaders/swirl.d.ts +63 -0
- package/dist/shaders/swirl.js +104 -0
- package/dist/shaders/swirl.js.map +7 -0
- package/dist/shaders/voronoi.d.ts +65 -0
- package/dist/shaders/voronoi.js +139 -0
- package/dist/shaders/voronoi.js.map +7 -0
- package/dist/shaders/warp.d.ts +70 -0
- package/dist/shaders/warp.js +130 -0
- package/dist/shaders/warp.js.map +7 -0
- package/dist/shaders/water.d.ts +63 -0
- package/dist/shaders/water.js +135 -0
- package/dist/shaders/water.js.map +7 -0
- package/dist/shaders/waves.d.ts +53 -0
- package/dist/shaders/waves.js +66 -0
- package/dist/shaders/waves.js.map +7 -0
- package/dist/types.d.ts +3 -0
- package/dist/types.js +6 -0
- package/dist/types.js.map +7 -0
- package/dist/vertex-shader.d.ts +2 -0
- package/dist/vertex-shader.js +163 -0
- package/dist/vertex-shader.js.map +7 -0
- package/package.json +29 -0
|
@@ -0,0 +1,301 @@
|
|
|
1
|
+
/* * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
|
2
|
+
* Paper Shaders *
|
|
3
|
+
* https://github.com/paper-design/shaders *
|
|
4
|
+
* * * * * * * * * * * * * * * * * * * * * * * * * * * */
|
|
5
|
+
|
|
6
|
+
import {
|
|
7
|
+
} from "../shader-sizing.js";
|
|
8
|
+
import {
|
|
9
|
+
simplexNoise,
|
|
10
|
+
declarePI,
|
|
11
|
+
rotation2,
|
|
12
|
+
textureRandomizerR,
|
|
13
|
+
proceduralHash11
|
|
14
|
+
} from "../shader-utils.js";
|
|
15
|
+
const grainGradientMeta = {
|
|
16
|
+
maxColorCount: 7
|
|
17
|
+
};
|
|
18
|
+
const grainGradientFragmentShader = `#version 300 es
|
|
19
|
+
precision lowp float;
|
|
20
|
+
|
|
21
|
+
uniform mediump float u_time;
|
|
22
|
+
uniform mediump vec2 u_resolution;
|
|
23
|
+
uniform mediump float u_pixelRatio;
|
|
24
|
+
|
|
25
|
+
uniform sampler2D u_noiseTexture;
|
|
26
|
+
|
|
27
|
+
uniform vec4 u_colorBack;
|
|
28
|
+
uniform vec4 u_colors[${grainGradientMeta.maxColorCount}];
|
|
29
|
+
uniform float u_colorsCount;
|
|
30
|
+
uniform float u_softness;
|
|
31
|
+
uniform float u_intensity;
|
|
32
|
+
uniform float u_noise;
|
|
33
|
+
uniform float u_shape;
|
|
34
|
+
|
|
35
|
+
uniform mediump float u_worldWidth;
|
|
36
|
+
uniform mediump float u_worldHeight;
|
|
37
|
+
uniform mediump float u_fit;
|
|
38
|
+
|
|
39
|
+
uniform mediump float u_scale;
|
|
40
|
+
uniform mediump float u_rotation;
|
|
41
|
+
uniform mediump float u_offsetX;
|
|
42
|
+
uniform mediump float u_offsetY;
|
|
43
|
+
|
|
44
|
+
in vec2 v_objectUV;
|
|
45
|
+
in vec2 v_patternUV;
|
|
46
|
+
in vec2 v_objectBoxSize;
|
|
47
|
+
in vec2 v_patternBoxSize;
|
|
48
|
+
|
|
49
|
+
out vec4 fragColor;
|
|
50
|
+
|
|
51
|
+
${declarePI}
|
|
52
|
+
${simplexNoise}
|
|
53
|
+
${rotation2}
|
|
54
|
+
${textureRandomizerR}
|
|
55
|
+
|
|
56
|
+
float valueNoiseR(vec2 st) {
|
|
57
|
+
vec2 i = floor(st);
|
|
58
|
+
vec2 f = fract(st);
|
|
59
|
+
float a = randomR(i);
|
|
60
|
+
float b = randomR(i + vec2(1.0, 0.0));
|
|
61
|
+
float c = randomR(i + vec2(0.0, 1.0));
|
|
62
|
+
float d = randomR(i + vec2(1.0, 1.0));
|
|
63
|
+
vec2 u = f * f * (3.0 - 2.0 * f);
|
|
64
|
+
float x1 = mix(a, b, u.x);
|
|
65
|
+
float x2 = mix(c, d, u.x);
|
|
66
|
+
return mix(x1, x2, u.y);
|
|
67
|
+
}
|
|
68
|
+
vec4 fbmR(vec2 n0, vec2 n1, vec2 n2, vec2 n3) {
|
|
69
|
+
float amplitude = 0.2;
|
|
70
|
+
vec4 total = vec4(0.);
|
|
71
|
+
for (int i = 0; i < 3; i++) {
|
|
72
|
+
n0 = rotate(n0, 0.3);
|
|
73
|
+
n1 = rotate(n1, 0.3);
|
|
74
|
+
n2 = rotate(n2, 0.3);
|
|
75
|
+
n3 = rotate(n3, 0.3);
|
|
76
|
+
total.x += valueNoiseR(n0) * amplitude;
|
|
77
|
+
total.y += valueNoiseR(n1) * amplitude;
|
|
78
|
+
total.z += valueNoiseR(n2) * amplitude;
|
|
79
|
+
total.z += valueNoiseR(n3) * amplitude;
|
|
80
|
+
n0 *= 1.99;
|
|
81
|
+
n1 *= 1.99;
|
|
82
|
+
n2 *= 1.99;
|
|
83
|
+
n3 *= 1.99;
|
|
84
|
+
amplitude *= 0.6;
|
|
85
|
+
}
|
|
86
|
+
return total;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
${proceduralHash11}
|
|
90
|
+
|
|
91
|
+
vec2 truchet(vec2 uv, float idx){
|
|
92
|
+
idx = fract(((idx - .5) * 2.));
|
|
93
|
+
if (idx > 0.75) {
|
|
94
|
+
uv = vec2(1.0) - uv;
|
|
95
|
+
} else if (idx > 0.5) {
|
|
96
|
+
uv = vec2(1.0 - uv.x, uv.y);
|
|
97
|
+
} else if (idx > 0.25) {
|
|
98
|
+
uv = 1.0 - vec2(1.0 - uv.x, uv.y);
|
|
99
|
+
}
|
|
100
|
+
return uv;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
void main() {
|
|
104
|
+
|
|
105
|
+
const float firstFrameOffset = 7.;
|
|
106
|
+
float t = .1 * (u_time + firstFrameOffset);
|
|
107
|
+
|
|
108
|
+
vec2 shape_uv = vec2(0.);
|
|
109
|
+
vec2 grain_uv = vec2(0.);
|
|
110
|
+
|
|
111
|
+
float r = u_rotation * PI / 180.;
|
|
112
|
+
float cr = cos(r);
|
|
113
|
+
float sr = sin(r);
|
|
114
|
+
mat2 graphicRotation = mat2(cr, sr, -sr, cr);
|
|
115
|
+
vec2 graphicOffset = vec2(-u_offsetX, u_offsetY);
|
|
116
|
+
|
|
117
|
+
if (u_shape > 3.5) {
|
|
118
|
+
shape_uv = v_objectUV;
|
|
119
|
+
grain_uv = shape_uv;
|
|
120
|
+
|
|
121
|
+
// apply inverse transform to grain_uv so it respects the originXY
|
|
122
|
+
grain_uv = transpose(graphicRotation) * grain_uv;
|
|
123
|
+
grain_uv *= u_scale;
|
|
124
|
+
grain_uv -= graphicOffset;
|
|
125
|
+
grain_uv *= v_objectBoxSize;
|
|
126
|
+
grain_uv *= .7;
|
|
127
|
+
} else {
|
|
128
|
+
shape_uv = .5 * v_patternUV;
|
|
129
|
+
grain_uv = 100. * v_patternUV;
|
|
130
|
+
|
|
131
|
+
// apply inverse transform to grain_uv so it respects the originXY
|
|
132
|
+
grain_uv = transpose(graphicRotation) * grain_uv;
|
|
133
|
+
grain_uv *= u_scale;
|
|
134
|
+
if (u_fit > 0.) {
|
|
135
|
+
vec2 givenBoxSize = vec2(u_worldWidth, u_worldHeight);
|
|
136
|
+
givenBoxSize = max(givenBoxSize, vec2(1.)) * u_pixelRatio;
|
|
137
|
+
float patternBoxRatio = givenBoxSize.x / givenBoxSize.y;
|
|
138
|
+
vec2 patternBoxGivenSize = vec2(
|
|
139
|
+
(u_worldWidth == 0.) ? u_resolution.x : givenBoxSize.x,
|
|
140
|
+
(u_worldHeight == 0.) ? u_resolution.y : givenBoxSize.y
|
|
141
|
+
);
|
|
142
|
+
patternBoxRatio = patternBoxGivenSize.x / patternBoxGivenSize.y;
|
|
143
|
+
float patternBoxNoFitBoxWidth = patternBoxRatio * min(patternBoxGivenSize.x / patternBoxRatio, patternBoxGivenSize.y);
|
|
144
|
+
grain_uv /= (patternBoxNoFitBoxWidth / v_patternBoxSize.x);
|
|
145
|
+
}
|
|
146
|
+
vec2 patternBoxScale = u_resolution.xy / v_patternBoxSize;
|
|
147
|
+
grain_uv -= graphicOffset / patternBoxScale;
|
|
148
|
+
grain_uv *= 1.6;
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
|
|
152
|
+
float shape = 0.;
|
|
153
|
+
|
|
154
|
+
if (u_shape < 1.5) {
|
|
155
|
+
// Sine wave
|
|
156
|
+
|
|
157
|
+
float wave = cos(.5 * shape_uv.x - 4. * t) * sin(1.5 * shape_uv.x + 2. * t) * (.75 + .25 * cos(6. * t));
|
|
158
|
+
shape = 1. - smoothstep(-1., 1., shape_uv.y + wave);
|
|
159
|
+
|
|
160
|
+
} else if (u_shape < 2.5) {
|
|
161
|
+
// Grid (dots)
|
|
162
|
+
|
|
163
|
+
float stripeIdx = floor(2. * shape_uv.x / TWO_PI);
|
|
164
|
+
float rand = hash11(stripeIdx * 100.);
|
|
165
|
+
rand = sign(rand - .5) * pow(4. * abs(rand), .3);
|
|
166
|
+
shape = sin(shape_uv.x) * cos(shape_uv.y - 5. * rand * t);
|
|
167
|
+
shape = pow(abs(shape), 4.);
|
|
168
|
+
|
|
169
|
+
} else if (u_shape < 3.5) {
|
|
170
|
+
// Truchet pattern
|
|
171
|
+
|
|
172
|
+
float n2 = valueNoiseR(shape_uv * .4 - 3.75 * t);
|
|
173
|
+
shape_uv.x += 10.;
|
|
174
|
+
shape_uv *= .6;
|
|
175
|
+
|
|
176
|
+
vec2 tile = truchet(fract(shape_uv), randomR(floor(shape_uv)));
|
|
177
|
+
|
|
178
|
+
float distance1 = length(tile);
|
|
179
|
+
float distance2 = length(tile - vec2(1.));
|
|
180
|
+
|
|
181
|
+
n2 -= .5;
|
|
182
|
+
n2 *= .1;
|
|
183
|
+
shape = smoothstep(.2, .55, distance1 + n2) * (1. - smoothstep(.45, .8, distance1 - n2));
|
|
184
|
+
shape += smoothstep(.2, .55, distance2 + n2) * (1. - smoothstep(.45, .8, distance2 - n2));
|
|
185
|
+
|
|
186
|
+
shape = pow(shape, 1.5);
|
|
187
|
+
|
|
188
|
+
} else if (u_shape < 4.5) {
|
|
189
|
+
// Corners
|
|
190
|
+
|
|
191
|
+
shape_uv *= .6;
|
|
192
|
+
vec2 outer = vec2(.5);
|
|
193
|
+
|
|
194
|
+
vec2 bl = smoothstep(vec2(0.), outer, shape_uv + vec2(.1 + .1 * sin(3. * t), .2 - .1 * sin(5.25 * t)));
|
|
195
|
+
vec2 tr = smoothstep(vec2(0.), outer, 1. - shape_uv);
|
|
196
|
+
shape = 1. - bl.x * bl.y * tr.x * tr.y;
|
|
197
|
+
|
|
198
|
+
shape_uv = -shape_uv;
|
|
199
|
+
bl = smoothstep(vec2(0.), outer, shape_uv + vec2(.1 + .1 * sin(3. * t), .2 - .1 * cos(5.25 * t)));
|
|
200
|
+
tr = smoothstep(vec2(0.), outer, 1. - shape_uv);
|
|
201
|
+
shape -= bl.x * bl.y * tr.x * tr.y;
|
|
202
|
+
|
|
203
|
+
shape = 1. - smoothstep(0., 1., shape);
|
|
204
|
+
|
|
205
|
+
} else if (u_shape < 5.5) {
|
|
206
|
+
// Ripple
|
|
207
|
+
|
|
208
|
+
shape_uv *= 2.;
|
|
209
|
+
float dist = length(.4 * shape_uv);
|
|
210
|
+
float waves = sin(pow(dist, 1.2) * 5. - 3. * t) * .5 + .5;
|
|
211
|
+
shape = waves;
|
|
212
|
+
|
|
213
|
+
} else if (u_shape < 6.5) {
|
|
214
|
+
// Blob
|
|
215
|
+
|
|
216
|
+
t *= 2.;
|
|
217
|
+
|
|
218
|
+
vec2 f1_traj = .25 * vec2(1.3 * sin(t), .2 + 1.3 * cos(.6 * t + 4.));
|
|
219
|
+
vec2 f2_traj = .2 * vec2(1.2 * sin(-t), 1.3 * sin(1.6 * t));
|
|
220
|
+
vec2 f3_traj = .25 * vec2(1.7 * cos(-.6 * t), cos(-1.6 * t));
|
|
221
|
+
vec2 f4_traj = .3 * vec2(1.4 * cos(.8 * t), 1.2 * sin(-.6 * t - 3.));
|
|
222
|
+
|
|
223
|
+
shape = .5 * pow(1. - clamp(0., 1., length(shape_uv + f1_traj)), 5.);
|
|
224
|
+
shape += .5 * pow(1. - clamp(0., 1., length(shape_uv + f2_traj)), 5.);
|
|
225
|
+
shape += .5 * pow(1. - clamp(0., 1., length(shape_uv + f3_traj)), 5.);
|
|
226
|
+
shape += .5 * pow(1. - clamp(0., 1., length(shape_uv + f4_traj)), 5.);
|
|
227
|
+
|
|
228
|
+
shape = smoothstep(.0, .9, shape);
|
|
229
|
+
float edge = smoothstep(.25, .3, shape);
|
|
230
|
+
shape = mix(.0, shape, edge);
|
|
231
|
+
|
|
232
|
+
} else {
|
|
233
|
+
// Sphere
|
|
234
|
+
|
|
235
|
+
shape_uv *= 2.;
|
|
236
|
+
float d = 1. - pow(length(shape_uv), 2.);
|
|
237
|
+
vec3 pos = vec3(shape_uv, sqrt(max(d, 0.)));
|
|
238
|
+
vec3 lightPos = normalize(vec3(cos(1.5 * t), .8, sin(1.25 * t)));
|
|
239
|
+
shape = .5 + .5 * dot(lightPos, pos);
|
|
240
|
+
shape *= step(0., d);
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
float baseNoise = snoise(grain_uv * .5);
|
|
244
|
+
vec4 fbmVals = fbmR(
|
|
245
|
+
.002 * grain_uv + 10.,
|
|
246
|
+
.003 * grain_uv,
|
|
247
|
+
.001 * grain_uv,
|
|
248
|
+
rotate(.4 * grain_uv, 2.)
|
|
249
|
+
);
|
|
250
|
+
float grainDist = baseNoise * snoise(grain_uv * .2) - fbmVals.x - fbmVals.y;
|
|
251
|
+
float rawNoise = .75 * baseNoise - fbmVals.w - fbmVals.z;
|
|
252
|
+
float noise = clamp(rawNoise, 0., 1.);
|
|
253
|
+
|
|
254
|
+
shape += u_intensity * 2. / u_colorsCount * (grainDist + .5);
|
|
255
|
+
shape += u_noise * 10. / u_colorsCount * noise;
|
|
256
|
+
|
|
257
|
+
float aa = fwidth(shape);
|
|
258
|
+
|
|
259
|
+
shape = clamp(shape - .5 / u_colorsCount, 0., 1.);
|
|
260
|
+
float totalShape = smoothstep(0., u_softness + 2. * aa, clamp(shape * u_colorsCount, 0., 1.));
|
|
261
|
+
float mixer = shape * (u_colorsCount - 1.);
|
|
262
|
+
|
|
263
|
+
int cntStop = int(u_colorsCount) - 1;
|
|
264
|
+
vec4 gradient = u_colors[0];
|
|
265
|
+
gradient.rgb *= gradient.a;
|
|
266
|
+
for (int i = 1; i < ${grainGradientMeta.maxColorCount}; i++) {
|
|
267
|
+
if (i > cntStop) break;
|
|
268
|
+
|
|
269
|
+
float localT = clamp(mixer - float(i - 1), 0., 1.);
|
|
270
|
+
localT = smoothstep(.5 - .5 * u_softness - aa, .5 + .5 * u_softness + aa, localT);
|
|
271
|
+
|
|
272
|
+
vec4 c = u_colors[i];
|
|
273
|
+
c.rgb *= c.a;
|
|
274
|
+
gradient = mix(gradient, c, localT);
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
vec3 color = gradient.rgb * totalShape;
|
|
278
|
+
float opacity = gradient.a * totalShape;
|
|
279
|
+
|
|
280
|
+
vec3 bgColor = u_colorBack.rgb * u_colorBack.a;
|
|
281
|
+
color = color + bgColor * (1.0 - opacity);
|
|
282
|
+
opacity = opacity + u_colorBack.a * (1.0 - opacity);
|
|
283
|
+
|
|
284
|
+
fragColor = vec4(color, opacity);
|
|
285
|
+
}
|
|
286
|
+
`;
|
|
287
|
+
const GrainGradientShapes = {
|
|
288
|
+
wave: 1,
|
|
289
|
+
dots: 2,
|
|
290
|
+
truchet: 3,
|
|
291
|
+
corners: 4,
|
|
292
|
+
ripple: 5,
|
|
293
|
+
blob: 6,
|
|
294
|
+
sphere: 7
|
|
295
|
+
};
|
|
296
|
+
export {
|
|
297
|
+
GrainGradientShapes,
|
|
298
|
+
grainGradientFragmentShader,
|
|
299
|
+
grainGradientMeta
|
|
300
|
+
};
|
|
301
|
+
//# sourceMappingURL=grain-gradient.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/shaders/grain-gradient.ts"],
|
|
4
|
+
"sourcesContent": ["import type { vec4 } from '../types.js';\nimport type { ShaderMotionParams } from '../shader-mount.js';\nimport {\n type ShaderSizingParams,\n type ShaderSizingUniforms,\n} from '../shader-sizing.js';\nimport {\n simplexNoise,\n declarePI,\n rotation2,\n textureRandomizerR,\n proceduralHash11,\n} from '../shader-utils.js';\n\nexport const grainGradientMeta = {\n maxColorCount: 7,\n} as const;\n\n/**\n * Multi-color gradients with grainy, noise-textured distortion available in 7 animated abstract forms.\n *\n * Note: grains are calculated using gl_FragCoord & u_resolution, meaning grains don't react to scaling and fit\n *\n * Fragment shader uniforms:\n * - u_time (float): Animation time\n * - u_resolution (vec2): Canvas resolution in pixels\n * - u_pixelRatio (float): Device pixel ratio\n * - u_worldWidth (float): Virtual width of the graphic\n * - u_worldHeight (float): Virtual height of the graphic\n * - u_fit (float): Fit mode (0 = none, 1 = contain, 2 = cover)\n * - u_scale (float): Overall zoom level (0.01 to 4)\n * - u_rotation (float): Rotation angle in degrees (0 to 360)\n * - u_offsetX (float): Horizontal offset (-1 to 1)\n * - u_offsetY (float): Vertical offset (-1 to 1)\n * - u_colorBack (vec4): Background color in RGBA\n * - u_colors (vec4[]): Up to 7 gradient colors in RGBA\n * - u_colorsCount (float): Number of active colors\n * - u_softness (float): Color transition sharpness, 0 = hard edge, 1 = smooth gradient (0 to 1)\n * - u_intensity (float): Distortion between color bands (0 to 1)\n * - u_noise (float): Grainy noise overlay (0 to 1)\n * - u_shape (float): Shape type (1 = wave, 2 = dots, 3 = truchet, 4 = corners, 5 = ripple, 6 = blob, 7 = sphere)\n * - u_noiseTexture (sampler2D): Pre-computed randomizer source texture\n *\n * Vertex shader outputs (used in fragment shader):\n * - v_objectUV (vec2): Object box UV coordinates with global sizing (scale, rotation, offsets, etc) applied (used for shapes 4-7)\n * - v_objectBoxSize (vec2): Size of the object bounding box in pixels\n * - v_patternUV (vec2): UV coordinates for pattern with global sizing (rotation, scale, offset, etc) applied (used for shapes 1-3)\n * - v_patternBoxSize (vec2): Size of the pattern bounding box in pixels\n *\n * Vertex shader uniforms:\n * - u_resolution (vec2): Canvas resolution in pixels\n * - u_pixelRatio (float): Device pixel ratio\n * - u_originX (float): Reference point for positioning world width in the canvas (0 to 1)\n * - u_originY (float): Reference point for positioning world height in the canvas (0 to 1)\n * - u_worldWidth (float): Virtual width of the graphic before it's scaled to fit the canvas\n * - u_worldHeight (float): Virtual height of the graphic before it's scaled to fit the canvas\n * - u_fit (float): How to fit the rendered shader into the canvas dimensions (0 = none, 1 = contain, 2 = cover)\n * - u_scale (float): Overall zoom level of the graphics (0.01 to 4)\n * - u_rotation (float): Overall rotation angle of the graphics in degrees (0 to 360)\n * - u_offsetX (float): Horizontal offset of the graphics center (-1 to 1)\n * - u_offsetY (float): Vertical offset of the graphics center (-1 to 1)\n *\n */\n\n// language=GLSL\nexport const grainGradientFragmentShader: string = `#version 300 es\nprecision lowp float;\n\nuniform mediump float u_time;\nuniform mediump vec2 u_resolution;\nuniform mediump float u_pixelRatio;\n\nuniform sampler2D u_noiseTexture;\n\nuniform vec4 u_colorBack;\nuniform vec4 u_colors[${ grainGradientMeta.maxColorCount }];\nuniform float u_colorsCount;\nuniform float u_softness;\nuniform float u_intensity;\nuniform float u_noise;\nuniform float u_shape;\n\nuniform mediump float u_worldWidth;\nuniform mediump float u_worldHeight;\nuniform mediump float u_fit;\n\nuniform mediump float u_scale;\nuniform mediump float u_rotation;\nuniform mediump float u_offsetX;\nuniform mediump float u_offsetY;\n\nin vec2 v_objectUV;\nin vec2 v_patternUV;\nin vec2 v_objectBoxSize;\nin vec2 v_patternBoxSize;\n\nout vec4 fragColor;\n\n${ declarePI }\n${ simplexNoise }\n${ rotation2 }\n${ textureRandomizerR }\n\nfloat valueNoiseR(vec2 st) {\n vec2 i = floor(st);\n vec2 f = fract(st);\n float a = randomR(i);\n float b = randomR(i + vec2(1.0, 0.0));\n float c = randomR(i + vec2(0.0, 1.0));\n float d = randomR(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}\nvec4 fbmR(vec2 n0, vec2 n1, vec2 n2, vec2 n3) {\n float amplitude = 0.2;\n vec4 total = vec4(0.);\n for (int i = 0; i < 3; i++) {\n n0 = rotate(n0, 0.3);\n n1 = rotate(n1, 0.3);\n n2 = rotate(n2, 0.3);\n n3 = rotate(n3, 0.3);\n total.x += valueNoiseR(n0) * amplitude;\n total.y += valueNoiseR(n1) * amplitude;\n total.z += valueNoiseR(n2) * amplitude;\n total.z += valueNoiseR(n3) * amplitude;\n n0 *= 1.99;\n n1 *= 1.99;\n n2 *= 1.99;\n n3 *= 1.99;\n amplitude *= 0.6;\n }\n return total;\n}\n\n${ proceduralHash11 }\n\nvec2 truchet(vec2 uv, float idx){\n idx = fract(((idx - .5) * 2.));\n if (idx > 0.75) {\n uv = vec2(1.0) - uv;\n } else if (idx > 0.5) {\n uv = vec2(1.0 - uv.x, uv.y);\n } else if (idx > 0.25) {\n uv = 1.0 - vec2(1.0 - uv.x, uv.y);\n }\n return uv;\n}\n\nvoid main() {\n\n const float firstFrameOffset = 7.;\n float t = .1 * (u_time + firstFrameOffset);\n\n vec2 shape_uv = vec2(0.);\n vec2 grain_uv = vec2(0.);\n\n float r = u_rotation * PI / 180.;\n float cr = cos(r);\n float sr = sin(r);\n mat2 graphicRotation = mat2(cr, sr, -sr, cr);\n vec2 graphicOffset = vec2(-u_offsetX, u_offsetY);\n\n if (u_shape > 3.5) {\n shape_uv = v_objectUV;\n grain_uv = shape_uv;\n\n // apply inverse transform to grain_uv so it respects the originXY\n grain_uv = transpose(graphicRotation) * grain_uv;\n grain_uv *= u_scale;\n grain_uv -= graphicOffset;\n grain_uv *= v_objectBoxSize;\n grain_uv *= .7;\n } else {\n shape_uv = .5 * v_patternUV;\n grain_uv = 100. * v_patternUV;\n\n // apply inverse transform to grain_uv so it respects the originXY\n grain_uv = transpose(graphicRotation) * grain_uv;\n grain_uv *= u_scale;\n if (u_fit > 0.) {\n vec2 givenBoxSize = vec2(u_worldWidth, u_worldHeight);\n givenBoxSize = max(givenBoxSize, vec2(1.)) * u_pixelRatio;\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 patternBoxRatio = patternBoxGivenSize.x / patternBoxGivenSize.y;\n float patternBoxNoFitBoxWidth = patternBoxRatio * min(patternBoxGivenSize.x / patternBoxRatio, patternBoxGivenSize.y);\n grain_uv /= (patternBoxNoFitBoxWidth / v_patternBoxSize.x);\n }\n vec2 patternBoxScale = u_resolution.xy / v_patternBoxSize;\n grain_uv -= graphicOffset / patternBoxScale;\n grain_uv *= 1.6;\n }\n\n\n float shape = 0.;\n\n if (u_shape < 1.5) {\n // Sine wave\n\n float wave = cos(.5 * shape_uv.x - 4. * t) * sin(1.5 * shape_uv.x + 2. * t) * (.75 + .25 * cos(6. * t));\n shape = 1. - smoothstep(-1., 1., shape_uv.y + wave);\n\n } else if (u_shape < 2.5) {\n // Grid (dots)\n\n float stripeIdx = floor(2. * shape_uv.x / TWO_PI);\n float rand = hash11(stripeIdx * 100.);\n rand = sign(rand - .5) * pow(4. * abs(rand), .3);\n shape = sin(shape_uv.x) * cos(shape_uv.y - 5. * rand * t);\n shape = pow(abs(shape), 4.);\n\n } else if (u_shape < 3.5) {\n // Truchet pattern\n\n float n2 = valueNoiseR(shape_uv * .4 - 3.75 * t);\n shape_uv.x += 10.;\n shape_uv *= .6;\n\n vec2 tile = truchet(fract(shape_uv), randomR(floor(shape_uv)));\n\n float distance1 = length(tile);\n float distance2 = length(tile - vec2(1.));\n\n n2 -= .5;\n n2 *= .1;\n shape = smoothstep(.2, .55, distance1 + n2) * (1. - smoothstep(.45, .8, distance1 - n2));\n shape += smoothstep(.2, .55, distance2 + n2) * (1. - smoothstep(.45, .8, distance2 - n2));\n\n shape = pow(shape, 1.5);\n\n } else if (u_shape < 4.5) {\n // Corners\n\n shape_uv *= .6;\n vec2 outer = vec2(.5);\n\n vec2 bl = smoothstep(vec2(0.), outer, shape_uv + vec2(.1 + .1 * sin(3. * t), .2 - .1 * sin(5.25 * t)));\n vec2 tr = smoothstep(vec2(0.), outer, 1. - shape_uv);\n shape = 1. - bl.x * bl.y * tr.x * tr.y;\n\n shape_uv = -shape_uv;\n bl = smoothstep(vec2(0.), outer, shape_uv + vec2(.1 + .1 * sin(3. * t), .2 - .1 * cos(5.25 * t)));\n tr = smoothstep(vec2(0.), outer, 1. - shape_uv);\n shape -= bl.x * bl.y * tr.x * tr.y;\n\n shape = 1. - smoothstep(0., 1., shape);\n\n } else if (u_shape < 5.5) {\n // Ripple\n\n shape_uv *= 2.;\n float dist = length(.4 * shape_uv);\n float waves = sin(pow(dist, 1.2) * 5. - 3. * t) * .5 + .5;\n shape = waves;\n\n } else if (u_shape < 6.5) {\n // Blob\n\n t *= 2.;\n\n vec2 f1_traj = .25 * vec2(1.3 * sin(t), .2 + 1.3 * cos(.6 * t + 4.));\n vec2 f2_traj = .2 * vec2(1.2 * sin(-t), 1.3 * sin(1.6 * t));\n vec2 f3_traj = .25 * vec2(1.7 * cos(-.6 * t), cos(-1.6 * t));\n vec2 f4_traj = .3 * vec2(1.4 * cos(.8 * t), 1.2 * sin(-.6 * t - 3.));\n\n shape = .5 * pow(1. - clamp(0., 1., length(shape_uv + f1_traj)), 5.);\n shape += .5 * pow(1. - clamp(0., 1., length(shape_uv + f2_traj)), 5.);\n shape += .5 * pow(1. - clamp(0., 1., length(shape_uv + f3_traj)), 5.);\n shape += .5 * pow(1. - clamp(0., 1., length(shape_uv + f4_traj)), 5.);\n\n shape = smoothstep(.0, .9, shape);\n float edge = smoothstep(.25, .3, shape);\n shape = mix(.0, shape, edge);\n\n } else {\n // Sphere\n\n shape_uv *= 2.;\n float d = 1. - pow(length(shape_uv), 2.);\n vec3 pos = vec3(shape_uv, sqrt(max(d, 0.)));\n vec3 lightPos = normalize(vec3(cos(1.5 * t), .8, sin(1.25 * t)));\n shape = .5 + .5 * dot(lightPos, pos);\n shape *= step(0., d);\n }\n\n float baseNoise = snoise(grain_uv * .5);\n vec4 fbmVals = fbmR(\n .002 * grain_uv + 10.,\n .003 * grain_uv,\n .001 * grain_uv,\n rotate(.4 * grain_uv, 2.)\n );\n float grainDist = baseNoise * snoise(grain_uv * .2) - fbmVals.x - fbmVals.y;\n float rawNoise = .75 * baseNoise - fbmVals.w - fbmVals.z;\n float noise = clamp(rawNoise, 0., 1.);\n\n shape += u_intensity * 2. / u_colorsCount * (grainDist + .5);\n shape += u_noise * 10. / u_colorsCount * noise;\n\n float aa = fwidth(shape);\n\n shape = clamp(shape - .5 / u_colorsCount, 0., 1.);\n float totalShape = smoothstep(0., u_softness + 2. * aa, clamp(shape * u_colorsCount, 0., 1.));\n float mixer = shape * (u_colorsCount - 1.);\n\n int cntStop = int(u_colorsCount) - 1;\n vec4 gradient = u_colors[0];\n gradient.rgb *= gradient.a;\n for (int i = 1; i < ${ grainGradientMeta.maxColorCount }; i++) {\n if (i > cntStop) break;\n\n float localT = clamp(mixer - float(i - 1), 0., 1.);\n localT = smoothstep(.5 - .5 * u_softness - aa, .5 + .5 * u_softness + aa, localT);\n\n vec4 c = u_colors[i];\n c.rgb *= c.a;\n gradient = mix(gradient, c, localT);\n }\n\n vec3 color = gradient.rgb * totalShape;\n float opacity = gradient.a * totalShape;\n\n vec3 bgColor = u_colorBack.rgb * u_colorBack.a;\n color = color + bgColor * (1.0 - opacity);\n opacity = opacity + u_colorBack.a * (1.0 - opacity);\n\n fragColor = vec4(color, opacity);\n}\n`;\n\nexport interface GrainGradientUniforms extends ShaderSizingUniforms {\n u_colorBack: [number, number, number, number];\n u_colors: vec4[];\n u_colorsCount: number;\n u_softness: number;\n u_intensity: number;\n u_noise: number;\n u_shape: (typeof GrainGradientShapes)[GrainGradientShape];\n u_noiseTexture?: HTMLImageElement;\n}\n\nexport interface GrainGradientParams extends ShaderSizingParams, ShaderMotionParams {\n colorBack?: string;\n colors?: string[];\n softness?: number;\n intensity?: number;\n noise?: number;\n shape?: GrainGradientShape;\n}\n\nexport const GrainGradientShapes = {\n wave: 1,\n dots: 2,\n truchet: 3,\n corners: 4,\n ripple: 5,\n blob: 6,\n sphere: 7,\n};\n\nexport type GrainGradientShape = keyof typeof GrainGradientShapes;\n"],
|
|
5
|
+
"mappings": ";;;;;AAEA;AAAA,OAGO;AACP;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAEA,MAAM,oBAAoB;AAAA,EAC/B,eAAe;AACjB;AAiDO,MAAM,8BAAsC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,wBAU1B,kBAAkB,aAAc;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAuBtD,SAAU;AAAA,EACV,YAAa;AAAA,EACb,SAAU;AAAA,EACV,kBAAmB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAmCnB,gBAAiB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,wBAiLK,kBAAkB,aAAc;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AA0ClD,MAAM,sBAAsB;AAAA,EACjC,MAAM;AAAA,EACN,MAAM;AAAA,EACN,SAAS;AAAA,EACT,SAAS;AAAA,EACT,QAAQ;AAAA,EACR,MAAM;AAAA,EACN,QAAQ;AACV;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import type { ShaderMotionParams } from '../shader-mount.js';
|
|
2
|
+
import { type ShaderSizingParams, type ShaderSizingUniforms } from '../shader-sizing.js';
|
|
3
|
+
/**
|
|
4
|
+
* CMYK halftone printing effect applied to images with customizable dot patterns
|
|
5
|
+
* and ink colors for each channel (Cyan, Magenta, Yellow, Black).
|
|
6
|
+
*
|
|
7
|
+
* Fragment shader uniforms:
|
|
8
|
+
* - u_image (sampler2D): Source image texture, premultiplied alpha
|
|
9
|
+
* - u_imageAspectRatio (float): Aspect ratio of the source image; over HTML the canvas aspect from u_resolution is used instead
|
|
10
|
+
* - u_imageIsHtml (float): 1 when u_image is HTML. HTML is drawn 1:1, so the grid and grain are sized in CSS px to keep
|
|
11
|
+
* their size over it: size sets the grid cell from about 2.5px to 143px, and the grain looks as it does over an image box 1000px wide.
|
|
12
|
+
* The grid and grain are anchored at originX / originY instead of the center, 0 0 being the top left like CSS
|
|
13
|
+
* - u_colorBack (vec4): Background (paper) color in RGBA
|
|
14
|
+
* - u_colorC (vec4): Cyan ink color in RGBA
|
|
15
|
+
* - u_colorM (vec4): Magenta ink color in RGBA
|
|
16
|
+
* - u_colorY (vec4): Yellow ink color in RGBA
|
|
17
|
+
* - u_colorK (vec4): Black ink color in RGBA
|
|
18
|
+
* - u_size (float): Halftone cell size (0 to 1)
|
|
19
|
+
* - u_contrast (float): Image contrast adjustment (0 to 2)
|
|
20
|
+
* - u_softness (float): Edge softness of dots (0 to 1)
|
|
21
|
+
* - u_grainSize (float): Size of grain texture, applied to both grain and overlay, needs grainMixer or grainOverlay > 0 (0 to 1)
|
|
22
|
+
* - u_grainMixer (float): Strength of grain affecting dot size (0 to 1)
|
|
23
|
+
* - u_grainOverlay (float): Strength of grain overlay on final output (0 to 1)
|
|
24
|
+
* - u_gridNoise (float): Strength of smooth noise applied to both dot positions and color sampling, positions only with sharp type (0 to 1)
|
|
25
|
+
* - u_floodC (float): Flat cyan dot size adjustment applied uniformly, needs colorC alpha > 0 (0 to 1)
|
|
26
|
+
* - u_floodM (float): Flat magenta dot size adjustment applied uniformly, needs colorM alpha > 0 (0 to 1)
|
|
27
|
+
* - u_floodY (float): Flat yellow dot size adjustment applied uniformly, needs colorY alpha > 0 (0 to 1)
|
|
28
|
+
* - u_floodK (float): Flat black dot size adjustment applied uniformly, needs colorK alpha > 0 (0 to 1)
|
|
29
|
+
* - u_gainC (float): Proportional cyan dot size gain, needs colorC alpha > 0 (enhances existing dots, -1 to 1)
|
|
30
|
+
* - u_gainM (float): Proportional magenta dot size gain, needs colorM alpha > 0 (enhances existing dots, -1 to 1)
|
|
31
|
+
* - u_gainY (float): Proportional yellow dot size gain, needs colorY alpha > 0 (enhances existing dots, -1 to 1)
|
|
32
|
+
* - u_gainK (float): Proportional black dot size gain, needs colorK alpha > 0 (enhances existing dots, -1 to 1)
|
|
33
|
+
* - u_type (float): Dot shape style (0 = dots, 1 = ink, 2 = sharp)
|
|
34
|
+
* - u_noiseTexture (sampler2D): Pre-computed randomizer source texture
|
|
35
|
+
*
|
|
36
|
+
* Vertex shader outputs (used in fragment shader):
|
|
37
|
+
* - v_imageUV (vec2): UV coordinates for sampling the source image, with fit, scale, rotation, and offset applied
|
|
38
|
+
*
|
|
39
|
+
* Vertex shader uniforms:
|
|
40
|
+
* - u_resolution (vec2): Canvas resolution in pixels
|
|
41
|
+
* - u_pixelRatio (float): Device pixel ratio
|
|
42
|
+
* - u_originX (float): Reference point for positioning world width in the canvas, over HTML where the effect is anchored (0 to 1)
|
|
43
|
+
* - u_originY (float): Reference point for positioning world height in the canvas, over HTML where the effect is anchored from the top (0 to 1)
|
|
44
|
+
* - u_fit (float): How to fit the rendered shader into the canvas dimensions (0 = none, 1 = contain, 2 = cover)
|
|
45
|
+
* - u_scale (float): Overall zoom level of the graphics (0.1 to 4)
|
|
46
|
+
* - u_rotation (float): Overall rotation angle of the graphics in degrees (0 to 360)
|
|
47
|
+
* - u_offsetX (float): Horizontal offset of the graphics center (-1 to 1)
|
|
48
|
+
* - u_offsetY (float): Vertical offset of the graphics center (-1 to 1)
|
|
49
|
+
* - u_imageAspectRatio (float): Aspect ratio of the source image
|
|
50
|
+
*
|
|
51
|
+
*/
|
|
52
|
+
export declare const halftoneCmykFragmentShader: string;
|
|
53
|
+
export interface HalftoneCmykUniforms extends ShaderSizingUniforms {
|
|
54
|
+
u_image: HTMLImageElement | string | undefined;
|
|
55
|
+
u_noiseTexture?: HTMLImageElement;
|
|
56
|
+
u_colorBack: [number, number, number, number];
|
|
57
|
+
u_colorC: [number, number, number, number];
|
|
58
|
+
u_colorM: [number, number, number, number];
|
|
59
|
+
u_colorY: [number, number, number, number];
|
|
60
|
+
u_colorK: [number, number, number, number];
|
|
61
|
+
u_size: number;
|
|
62
|
+
u_contrast: number;
|
|
63
|
+
u_softness: number;
|
|
64
|
+
u_grainSize: number;
|
|
65
|
+
u_grainMixer: number;
|
|
66
|
+
u_grainOverlay: number;
|
|
67
|
+
u_gridNoise: number;
|
|
68
|
+
u_floodC: number;
|
|
69
|
+
u_floodM: number;
|
|
70
|
+
u_floodY: number;
|
|
71
|
+
u_floodK: number;
|
|
72
|
+
u_gainC: number;
|
|
73
|
+
u_gainM: number;
|
|
74
|
+
u_gainY: number;
|
|
75
|
+
u_gainK: number;
|
|
76
|
+
u_type: (typeof HalftoneCmykTypes)[HalftoneCmykType];
|
|
77
|
+
}
|
|
78
|
+
export interface HalftoneCmykParams extends ShaderSizingParams, ShaderMotionParams {
|
|
79
|
+
image?: HTMLImageElement | string;
|
|
80
|
+
colorBack?: string;
|
|
81
|
+
colorC?: string;
|
|
82
|
+
colorM?: string;
|
|
83
|
+
colorY?: string;
|
|
84
|
+
colorK?: string;
|
|
85
|
+
size?: number;
|
|
86
|
+
contrast?: number;
|
|
87
|
+
softness?: number;
|
|
88
|
+
grainSize?: number;
|
|
89
|
+
grainMixer?: number;
|
|
90
|
+
grainOverlay?: number;
|
|
91
|
+
gridNoise?: number;
|
|
92
|
+
floodC?: number;
|
|
93
|
+
floodM?: number;
|
|
94
|
+
floodY?: number;
|
|
95
|
+
floodK?: number;
|
|
96
|
+
gainC?: number;
|
|
97
|
+
gainM?: number;
|
|
98
|
+
gainY?: number;
|
|
99
|
+
gainK?: number;
|
|
100
|
+
type?: HalftoneCmykType;
|
|
101
|
+
}
|
|
102
|
+
export declare const HalftoneCmykTypes: {
|
|
103
|
+
readonly dots: 0;
|
|
104
|
+
readonly ink: 1;
|
|
105
|
+
readonly sharp: 2;
|
|
106
|
+
};
|
|
107
|
+
export type HalftoneCmykType = keyof typeof HalftoneCmykTypes;
|