manim icon indicating copy to clipboard operation
manim copied to clipboard

Orientation of line differs between cairo and opengl render

Open henrikmidtiby opened this issue 5 months ago • 2 comments

Description of bug / unexpected behavior

When I render a scene with the Line3D object, the orientation of the line differs between the Cairo and OpenGL based render.

Expected behavior

I would expect to see the same from both renderers.

How to reproduce the issue

Code for reproducing the problem

from manim import *

RENDERER_TYPE: RendererType = RendererType.CAIRO
# RENDERER_TYPE: RendererType = RendererType.OPENGL

class LineIn3DExample(ThreeDScene):
    def construct(self):
        renderer_str = f"renderer: {config.renderer.value}"
        renderer_text = Text(renderer_str, font_size=24)
        self.add_fixed_in_frame_mobjects(renderer_text)
        renderer_text.to_corner(UL)

        self.set_camera_orientation(phi=-15 * DEGREES, theta=-90 * DEGREES, gamma=0 * DEGREES)


        line: Line3D = Line3D(LEFT, RIGHT)
        # With the cairo render the line is horisontal.
        # With the opengl render the line is vertical.
        self.add(line)


# For running the scene directly
if __name__ == "__main__":
    print(RENDERER_TYPE)
    with tempconfig({
        "renderer": RENDERER_TYPE
    }):
        scene = LineIn3DExample()
        scene.render()

Additional media files

Images/GIFs Image Image

Additional comments

The issue was found while debugging this issue https://github.com/ManimCommunity/manim/issues/4337

henrikmidtiby avatar Jul 21 '25 13:07 henrikmidtiby

If the call to self.set_camera_orientation is removed, the two output match each other.

henrikmidtiby avatar Jul 21 '25 13:07 henrikmidtiby

If the call to self.set_camera_orientation is removed, the two output match each other.

actually the lines have the same direction, which you could check if you e.g. add a ThreeDAxes() object to your scene, but the Cairo renderer and the opengl renderer have different definitions for their camera angles.

uwezi avatar Jul 21 '25 18:07 uwezi