ManimCommunity / ManimCommunity/manim

Transparent background impossible with OpenGL renderer

Open
#4,079 0 comments 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
40.9k
Forks
3.1k
Avg merge
3d 12h
Merged PRs (30d)
25

Description

## Description of bug / unexpected behavior
When you try to export a video with the `--transparent` flag and the `opengl` renderer, the output video doesn't have any alpha channel.

## Expected behavior
Rendered video should have transparency (alpha channel).

## How to reproduce the issue
Use a `ThreeDScene` or `Scene` (the problem is the renderer, not the scene) with some `OpenGLRectangle` (or `OpenGLMobject` you want), set the `self.camera.background_opacity = 0` and use the `--renderer opengl` and the `-t` tags/flags.

## Additional comments
If you check the `opengl_renderer.py` file, that is the specific renderer that takes part when you send that flag, you can see in the line 596 that the background color is forced to have `1.0` as alpha background. This means that the background will never be transparent. That alpha value should check if the flag `--transparent` is set as `True`, as the `cairo_renderer.py` does, or at least allow you changing that value.

Even in the `update_frame` method of that file, if you manually force the `background_color` to be (0, 0, 0, 0) as a numpy array, it is set as `1.0` for the alpha as the setter is forcing it.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in opengl_renderer.py at the background-color handling around line 596 and inspect update_frame, then compare the transparent-background behavior in cairo_renderer.py. Trace how the --transparent or -t flag reaches the OpenGL renderer and verify that exporting a Scene or ThreeDScene with background_opacity set to 0 preserves an alpha channel.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
computer-graphics
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
56/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.