ManimCommunity / manim

A community-maintained Python framework for creating mathematical animations.
https://www.manim.community
MIT License
25.26k stars 1.76k forks source link

Strokes are not rendered in some installations of Manim using OpenGL renderer #1240

Open Darylgolden opened 3 years ago

Darylgolden commented 3 years ago

Description of bug / unexpected behavior

from manim import *
from manim.opengl import *

class Test(Scene):
    def construct(self):
        circle = OpenGLCircle()
        circle.set_fill(BLUE, opacity=0.5)
        circle.set_stroke(BLUE_E, width=4)
        square = OpenGLSquare(fill_opacity=0, stroke_opacity=1, stroke_color=RED, stroke_width=5, draw_stroke_behind_fill=False)

        self.play(FadeIn(square))
        self.wait()

Gives a blank black screen:

https://user-images.githubusercontent.com/9102529/113471180-40006780-948d-11eb-88f6-38218c3f2ffe.mp4

While

from manim import *
from manim.opengl import *

class Test(Scene):
    def construct(self):
        circle = OpenGLCircle()
        circle.set_fill(BLUE, opacity=0.5)
        circle.set_stroke(BLUE_E, width=4)
        square = OpenGLSquare(fill_opacity=1, stroke_opacity=1, stroke_color=RED, stroke_width=5, draw_stroke_behind_fill=False)

        self.play(FadeIn(square))
        self.wait()

Gives this:

https://user-images.githubusercontent.com/9102529/113471210-88b82080-948d-11eb-8330-0a17f7c3915e.mp4

This shows that the problem in my local installation lies with rendering strokes.

Expected behavior

Strokes should render correctly.

How to reproduce the issue

Code for reproducing the problem ```py Paste your code here. ```

Additional media files

Images/GIFs

Logs

Terminal output ``` PASTE HERE OR PROVIDE LINK TO https://pastebin.com/ OR SIMILAR ```

System specifications

System Details - OS Microsoft Windows 10 Home Insider Preview Version10.0.21343 Build 21343 - RAM: Is this relevant? - Python version (`python/py/python3 --version`): Python 3.9.2 - Installed modules (provide output from `pip list`): ``` Package Version ----------------------------- ----------- alabaster 0.7.12 ansicon 1.89.0 anyio 2.2.0 appdirs 1.4.4 argon2-cffi 20.1.0 astroid 2.5.2 async-generator 1.10 attrs 20.3.0 Babel 2.9.0 backcall 0.2.0 bleach 3.3.0 blessed 1.18.0 certifi 2020.12.5 cffi 1.14.5 chardet 4.0.0 colorama 0.4.4 colour 0.1.5 commonmark 0.9.1 decorator 4.4.2 defusedxml 0.7.0 dnspython 1.16.0 docopt 0.6.2 docutils 0.16 entrypoints 0.3 fett 0.3.2 flyingcircus 0.1.3.2 glcontext 2.3.3 grpcio 1.33.2 grpcio-tools 1.33.2 idna 2.10 imagesize 1.2.0 ipykernel 5.5.0 ipython 7.21.0 ipython-genutils 0.2.0 isort 5.8.0 jedi 0.18.0 Jinja2 2.11.3 jinxed 1.0.1 json5 0.9.5 jsonschema 3.2.0 jupyter-client 6.1.11 jupyter-core 4.7.1 jupyter-packaging 0.7.12 jupyter-server 1.4.1 jupyterlab 3.0.9 jupyterlab-pygments 0.1.2 jupyterlab-server 2.3.0 lazy-object-proxy 1.6.0 livereload 2.6.3 manim 0.5.0 ManimPango 0.2.4 mapbox-earcut 0.12.10 MarkupSafe 1.1.1 mccabe 0.6.1 mistune 0.8.4 moderngl 5.6.4 moderngl-window 2.3.0 multipledispatch 0.6.0 nbclassic 0.2.6 nbclient 0.5.3 nbconvert 6.0.7 nbformat 5.1.2 nest-asyncio 1.5.1 networkx 2.5 notebook 6.2.0 numpy 1.20.1 packaging 20.9 pandocfilters 1.4.3 parso 0.8.1 pickleshare 0.7.5 Pillow 8.1.0 pip 21.0.1 prometheus-client 0.9.0 prompt-toolkit 3.0.16 protobuf 3.15.5 pycairo 1.20.0 pycparser 2.20 pydub 0.24.1 pyglet 1.5.15 Pygments 2.8.0 pylint 2.7.3 pymongo 3.11.3 pyparsing 2.4.7 pyrr 0.10.3 pyrsistent 0.17.3 python-dateutil 2.8.1 python-jsonrpc-server 0.3.4 pytk 0.0.2.1 pytz 2021.1 pywin32 300 pywinpty 0.5.7 PyYAML 5.4.1 pyzmq 22.0.3 requests 2.25.1 rich 6.2.0 rstcheck 3.3.1 scipy 1.6.1 Send2Trash 1.5.0 setuptools 53.1.0 setuptools-scm 5.0.2 six 1.15.0 sniffio 1.2.0 snooty-lextudio 1.8.10.dev0 snowballstemmer 2.1.0 Sphinx 3.5.3 sphinx-autobuild 2021.3.14 sphinxcontrib-applehelp 1.0.2 sphinxcontrib-devhelp 1.0.2 sphinxcontrib-htmlhelp 1.0.3 sphinxcontrib-jsmath 1.0.1 sphinxcontrib-qthelp 1.0.3 sphinxcontrib-serializinghtml 1.1.4 terminado 0.9.2 testpath 0.4.4 toml 0.10.2 tornado 6.1 tqdm 4.58.0 traitlets 5.0.5 typing-extensions 3.7.4.3 urllib3 1.26.3 watchdog 1.0.2 wcwidth 0.2.5 webencodings 0.5.1 wheel 0.36.2 wrapt 1.12.1 ```
LaTeX details + LaTeX distribution (e.g. TeX Live 2020): + Installed LaTeX packages:
FFMPEG Output of `ffmpeg -version`: ``` ```

Additional comments

markromanmiller commented 3 years ago

Has OpenGL rendering ever worked reasonably on your machine? In other words, is this a regression or something else?

Darylgolden commented 3 years ago

It's the first time I'm ever trying OpenGL rendering, so I have no idea.

markromanmiller commented 3 years ago

@ManimCommunity/windows crew, is anyone able to replicate? With master and Ubuntu, I'm not.

Darylgolden commented 3 years ago

For good measure, I've updated to master, and it still isn't working for me.

Darylgolden commented 3 years ago

opengl1 opengl2 Here are my tests on OpenGL Extensions Viewer 6, if that means anything.

naveen521kk commented 3 years ago

No idea why this happens to you, I can't reproduce this.

https://user-images.githubusercontent.com/49693820/113669711-c3aa9600-96d1-11eb-9ad6-13e6932f8299.mp4

I also tried the mesa setup, like done in our CI and still can't reproduce this. See https://moderngl.readthedocs.io/en/latest/install/installation.html#using-with-mesa-3d-on-windows on how to.

Darylgolden commented 3 years ago

I figured out the issue! Moderngl was running on Intel integrated graphics, which somehow didn't work. After making it use my NVIDIA graphics card, it worked properly. image

From the OpenGL report for my graphics card. I think the problem with the Intel rendering lies somewhere in "ARB 2015".

einarf commented 3 years ago

It would be useful if the opengl renderer showed the context and enviroment info on startup?

python -m moderngl outputs

moderngl 5.7.0
--------------
vendor: NVIDIA Corporation
renderer: GeForce RTX 2080 SUPER/PCIe/SSE2
version: 3.3.0 NVIDIA 456.71
python: 3.9.0 (tags/v3.9.0:9cf6752, Oct  5 2020, 15:34:40) [MSC v.1927 64 bit (AMD64)]
platform: win32
code: 330

https://github.com/moderngl/moderngl/blob/e6ca0dc2bc55914724594c5060313b54873ed17b/moderngl/__main__.py#L19-L46

Darylgolden commented 3 years ago

For integrated graphics (which doesn't work properly):

moderngl 5.6.4
--------------
vendor: Intel
renderer: Intel(R) UHD Graphics
version: 3.3.0 - Build 27.20.100.9168
python: 3.9.2 (tags/v3.9.2:1a79785, Feb 19 2021, 13:44:55) [MSC v.1928 64 bit (AMD64)]
platform: win32
code: 330
einarf commented 3 years ago

I don't really now how graphics switching works on Windows. I think this is based on power usage settings?

I know there is a hack in the manim rendered related to copying a multisampled framebuffer. I suspect it's related to this? I'm guessing a gl error is raised during the buffer copy?

.. or does this only apply when stokes are applied? I have to play more with manim because I don't know what I am looking at 😄

Intel UHD Graphics should be more that capable if the drivers are updated.

Darylgolden commented 3 years ago

Most mid-end and up laptops have a dedicated graphics card but use integrated graphics for most things to save power, but the user can switch the default graphics renderer and the renderer for specific programs. Therefore it's not a problem for me anymore, but it would be a problem for someone who only has integrated graphics.

fabriciosb commented 3 years ago

the issue! Moderngl was running on Intel integrated graphics, which somehow didn't work. After making it use my NVIDIA graphics card, it worked properly.

I am having the same problem (no strokes, only fill) when running ManimCE with "--use_opengl_renderer". My python -m moderngl also return my intel, though I have a (super simple) Nvidea. May I ask how did you select the graphics card?

fabriciosb commented 3 years ago

python -m moderngl

Ok. I have managed to select default graphics card (for all programs) in Nvidea panel. So, when I changed from Intel to Nvidea, I got the strokes working as well.

Darylgolden commented 3 years ago

python -m moderngl

Ok. I have managed to select default graphics card (for all programs) in Nvidea panel. So, when I changed from Intel to Nvidea, I got the strokes working as well.

I think it suffices to change python to use Nvidia.

Darylgolden commented 3 years ago

Update: This will be resolved on the new (non-default) stroke shaders introduced in #1680! This issue will still be open until it becomes the default though.

niedong commented 3 years ago

Hi, I've solved this problem. Please change your graphics processor. I changed my graphics processor and everything becomes fine.

Original settings:

moderngl 5.6.4 vendor: Intel renderer: Intel(R) HD Graphics 620 version: 3.3.0 - Build 27.20.100.8854 python: 3.9.4 (tags/v3.9.4:1f2e308, Apr 6 2021, 13:40:21) [MSC v.1928 64 bit (AMD64)] platform: win32 code: 330

Now:

vendor: NVIDIA Corporation renderer: GeForce 940MX/PCIe/SSE2 version: 3.3.0 NVIDIA 461.40 python: 3.9.4 (tags/v3.9.4:1f2e308, Apr 6 2021, 13:40:21) [MSC v.1928 64 bit (AMD64)] platform: win32 code: 330

Darylgolden commented 3 years ago

Hi, I've solved this problem. Please change your graphics processor. I changed my graphics processor and everything becomes fine.

Original settings:

moderngl 5.6.4 vendor: Intel renderer: Intel(R) HD Graphics 620 version: 3.3.0 - Build 27.20.100.8854 python: 3.9.4 (tags/v3.9.4:1f2e308, Apr 6 2021, 13:40:21) [MSC v.1928 64 bit (AMD64)] platform: win32 code: 330

Now:

vendor: NVIDIA Corporation renderer: GeForce 940MX/PCIe/SSE2 version: 3.3.0 NVIDIA 461.40 python: 3.9.4 (tags/v3.9.4:1f2e308, Apr 6 2021, 13:40:21) [MSC v.1928 64 bit (AMD64)] platform: win32 code: 330

This isn't really a resolution as it does not work for people who do not have a dedicated graphics card.