3b1b-manim/manimlib/shaders/quadratic_bezier_stroke/frag.glsl

17 lines
452 B
Text
Raw Normal View History

2020-02-03 10:52:39 -08:00
#version 330
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;
in vec4 color;
2020-02-03 10:52:39 -08:00
out vec4 frag_color;
void main() {
if (uv_stroke_width == 0) discard;
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.
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
}