-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathconcentricCircles_animated_2.frag
51 lines (37 loc) · 1.39 KB
/
concentricCircles_animated_2.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
// 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*2.0)-0.5;
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 =
min(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)));
float cScale = 1.0;
vec3 color = vec3(pct*stime*cScale,pct*sqrt(ctime*stime)*cScale,pct*ctime*cScale);
gl_FragColor = vec4( color*4.0, 1.0 );
}