From 6c2544098bb609ff98f88ee0abf078db42ce6c79 Mon Sep 17 00:00:00 2001 From: Grant Sanderson Date: Wed, 18 Jan 2023 13:50:09 -0800 Subject: [PATCH] Store pixel_size instead of pixel_shape --- manimlib/camera/camera.py | 5 +++-- manimlib/shaders/quadratic_bezier_fill/geom.glsl | 4 ++-- manimlib/shaders/quadratic_bezier_stroke/geom.glsl | 4 ++-- manimlib/shaders/true_dot/geom.glsl | 4 ++-- 4 files changed, 9 insertions(+), 8 deletions(-) diff --git a/manimlib/camera/camera.py b/manimlib/camera/camera.py index bc91df93..5e94bbfb 100644 --- a/manimlib/camera/camera.py +++ b/manimlib/camera/camera.py @@ -497,10 +497,11 @@ class Camera(object): perspective_transform = frame.get_perspective_transform() light_pos = self.light_source.get_location() cam_pos = self.frame.get_implied_camera_location() + frame_shape = frame.get_shape() self.perspective_uniforms = { - "frame_shape": frame.get_shape(), - "pixel_shape": self.get_pixel_shape(), + "frame_shape": frame_shape, + "pixel_size": frame_shape[0] / self.get_pixel_shape()[0], "perspective": tuple(perspective_transform.T.flatten()), "camera_position": tuple(cam_pos), "light_position": tuple(light_pos), diff --git a/manimlib/shaders/quadratic_bezier_fill/geom.glsl b/manimlib/shaders/quadratic_bezier_fill/geom.glsl index 0d8d12f2..5f9f8ab6 100644 --- a/manimlib/shaders/quadratic_bezier_fill/geom.glsl +++ b/manimlib/shaders/quadratic_bezier_fill/geom.glsl @@ -4,7 +4,7 @@ layout (triangles) in; layout (triangle_strip, max_vertices = 5) out; uniform float anti_alias_width; -uniform vec2 pixel_shape; +uniform float pixel_size; in vec3 verts[3]; in float v_orientation[3]; @@ -63,7 +63,7 @@ void emit_pentagon( is_linear = float(angle < ANGLE_THRESHOLD); bool fill_inside = orientation > 0.0; - float aaw = anti_alias_width * frame_shape.y / pixel_shape.y; + float aaw = anti_alias_width * pixel_size; vec3 corners[5] = vec3[5](p0, p0, p1, p2, p2); if(fill_inside || bool(is_linear)){ diff --git a/manimlib/shaders/quadratic_bezier_stroke/geom.glsl b/manimlib/shaders/quadratic_bezier_stroke/geom.glsl index dae2d0d5..f19484cb 100644 --- a/manimlib/shaders/quadratic_bezier_stroke/geom.glsl +++ b/manimlib/shaders/quadratic_bezier_stroke/geom.glsl @@ -5,7 +5,7 @@ layout (triangle_strip, max_vertices = 6) out; uniform float anti_alias_width; uniform float flat_stroke; -uniform vec2 pixel_shape; +uniform float pixel_size; uniform float joint_type; in vec3 verts[3]; @@ -181,7 +181,7 @@ void main() { mat4 xyz_to_uv = get_xyz_to_uv(p0, p1, p2, is_linear, is_linear); float uv_scale_factor = length(xyz_to_uv[0].xyz); - float scaled_aaw = anti_alias_width * (frame_shape.y / pixel_shape.y); + float scaled_aaw = anti_alias_width * pixel_size; uv_anti_alias_width = uv_scale_factor * scaled_aaw; vec3 corners[6]; diff --git a/manimlib/shaders/true_dot/geom.glsl b/manimlib/shaders/true_dot/geom.glsl index 0ff8cca5..e0148dc3 100644 --- a/manimlib/shaders/true_dot/geom.glsl +++ b/manimlib/shaders/true_dot/geom.glsl @@ -4,7 +4,7 @@ layout (points) in; layout (triangle_strip, max_vertices = 4) out; uniform float anti_alias_width; -uniform vec2 pixel_shape; +uniform float pixel_size; uniform vec3 camera_position; in vec3 v_point[1]; @@ -24,7 +24,7 @@ void main() { radius = v_radius[0]; center = v_point[0].xy; - scaled_aaw = (frame_shape.y / pixel_shape.y); + scaled_aaw = anti_alias_width * pixel_size; radius = v_radius[0] / max(1.0 - v_point[0].z / focal_distance / frame_shape.y, 0.0); float rpa = radius + scaled_aaw;