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

18 lines
485 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;
frag_color.a *= smoothstep(1.0, 0.0, signed_dist_to_region / uv_anti_alias_width);
frag_color.a += 0.2; // undo
2020-02-03 10:52:39 -08:00
}