-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathconcentricCircles_animated.frag
48 lines (36 loc) · 1.33 KB
/
concentricCircles_animated.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
// Author @patriciogv - 2015
// http://patriciogonzalezvivo.com
#ifdef GL_ES
precision mediump float;
#endif
uniform vec2 u_resolution;
uniform vec2 u_mouse;
uniform float u_time;
float concentricCircles(in vec2 st, in vec2 radius, in float resolution, in float scale) {
float dist = distance(st,radius);
float pct = floor(dist*resolution)/scale;
return pct;
}
void main(){
vec2 st = gl_FragCoord.xy/u_resolution;
float pct = 0.0;
float stime = abs(sin(u_time));
float ctime = abs(cos(u_time));
// a. The DISTANCE from the pixel to the center
pct =
concentricCircles(st,vec2(0.2,0.5), 10.0, 30.0*stime) + concentricCircles(st,vec2(0.8,0.5), 10.0, 30.0*ctime);
// b. The LENGTH of the vector
// from the pixel to the center
// vec2 toCenter = vec2(0.5)-st;
// pct = length(toCenter);
// c. The SQUARE ROOT of the vector
// from the pixel to the center
// vec2 tC = vec2(0.5)-st;
// pct = sqrt(tC.x*tC.x+tC.y*tC.y);
// pct = distance(st,vec2(0.4)) * distance(st,vec2(0.6));
// pct = min(distance(st,vec2(0.4)),distance(st,vec2(0.6)));
// pct = max(distance(st,vec2(0.4)),distance(st,vec2(0.6)));
// pct = pow(distance(st,vec2(0.4)),distance(st,vec2(0.6)));
vec3 color = vec3(pct*stime,pct*sqrt(ctime*stime),pct*ctime);
gl_FragColor = vec4( color, 1.0 );
}