-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathNoise3e.frag
70 lines (53 loc) · 1.69 KB
/
Noise3e.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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
#ifdef GL_ES
precision highp float;
#endif
uniform vec2 u_resolution;
uniform vec2 u_mouse;
uniform float u_time;
//---------------------------------------------------------------------
#define seed 43758.5453123
vec2 random2(vec2 st) {
st = vec2(dot(st, vec2(127.1, 311.7)),
dot(st, vec2(269.5, 183.3)));
return -1.0 + 2.0 * fract(sin(st) * seed);
}
// Gradient Noise by Inigo Quilez - iq/2013
// https://www.shadertoy.com/view/XdXGW8
float noise(vec2 st) {
vec2 i = floor(st);
vec2 f = fract(st);
vec2 u = f * f * (3.0 - 2.0 * f);
return mix( mix( dot( random2(i + vec2(0.0, 0.0) ), f - vec2(0.0, 0.0) ),
dot( random2(i + vec2(1.0, 0.0) ), f - vec2(1.0, 0.0) ), u.x),
mix( dot( random2(i + vec2(0.0, 1.0) ), f - vec2(0.0, 1.0) ),
dot( random2(i + vec2(1.0, 1.0) ), f - vec2(1.0, 1.0) ), u.x), u.y);
}
float circle(in vec2 _st, in float _radius) {
vec2 dist = _st - vec2(0.5);
return 1. - smoothstep(_radius - (_radius * 0.01),
_radius + (_radius * 0.01),
dot(dist, dist) * 4.0);
}
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 noiseTranslate(in vec2 _st) {
vec2 translate = vec2(noise(_st));
return _st + rotate2D(translate, abs(u_time));
}
//---------------------------------------------------------------------
void main() {
vec2 st = gl_FragCoord.xy / u_resolution.xy;
st *= 10.0;
st -= 7.5;
vec3 color = vec3(.0, .7, .7);
st += noiseTranslate(st);
for(int i = 0; i <= 10; i++) {
color += circle(st + vec2(float(i)), 1.);
}
gl_FragColor = vec4(color, 1.0);
}