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

20 lines
461 B
Text
Raw Normal View History

2020-02-03 10:52:39 -08:00
#version 330
2024-08-01 07:17:26 -05:00
// Value between -1 and 1
in float scaled_signed_dist_to_curve;
in float scaled_anti_alias_width;
in vec4 color;
2020-02-03 10:52:39 -08:00
out vec4 frag_color;
void main() {
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-08-01 07:17:26 -05:00
float signed_dist_to_region = abs(scaled_signed_dist_to_curve) - 1.0;
frag_color.a *= smoothstep(
scaled_anti_alias_width,
-scaled_anti_alias_width,
signed_dist_to_region
);
2020-02-03 10:52:39 -08:00
}