#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));
}
void main() {
vec2 pos = gl_FragCoord.xy / uResolution.xy;
pos *= 2.0;
pos -= 1.0;
float shape = rect(pos, vec2(0.25, 0.25), 0.5, 0.5);
outColor.rgb = vec3(smoothedge(shape));
outColor.a = 1.0;
}