bgfx/tools/texturev/fs_texture_sdf.sc
Бранимир Караџић 466c6a4e95 Happy New Year!
2023-01-14 10:05:12 -08:00

24 lines
581 B
Scala

$input v_texcoord0, v_color0
/*
* Copyright 2011-2023 Branimir Karadzic. All rights reserved.
* License: https://github.com/bkaradzic/bgfx/blob/master/LICENSE
*/
#include "common.sh"
SAMPLER2D(s_texColor, 0);
void main()
{
vec4 bgColor = vec4(0.0, 0.0, 0.0, 0.0);
vec4 fgColor = vec4(1.0, 1.0, 1.0, 1.0);
float sigDist = texture2DLod(s_texColor, v_texcoord0.xy, u_textureLod).x;
float width = fwidth(sigDist);
float edge = 0.5;
float opacity = clamp(smoothstep(edge - width, edge + width, sigDist), 0.0, 1.0);
gl_FragColor = mix(bgColor, fgColor, opacity);
}