-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathLCH_VJ-hydra_webgl_audioreactive_saturn_with_p5.js
160 lines (160 loc) · 3.11 KB
/
LCH_VJ-hydra_webgl_audioreactive_saturn_with_p5.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
setFunction({
name: "mesh",
type: "src",
inputs: [
{
type: "float",
name: "scale",
default: 10,
},
{
type: "float",
name: "offset",
default: 0.1,
},
],
glsl: ` vec2 st = _st;
vec2 s_st=sin(st);
vec2 c_st=cos(st);
vec2 t_st=tan(st);
vec2 sc=sin(c_st);
vec2 cs=cos(s_st);
float p = 0.01;
float xsin=sin(st.x);
float xcos=cos(st.x);
float ysin=sin(st.y);
float ycos=cos(st.y);
return vec4(vec3(_noise(vec3(sin(st*scale+c_st*t_st+p*cs*xsin/ycos), cos(time/offset*st+s_st/t_st-p*sc/ysin*xcos)))), 1.0);`,
});
setFunction({
name: "swing",
type: "coord",
inputs: [
{
type: "float",
name: "angle",
default: 10,
},
{
type: "float",
name: "speed",
default: 0,
},
{
type: "float",
name: "amount",
default: 1.5,
},
{
type: "float",
name: "xMult",
default: 1,
},
{
type: "float",
name: "yMult",
default: 1,
},
{
type: "float",
name: "offsetX",
default: 0.5,
},
{
type: "float",
name: "offsetY",
default: 0.5,
},
],
glsl: ` vec2 xy = _st - vec2(0.5)- vec2(offsetX, offsetY);
float ang = angle + log(tan(speed)) *sin(cos(time));
xy = mat2(cos(ang),-sin(ang), sin(ang),cos(ang))*xy;
xy += 0.5;
xy*=(1.0/vec2(cos(amount)*asin(xMult), sin(amount)*acos(yMult)));
xy+=vec2(offsetX, offsetY);
return xy;`,
});
p5 = new P5({ mode: "WEBGL" });
p5.hide();
s0.init({ src: p5.canvas });
p5.draw = () => {
p5.background(0, 0, 0, 0);
p5.rotateX(time);
p5.rotateY(time);
p5.rotateZ(time);
p5.push();
p5.noStroke();
p5.torus(50, 25);
p5.erase();
p5.sphere(50);
p5.noErase();
p5.pop();
};
sat = () => src(s0).diff(src(s0).scale(0.9));
osc(1, 2, 300)
.diff(
mesh(5, 100).swing(
[0, -0.1].smooth(),
-100,
[7 / 16, 9 / 16]
.ease("easeInOutQuart")
.fit(4)
.offset(1 / 4)
.fast(1 / 4),
0.5,
0.5,
[7 / 16, 9 / 16]
.reverse()
.ease("easeInOutQuart")
.fit(1 / 4)
.offset(4)
.fast(1 / 4),
[7 / 16, 9 / 16]
.reverse()
.ease("easeInOutQuart")
.fit(1 / 4)
.offset(4)
.fast(1 / 4)
)
)
.modulateKaleid(
src(o0)
.swing(
[0, 0.1].reverse().smooth(),
-100,
[7 / 16, 9 / 16]
.reverse()
.ease("easeInOutQuart")
.fit(4)
.offset(1 / 4)
.fast(1 / 4),
0.5,
0.5,
[7 / 16, 9 / 16]
.ease("easeInOutQuart")
.fit(1 / 4)
.offset(4)
.fast(1 / 4),
[7 / 16, 9 / 16]
.ease("easeInOutQuart")
.fit(1 / 4)
.offset(4)
.fast(1 / 4)
)
.thresh(),
() => a.fft[0] * 2 + 4,
(speed = 1 / 4),
(fps = 8),
(bpm = 45)
)
.modulate(
sat()
.scale(() => a.fft[0] + 1)
.add(sat().scale(() => a.fft[1] + 1.5))
.add(sat().scale(() => a.fft[2] + 2))
.add(sat().scale(() => a.fft[3] + 2.5))
.thresh()
)
.luma(0.9, -0.6, 0.2)
.out();
//hush()