#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 mixUnion(float shape1, float shape2) {
return min(shape1, shape2);
}
float crossSymbol(vec2 xy, vec2 center, float size) {
float horizontal = rect(xy, center, size * 0.25, size);
float vertical = rect(xy, center, size, size * 0.25);
return mixUnion(horizontal, vertical);
}
void main() {
vec2 pos = (2.0 * gl_FragCoord.xy - uResolution.xy) / min(uResolution.x, uResolution.y);
float shape = crossSymbol(pos, vec2(0.0), 1.0);
outColor.rgb = vec3(smoothedge(shape));
outColor.a = 1.0;
}