#version 300 es
precision highp float;
uniform vec2 uResolution;
out vec4 outColor;
float norm(float v, float min, float max) {
return (v - min) / (max - min);
}
float map(float v, float min1, float max1, float min2, float max2) {
return mix(min2, max2, norm(v, min1, max1));
}
float circleSdf(vec2 xy, vec2 center, float radius) {
vec2 fromCenter = xy - center;
return pow(dot(fromCenter, fromCenter), 0.5) - radius;
}
float circle(vec2 xy, vec2 center, float radius, float spread) {
float sdf = circleSdf(xy, center, radius);
return smoothstep(radius - radius * spread, radius + radius * spread, sdf);
}
void main() {
vec2 pos = (2.0 * gl_FragCoord.xy - uResolution.xy) / max(uResolution.x, uResolution.y);
float fromCenter = distance(pos, vec2(0.0));
float fromCenterMax = distance(vec2(1.0), vec2(0.0));
float maxRadius = 0.2;
float radius = map(fromCenter, 0.0, fromCenterMax, maxRadius, 0.0);
pos *= 10.0;
vec2 center = vec2(0.5, 0.5);
float pattern = 1.0 - circle(fract(pos + 0.5), center, radius, 0.1);
outColor.rgb = vec3(pattern);
outColor.a = 1.0;
}