#version 330 core

precision highp float;

uniform sampler2D tex;
uniform float scale;

in struct
{
	vec4 color;
	vec2 texCoord;
}fInfo;

out vec4 fragColor;

const float smoothing = 1.0/32.0;

void main() {
	float distance = texture2D(tex, fInfo.texCoord).a;
	if (distance < 0.5) {
		fragColor = vec4(0);
		fragColor.a = smoothstep(0.3 - smoothing/scale, 0.3 + smoothing/scale, distance);
	} else {
		fragColor = fInfo.color;
		fragColor.a *= smoothstep(0.5 - smoothing/scale, 0.5 + smoothing/scale, distance);
	}
}