thebookofshaders/07/circle-making.frag

32 lines
710 B
GLSL
Raw Normal View History

2015-03-15 15:35:14 +00:00
// Author @patriciogv - 2015
// http://patriciogonzalezvivo.com
2015-03-21 13:02:43 +00:00
2015-03-15 15:35:14 +00:00
#ifdef GL_ES
precision mediump float;
#endif
uniform vec2 u_resolution;
2015-04-02 17:43:22 +00:00
uniform vec2 u_mouse;
2015-03-15 15:35:14 +00:00
uniform float u_time;
void main(){
vec2 st = gl_FragCoord.xy/u_resolution;
float pct = 0.0;
2015-03-15 15:35:14 +00:00
2015-05-10 22:18:02 +00:00
// a. The DISTANCE from the pixel to the center
pct = distance(st,vec2(0.5));
2015-03-15 15:35:14 +00:00
2015-05-10 22:18:02 +00:00
// b. The LENGTH of the vector
// from the pixel to the center
2015-05-10 19:52:56 +00:00
// vec2 toCenter = vec2(0.5)-st;
// pct = length(toCenter);
2015-03-15 15:35:14 +00:00
2015-05-10 22:18:02 +00:00
// c. The SQUARE ROOT of the vector
// from the pixel to the center
2015-05-10 19:52:56 +00:00
// vec2 tC = vec2(0.5)-st;
// pct = sqrt(tC.x*tC.x+tC.y*tC.y);
2015-03-15 15:35:14 +00:00
vec3 color = vec3(pct);
gl_FragColor = vec4( color, 1.0 );
}