Skip to main content

Overview

The VTK renderer is one of three rendering backends available in ManimVTK (alongside Cairo and OpenGL). It leverages the VTK (Visualization Toolkit) library for high-quality 3D rendering with advanced shading and lighting.
The VTK renderer is particularly powerful for 3D scenes and scientific visualization, providing superior quality compared to the standard Cairo renderer.

Basic Usage

Selecting the VTK Renderer

Use the --renderer vtk flag when rendering:

In Code

You can also specify the renderer in your scene configuration:
ThreeDScene works with all renderers, but VTK provides the best quality for 3D content

Renderer Comparison

FeatureCairoOpenGLVTK
2D Quality⭐⭐⭐⭐⭐⭐⭐
3D Quality⭐⭐⭐⭐⭐
Performance⭐⭐⭐⭐⭐⭐⭐
Export SupportImages onlyImages onlyVTK files
LightingBasicGoodExcellent
ShadingNoneBasicAdvanced
Anti-aliasingGoodGoodExcellent

VTK Renderer Features

Advanced Lighting

VTK supports sophisticated lighting models:
When rendered with VTK (--renderer vtk), you’ll see realistic shading and highlights.

Surface Shading

VTK provides multiple shading options:
  • Flat shading: Each polygon rendered with uniform color
  • Gouraud shading: Smooth interpolation across polygons
  • Phong shading: High-quality specular highlights
VTK automatically selects the appropriate shading based on your geometry and lighting

Transparency and Opacity

VTK handles transparency correctly with depth sorting:

Configuration

Camera Settings

Configure the camera for optimal VTK rendering:

Resolution Settings

Control render quality in config:
Or via CLI:

Best Practices

The VTK renderer excels at 3D visualization. For pure 2D animations, Cairo may be faster and sufficient.VTK recommended for:
  • Surfaces and parametric surfaces
  • 3D primitives (spheres, cubes, etc.)
  • Scientific 3D data
  • Complex lighting scenarios
Start with lower resolution for testing, then render at full quality:
VTK rendering may display colors differently than Cairo due to lighting. Test your colors with VTK early in development.
Smooth camera movements work beautifully with VTK:

Combining with Export

The VTK renderer works seamlessly with VTK export:
This produces:
  1. High-quality video rendered with VTK
  2. VTK files (.vtp or .vtm) for further analysis

Troubleshooting

Cause: VTK initialization failed or display not availableSolution:
Cause: High polygon count or complex geometrySolution:
  • Reduce surface resolution
  • Lower video quality for testing
  • Use simpler geometry during development
Cause: VTK applies lighting and shadingSolution:
  • Adjust colors to account for lighting
  • Increase ambient light if colors are too dark
  • Test with different camera angles
Cause: VTK not installedSolution:

Advanced Examples

Parametric Surface with Lighting

Render:

Multiple 3D Objects

Next Steps

VTK Export

Learn how to export VTK files

3D Scenes

Master 3D scene creation

Surfaces

Explore 3D surface objects

Examples

View 3D rendering examples