#version 300 es
precision highp float;
uniform vec2 uResolution;
uniform vec2 uMouse;
out vec4 outColor;
float circleSdf(vec2 xy, vec2 center, float radius) {
vec2 fromCenter = xy - center;
return pow(dot(fromCenter, fromCenter), 0.5) - radius;
}
vec4 circle(vec2 xy, vec2 center, float radius, float spread, vec4 color) {
float sdf = circleSdf(xy, center, radius);
float shape = smoothstep(radius - radius * spread, radius + radius * spread, sdf);
return mix(color, vec4(1.0, 0.0, 0.0, 0.0), shape);
}
void main() {
vec2 pos = gl_FragCoord.xy / min(uResolution.x, uResolution.y);
pos *= 2.0;
pos -= 1.0;
vec2 mouse = uMouse.xy / min(uResolution.x, uResolution.y);
mouse *= 2.0;
mouse -= 1.0;
mouse.y *= -1.0;
vec4 shapeColor = vec4(1.0, 0.0, 1.0, 0.5);
outColor = circle(pos, mouse, 0.1, 0.005, shapeColor);
}