#version 300 es
precision highp float;
uniform vec2 uResolution;
out vec4 outColor;
float smoothedge(float shape) {
return smoothstep(0.0, 1.0 / uResolution.x, shape);
}
float rect(vec2 xy, vec2 center, float width, float height) {
vec2 p = abs(xy - center);
vec2 v = vec2(width, height) * 0.5;
vec2 d = p - v;
return length(max(d, 0.0));
}
float roundRect(vec2 xy, vec2 center, float width, float height, float radius) {
vec2 p = abs(xy - center);
vec2 v = vec2(width, height) * 0.5 - radius;
vec2 d = p - v;
return length(max(d, 0.0)) - radius;
}
void main() {
vec2 pos = gl_FragCoord.xy / uResolution.xy;
pos *= 2.0;
pos -= 1.0;
float shape1 = roundRect(pos, vec2(0.0, 0.5), 0.5, 0.5, 0.05);
float shape2 = rect(pos, vec2(0.0, -0.5), 0.5, 0.5);
outColor.rgb = vec3(smoothedge(min(shape1, shape2)));
outColor.a = 1.0;
}