diff --git a/manimlib/shaders/point_to_gl_position.glsl b/manimlib/shaders/point_to_gl_position.glsl new file mode 100644 index 00000000..1cbdaa15 --- /dev/null +++ b/manimlib/shaders/point_to_gl_position.glsl @@ -0,0 +1,11 @@ +// Assumes theese uniforms exist in the surrounding context +// uniform float scale; +// uniform float aspect_ratio; +// uniform float frame_center; + +vec4 point_to_gl_Position(vec3 p){ + vec3 result = p / scale; + result.x /= aspect_ratio; + result -= frame_center; + gl_Position = vec4(result, 1.0); +} \ No newline at end of file diff --git a/manimlib/shaders/quadratic_bezier_fill_geom.glsl b/manimlib/shaders/quadratic_bezier_fill_geom.glsl index a8b5f82e..5708f1a4 100644 --- a/manimlib/shaders/quadratic_bezier_fill_geom.glsl +++ b/manimlib/shaders/quadratic_bezier_fill_geom.glsl @@ -36,6 +36,7 @@ const float SQRT5 = 2.236068; // so to share functionality between this and others, the caller // replaces this line with the contents of named file #INSERT quadratic_bezier_geometry_functions.glsl +#INSERT set_gl_Position.glsl mat3 get_xy_to_wz(vec2 b0, vec2 b1, vec2 b2){ @@ -60,18 +61,11 @@ mat3 get_xy_to_wz(vec2 b0, vec2 b1, vec2 b2){ return transform * shift; } -void set_gl_Position(vec2 p){ - vec2 result = p / scale; - result.x /= aspect_ratio; - result -= frame_center.xy; - gl_Position = vec4(result, 0.0, 1.0); -} - void emit_simple_triangle(){ for(int i = 0; i < 3; i++){ color = v_color[i]; - set_gl_Position(bp[i]); + set_gl_Position(vec3(bp[i], 0)); EmitVertex(); } EndPrimitive(); @@ -129,7 +123,7 @@ void emit_pentagon(vec2 bp0, vec2 bp1, vec2 bp2, float orientation){ if(i < 2) color = v_color[0]; else if(i == 2) color = v_color[1]; else color = v_color[2]; - set_gl_Position(corner); + set_gl_Position(vec3(corner, 0)); EmitVertex(); } EndPrimitive(); diff --git a/manimlib/shaders/quadratic_bezier_stroke_geom.glsl b/manimlib/shaders/quadratic_bezier_stroke_geom.glsl index 2486ad33..4802c9be 100644 --- a/manimlib/shaders/quadratic_bezier_stroke_geom.glsl +++ b/manimlib/shaders/quadratic_bezier_stroke_geom.glsl @@ -43,6 +43,7 @@ const float MITER_JOINT = 3; // so to share functionality between this and others, the caller // replaces this line with the contents of named file #INSERT quadratic_bezier_geometry_functions.glsl +#INSERT set_gl_Position.glsl float angle_between_vectors(vec2 v1, vec2 v2){ @@ -264,14 +265,6 @@ void set_previous_and_next(vec2 controls[3], int degree){ } -void set_gl_Position(vec2 p){ - vec2 result = p / scale; - result.x /= aspect_ratio; - result -= frame_center.xy; - gl_Position = vec4(result, 0.0, 1.0); -} - - void main() { vec2 controls[3]; int degree = get_reduced_control_points(bp[0], bp[1], bp[2], controls); @@ -311,7 +304,7 @@ void main() { uv_stroke_width = stroke_widths[i] / scale_factor; color = stroke_colors[i]; - set_gl_Position(corner); + set_gl_Position(vec3(corner, 0)); EmitVertex(); } EndPrimitive(); diff --git a/manimlib/shaders/set_gl_Position.glsl b/manimlib/shaders/set_gl_Position.glsl new file mode 100644 index 00000000..e83900d6 --- /dev/null +++ b/manimlib/shaders/set_gl_Position.glsl @@ -0,0 +1,12 @@ +// Assumes theese uniforms exist in the surrounding context +// uniform float scale; +// uniform float aspect_ratio; +// uniform float frame_center; + +void set_gl_Position(vec3 point){ + // TODO, orient in 3d based on certain rotation matrices + point /= scale; + point.x /= aspect_ratio; + point -= frame_center; + gl_Position = vec4(point, 1.0); +} \ No newline at end of file