Skip to content

01 Overview

Tagin T edited this page Nov 24, 2026 · 2 revisions

English | 中文

01 Overview & Architecture

What RTM is

RTM splits ManimCE's "director" role from Vulkan's "rasterizer" role:

  • ManimCE owns the data model: Mobject, Animation, Scene, Camera, layout, colours, text, graphs.
  • RTM owns the timeline, paint order, native vertex/texture upload, Vulkan rendering, readback and recording.

So from real_time_manim import * still hands you ManimCE classes; RTM patches the namespace at import time and wires the native renderer into MLWindow.

user script
  └─ Scene / Mobject / Animation   (ManimCE data model)
       └─ MLWindow                  (RTM window + native bindings)
            ├─ sync / paint          (Python: order, projection, commands)
            └─ vulkan_core.dll/.dylib (native: Vulkan)

Components

Layer Location Responsibility
Scene & timeline real_time_manim/timeline.py, frames.py animation scheduling, frame addressing, FrameServer
Window & drawing real_time_manim/window/ MLWindow, sync, paint queue, recording
Emitters real_time_manim/render/ turn shapes/text/images/meshes into native commands
Native layer native/ Vulkan init, pipelines, vertex building, readback, post
Platform layer native/platform.c, native/platform_mac.m Win32 / Cocoa + MoltenVK

Five execution modes

Mode Entry point Characteristics
Live window MLWindow.play(...) wall-clock paced, watch it draw
Frame on demand FrameServer.render_frame(t) one construct(), then O(1)
Offline recording fast_record_scene hidden window, per-frame readback → ffmpeg
Live recording record_scene visible window, render thread samples frames
Parallel recording jobs=N multi-process segments, then lossless join

Design trade-offs

  1. Frame addressability first: a scene becomes a timeline, so any t can be evaluated directly instead of replayed from 0.
  2. One drawing path: live, stills, recording and parallel workers all go through sync → paint → native, so the preview and the final video cannot diverge.
  3. One window per process: native Vulkan state is process-global (g_inst / g_dev / g_swapchain); multi-window is not supported yet.
  4. Fixed output: 1920×1080@60 removes a whole class of resolution-dependent bugs; downscale after rendering if you need something smaller.
  5. ManimCE compatibility: finish(), clean_up_from_scene(), updaters and z_index follow CE semantics as closely as possible.

Code map

real_time_manim/
  __init__.py          # namespace reassembly, lazy RTM entry points
  record.py            # fast_record_scene / record_scene / parallel scheduling
  frames.py            # FrameServer: construct once, render any frame
  timeline.py          # Timeline: begin/evaluate/render_at/frame_times
  preview.py           # interactive preview (slider / terminal)
  window/
    core.py            # DLL bindings, camera publish, sync
    paint.py           # per-mobject -> native Add* emitters
    paint_order.py     # CE paint order and _PaintQueue
    play.py            # play loop, timeline rendering, static layer
    recording.py       # screenshots, ffmpeg pipe, recording lifecycle
  render/              # shape/text/image emission, shading, caches
native/
  vulkan_init.c        # instance/device/swapchain/render pass/pipelines
  vulkan_draw.c        # command replay, vertex upload, command buffer recording
  vulkan_texture.c     # image texture pipeline and interleaved draws
  vulkan_post.c        # bloom/tonemap post-processing
  platform.c/.m        # platform entry points, shape pool, readback

The next chapter starts with the Scene lifecycle and MLWindow.

Clone this wiki locally