-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Description
Description of bug / unexpected behavior
Rendering parametric surfaces that self-occlude causes strange issues where from certain view directions the parts that should be hidden behind others are instead rendered on top.
In the example provided the surface is rotating such that the "convex" side is on top, but in some sections of the animation the surface appears to be "flipped".
This effect does not occur if I use ThreeDScene, but that mode has some properties that do not fit my use-case.
Expected behavior
The code below (reproduction section) should show a 2D Gaussian surface that rotates about its Z axis, such that the "peak" should always occlude the "floor" when the latter is behind the former.
How to reproduce the issue
Run this code. This was tested to reproduce the issue on both manim v0.19.0 and v0.18.0.
Code for reproducing the problem
from manim import *
import math
def surfaceExampleC(u,v,mu,covar,scaler=0):
diff = np.array([u,v])-mu
numerator = math.exp(-0.5*(diff.T @ np.linalg.inv(covar) @ diff))
if (scaler==0):
denominator = math.sqrt(np.linalg.det(covar)*((2*PI)**2))
elif (scaler==-1):
denominator = 1
else:
denominator=scaler
output = numerator/denominator
# if ( output > 0.1):
# print(f"output: {output}")
return output
class SurfaceView(Scene):
def construct(self):
axes = ThreeDAxes(x_range=(-5, 5, 1), y_range=(-5, 5, 1), z_range=(0, 1, 0.5))
surface_ex = Surface(
lambda u,v: axes.c2p(u,v,surfaceExampleC(
u,v,
mu=np.array([0,0]),
covar=np.matrix('2,1;1,2'),
scaler=-1)),
u_range=[-5, +5],
v_range=[-5, +5],
resolution=32,
should_make_jagged=False
)
self.play(
FadeIn(surface_ex),
)
self.play(
Rotate(
surface_ex,
angle = 20*DEGREES,
axis=OUT,
about_point = ORIGIN
)
,
)
tilt_angle = -45*DEGREES
self.play(
Rotate(
surface_ex,
angle = -45*DEGREES,
axis=[1,0,0],
about_point = ORIGIN
)
)
self.play(
Rotate(
surface_ex,
angle = -180*DEGREES,
axis=[0,math.sin(-tilt_angle),math.cos(tilt_angle)],
about_point = ORIGIN
)
,
run_time=5
)
self.play(
Rotate(
surface_ex,
angle = 360*DEGREES,
axis=[0,math.sin(-tilt_angle),math.cos(tilt_angle)],
about_point = ORIGIN
)
,
run_time=5
)
self.play(
FadeOut(surface_ex)
)Additional media files
Images/GIFs
Rendered using `docker run --rm -it -v "$(pwd):/manim" manimcommunity/manim manim -ql $filename` and converted with ffmpeg:Logs
Terminal output
Manim Community v0.19.0
/manim/surface_view.py:6: DeprecationWarning: Conversion of an array with ndim > 0 to a scalar is deprecated, and will error in future. Ensure you extract a single element from your array before performing this operation. (Deprecated NumPy 1.25.)
numerator = math.exp(-0.5*(diff.T @ np.linalg.inv(covar) @ diff))
[11/10/25 21:27:14] DEBUG Hashing ... hashing.py:360
[11/10/25 21:27:15] DEBUG Hashing done in 1.260841 s. hashing.py:372
DEBUG Hash generated : 1584795214_2861881079_223132457 hashing.py:375
DEBUG List of the first few animation hashes of the scene: ['1584795214_2861881079_223132457'] cairo_renderer.py:103
[11/10/25 21:27:17] INFO Animation 0 : Partial movie file written in scene_file_writer.py:590
'/manim/media/videos/surface_view/480p15/partial_movie_files/SurfaceView/1584795214_2861881079_223132457.mp4'
DEBUG Hashing ... hashing.py:360
[11/10/25 21:27:18] DEBUG Hashing done in 1.008502 s. hashing.py:372
DEBUG Hash generated : 4072820271_96294947_2999109411 hashing.py:375
DEBUG List of the first few animation hashes of the scene: ['1584795214_2861881079_223132457', '4072820271_96294947_2999109411'] cairo_renderer.py:103
[11/10/25 21:27:21] INFO Animation 1 : Partial movie file written in scene_file_writer.py:590
'/manim/media/videos/surface_view/480p15/partial_movie_files/SurfaceView/4072820271_96294947_2999109411.mp4'
DEBUG Hashing ... hashing.py:360
[11/10/25 21:27:22] DEBUG Hashing done in 1.389540 s. hashing.py:372
DEBUG Hash generated : 4072820271_642620281_2999109411 hashing.py:375
DEBUG List of the first few animation hashes of the scene: ['1584795214_2861881079_223132457', '4072820271_96294947_2999109411', cairo_renderer.py:103
'4072820271_642620281_2999109411']
[11/10/25 21:27:25] INFO Animation 2 : Partial movie file written in scene_file_writer.py:590
'/manim/media/videos/surface_view/480p15/partial_movie_files/SurfaceView/4072820271_642620281_2999109411.mp4'
DEBUG Hashing ... hashing.py:360
[11/10/25 21:27:26] DEBUG Hashing done in 1.096327 s. hashing.py:372
DEBUG Hash generated : 4072820271_3255438960_2999109411 hashing.py:375
DEBUG List of the first few animation hashes of the scene: ['1584795214_2861881079_223132457', '4072820271_96294947_2999109411', cairo_renderer.py:103
'4072820271_642620281_2999109411', '4072820271_3255438960_2999109411']
[11/10/25 21:27:39] INFO Animation 3 : Partial movie file written in scene_file_writer.py:590
'/manim/media/videos/surface_view/480p15/partial_movie_files/SurfaceView/4072820271_3255438960_2999109411.mp4'
DEBUG Hashing ... hashing.py:360
[11/10/25 21:27:40] DEBUG Hashing done in 1.173598 s. hashing.py:372
DEBUG Hash generated : 4072820271_724292003_2999109411 hashing.py:375
DEBUG List of the first few animation hashes of the scene: ['1584795214_2861881079_223132457', '4072820271_96294947_2999109411', cairo_renderer.py:103
'4072820271_642620281_2999109411', '4072820271_3255438960_2999109411', '4072820271_724292003_2999109411']
[11/10/25 21:27:53] INFO Animation 4 : Partial movie file written in scene_file_writer.py:590
'/manim/media/videos/surface_view/480p15/partial_movie_files/SurfaceView/4072820271_724292003_2999109411.mp4'
DEBUG Hashing ... hashing.py:360
[11/10/25 21:27:54] DEBUG Hashing done in 1.176449 s. hashing.py:372
DEBUG Hash generated : 4072820271_406270278_2999109411 hashing.py:375
DEBUG List of the first few animation hashes of the scene: ['1584795214_2861881079_223132457', '4072820271_96294947_2999109411', cairo_renderer.py:103
'4072820271_642620281_2999109411', '4072820271_3255438960_2999109411', '4072820271_724292003_2999109411']
[11/10/25 21:27:56] INFO Animation 5 : Partial movie file written in scene_file_writer.py:590
'/manim/media/videos/surface_view/480p15/partial_movie_files/SurfaceView/4072820271_406270278_2999109411.mp4'
INFO Combining to Movie file. scene_file_writer.py:740
DEBUG Partial movie files to combine (6 files): scene_file_writer.py:624
['/manim/media/videos/surface_view/480p15/partial_movie_files/SurfaceView/1584795214_2861881079_223132457.mp4',
'/manim/media/videos/surface_view/480p15/partial_movie_files/SurfaceView/4072820271_96294947_2999109411.mp4',
'/manim/media/videos/surface_view/480p15/partial_movie_files/SurfaceView/4072820271_642620281_2999109411.mp4',
'/manim/media/videos/surface_view/480p15/partial_movie_files/SurfaceView/4072820271_3255438960_2999109411.mp4',
'/manim/media/videos/surface_view/480p15/partial_movie_files/SurfaceView/4072820271_724292003_2999109411.mp4']
INFO scene_file_writer.py:887
File ready at '/manim/media/videos/surface_view/480p15/SurfaceView.mp4'
INFO Rendered SurfaceView scene.py:279
Played 6 animations
System specifications
System Details
This was tested with the official docker, so details are taken from prints like docker run --rm -it -v "$(pwd):/manim" manimcommunity/manim pip list
- OS: Ubuntu 20.04
- RAM: 40GB
- Python version: 3.11.14
- Installed modules:
Package Version
----------------------------- -----------
accessible-pygments 0.0.5
alabaster 1.0.0
anyio 4.11.0
argon2-cffi 25.1.0
argon2-cffi-bindings 25.1.0
arrow 1.4.0
asttokens 3.0.0
async-lru 2.0.5
attrs 25.4.0
av 13.1.0
babel 2.17.0
beautifulsoup4 4.14.2
bleach 6.3.0
certifi 2025.10.5
cffi 2.0.0
charset-normalizer 3.4.4
click 8.3.0
cloup 3.0.8
comm 0.2.3
debugpy 1.8.17
decorator 5.2.1
defusedxml 0.7.1
docutils 0.21.2
executing 2.2.1
fastjsonschema 2.21.2
fqdn 1.5.1
furo 2025.9.25
glcontext 3.0.0
h11 0.16.0
httpcore 1.0.9
httpx 0.28.1
idna 3.11
imagesize 1.4.1
ipykernel 7.1.0
ipython 9.7.0
ipython_pygments_lexers 1.1.1
isoduration 20.11.0
isosurfaces 0.1.2
jedi 0.19.2
Jinja2 3.1.6
json5 0.12.1
jsonpointer 3.0.0
jsonschema 4.25.1
jsonschema-specifications 2025.9.1
jupyter_client 8.6.3
jupyter_core 5.9.1
jupyter-events 0.12.0
jupyter-lsp 2.3.0
jupyter_server 2.17.0
jupyter_server_terminals 0.5.3
jupyterlab 4.4.10
jupyterlab_pygments 0.3.0
jupyterlab_server 2.28.0
lark 1.3.1
manim 0.19.0
ManimPango 0.6.1
mapbox_earcut 1.0.3
markdown-it-py 3.0.0
MarkupSafe 3.0.3
matplotlib-inline 0.2.1
mdit-py-plugins 0.5.0
mdurl 0.1.2
mistune 3.1.4
moderngl 5.12.0
moderngl-window 3.1.1
myst-parser 4.0.1
nbclient 0.10.2
nbconvert 7.16.6
nbformat 5.10.4
nest-asyncio 1.6.0
networkx 3.5
notebook 7.4.7
notebook_shim 0.2.4
numpy 2.3.4
overrides 7.7.0
packaging 25.0
pandocfilters 1.5.1
parso 0.8.5
pexpect 4.9.0
pillow 12.0.0
pip 24.0
platformdirs 4.5.0
prometheus_client 0.23.1
prompt_toolkit 3.0.52
psutil 7.1.3
ptyprocess 0.7.0
pure_eval 0.2.3
pycairo 1.28.0
pycparser 2.23
pydub 0.25.1
pyglet 2.1.11
pyglm 2.8.2
Pygments 2.19.2
python-dateutil 2.9.0.post0
python-json-logger 4.0.0
PyYAML 6.0.3
pyzmq 27.1.0
referencing 0.37.0
requests 2.32.5
rfc3339-validator 0.1.4
rfc3986-validator 0.1.1
rfc3987-syntax 1.1.0
rich 14.2.0
roman-numerals-py 3.1.0
rpds-py 0.28.0
scipy 1.16.3
screeninfo 0.8.1
Send2Trash 1.8.3
setuptools 79.0.1
six 1.17.0
skia-pathops 0.8.0.post2
sniffio 1.3.1
snowballstemmer 3.0.1
soupsieve 2.8
Sphinx 8.2.3
sphinx-basic-ng 1.0.0b2
sphinx-copybutton 0.5.2
sphinx_design 0.6.1
sphinx-reredirects 1.0.0
sphinxcontrib-applehelp 2.0.0
sphinxcontrib-devhelp 2.0.0
sphinxcontrib-htmlhelp 2.1.0
sphinxcontrib-jsmath 1.0.1
sphinxcontrib-qthelp 2.0.0
sphinxcontrib-serializinghtml 2.0.0
sphinxext-opengraph 0.13.0
srt 3.5.3
stack-data 0.6.3
svgelements 1.9.6
terminado 0.18.1
tinycss2 1.4.0
tornado 6.5.2
tqdm 4.67.1
traitlets 5.14.3
typing_extensions 4.15.0
tzdata 2025.2
uri-template 1.3.0
urllib3 2.5.0
watchdog 6.0.0
wcwidth 0.2.14
webcolors 25.10.0
webencodings 0.5.1
websocket-client 1.9.0
wheel 0.45.1
LaTeX details
-
LaTeX distribution:
pdfTeX 3.141592653-2.6-1.40.28 (TeX Live 2025)
kpathsea version 6.4.1
Copyright 2025 Han The Thanh (pdfTeX) et al.
There is NO warranty. Redistribution of this software is
covered by the terms of both the pdfTeX copyright and
the Lesser GNU General Public License.
For more information about these matters, see the file
named COPYING and the pdfTeX source.
Primary author of pdfTeX: Han The Thanh (pdfTeX) et al.
Compiled with libpng 1.6.46; using libpng 1.6.46
Compiled with zlib 1.3.1; using zlib 1.3.1
Compiled with xpdf version 4.04 -
Installed LaTeX packages:
i adjustbox: Graphics package-alike macros for "general" boxes
i adobemapping: Adobe cmap and pdfmapping files
i amscls: AMS document classes for LaTeX
i amsfonts: TeX fonts from the American Mathematical Society
i amsmath: AMS mathematical facilities for LaTeX
i arphic: Arphic (Chinese) font packages
i atbegshi: Execute stuff at \shipout time
i atveryend: Hooks at the very end of a document
i auxhook: Hooks for auxiliary files
i babel: Multilingual support for LaTeX, LuaLaTeX, XeLaTeX, and Plain TeX
i babel-english: Babel support for English
i beamer: A LaTeX class for producing presentations and slides
i bibtex: Process bibliographies (bib files) for LaTeX or other formats
i bibtex.x86_64-linux: x86_64-linux files of bibtex
i bigintcalc: Integer calculations on very large numbers
i bitset: Handle bit-vector datatype
i cbfonts-fd: LaTeX font description files for the CB Greek fonts
i cjk: CJK language support
i cjkpunct: Adjust locations and kerning of CJK punctuation marks
i cm: Computer Modern fonts
i cm-super: CM-Super family of fonts
i cns: Chinese/Japanese/Korean bitmap fonts
i collectbox: Collect and process macro arguments as boxes
i collection-basic: Essential programs and files
i colorprofiles: Collection of free ICC profiles
i count1to: Make use of count1 to count9
i ctablestack: Catcode table stable support
i ctex: LaTeX classes and packages for Chinese typesetting
i currfile: Provide file name and path of input files
i dehyph: German hyphenation patterns for traditional orthography
i doublestroke: Typeset mathematical double stroke symbols
i dvipdfmx: An extended version of dvipdfm
i dvipdfmx.x86_64-linux: x86_64-linux files of dvipdfmx
i dvips: A DVI to PostScript driver
i dvips.x86_64-linux: x86_64-linux files of dvips
i dvisvgm: Convert DVI, EPS, and PDF files to Scalable Vector Graphics format (SVG)
i dvisvgm.x86_64-linux: x86_64-linux files of dvisvgm
i ec: Computer modern fonts in T1 and TS1 encodings
i enctex: A TeX extension that translates input on its way into TeX
i epstopdf: Convert EPS to PDF using Ghostscript
i epstopdf-pkg: Call epstopdf "on the fly"
i epstopdf.x86_64-linux: x86_64-linux files of epstopdf
i etex: An extended version of TeX, from the NTS project
i etex-pkg: E-TeX support package
i etexcmds: Avoid name clashes with e-TeX commands
i etoolbox: e-TeX tools for LaTeX
i euenc: Unicode font encoding definitions for XeTeX
i everyhook: Hooks for standard TeX token lists
i everysel: Provides hooks into \selectfont
i extractbb: A reimplementation of extractbb, written in Lua
i extractbb.x86_64-linux: x86_64-linux files of extractbb
i fandol: Four basic fonts for Chinese typesetting
i filemod: Provide file modification times, and compare them
i firstaid: First aid for external LaTeX files and packages that need updating
i fonts-tlwg: Thai fonts for LaTeX from TLWG
i fontspec: Advanced font selection in XeLaTeX and LuaLaTeX
i fp: Fixed point arithmetic
i frcursive: French cursive hand fonts
i fundus-calligra: Support for the calligra font in LaTeX documents
i garuda-c90: TeX support (from CJK) for the garuda font
i geometry: Flexible and complete interface to document dimensions
i gettitlestring: Clean up title references
i gincltex: Include TeX files as graphics (.tex support for \includegraphics)
i glyphlist: Adobe Glyph List and TeX extensions
i gnu-freefont: A Unicode font, with rather wide coverage
i graphics: The LaTeX standard graphics bundle
i graphics-cfg: Sample configuration files for LaTeX color and graphics
i graphics-def: Colour and graphics option files
i hycolor: Implements colour for packages hyperref and bookmark
i hyperref: Extensive support for hypertext in LaTeX
i hyph-utf8: Hyphenation patterns expressed in UTF-8
i hyphen-base: core hyphenation support files
i hyphen-english: English hyphenation patterns.
i hyphenex: US English hyphenation exceptions file
i ifplatform: Conditionals to test which platform is being used
i iftex: Am I running under pdfTeX, XeTeX or LuaTeX?
i infwarerr: Complete set of information/warning/error message macros
i intcalc: Expandable arithmetic operations with integers
i jknapltx: Miscellaneous packages by Joerg Knappen
i knuth-lib: Core TeX and Metafont sources from Knuth
i knuth-local: Knuth's local information
i kpathsea: Path searching library for TeX-related files
i kpathsea.x86_64-linux: x86_64-linux files of kpathsea
i kvdefinekeys: Define keys for use in the kvsetkeys package
i kvoptions: Key value format for package options
i kvsetkeys: Key value parser with default handler support
i l3backend: LaTeX3 backend drivers
i l3backend-dev: LaTeX3 backend drivers (dev)
i l3kernel: LaTeX3 programming conventions
i l3kernel-dev: Development pre-release of l3kernel
i l3packages: High-level LaTeX3 concepts
i latex: A TeX macro package that defines LaTeX
i latex-base-dev: Development pre-release of the LaTeX kernel
i latex-bin: LaTeX executables and man pages
i latex-bin.x86_64-linux: x86_64-linux files of latex-bin
i latex-firstaid-dev: Development pre-release of the LaTeX firstaid package
i latex-fonts: A collection of fonts used in LaTeX distributions
i latexconfig: configuration files for LaTeX-related formats
i letltxmacro: Let assignment for LaTeX macros
i lm: Latin modern fonts in outline formats
i ltxcmds: Some LaTeX kernel commands for general use
i lua-alt-getopt: Process application arguments the same way as getopt_long
i lua-uni-algos: Unicode algorithms for LuaTeX
i luahbtex: LuaTeX with HarfBuzz library for glyph shaping
i luahbtex.x86_64-linux: x86_64-linux files of luahbtex
i lualibs: Additional Lua functions for LuaTeX macro programmers
i luaotfload: OpenType 'loader' for Plain TeX and LaTeX
i luaotfload.x86_64-linux: x86_64-linux files of luaotfload
i luatex: The LuaTeX engine
i luatex.x86_64-linux: x86_64-linux files of luatex
i luatexbase: Basic resource management for LuaTeX code
i luatexja: Typeset Japanese with Lua(La)TeX
i makeindex: Makeindex development sources
i makeindex.x86_64-linux: x86_64-linux files of makeindex
i mathastext: Use the text font in maths mode
i metafont: A system for specifying fonts
i metafont.x86_64-linux: x86_64-linux files of metafont
i mflogo: LaTeX support for Metafont logo fonts
i mfware: Supporting tools for use with Metafont
i mfware.x86_64-linux: x86_64-linux files of mfware
i microtype: Subliminal refinements towards typographical perfection
i modes: A collection of Metafont mode_def's
i mptopdf: mpost to PDF, native MetaPost graphics inclusion
i mptopdf.x86_64-linux: x86_64-linux files of mptopdf
i multitoc: Set table of contents in multiple columns
i norasi-c90: TeX support (from CJK) for the norasi font
i pdfescape: Implements pdfTeX's escape features using TeX or e-TeX
i pdftex: A TeX extension for direct creation of PDF
i pdftex.x86_64-linux: x86_64-linux files of pdftex
i pdftexcmds: LuaTeX support for pdfTeX utility functions
i pgf: Create PostScript and PDF graphics in TeX
i physics: Macros supporting the Mathematics of Physics
i plain: The Plain TeX format
i platex: pLaTeX2e and miscellaneous macros for pTeX
i platex-tools: pLaTeX standard tools bundle
i platex.x86_64-linux: x86_64-linux files of platex
i prelim2e: Allows the marking of preliminary versions of a document
i preview: Extract bits of a LaTeX source for output
i ptex: A TeX system for publishing in Japanese
i ptex-base: Plain TeX format for pTeX and e-pTeX
i ptex-fonts: Fonts for use with pTeX
i ptex.x86_64-linux: x86_64-linux files of ptex
i ragged2e: Alternative versions of "ragged"-type commands
i refcount: Counter operations with label references
i relsize: Set the font size relative to the current font size
i rerunfilecheck: Checksum based rerun checks on auxiliary files
i rsfs: Ralph Smith's Formal Script font
i scheme-infraonly: infrastructure-only scheme (no TeX at all)
i scheme-minimal: minimal scheme (plain only)
i setspace: Set space between lines
i standalone: Compile TeX pictures stand-alone or as part of a document
i stringenc: Converting a string between different encodings
i svn-prov: Subversion variants of \Provides... macros
i tex: A sophisticated typesetting engine
i tex-ini-files: Model TeX format creation files
i tex.x86_64-linux: x86_64-linux files of tex
i texlive-common: TeX Live documentation (common elements)
i texlive-en: TeX Live manual (English)
i texlive-msg-translations: translations of the TeX Live installer and TeX Live Manager
i texlive-scripts: TeX Live infrastructure programs
i texlive-scripts-extra: TeX Live scripts
i texlive-scripts-extra.x86_64-linux: x86_64-linux files of texlive-scripts-extra
i texlive-scripts.x86_64-linux: x86_64-linux files of texlive-scripts
i texlive.infra: basic TeX Live infrastructure
i texlive.infra.x86_64-linux: x86_64-linux files of texlive.infra
i tipa: Fonts and macros for IPA phonetics characters
i tlshell: GUI frontend (tcl/tk-based) for tlmgr
i tlshell.x86_64-linux: x86_64-linux files of tlshell
i tools: The LaTeX standard tools bundle
i translator: Easy translation of strings in LaTeX
i ttfutils: convert TrueType to TFM and PK fonts
i ttfutils.x86_64-linux: x86_64-linux files of ttfutils
i uhc: Fonts for the Korean language
i ulem: Package for underlining
i unicode-data: Unicode data and loaders for TeX
i uniquecounter: Provides unlimited unique counter
i uplatex: pLaTeX2e and miscellaneous macros for upTeX
i uplatex.x86_64-linux: x86_64-linux files of uplatex
i uptex: Unicode version of pTeX
i uptex-base: Plain TeX formats and documents for upTeX
i uptex-fonts: Fonts for use with upTeX
i uptex.x86_64-linux: x86_64-linux files of uptex
i url: Verbatim with URL-sensitive line breaks
i wadalab: Wadalab (Japanese) font packages
i wasy: The wasy fonts (Waldi symbol fonts)
i wasysym: LaTeX support for the wasy fonts
i xcjk2uni: Convert CJK characters to Unicode, in pdfTeX
i xcolor: Driver-independent color extensions for LaTeX and pdfLaTeX
i xdvi: A DVI previewer for the X Window System
i xdvi.x86_64-linux: x86_64-linux files of xdvi
i xecjk: Support for CJK documents in XeLaTeX
i xetex: An extended variant of TeX for use with Unicode sources
i xetex.x86_64-linux: x86_64-linux files of xetex
i xetexconfig: crop.cfg for XeLaTeX
i xkeyval: Extension of the keyval package
i xpinyin: Automatically add pinyin to Chinese characters
i xunicode: Generate Unicode characters from accented glyphs
i zapfding: URW 'Base 35' font pack for LaTeX
i zhmetrics: TFM subfont files for using Chinese fonts in 8-bit TeX
i zhmetrics-uptex: Chinese font metrics for upTeX
i zhnumber: Typeset Chinese representations of numbers
Metadata
Metadata
Assignees
Labels
Type
Projects
Status
