From a429a146c723493291633d1b3eadca94cbe9c4d7 Mon Sep 17 00:00:00 2001 From: Grant Sanderson Date: Sat, 9 Jan 2021 10:30:11 -0800 Subject: [PATCH] Fix how stroke is scaled for perspective --- manimlib/shaders/quadratic_bezier_stroke/geom.glsl | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/manimlib/shaders/quadratic_bezier_stroke/geom.glsl b/manimlib/shaders/quadratic_bezier_stroke/geom.glsl index 91c74e54..0c768be4 100644 --- a/manimlib/shaders/quadratic_bezier_stroke/geom.glsl +++ b/manimlib/shaders/quadratic_bezier_stroke/geom.glsl @@ -216,7 +216,8 @@ void main() { for(int i = 0; i < 3; i++){ float sf = perspective_scale_factor(controls[i].z, focal_distance); if(bool(flat_stroke)){ - sf *= abs(dot(v_global_unit_normal[i], vec3(0.0, 0.0, 1.0))); + vec3 to_cam = normalize(vec3(0.0, 0.0, focal_distance) - controls[i]); + sf *= abs(dot(v_global_unit_normal[i], to_cam)); } scaled_strokes[i] = v_stroke_width[i] * sf; }