-
Notifications
You must be signed in to change notification settings - Fork 3
/
47.frag
34 lines (32 loc) · 1.15 KB
/
47.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
uniform float time;
uniform vec2 resolution;
out vec4 fragColor;
vec4 mod289(vec4 x){return x - floor(x * (1.0 / 289.0)) * 289.0;}
vec4 perm(vec4 x){return mod289(((x * 34.0) + 1.0) * x);}
float noise(vec3 p){
vec3 a = floor(p);
vec3 d = p - a;
d = d * d * (3.0 - 2.0 * d);
vec4 b = a.xxyy + vec4(0.0, 1.0, 0.0, 1.0);
vec4 k1 = perm(b.xyxy);
vec4 k2 = perm(k1.xyxy + b.zzww);
vec4 c = k2 + a.zzzz;
vec4 k3 = perm(c);
vec4 k4 = perm(c + 1.0);
vec4 o1 = fract(k3 * (1.0 / 41.0));
vec4 o2 = fract(k4 * (1.0 / 41.0));
vec4 o3 = o2 * d.z + o1 * (1.0 - d.z);
vec2 o4 = o3.yw * d.x + o3.xz * (1.0 - d.x);
return o4.y * d.y + o4.x * (1.0 - d.y);
}
void main(void) {
vec2 st = gl_FragCoord.xy / resolution.xy;
vec2 pos = vec2(st) * vec2(100.0, 4.0);
float speed = 100.0;
float brightness = 1.2;
float r = noise(vec3(pos.x, pos.y, time * speed)) * brightness;
float g = noise(vec3(pos.x, pos.y + 0.2, time * speed + 200.0)) * brightness;
float b = noise(vec3(pos.x, pos.y + 0.4, time * speed + 800.0)) * brightness;
vec4 color = vec4(vec3(r, g, b), 1.0);
fragColor = TDOutputSwizzle(color);
}