-
Notifications
You must be signed in to change notification settings - Fork 6.9k
Description
Describe the bug
When rendering a complex VMobject with a gradient fill, unexpected colors may appear in certain areas.
Code example:
class Test(Scene):
def construct(self):
tex = Tex(R"2").set_height(7).set_color([BLUE, GREEN])
self.add(tex)Observed behavior:
Instead of a smooth gradient, some regions display incorrect or “extra” colors.
Root cause analysis
This appears to be related to how VMobject fills are implemented.
Currently, the fill is constructed by blending a sequence of triangles, each defined by one fixed vertex and two consecutive vertices along the shape’s boundary (i.e., the 1st, i-th, and (i+1)-th points).
When a gradient is applied, overlapping triangles end up with slightly different colors. Since overlapping regions use blending with negative opacity, the colors don’t fully cancel out, leaving visible artifacts.
Possible fix
Instead of the current “fan” triangulation approach, use a proper polygon triangulation algorithm to generate non-overlapping triangles for rendering. This should eliminate color inconsistencies caused by overlapping regions.
Additional Content
System info:
- ManimGL 1.7.2
- Python 3.12.9
- Windows 11
- GPU: Intel Arc Pro Graphics (Driver 32.0.101.6637)
