-
Notifications
You must be signed in to change notification settings - Fork 3
/
13.frag
47 lines (43 loc) · 1.24 KB
/
13.frag
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
uniform float time;
uniform vec2 resolution;
out vec4 fragColor;
float random(in vec2 st) {
return fract(sin(dot(st.xy, vec2(12.9898, 78.233))) *
43758.5453123);
}
float noise(in vec2 st) {
vec2 i = floor(st);
vec2 f = fract(st);
// Four corners in 2D of a tile
float a = random(i);
float b = random(i + vec2(1.0, 0.0));
float c = random(i + vec2(0.0, 1.0));
float d = random(i + vec2(1.0, 1.0));
vec2 u = f * f * (3.0 - 2.0 * f);
return mix(a, b, u.x) +
(c - a) * u.y * (1.0 - u.x) +
(d - b) * u.x * u.y;
}
#define OCTAVES 4
float fbm(in vec2 st) {
float value = 0.0;
float amplitude = .5;
float frequency = 0.;
for (int i = 0 ; i < OCTAVES ; i ++) {
value += amplitude * noise(st);
st *= 2.;
amplitude *= .5;
}
return value;
}
void main() {
vec2 st = gl_FragCoord.xy / resolution.xy;
st.x *= resolution.x / resolution.y;
vec3 color = vec3(0.0);
color += fbm(st * 18.3 + vec2(time * 7.1, time * 10.3));
color *= fbm(st * 12.2 + vec2(time * 5.2, time * 10.2));
color *= fbm(st * 10.2 + vec2(time * 3.3, time * 10.1));
color = mod(color * 12.0, 1.0);
vec4 fcolor = vec4(color, 1.0);
fragColor = TDOutputSwizzle(fcolor);
}