2020-02-03 10:52:39 -08:00
|
|
|
#version 330
|
|
|
|
|
2024-07-31 15:51:06 -04:00
|
|
|
in float signed_dist_to_curve;
|
2020-02-03 10:52:39 -08:00
|
|
|
in float uv_stroke_width;
|
|
|
|
in float uv_anti_alias_width;
|
2023-01-09 16:46:38 -08:00
|
|
|
in vec4 color;
|
2020-02-03 10:52:39 -08:00
|
|
|
|
|
|
|
out vec4 frag_color;
|
|
|
|
|
|
|
|
void main() {
|
|
|
|
if (uv_stroke_width == 0) discard;
|
2023-01-20 13:22:18 -08:00
|
|
|
frag_color = color;
|
2023-01-08 23:33:39 -05:00
|
|
|
|
2023-01-18 13:07:18 -08:00
|
|
|
// sdf for the region around the curve we wish to color.
|
2024-07-31 15:51:06 -04:00
|
|
|
float signed_dist_to_region = abs(signed_dist_to_curve) - 0.5 * uv_stroke_width;
|
2024-07-31 16:27:37 -04:00
|
|
|
frag_color.a *= smoothstep(0.5, -0.5, signed_dist_to_region / uv_anti_alias_width);
|
2020-02-03 10:52:39 -08:00
|
|
|
}
|