forked from githole/Live-Coder
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscene2.glsl
37 lines (29 loc) · 847 Bytes
/
scene2.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
//
// Mandelbrot
uniform float lowFreq;
uniform vec2 resolution;
uniform float time;
float mandel(vec2 pos) {
vec2 z = vec2(0.0, 0.0);
const int limit = 16;
int count;
for (count = 0; count < limit; count ++) {
if (length(z) > 2.0 * lowFreq * 10.0)
break;
z = vec2(z.x * z.x - z.y * z.y, 2.0 * z.x * z.y) + pos;
}
return float(count) / float(limit);
}
void main() {
vec2 z = vec2(0.0, 0.0);
vec2 pos = vec2(-(1.0 - gl_FragCoord.x / resolution.x) / 0.5,
-(0.5 - gl_FragCoord.y / resolution.y) / 0.75);
float r = mandel(pos);
for (int i = 0; i < 8; i ++) {
float a = sin(time / 0.1) * lowFreq * lowFreq;
vec2 p = pos + a * vec2(sin(float(i) / 8.0 * 6.29), cos(float(i) / 8.0 * 6.28));
r += mandel(p);
}
r /= 8.0;
gl_FragColor = vec4(r, r/2.5, r/8.0, 1.0);
}