thebookofshaders/09/grid-making.frag

31 lines
658 B
GLSL
Raw Normal View History

2015-03-15 15:35:14 +00:00
// Author @patriciogv - 2015
2015-06-20 12:39:58 +00:00
2015-03-15 15:35:14 +00:00
#ifdef GL_ES
precision mediump float;
#endif
uniform vec2 u_resolution;
uniform float u_time;
float circle(in vec2 _st, in float _radius){
vec2 l = _st-vec2(0.5);
return 1.-smoothstep(_radius-(_radius*0.01),
_radius+(_radius*0.01),
dot(l,l)*4.0);
}
void main() {
vec2 st = gl_FragCoord.xy/u_resolution;
vec3 color = vec3(0.0);
2015-06-20 12:39:58 +00:00
st *= 3.0; // Scale up the space by 3
st = fract(st); // Wrap arround 1.0
// Now we have 3 spaces that goes from 0-1
2015-03-15 15:35:14 +00:00
color = vec3(st,0.0);
//color = vec3(circle(st,0.5));
2017-08-19 10:11:58 +00:00
2015-03-15 15:35:14 +00:00
gl_FragColor = vec4(color,1.0);
}