bgfx/tools/texturev/fs_texture_sdf.sc

21 lines
507 B
Python
Raw Normal View History

$input v_texcoord0, v_color0
/*
2017-01-01 11:18:41 +03:00
* Copyright 2011-2017 Branimir Karadzic. All rights reserved.
* License: https://github.com/bkaradzic/bgfx#license-bsd-2-clause
*/
2017-10-26 02:17:54 +03:00
#include "common.sh"
SAMPLER2D(s_texColor, 0);
2017-11-30 03:53:39 +03:00
void main()
2017-07-09 21:47:13 +03:00
{
2017-11-30 03:53:39 +03: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-30 03:53:39 +03:00
float sigDist = texture2DLod(s_texColor, v_texcoord0.xy, u_textureLod).x;
2017-07-09 21:47:13 +03:00
float opacity = clamp(sigDist/fwidth(sigDist) + 0.5, 0.0, 1.0);
2017-11-30 03:53:39 +03:00
gl_FragColor = mix(bgColor, fgColor, opacity);
}