-
Notifications
You must be signed in to change notification settings - Fork 0
/
11.glsl
246 lines (167 loc) · 4.09 KB
/
11.glsl
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
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
uniform float u_amp;
uniform float u_beat;
uniform float u_time;
uniform vec2 u_mouse;
uniform vec2 u_resolution;
#define M_PI 3.14159265358979323846
vec2 rotate(vec2 _in, float _angle){
return _in * mat2(cos(M_PI*_angle),-sin(M_PI*_angle),
sin(M_PI*_angle),cos(M_PI*_angle));
}
vec2 rotate2D (vec2 _st, float _angle) {
_st -= 0.5;
_st = mat2(cos(_angle),-sin(_angle),
sin(_angle),cos(_angle)) * _st;
_st += 0.5;
return _st;
}
vec2 tile (vec2 _st, float _zoom) {
_st *= _zoom;
return fract(_st);
}
vec2 rotateTilePattern(vec2 _st){
// Scale the coordinate system by 2x2
_st *= 2.0;
// Give each cell an index number
// according to its position
float index = 0.0;
index += step(1., mod(_st.x,2.0));
index += step(1., mod(_st.y,2.0))*2.0;
// |
// 2 | 3
// |
//--------------
// |
// 0 | 1
// |
// Make each cell between 0.0 - 1.0
_st = fract(_st);
// Rotate each cell according to the index
if(index == 1.0){
// Rotate cell 1 by 90 degrees
_st = rotate2D(_st,M_PI*0.5);
} else if(index == 2.0){
// Rotate cell 2 by -90 degrees
_st = rotate2D(_st,M_PI*-0.5);
} else if(index == 3.0){
// Rotate cell 3 by 180 degrees
_st = rotate2D(_st,M_PI);
}
return _st;
}
vec2 random2( vec2 p ) {
return fract(sin(vec2(dot(p,vec2(127.1,311.7)),dot(p,vec2(269.5,183.3))))*43758.5453);
}
void main() {
vec2 s = gl_FragCoord.xy/u_resolution.xy + vec2(-0.5);
vec2 o = s;
vec3 c = vec3(0.);
vec3 d = vec3(1.);
float p = u_beat;
float a = u_amp;
float t = u_time;
float spin_speed = 0.10;
float angle = 0.0;
float cscale = 1.0;
float tscale = 0.152;
float pscale = 0.3;
float ascale = 0.2;
t *= tscale;
p *= pscale;
a *= ascale;
// // TIME SLOW
// t *= 0.1648;
// spin_speed *= 0.2;
// cscale = 0.7;
// a *= 0.05;
// p = 0.;
// ANGLE
angle = t * spin_speed;
// // BEAT
// p *= 0.3;
// // AMP
// a *= 0.04;
// ROTATE BEFORE
s = rotate(s, angle);
// SYM X
if (s.x < 0.) {
s.x = abs(s.x);
}
// // SYM Y
// if (s.y < 0.) {
// s.y = abs(s.y);
// }
// s.x = s.x * -6.5;
// s.y = s.y * -6.5;
// s.x = s.x * 2.5;
// s.y = s.y * 2.5;
// SIMPLE TILE
// s = rotateTilePattern(s+a*.5);
// // ROTATE AFTER
s = rotate(s, angle);
// s = tile(s,3.0);
// s += p*0.4;
// s *= p*1.1;
// s *= 2.0;
vec2 r = s;
// pulse
// s.x = cos(abs(s.y-s.x)*sin(t)+p);
// s.y = abs(cos(s.x-s.y)*sin(t)+p);
// // zebra
s.x /= atan((s.x-s.y)*(sin(t*3.)+2.));
s.y /= cos((s.y-s.x)*(sin(t*2.)+2.));
s.x += atan((s.x-s.y)*(sin(t*4.)+2.));
s.y += cos((s.y-s.x)*(sin(t*5.)+2.));
// tv
// s.x /= cos(abs(r.x)*sin(t)+a*.01);
// s.y /= abs(cos(r.y)*sin(t)-a*.01);
s = tile(s,3.0);
// s.x = -s.x;
s = rotateTilePattern(s);
// s = rotateTilePattern(s);
c = vec3(0.0);
// Cell positions
vec2 point[5];
point[0] = vec2(-0.4,-0.4);
point[1] = vec2(-0.4,0.4);
point[2] = vec2(0.4,0.4);
point[3] = vec2(0.4,-0.4);
point[4] = vec2(sin(t)*.5,cos(t)*.5)*.4+a*.2;
float m_dist = 1.;
for (int i = 0; i < 4; i++) {
point[i] += tan(t*(2.1+float(i))) * .1;
point[i] -= cos(t*(2.1+float(i))) * .1;
}
for (int i = 0; i < 5; i++) {
float dist = distance(s, point[i]);
m_dist = min(m_dist, dist);
}
c += m_dist;
if (mod(t*0.5, 13.) > 4.) {
c -= step(.6+p,abs(sin(40.0*m_dist)))*.4*a;
} else {
c -= step(.6+p,abs(sin(40.0*m_dist)))*.7*a;
}
vec2 or = rotate(o, angle);
// CUTOUT
c += vec3(tan(r.x) - tan(r.y));
// COLORS
c.g /= sin(s.y+p);
c.b += or.x-or.y;
// c.r /= (cos(t)/sin(c.r))*p;
// c.b /= tan(sin(t)+p);
// MASKING
d = vec3(abs(sin(o.x+t) + cos(o.y+a)));
d = clamp(d,0.0,1.0);
// c /= d;
// c -= d * 0.5;
// red-pink override
c.r = c.g + sin(c.b);
// c.g = c.b - c.r;
c.r = clamp(c.r,0.0,1.0);
c.b = clamp(c.b,0.0,1.0);
c.g = clamp(c.g,0.0,1.0);
c = clamp(c,0.0,1.0);
c *= cscale;
gl_FragColor = vec4( c, 1.0 );
}