From 7c4874bdad593b1ee39d62ce61c82891f92f9ef2 Mon Sep 17 00:00:00 2001 From: Grant Sanderson Date: Tue, 9 Jun 2020 17:12:52 -0700 Subject: [PATCH] Changed how focal_distance works --- manimlib/camera/camera.py | 2 +- manimlib/shaders/get_gl_Position.glsl | 18 ++++++++++-------- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/manimlib/camera/camera.py b/manimlib/camera/camera.py index cf7040b9..3d18716a 100644 --- a/manimlib/camera/camera.py +++ b/manimlib/camera/camera.py @@ -30,7 +30,7 @@ class CameraFrame(Mobject): "center_point": ORIGIN, # Theta, phi, gamma "euler_angles": [0, 0, 0], - "focal_distance": 5, + "focal_distance": 3, } def init_points(self): diff --git a/manimlib/shaders/get_gl_Position.glsl b/manimlib/shaders/get_gl_Position.glsl index a84c3951..bc7b405f 100644 --- a/manimlib/shaders/get_gl_Position.glsl +++ b/manimlib/shaders/get_gl_Position.glsl @@ -3,22 +3,24 @@ // uniform float focal_distance; // uniform float is_fixed_in_frame; -const vec2 DEFAULT_FRAME_SHAPE = vec2(8 * 16 / 9, 8); +const vec2 DEFAULT_FRAME_SHAPE = vec2(8.0 * 16.0 / 9.0, 8.0); vec4 get_gl_Position(vec3 point){ - vec4 result = vec4(point, 1); + vec4 result = vec4(point, 1.0); if(!bool(is_fixed_in_frame)){ - result.x *= 2 / frame_shape.x; - result.y *= 2 / frame_shape.y; + result.x *= 2.0 / frame_shape.x; + result.y *= 2.0 / frame_shape.y; + result.z *= 2.0 / frame_shape.y; // Should we give the frame a z shape? Does that make sense? result.z /= focal_distance; - result.xy /= max(1 - point.z, 0); - // Todo, does this discontinuity add weirdness? Theoretically, by this point, + result.xy /= max(1.0 - result.z, 0.0); + // Todo, does this discontinuity add weirdness? Theoretically, by this result, // the z-coordiante of gl_Position only matter for z-indexing. The reason // for thie line is to avoid agressive clipping of distant points. if(result.z < 0) result.z *= 0.1; } else{ - result.x *= 2 / DEFAULT_FRAME_SHAPE.x; - result.y *= 2 / DEFAULT_FRAME_SHAPE.y; + result.x *= 2.0 / DEFAULT_FRAME_SHAPE.x; + result.y *= 2.0 / DEFAULT_FRAME_SHAPE.y; } + result.z *= -1; return result; } \ No newline at end of file