hydra-nodegl 2.1.0
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/.github/FUNDING.yml +4 -0
- package/.github/ISSUE_TEMPLATE/bug_report.md +38 -0
- package/.github/ISSUE_TEMPLATE/custom.md +10 -0
- package/.github/ISSUE_TEMPLATE/feature_request.md +20 -0
- package/.github/workflows/main.yml +62 -0
- package/README.md +45 -0
- package/index.cjs +956 -0
- package/index.html +776 -0
- package/package.json +27 -0
- package/script.cjs +93 -0
- package/style.css +82 -0
package/index.cjs
ADDED
|
@@ -0,0 +1,956 @@
|
|
|
1
|
+
function glslAxis(perspective = "1.0") {
|
|
2
|
+
if (perspective === "x") {
|
|
3
|
+
return "st.x";
|
|
4
|
+
} else if (perspective === "y") {
|
|
5
|
+
return "st.y";
|
|
6
|
+
} else if (perspective === "2x") {
|
|
7
|
+
return "st.x*2.0";
|
|
8
|
+
} else if (perspective === "x/2") {
|
|
9
|
+
return "st.x/2.0";
|
|
10
|
+
} else if (perspective === "pow(x,2)") {
|
|
11
|
+
return "pow(st.x,2.0)";
|
|
12
|
+
} else if (perspective === "x+y") {
|
|
13
|
+
return "st.x+st.y";
|
|
14
|
+
} else if (perspective === "x-y") {
|
|
15
|
+
return "st.x-st.y";
|
|
16
|
+
} else if (perspective === "x*y") {
|
|
17
|
+
return "st.x*st.y";
|
|
18
|
+
} else if (perspective === "x/y") {
|
|
19
|
+
return "st.x/st.y";
|
|
20
|
+
} else if (perspective === "y-x") {
|
|
21
|
+
return "st.y-st.x";
|
|
22
|
+
} else if (perspective === "y/x") {
|
|
23
|
+
return "st.y/st.x";
|
|
24
|
+
} else if (perspective === "2y") {
|
|
25
|
+
return "st.y*2.0";
|
|
26
|
+
} else if (perspective === "y/2") {
|
|
27
|
+
return "st.y/2.0";
|
|
28
|
+
} else if (perspective === "pow(y,2)") {
|
|
29
|
+
return "pow(st.y,2.0)";
|
|
30
|
+
} else {
|
|
31
|
+
return perspective;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
function flash(fast0 = 1, fast1 = 1, fast2 = 0.01) {
|
|
35
|
+
return solid(glslAxis("x"), glslAxis("y"), () => time * fast0)
|
|
36
|
+
.diff(gradient(fast1))
|
|
37
|
+
.colorama(fast2);
|
|
38
|
+
}
|
|
39
|
+
function list(s = 0, t = 1) {
|
|
40
|
+
let sin = () => Math.sin(time * t);
|
|
41
|
+
let cos = () => Math.cos(time * t);
|
|
42
|
+
let tan = () => Math.tan(time * t);
|
|
43
|
+
let asin = () => Math.asin(time * t);
|
|
44
|
+
let acos = () => Math.acos(time * t);
|
|
45
|
+
let atan = () => Math.atan(time * t);
|
|
46
|
+
const ar = [sin(), cos(), tan(), asin(), acos(), atan()];
|
|
47
|
+
return ar[s];
|
|
48
|
+
}
|
|
49
|
+
function easeInOut(k = 0) {
|
|
50
|
+
const linear = "linear";
|
|
51
|
+
const sine = "sine";
|
|
52
|
+
const easeInOut = "easeInOut";
|
|
53
|
+
const easeInOutHalf = "easeInOutHalf";
|
|
54
|
+
const easeInOutQuad = "easeInOutQuad";
|
|
55
|
+
const easeInOutCubic = "easeInOutCubic";
|
|
56
|
+
const easeInOutQuart = "easeInOutQuart";
|
|
57
|
+
const easeInOutQuint = "easeInOutQuint";
|
|
58
|
+
const easeInOutExpo = "easeInOutExpo";
|
|
59
|
+
const easeInOutCirc = "easeInOutCirc";
|
|
60
|
+
const easeInOutBack = "easeInOutBack";
|
|
61
|
+
const easeInOutElastic = "easeInOutElastic";
|
|
62
|
+
const easeInOutBounce = "easeInOutBounce";
|
|
63
|
+
const array = [
|
|
64
|
+
linear,
|
|
65
|
+
sine,
|
|
66
|
+
easeInOut,
|
|
67
|
+
easeInOutHalf,
|
|
68
|
+
easeInOutQuad,
|
|
69
|
+
easeInOutCubic,
|
|
70
|
+
easeInOutQuart,
|
|
71
|
+
easeInOutQuint,
|
|
72
|
+
easeInOutExpo,
|
|
73
|
+
easeInOutCirc,
|
|
74
|
+
easeInOutBack,
|
|
75
|
+
easeInOutElastic,
|
|
76
|
+
easeInOutBounce,
|
|
77
|
+
];
|
|
78
|
+
return array[k];
|
|
79
|
+
}
|
|
80
|
+
function varDef(func2 = "hydra", func3 = Math.sin, v = 10) {
|
|
81
|
+
func2 = [...Array(v).keys()];
|
|
82
|
+
for (let u = 0; u <= v; u++) {
|
|
83
|
+
func2[v] = func3(v);
|
|
84
|
+
}
|
|
85
|
+
return func2[v];
|
|
86
|
+
}
|
|
87
|
+
function funcAry(
|
|
88
|
+
init = 0,
|
|
89
|
+
r = 0.5,
|
|
90
|
+
term = 1,
|
|
91
|
+
step0 = 0.01,
|
|
92
|
+
step1 = 0.1,
|
|
93
|
+
func0 = Math.sin,
|
|
94
|
+
func1 = Math.cos
|
|
95
|
+
) {
|
|
96
|
+
let ary = [];
|
|
97
|
+
for (let i = init; i <= r; i += step0) {
|
|
98
|
+
ary.push(func0(i));
|
|
99
|
+
}
|
|
100
|
+
for (let j = r; j <= term; j += step1) {
|
|
101
|
+
ary.push(func1(j));
|
|
102
|
+
}
|
|
103
|
+
return ary;
|
|
104
|
+
}
|
|
105
|
+
function randAry(m = 100, mag = 0.01) {
|
|
106
|
+
let ay = [];
|
|
107
|
+
for (let l = 0; l <= m; l++) {
|
|
108
|
+
ay.push(l);
|
|
109
|
+
}
|
|
110
|
+
return ay[Math.floor(Math.random() * ay.length)] * mag;
|
|
111
|
+
}
|
|
112
|
+
function genAry(m = 100, mag = 0.01, rep = 10) {
|
|
113
|
+
let xy = [];
|
|
114
|
+
for (let z = 0; z <= rep; z++) {
|
|
115
|
+
xy.push(randAry(m, mag));
|
|
116
|
+
}
|
|
117
|
+
return xy;
|
|
118
|
+
}
|
|
119
|
+
function setLoop(speed0 = 1, speed1 = 1, speed2 = 1, speed3 = 1, ms = 1000) {
|
|
120
|
+
let count = 0;
|
|
121
|
+
let sf = [speed0, speed1, speed2, speed3];
|
|
122
|
+
let o = [o0, o1, o2, o3];
|
|
123
|
+
const countUp = () => {
|
|
124
|
+
count++;
|
|
125
|
+
};
|
|
126
|
+
const intervalId = setInterval(() => {
|
|
127
|
+
countUp();
|
|
128
|
+
for (let i = 0; i < o.length; i++) {
|
|
129
|
+
if (count % o.length == i) {
|
|
130
|
+
speed = sf[i];
|
|
131
|
+
render(o[i]);
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
}, ms);
|
|
135
|
+
}
|
|
136
|
+
function pad(
|
|
137
|
+
amount = 10,
|
|
138
|
+
output = o0,
|
|
139
|
+
form = 4,
|
|
140
|
+
inside = 0,
|
|
141
|
+
outside = 1,
|
|
142
|
+
breath = 0.99
|
|
143
|
+
) {
|
|
144
|
+
return solid().diff(
|
|
145
|
+
src(output)
|
|
146
|
+
.pixelate(amount, amount)
|
|
147
|
+
.mult(shape(form, inside, outside).repeat(amount, amount).invert())
|
|
148
|
+
.diff(
|
|
149
|
+
src(output)
|
|
150
|
+
.scale(breath)
|
|
151
|
+
.diff(src(output).scale(2 - breath))
|
|
152
|
+
)
|
|
153
|
+
);
|
|
154
|
+
}
|
|
155
|
+
function particle(output = o0, breath = 0.99) {
|
|
156
|
+
return solid().diff(
|
|
157
|
+
src(output)
|
|
158
|
+
.scale(breath)
|
|
159
|
+
.diff(src(output).scale(2 - breath))
|
|
160
|
+
);
|
|
161
|
+
}
|
|
162
|
+
function rgba(output = o0, red = 0, green = 0, blue = 0, alpha = 1) {
|
|
163
|
+
return src(output).r(red).g(green).b(blue).a(alpha);
|
|
164
|
+
}
|
|
165
|
+
function hsb(output = o0, hue = 0.5, saturation = 0.5, bright = 0.5) {
|
|
166
|
+
return src(output).hue(hue).saturate(saturation).brightness(bright);
|
|
167
|
+
}
|
|
168
|
+
function zebra(
|
|
169
|
+
video = src(o0),
|
|
170
|
+
timesY = 1,
|
|
171
|
+
timesX = 1,
|
|
172
|
+
func4 = Math.sin,
|
|
173
|
+
speed4 = 0.1
|
|
174
|
+
) {
|
|
175
|
+
synth = () => video;
|
|
176
|
+
return synth().modulateRepeatY(shape(2).repeatY(timesY), timesX, () =>
|
|
177
|
+
func4(time * speed4)
|
|
178
|
+
);
|
|
179
|
+
}
|
|
180
|
+
function form(n = 4, k = 2, n0 = 0, n1 = 1, o = 60, p = 1 / 8, q = 300) {
|
|
181
|
+
if (n % 2 === 1) {
|
|
182
|
+
return osc(o, p, q)
|
|
183
|
+
.kaleid(n)
|
|
184
|
+
.rotate(Math.PI / 2)
|
|
185
|
+
.mult(shape(n, n0, n1));
|
|
186
|
+
} else if (n % Math.pow(2, k) === 0) {
|
|
187
|
+
return osc(o, p, q)
|
|
188
|
+
.kaleid(Math.pow(2, k))
|
|
189
|
+
.rotate(Math.PI / Math.pow(2, k))
|
|
190
|
+
.mult(shape(Math.pow(2, k)));
|
|
191
|
+
} else if (n % 2 === 0) {
|
|
192
|
+
return osc().kaleid(n).rotate(Math.PI).mult(shape(n, n0, n1));
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
function rainbow(spectrum = 0) {
|
|
196
|
+
red = () => solid(1, 0, 0);
|
|
197
|
+
orange = () => solid(1, 0.5, 0);
|
|
198
|
+
yellow = () => solid(1, 1, 0);
|
|
199
|
+
green = () => solid(0, 1, 0);
|
|
200
|
+
blue = () => solid(0, 0, 1);
|
|
201
|
+
indigo = () => solid(75 / 255, 0, 130 / 255);
|
|
202
|
+
violet = () => solid(238 / 255, 130 / 255, 238 / 255);
|
|
203
|
+
let filter = [red(), orange(), yellow(), green(), blue(), indigo(), violet()];
|
|
204
|
+
return filter[spectrum];
|
|
205
|
+
}
|
|
206
|
+
setFunction({
|
|
207
|
+
name: "chroma",
|
|
208
|
+
type: "color",
|
|
209
|
+
inputs: [],
|
|
210
|
+
glsl: `
|
|
211
|
+
float maxrb = max(_c0.r, _c0.b);
|
|
212
|
+
float k = smoothstep(0.0, 1.0, (_c0.g - maxrb) * 5.0);
|
|
213
|
+
_c0.g = mix(_c0.g, maxrb * 0.8, k);
|
|
214
|
+
return vec4(_c0.rgb, 1.0 - k);
|
|
215
|
+
`,
|
|
216
|
+
});
|
|
217
|
+
setFunction({
|
|
218
|
+
name: "swirl",
|
|
219
|
+
type: "coord",
|
|
220
|
+
inputs: [
|
|
221
|
+
{
|
|
222
|
+
name: "strength",
|
|
223
|
+
type: "float",
|
|
224
|
+
default: 1.0,
|
|
225
|
+
},
|
|
226
|
+
],
|
|
227
|
+
glsl: `
|
|
228
|
+
vec2 pos = _st - vec2(0.5);
|
|
229
|
+
float angle = strength * length(pos);
|
|
230
|
+
float sinA = sin(angle);
|
|
231
|
+
float cosA = cos(angle);
|
|
232
|
+
return mat2(cosA, -sinA, sinA, cosA) * pos + vec2(0.5);
|
|
233
|
+
`,
|
|
234
|
+
});
|
|
235
|
+
setFunction({
|
|
236
|
+
name: "modulateGlitch",
|
|
237
|
+
type: "combineCoord",
|
|
238
|
+
inputs: [
|
|
239
|
+
{
|
|
240
|
+
name: "amount",
|
|
241
|
+
type: "float",
|
|
242
|
+
default: 0.05,
|
|
243
|
+
},
|
|
244
|
+
],
|
|
245
|
+
glsl: `
|
|
246
|
+
vec2 offset = vec2(
|
|
247
|
+
(fract(sin(dot(_st, vec2(12.9898, 78.233))) * 43758.5453) - 0.5) * amount,
|
|
248
|
+
(fract(cos(dot(_st, vec2(93.9898, 67.233))) * 35758.5453) - 0.5) * amount
|
|
249
|
+
);
|
|
250
|
+
return _st + offset;
|
|
251
|
+
`,
|
|
252
|
+
});
|
|
253
|
+
setFunction({
|
|
254
|
+
name: "modulateWarp",
|
|
255
|
+
type: "combineCoord",
|
|
256
|
+
inputs: [
|
|
257
|
+
{
|
|
258
|
+
name: "intensity",
|
|
259
|
+
type: "float",
|
|
260
|
+
default: 0.3,
|
|
261
|
+
},
|
|
262
|
+
],
|
|
263
|
+
glsl: `
|
|
264
|
+
vec2 uv = _st - 0.5;
|
|
265
|
+
float distortion = sin(uv.x * 10.0) * sin(uv.y * 10.0) * intensity;
|
|
266
|
+
return _st + vec2(distortion, distortion * 0.5);
|
|
267
|
+
`,
|
|
268
|
+
});
|
|
269
|
+
setFunction({
|
|
270
|
+
name: "polar",
|
|
271
|
+
type: "coord",
|
|
272
|
+
inputs: [],
|
|
273
|
+
glsl: `
|
|
274
|
+
vec2 uv = _st - 0.5;
|
|
275
|
+
float r = length(uv);
|
|
276
|
+
float a = atan(uv.y, uv.x);
|
|
277
|
+
return vec2(r, a / 6.2831 + 0.5);
|
|
278
|
+
`,
|
|
279
|
+
});
|
|
280
|
+
setFunction({
|
|
281
|
+
name: "modulateSpiral",
|
|
282
|
+
type: "combineCoord",
|
|
283
|
+
inputs: [
|
|
284
|
+
{
|
|
285
|
+
name: "twist",
|
|
286
|
+
type: "float",
|
|
287
|
+
default: 5.0,
|
|
288
|
+
},
|
|
289
|
+
],
|
|
290
|
+
glsl: `
|
|
291
|
+
vec2 uv = _st - 0.5;
|
|
292
|
+
float angle = length(uv) * twist;
|
|
293
|
+
mat2 rot = mat2(cos(angle), -sin(angle), sin(angle), cos(angle));
|
|
294
|
+
return rot * uv + 0.5;
|
|
295
|
+
`,
|
|
296
|
+
});
|
|
297
|
+
setFunction({
|
|
298
|
+
name: "modulateShear",
|
|
299
|
+
type: "combineCoord",
|
|
300
|
+
inputs: [
|
|
301
|
+
{
|
|
302
|
+
name: "strength",
|
|
303
|
+
type: "float",
|
|
304
|
+
default: 0.2,
|
|
305
|
+
},
|
|
306
|
+
],
|
|
307
|
+
glsl: `
|
|
308
|
+
return vec2(_st.x + _st.y * strength, _st.y);
|
|
309
|
+
`,
|
|
310
|
+
});
|
|
311
|
+
setFunction({
|
|
312
|
+
name: "modulateRandomNoise",
|
|
313
|
+
type: "combineCoord",
|
|
314
|
+
inputs: [
|
|
315
|
+
{
|
|
316
|
+
name: "scale",
|
|
317
|
+
type: "float",
|
|
318
|
+
default: 1.0,
|
|
319
|
+
},
|
|
320
|
+
],
|
|
321
|
+
glsl: `
|
|
322
|
+
float noise = fract(sin(dot(_st, vec2(12.9898, 78.233))) * 43758.5453);
|
|
323
|
+
return _st + vec2(noise * scale, noise * scale * 0.5);
|
|
324
|
+
`,
|
|
325
|
+
});
|
|
326
|
+
setFunction({
|
|
327
|
+
name: "visual",
|
|
328
|
+
type: "src",
|
|
329
|
+
inputs: [],
|
|
330
|
+
glsl: `
|
|
331
|
+
vec3 col = vec3(0.5 + 0.5 * cos(_st.x * 6.28318 + vec3(0.0, 2.0, 4.0)));
|
|
332
|
+
return vec4(col, 1.0);
|
|
333
|
+
`,
|
|
334
|
+
});
|
|
335
|
+
setFunction({
|
|
336
|
+
name: "huecircle",
|
|
337
|
+
type: "src",
|
|
338
|
+
inputs: [],
|
|
339
|
+
glsl: `
|
|
340
|
+
vec2 pos = _st * 2.0 - 1.0;
|
|
341
|
+
float angle = atan(pos.y, pos.x) / 6.28318 + 0.5;
|
|
342
|
+
vec3 col = vec3(0.5 + 0.5 * cos(angle * 6.28318 + vec3(0.0, 2.0, 4.0)));
|
|
343
|
+
return vec4(col, 1.0);
|
|
344
|
+
`,
|
|
345
|
+
});
|
|
346
|
+
setFunction({
|
|
347
|
+
name: "lightning",
|
|
348
|
+
type: "src",
|
|
349
|
+
inputs: [{ name: "scale", type: "float", default: 10.0 }],
|
|
350
|
+
glsl: `
|
|
351
|
+
float noise = fract(sin(dot(_st * scale, vec2(12.9898, 78.233))) * 43758.5453);
|
|
352
|
+
float lightning = smoothstep(0.4, 0.41, noise) - smoothstep(0.41, 0.42, noise);
|
|
353
|
+
return vec4(vec3(lightning), 1.0);
|
|
354
|
+
`,
|
|
355
|
+
});
|
|
356
|
+
setFunction({
|
|
357
|
+
name: "shake",
|
|
358
|
+
type: "coord",
|
|
359
|
+
inputs: [],
|
|
360
|
+
glsl: `
|
|
361
|
+
return vec2(_st.x + 0.5 * sin(time), _st.y);
|
|
362
|
+
`,
|
|
363
|
+
});
|
|
364
|
+
setFunction({
|
|
365
|
+
name: "modulateRainbow",
|
|
366
|
+
type: "combineCoord",
|
|
367
|
+
inputs: [],
|
|
368
|
+
glsl: `
|
|
369
|
+
return _st + 0.1 * sin(6.28318 * _st.y + time);
|
|
370
|
+
`,
|
|
371
|
+
});
|
|
372
|
+
setFunction({
|
|
373
|
+
name: "beam",
|
|
374
|
+
type: "src",
|
|
375
|
+
inputs: [],
|
|
376
|
+
glsl: `
|
|
377
|
+
float beam = abs(sin(time * 5.0)) * 0.05;
|
|
378
|
+
float line = smoothstep(beam, beam + 0.01, abs(_st.x - 0.5));
|
|
379
|
+
return vec4(vec3(line * 10.0, line * 0.2, line * 0.1), 1.0);
|
|
380
|
+
`,
|
|
381
|
+
});
|
|
382
|
+
setFunction({
|
|
383
|
+
name: "crystal",
|
|
384
|
+
type: "coord",
|
|
385
|
+
inputs: [],
|
|
386
|
+
glsl: `
|
|
387
|
+
vec2 p = _st * 2.0 - 1.0;
|
|
388
|
+
float r = length(p);
|
|
389
|
+
return _st + 0.1 * normalize(p) * sin(r * 10.0 - time);
|
|
390
|
+
`,
|
|
391
|
+
});
|
|
392
|
+
setFunction({
|
|
393
|
+
name: "fisheye",
|
|
394
|
+
type: "coord",
|
|
395
|
+
inputs: [],
|
|
396
|
+
glsl: `
|
|
397
|
+
vec2 p = _st * 2.0 - 1.0;
|
|
398
|
+
float r = length(p);
|
|
399
|
+
return _st * (1.0 + 0.5 * r);
|
|
400
|
+
`,
|
|
401
|
+
});
|
|
402
|
+
setFunction({
|
|
403
|
+
name: "echo",
|
|
404
|
+
type: "coord",
|
|
405
|
+
inputs: [],
|
|
406
|
+
glsl: `
|
|
407
|
+
return _st + 0.02 * sin(time * 2.0);
|
|
408
|
+
`,
|
|
409
|
+
});
|
|
410
|
+
setFunction({
|
|
411
|
+
name: "chorus",
|
|
412
|
+
type: "coord",
|
|
413
|
+
inputs: [],
|
|
414
|
+
glsl: `
|
|
415
|
+
return _st + vec2(0.02 * sin(time * 3.0), 0.02 * cos(time * 3.0));
|
|
416
|
+
`,
|
|
417
|
+
});
|
|
418
|
+
setFunction({
|
|
419
|
+
name: "vibrato",
|
|
420
|
+
type: "coord",
|
|
421
|
+
inputs: [],
|
|
422
|
+
glsl: `
|
|
423
|
+
return _st + 0.01 * sin(time * 6.0);
|
|
424
|
+
`,
|
|
425
|
+
});
|
|
426
|
+
setFunction({
|
|
427
|
+
name: "ringModulator",
|
|
428
|
+
type: "src",
|
|
429
|
+
inputs: [],
|
|
430
|
+
glsl: `
|
|
431
|
+
float baseFreq = 2.0;
|
|
432
|
+
float harmonics[9];
|
|
433
|
+
for (int i = 0; i < 8; i++) {
|
|
434
|
+
harmonics[i] = baseFreq * float(i + 1);
|
|
435
|
+
}
|
|
436
|
+
harmonics[8] = baseFreq * sqrt(2.0); // トライトーン
|
|
437
|
+
float mod = 0.0;
|
|
438
|
+
for (int i = 0; i < 9; i++) {
|
|
439
|
+
mod += sin(_st.x * harmonics[i] * 6.28318);
|
|
440
|
+
}
|
|
441
|
+
mod /= 9.0;
|
|
442
|
+
return vec4(vec3(0.5 + 0.5 * mod), 1.0);
|
|
443
|
+
`,
|
|
444
|
+
});
|
|
445
|
+
setFunction({
|
|
446
|
+
name: "ringModulate",
|
|
447
|
+
type: "coord",
|
|
448
|
+
inputs: [],
|
|
449
|
+
glsl: `
|
|
450
|
+
float baseFreq = 2.0;
|
|
451
|
+
float harmonics[9];
|
|
452
|
+
for (int i = 0; i < 8; i++) {
|
|
453
|
+
harmonics[i] = baseFreq * float(i + 1);
|
|
454
|
+
}
|
|
455
|
+
harmonics[8] = baseFreq * sqrt(2.0);
|
|
456
|
+
float mod = 0.0;
|
|
457
|
+
for (int i = 0; i < 9; i++) {
|
|
458
|
+
mod += sin(time * harmonics[i] * 6.28318);
|
|
459
|
+
}
|
|
460
|
+
mod /= 9.0;
|
|
461
|
+
return _st + vec2(0.01 * mod, 0.01 * mod);
|
|
462
|
+
`,
|
|
463
|
+
});
|
|
464
|
+
setFunction({
|
|
465
|
+
name: "modulateRingModulator",
|
|
466
|
+
type: "combineCoord",
|
|
467
|
+
inputs: [],
|
|
468
|
+
glsl: `
|
|
469
|
+
float baseFreq = 2.0;
|
|
470
|
+
float harmonics[9];
|
|
471
|
+
for (int i = 0; i < 8; i++) {
|
|
472
|
+
harmonics[i] = baseFreq * float(i + 1);
|
|
473
|
+
}
|
|
474
|
+
harmonics[8] = baseFreq * sqrt(2.0);
|
|
475
|
+
float mod = 0.0;
|
|
476
|
+
for (int i = 0; i < 9; i++) {
|
|
477
|
+
mod += sin(time * harmonics[i] * 6.28318);
|
|
478
|
+
}
|
|
479
|
+
mod /= 9.0;
|
|
480
|
+
return _st + vec2(0.02 * sin(time * 3.0 + mod), 0.02 * cos(time * 3.0 + mod));
|
|
481
|
+
`,
|
|
482
|
+
});
|
|
483
|
+
setFunction({
|
|
484
|
+
name: "sine",
|
|
485
|
+
type: "src",
|
|
486
|
+
inputs: [
|
|
487
|
+
{ name: "frequency", type: "float", default: 2.0 },
|
|
488
|
+
{ name: "amplitude", type: "float", default: 0.5 },
|
|
489
|
+
],
|
|
490
|
+
glsl: `
|
|
491
|
+
float wave = amplitude * sin(_st.x * frequency * 6.28318 + time);
|
|
492
|
+
return vec4(vec3(0.5 + 0.5 * wave), 1.0);
|
|
493
|
+
`,
|
|
494
|
+
});
|
|
495
|
+
setFunction({
|
|
496
|
+
name: "saw",
|
|
497
|
+
type: "src",
|
|
498
|
+
inputs: [
|
|
499
|
+
{ name: "frequency", type: "float", default: 2.0 },
|
|
500
|
+
{ name: "amplitude", type: "float", default: 0.5 },
|
|
501
|
+
],
|
|
502
|
+
glsl: `
|
|
503
|
+
float wave = amplitude * (fract(_st.x * frequency + time) * 2.0 - 1.0);
|
|
504
|
+
return vec4(vec3(0.5 + 0.5 * wave), 1.0);
|
|
505
|
+
`,
|
|
506
|
+
});
|
|
507
|
+
setFunction({
|
|
508
|
+
name: "triangle",
|
|
509
|
+
type: "src",
|
|
510
|
+
inputs: [
|
|
511
|
+
{ name: "frequency", type: "float", default: 2.0 },
|
|
512
|
+
{ name: "amplitude", type: "float", default: 0.5 },
|
|
513
|
+
],
|
|
514
|
+
glsl: `
|
|
515
|
+
float wave = amplitude * abs(mod(_st.x * frequency + time, 2.0) - 1.0) * 2.0 - 1.0;
|
|
516
|
+
return vec4(vec3(0.5 + 0.5 * wave), 1.0);
|
|
517
|
+
`,
|
|
518
|
+
});
|
|
519
|
+
setFunction({
|
|
520
|
+
name: "pulse",
|
|
521
|
+
type: "src",
|
|
522
|
+
inputs: [
|
|
523
|
+
{ name: "frequency", type: "float", default: 2.0 },
|
|
524
|
+
{ name: "amplitude", type: "float", default: 0.5 },
|
|
525
|
+
],
|
|
526
|
+
glsl: `
|
|
527
|
+
float wave = amplitude * (mod(_st.x * frequency + time, 1.0) < 0.5 ? 1.0 : -1.0);
|
|
528
|
+
return vec4(vec3(0.5 + 0.5 * wave), 1.0);
|
|
529
|
+
`,
|
|
530
|
+
});
|
|
531
|
+
setFunction({
|
|
532
|
+
name: "square",
|
|
533
|
+
type: "src",
|
|
534
|
+
inputs: [
|
|
535
|
+
{ name: "frequency", type: "float", default: 2.0 },
|
|
536
|
+
{ name: "amplitude", type: "float", default: 0.5 },
|
|
537
|
+
],
|
|
538
|
+
glsl: `
|
|
539
|
+
float wave = amplitude * sign(sin(_st.x * frequency * 6.28318 + time));
|
|
540
|
+
return vec4(vec3(0.5 + 0.5 * wave), 1.0);
|
|
541
|
+
`,
|
|
542
|
+
});
|
|
543
|
+
setFunction({
|
|
544
|
+
name: "sand",
|
|
545
|
+
type: "src",
|
|
546
|
+
inputs: [{ name: "density", type: "float", default: 10.0 }],
|
|
547
|
+
glsl: `
|
|
548
|
+
float noise = fract(sin(dot(_st * density, vec2(12.9898, 78.233))) * 43758.5453);
|
|
549
|
+
return vec4(vec3(noise), 1.0);
|
|
550
|
+
`,
|
|
551
|
+
});
|
|
552
|
+
setFunction({
|
|
553
|
+
name: "chaos",
|
|
554
|
+
type: "src",
|
|
555
|
+
inputs: [
|
|
556
|
+
{
|
|
557
|
+
name: "branches",
|
|
558
|
+
type: "float",
|
|
559
|
+
default: 8.0,
|
|
560
|
+
},
|
|
561
|
+
],
|
|
562
|
+
glsl: `
|
|
563
|
+
vec2 uv = _st * 2.0 - 1.0;
|
|
564
|
+
float angle = atan(uv.y, uv.x);
|
|
565
|
+
float radius = length(uv);
|
|
566
|
+
float chaos = sin(angle * branches + sin(radius * 10.0 + cos(time)) * 3.0 - sin(time)) * 0.5 + 0.5;
|
|
567
|
+
vec3 color = vec3(chaos*cos(time), chaos * 0.7*sin(time), chaos * 0.4*time);
|
|
568
|
+
return vec4(color, 1.0);
|
|
569
|
+
`,
|
|
570
|
+
});
|
|
571
|
+
setFunction({
|
|
572
|
+
name: "lissajous",
|
|
573
|
+
type: "src",
|
|
574
|
+
inputs: [],
|
|
575
|
+
glsl: `float x = sin(time * 2.0) * 0.5 + 0.5; float y = cos(time * 3.0) * 0.5 + 0.5; return vec4(x, y, 1.0 - x * y, 1.0);`,
|
|
576
|
+
});
|
|
577
|
+
setFunction({
|
|
578
|
+
name: "laser",
|
|
579
|
+
type: "color",
|
|
580
|
+
inputs: [],
|
|
581
|
+
glsl: `vec3 laser = vec3(cos(time), sin(time), cos(time/10.0)) * sin(time * 10.0); return vec4(laser, 1.0);`,
|
|
582
|
+
});
|
|
583
|
+
setFunction({
|
|
584
|
+
name: "lissajouslaser",
|
|
585
|
+
type: "src",
|
|
586
|
+
inputs: [],
|
|
587
|
+
glsl: `
|
|
588
|
+
vec2 uv = _st * 2.0 - 1.0;
|
|
589
|
+
float lissajousX = sin(3.0 * uv.y + time * 1.5);
|
|
590
|
+
float lissajousY = cos(4.0 * uv.x + time * 1.2);
|
|
591
|
+
float beam = exp(-abs(lissajousX - lissajousY) * 10.0);
|
|
592
|
+
return vec4(vec3(beam, 0.0, 1.0), 1.0);
|
|
593
|
+
`,
|
|
594
|
+
});
|
|
595
|
+
setFunction({
|
|
596
|
+
name: "sphere",
|
|
597
|
+
type: "src",
|
|
598
|
+
inputs: [],
|
|
599
|
+
glsl: `
|
|
600
|
+
vec2 uv = (gl_FragCoord.xy / resolution.xy) * 2.0 - 1.0;
|
|
601
|
+
uv.x *= resolution.x / resolution.y;
|
|
602
|
+
float r = length(uv);
|
|
603
|
+
float mask = smoothstep(1.0, 0.98, r);
|
|
604
|
+
float clamped = clamp(r, 0.0, 1.0);
|
|
605
|
+
float z = sqrt(1.0 - clamped * clamped);
|
|
606
|
+
vec3 normal = normalize(vec3(uv, z));
|
|
607
|
+
vec3 light = normalize(vec3(0.5, 0.8, 1.0));
|
|
608
|
+
float diff = max(dot(normal, light), 0.0);
|
|
609
|
+
vec3 col = mix(vec3(0.1, 0.1, 0.1), vec3(1.0, 1.0, 1.0), diff);
|
|
610
|
+
return vec4(col * mask, 1.0);
|
|
611
|
+
`,
|
|
612
|
+
});
|
|
613
|
+
setFunction({
|
|
614
|
+
name: "flower",
|
|
615
|
+
type: "src",
|
|
616
|
+
inputs: [],
|
|
617
|
+
glsl: `
|
|
618
|
+
vec2 uv = (gl_FragCoord.xy / resolution.xy) * 2.0 - 1.0;
|
|
619
|
+
uv.x *= resolution.x / resolution.y;
|
|
620
|
+
float t = time;
|
|
621
|
+
float r = length(uv);
|
|
622
|
+
float angle = atan(uv.y, uv.x);
|
|
623
|
+
float burst = abs(sin(10.0 * angle + t * 5.0));
|
|
624
|
+
float intensity = smoothstep(0.2, 0.0, r) * burst;
|
|
625
|
+
vec3 col = vec3(sin(t * 3.0 + angle * 2.0) * 0.5 + 0.5, sin(t * 2.0 + angle * 3.0) * 0.5 + 0.5, sin(t + angle) * 0.5 + 0.5);
|
|
626
|
+
return vec4(col * intensity, 1.0);
|
|
627
|
+
`,
|
|
628
|
+
});
|
|
629
|
+
setFunction({
|
|
630
|
+
name: "oil",
|
|
631
|
+
type: "color",
|
|
632
|
+
inputs: [],
|
|
633
|
+
glsl: `
|
|
634
|
+
vec3 col = _c0.rgb;
|
|
635
|
+
float noise = fract(sin(dot(col, vec3(12.9898,78.233,37.719)))*43758.5453);
|
|
636
|
+
vec3 tone = pow(col, vec3(1.2));
|
|
637
|
+
vec3 result = mix(tone, tone * noise, 0.3);
|
|
638
|
+
return vec4(result, _c0.a);
|
|
639
|
+
`,
|
|
640
|
+
});
|
|
641
|
+
setFunction({
|
|
642
|
+
name: "watercolor",
|
|
643
|
+
type: "color",
|
|
644
|
+
inputs: [],
|
|
645
|
+
glsl: `
|
|
646
|
+
vec3 col = _c0.rgb;
|
|
647
|
+
float noise = fract(sin(dot(col, vec3(12.9898,78.233,37.719)))*43758.5453);
|
|
648
|
+
vec3 soft = smoothstep(0.0, 1.0, col);
|
|
649
|
+
vec3 result = mix(soft, mix(soft, vec3(1.0) - soft, noise * 0.2), 0.5);
|
|
650
|
+
return vec4(result, _c0.a);
|
|
651
|
+
`,
|
|
652
|
+
});
|
|
653
|
+
setFunction({
|
|
654
|
+
name: "ink",
|
|
655
|
+
type: "color",
|
|
656
|
+
inputs: [],
|
|
657
|
+
glsl: `
|
|
658
|
+
float gray = dot(_c0.rgb, vec3(0.299,0.587,0.114));
|
|
659
|
+
float noise = fract(sin(gray * 12.9898) * 43758.5453);
|
|
660
|
+
gray = smoothstep(0.3, 0.7, gray + noise * 0.2);
|
|
661
|
+
return vec4(vec3(gray), _c0.a);
|
|
662
|
+
`,
|
|
663
|
+
});
|
|
664
|
+
setFunction({
|
|
665
|
+
name: "parametriclaser",
|
|
666
|
+
type: "src",
|
|
667
|
+
inputs: [
|
|
668
|
+
{
|
|
669
|
+
name: "x",
|
|
670
|
+
type: "float",
|
|
671
|
+
default: "sqrt(0.5)*cos(time)",
|
|
672
|
+
},
|
|
673
|
+
{
|
|
674
|
+
name: "y",
|
|
675
|
+
type: "float",
|
|
676
|
+
default: "sqrt(0.5)*sin(time)",
|
|
677
|
+
},
|
|
678
|
+
{
|
|
679
|
+
name: "thinness",
|
|
680
|
+
type: "float",
|
|
681
|
+
default: 100.0,
|
|
682
|
+
},
|
|
683
|
+
{
|
|
684
|
+
name: "intensity",
|
|
685
|
+
type: "float",
|
|
686
|
+
default: 0.125,
|
|
687
|
+
},
|
|
688
|
+
{
|
|
689
|
+
name: "r",
|
|
690
|
+
type: "float",
|
|
691
|
+
default: 1.0,
|
|
692
|
+
},
|
|
693
|
+
{
|
|
694
|
+
name: "g",
|
|
695
|
+
type: "float",
|
|
696
|
+
default: 1.0,
|
|
697
|
+
},
|
|
698
|
+
{
|
|
699
|
+
name: "b",
|
|
700
|
+
type: "float",
|
|
701
|
+
default: 1.0,
|
|
702
|
+
},
|
|
703
|
+
],
|
|
704
|
+
glsl: `
|
|
705
|
+
vec2 uv = _st * 2.0 - 1.0;
|
|
706
|
+
float d = length(uv - vec2(x, y));
|
|
707
|
+
float beam = exp(-1.0 * thinness * d) * intensity;
|
|
708
|
+
vec3 color = vec3(beam * r, beam * g, beam * b);
|
|
709
|
+
return vec4(color, 1.0);
|
|
710
|
+
`,
|
|
711
|
+
});
|
|
712
|
+
function repeatoperator(operator, parameterFn, count, stream) {
|
|
713
|
+
for (let i = 0; i < count; i++) {
|
|
714
|
+
stream = stream[operator](parameterFn());
|
|
715
|
+
}
|
|
716
|
+
return stream;
|
|
717
|
+
}
|
|
718
|
+
function delay(wait, synth, ms, output) {
|
|
719
|
+
output = typeof output !== "undefined" ? output : o0;
|
|
720
|
+
const fallback = synth.inputs && synth.inputs[0] ? synth.inputs[0] : wait;
|
|
721
|
+
return {
|
|
722
|
+
out: function () {
|
|
723
|
+
setTimeout(() => {
|
|
724
|
+
synth.out(output);
|
|
725
|
+
}, ms);
|
|
726
|
+
return fallback.out(output);
|
|
727
|
+
},
|
|
728
|
+
};
|
|
729
|
+
}
|
|
730
|
+
setFunction({
|
|
731
|
+
name: "disassemble",
|
|
732
|
+
type: "color",
|
|
733
|
+
inputs: [
|
|
734
|
+
{
|
|
735
|
+
type: "float",
|
|
736
|
+
name: "depthFactor",
|
|
737
|
+
default: 0.5,
|
|
738
|
+
},
|
|
739
|
+
{
|
|
740
|
+
type: "float",
|
|
741
|
+
name: "timeSpeed",
|
|
742
|
+
default: 1.0,
|
|
743
|
+
},
|
|
744
|
+
],
|
|
745
|
+
glsl: `
|
|
746
|
+
vec2 uv = _st;
|
|
747
|
+
float depth = texture2D(_c0, uv).r;
|
|
748
|
+
float offset = sin(time * timeSpeed + depth * depthFactor) * 0.05;
|
|
749
|
+
uv.x += offset;
|
|
750
|
+
uv.y += offset;
|
|
751
|
+
vec4 color = texture2D(_c0, uv);
|
|
752
|
+
return color;
|
|
753
|
+
`,
|
|
754
|
+
});
|
|
755
|
+
setFunction({
|
|
756
|
+
name: "split",
|
|
757
|
+
type: "coord",
|
|
758
|
+
inputs: [
|
|
759
|
+
{
|
|
760
|
+
type: "float",
|
|
761
|
+
name: "splitIntensity",
|
|
762
|
+
default: 0.3,
|
|
763
|
+
},
|
|
764
|
+
{
|
|
765
|
+
type: "float",
|
|
766
|
+
name: "timeSpeed",
|
|
767
|
+
default: 1.0,
|
|
768
|
+
},
|
|
769
|
+
],
|
|
770
|
+
glsl: `
|
|
771
|
+
vec2 uv = _st;
|
|
772
|
+
float depth = texture2D(_c0, uv).r;
|
|
773
|
+
float angle = time * timeSpeed + depth * 3.1415;
|
|
774
|
+
float offsetX = cos(angle) * splitIntensity;
|
|
775
|
+
float offsetY = sin(angle) * splitIntensity;
|
|
776
|
+
if (mod(gl_FragCoord.y, 2.0) < 1.0) {
|
|
777
|
+
uv.x += offsetX;
|
|
778
|
+
} else {
|
|
779
|
+
uv.y += offsetY;
|
|
780
|
+
}
|
|
781
|
+
return uv;
|
|
782
|
+
`,
|
|
783
|
+
});
|
|
784
|
+
setFunction({
|
|
785
|
+
name: "painting",
|
|
786
|
+
type: "color",
|
|
787
|
+
inputs: [
|
|
788
|
+
{ type: "float", name: "romanesque_textureScale", default: 4.0 },
|
|
789
|
+
{ type: "float", name: "romanesque_darkness", default: 0.5 },
|
|
790
|
+
{ type: "float", name: "renaissance_shadowIntensity", default: 0.7 },
|
|
791
|
+
{ type: "float", name: "renaissance_lightDirectionX", default: 0.5 },
|
|
792
|
+
{ type: "float", name: "renaissance_lightDirectionY", default: 0.5 },
|
|
793
|
+
{ type: "float", name: "baroque_contrast", default: 1.5 },
|
|
794
|
+
{ type: "float", name: "baroque_spotlightX", default: 0.5 },
|
|
795
|
+
{ type: "float", name: "baroque_spotlightY", default: 0.5 },
|
|
796
|
+
{ type: "float", name: "romanticism_lightIntensity", default: 1.2 },
|
|
797
|
+
{ type: "float", name: "romanticism_saturation", default: 1.3 },
|
|
798
|
+
{ type: "float", name: "barbizon_warmth", default: 0.2 },
|
|
799
|
+
{ type: "float", name: "barbizon_softFocus", default: 0.1 },
|
|
800
|
+
{ type: "float", name: "metaphysical_shadowIntensity", default: 0.7 },
|
|
801
|
+
{ type: "float", name: "metaphysical_desaturation", default: 0.5 },
|
|
802
|
+
],
|
|
803
|
+
glsl: `
|
|
804
|
+
vec2 uv = gl_FragCoord.xy / resolution.xy * romanesque_textureScale;
|
|
805
|
+
float stonePattern = fract(sin(dot(uv, vec2(12.9898, 78.233))) * 43758.5453);
|
|
806
|
+
vec3 stoneColor = vec3(0.6, 0.5, 0.4) * (1.0 - romanesque_darkness * stonePattern);
|
|
807
|
+
vec4 res = vec4(stoneColor * _c0.rgb, _c0.a);
|
|
808
|
+
uv = gl_FragCoord.xy / resolution.xy;
|
|
809
|
+
vec2 lightDir = normalize(vec2(renaissance_lightDirectionX, renaissance_lightDirectionY));
|
|
810
|
+
float lighting = dot(uv, lightDir) * 0.5 + 0.5;
|
|
811
|
+
vec3 shadedColor = mix(res.rgb * renaissance_shadowIntensity, res.rgb, lighting);
|
|
812
|
+
res = vec4(shadedColor, res.a);
|
|
813
|
+
float dist = distance(uv, vec2(baroque_spotlightX, baroque_spotlightY));
|
|
814
|
+
float spotlight = smoothstep(0.5, 0.2, dist);
|
|
815
|
+
vec3 contrasted = (res.rgb - 0.5) * baroque_contrast + 0.5;
|
|
816
|
+
vec3 finalColor = mix(contrasted, res.rgb, spotlight);
|
|
817
|
+
res = vec4(finalColor, res.a);
|
|
818
|
+
vec3 color = res.rgb;
|
|
819
|
+
vec3 light = vec3(0.5, 0.5, 0.5) * romanticism_lightIntensity;
|
|
820
|
+
color = mix(color, light, 0.5);
|
|
821
|
+
float gray = dot(color, vec3(0.299, 0.587, 0.114));
|
|
822
|
+
color = mix(vec3(gray), color, romanticism_saturation);
|
|
823
|
+
res = vec4(color, res.a);
|
|
824
|
+
color = res.rgb + vec3(barbizon_warmth, barbizon_warmth * 0.5, 0.0);
|
|
825
|
+
color = mix(color, vec3(0.5), barbizon_softFocus);
|
|
826
|
+
res = vec4(color, res.a);
|
|
827
|
+
color = res.rgb;
|
|
828
|
+
float lum = dot(color, vec3(0.299, 0.587, 0.114));
|
|
829
|
+
if (lum < 0.5) { color *= metaphysical_shadowIntensity; }
|
|
830
|
+
color = mix(color, vec3(lum), metaphysical_desaturation);
|
|
831
|
+
res = vec4(color, res.a);
|
|
832
|
+
return res;
|
|
833
|
+
`,
|
|
834
|
+
});
|
|
835
|
+
setFunction({
|
|
836
|
+
name: "over",
|
|
837
|
+
type: "color",
|
|
838
|
+
inputs: [
|
|
839
|
+
{ type: "float", name: "noiseScale", default: 1.0 },
|
|
840
|
+
{ type: "float", name: "grainIntensity", default: 0.3 },
|
|
841
|
+
{ type: "float", name: "edgeStrength", default: 1.0 },
|
|
842
|
+
{ type: "float", name: "shade", default: 0.6 },
|
|
843
|
+
],
|
|
844
|
+
glsl: `
|
|
845
|
+
vec2 uv = gl_FragCoord.xy / resolution.xy;
|
|
846
|
+
vec3 col = _c0.rgb;
|
|
847
|
+
float lum = dot(col, vec3(0.299, 0.587, 0.114));
|
|
848
|
+
float dx = 1.0 / resolution.x;
|
|
849
|
+
float dy = 1.0 / resolution.y;
|
|
850
|
+
float lumLeft = dot(texture2D(tex0, uv + vec2(-dx, 0.0)).rgb, vec3(0.299, 0.587, 0.114));
|
|
851
|
+
float lumRight = dot(texture2D(tex0, uv + vec2(dx, 0.0)).rgb, vec3(0.299, 0.587, 0.114));
|
|
852
|
+
float lumUp = dot(texture2D(tex0, uv + vec2(0.0, dy)).rgb, vec3(0.299, 0.587, 0.114));
|
|
853
|
+
float lumDown = dot(texture2D(tex0, uv + vec2(0.0, -dy)).rgb, vec3(0.299, 0.587, 0.114));
|
|
854
|
+
float edge = abs(lumLeft - lumRight) + abs(lumUp - lumDown);
|
|
855
|
+
edge = clamp(edge * edgeStrength, 0.0, 1.0);
|
|
856
|
+
float noise = fract(sin(dot(uv * noiseScale + time, vec2(12.9898, 78.233))) * 43758.5453);
|
|
857
|
+
float grain = (noise - 0.5) * grainIntensity;
|
|
858
|
+
float finalLum = lum * (1.0 - edge) + grain;
|
|
859
|
+
finalLum = mix(finalLum, lum, shade);
|
|
860
|
+
return vec4(vec3(finalLum), _c0.a);
|
|
861
|
+
`,
|
|
862
|
+
});
|
|
863
|
+
setFunction({
|
|
864
|
+
name: "sketch",
|
|
865
|
+
type: "color",
|
|
866
|
+
inputs: [
|
|
867
|
+
{
|
|
868
|
+
type: "float",
|
|
869
|
+
name: "edgeStrength",
|
|
870
|
+
default: 1.0,
|
|
871
|
+
},
|
|
872
|
+
{
|
|
873
|
+
type: "float",
|
|
874
|
+
name: "noiseScale",
|
|
875
|
+
default: 1.0,
|
|
876
|
+
},
|
|
877
|
+
{
|
|
878
|
+
type: "float",
|
|
879
|
+
name: "noiseIntensity",
|
|
880
|
+
default: 0.5,
|
|
881
|
+
},
|
|
882
|
+
{
|
|
883
|
+
type: "float",
|
|
884
|
+
name: "paperTexture",
|
|
885
|
+
default: 0.3,
|
|
886
|
+
},
|
|
887
|
+
],
|
|
888
|
+
glsl: `
|
|
889
|
+
vec3 color = _c0.rgb;
|
|
890
|
+
float lum = dot(color, vec3(0.299, 0.587, 0.114));
|
|
891
|
+
float edge = smoothstep(0.2, 0.8, abs(lum - 0.5)) * edgeStrength;
|
|
892
|
+
vec2 uv = gl_FragCoord.xy / resolution.xy;
|
|
893
|
+
float noise = fract(sin(dot(uv * noiseScale + time, vec2(12.9898,78.233))) * 43758.5453);
|
|
894
|
+
float paper = fract(sin(dot(uv * 100.0, vec2(12.9898,78.233))) * 43758.5453);
|
|
895
|
+
vec3 sketch = mix(vec3(1.0 - edge), vec3(noise), noiseIntensity);
|
|
896
|
+
sketch = mix(sketch, vec3(paper), paperTexture);
|
|
897
|
+
return vec4(sketch, _c0.a);
|
|
898
|
+
`,
|
|
899
|
+
});
|
|
900
|
+
setFunction({
|
|
901
|
+
name: 'fractal',
|
|
902
|
+
type: 'src',
|
|
903
|
+
inputs: [{
|
|
904
|
+
type: 'float',
|
|
905
|
+
name: 'len',
|
|
906
|
+
default: 0.5
|
|
907
|
+
},
|
|
908
|
+
{
|
|
909
|
+
type: 'float',
|
|
910
|
+
name: 'lr',
|
|
911
|
+
default: 0.7
|
|
912
|
+
},
|
|
913
|
+
{
|
|
914
|
+
type: 'float',
|
|
915
|
+
name: 'rr',
|
|
916
|
+
default: 0.7
|
|
917
|
+
},
|
|
918
|
+
{
|
|
919
|
+
type: 'float',
|
|
920
|
+
name: 'th',
|
|
921
|
+
default: 0.5
|
|
922
|
+
},
|
|
923
|
+
{
|
|
924
|
+
type: 'float',
|
|
925
|
+
name: 'n',
|
|
926
|
+
default: 6
|
|
927
|
+
},
|
|
928
|
+
{
|
|
929
|
+
type: 'float',
|
|
930
|
+
name: 'k',
|
|
931
|
+
default: 10
|
|
932
|
+
},
|
|
933
|
+
],
|
|
934
|
+
glsl: `
|
|
935
|
+
vec2 uv = (gl_FragCoord.xy / resolution.xy) * 2.0 - 1.0;
|
|
936
|
+
uv.x *= resolution.x / resolution.y;
|
|
937
|
+
vec3 col = vec3(0.0);
|
|
938
|
+
for(int b = 0; b < 2; b++){
|
|
939
|
+
vec2 p = uv;
|
|
940
|
+
float sc = len;
|
|
941
|
+
float ag = (b == 0 ? th : -th) * sin(time);
|
|
942
|
+
float rat = (b == 0 ? lr : rr);
|
|
943
|
+
for(int i = 0; i < 1000000000; i++){
|
|
944
|
+
if(i >= int(n)) break;
|
|
945
|
+
float d = length(vec2(p.x, p.y - sc * 0.5)) - 0.01;
|
|
946
|
+
col += vec3(smoothstep(0.01, 0.0, d));
|
|
947
|
+
p = mat2(cos(ag), -sin(ag),
|
|
948
|
+
sin(ag), cos(ag))
|
|
949
|
+
* (p - vec2(0.0, sc));
|
|
950
|
+
sc *= rat;
|
|
951
|
+
ag *= 0.9;
|
|
952
|
+
}
|
|
953
|
+
}
|
|
954
|
+
return vec4(col, 1.0);
|
|
955
|
+
`
|
|
956
|
+
});
|