uniform sampler2D tex; uniform float smoothness; void main() { const vec2 pix_sz = vec2(1.0 / 512.0, 1.0 / 256.0); // TODO: uniform vec2 uv = gl_TexCoord[0].st; float dist = texture2D(tex, uv).a; float dfdu = texture2D(tex, uv + vec2(pix_sz.x, 0.0)).a - dist; float dfdv = texture2D(tex, uv + vec2(0.0, pix_sz.y)).a - dist; vec2 grad = normalize(vec2(dfdu, dfdv)); float glyph = smoothstep(0.47 - smoothness, 0.47 + smoothness, dist); float outline = smoothstep(0.54 - smoothness, 0.54 + smoothness, dist); float beveldot = max(dot(grad, normalize(vec2(1.0, 1.0))), 0.0); vec3 bevelcol = mix(vec3(0.05, 0.1, 0.6), vec3(1.0, 0.2, 0.8), beveldot); gl_FragColor.rgb = mix(bevelcol, vec3(1.0), outline); gl_FragColor.a = glyph; }