#version 300 es precision mediump float; in vec2 vertTexCoord; in vec4 vertColor; uniform sampler2D sdfTexture; uniform float threshold; uniform float smoothRange; out vec4 fragColor; void main() { float smoothMin = threshold - smoothRange * 0.5; float smoothMax = smoothMin + smoothRange; float sdfSample = smoothstep(smoothMin, smoothMax, texture(sdfTexture, vertTexCoord).r); fragColor = vec4(min(1.0, sdfSample)) * vertColor; }