bgfx/tools/texturev/fs_texture_sdf.sc

24 lines
582 B
Python
Raw Normal View History

$input v_texcoord0, v_color0
/*
2021-01-14 15:53:49 -08:00
* Copyright 2011-2021 Branimir Karadzic. All rights reserved.
2017-01-01 00:18:41 -08:00
* License: https://github.com/bkaradzic/bgfx#license-bsd-2-clause
*/
2017-10-25 16:17:54 -07:00
#include "common.sh"
SAMPLER2D(s_texColor, 0);
2017-11-29 16:53:39 -08:00
void main()
2017-07-09 11:47:13 -07:00
{
2017-11-29 16:53:39 -08:00
vec4 bgColor = vec4(0.0, 0.0, 0.0, 0.0);
vec4 fgColor = vec4(1.0, 1.0, 1.0, 1.0);
2017-11-29 16:53:39 -08:00
float sigDist = texture2DLod(s_texColor, v_texcoord0.xy, u_textureLod).x;
2018-11-01 18:07:17 -07:00
float width = fwidth(sigDist);
float edge = 0.5;
float opacity = clamp(smoothstep(edge - width, edge + width, sigDist), 0.0, 1.0);
2017-11-29 16:53:39 -08:00
gl_FragColor = mix(bgColor, fgColor, opacity);
}