#version 300 es precision highp float; in vec2 vTexCoord; in vec4 vColor; uniform sampler2D uTexture; uniform int uUseSDF; out vec4 fragColor; void main() { if (uUseSDF == 1) { float dist = texture(uTexture, vTexCoord).a; float sd = (dist - 0.502) * 3.98; float w = fwidth(sd); float alpha = smoothstep(-w, w, sd); fragColor = vec4(vColor.rgb, vColor.a * alpha); } else { fragColor = texture(uTexture, vTexCoord) * vColor; } }