This directory contains helper scripts for generating trajectories, rendering batches, creating animations, and plotting ray data.
Run commands from the repository root.
scripts/
animate-rays/ # Manim scene + config for ray animations
plotting/ # Trajectory and direction plotting tools
rays/ # Ray export scripts
rendering/ # Camera paths, frame rendering, movie/Kerr batch generation
resources/ # Rendering script templates/assets
textures/ # UV/checker texture generation
cargo(Rust toolchain)uv(for Python scripts and Manim)ffmpeg(forrendering/create_movie_from_images.sh)magick/ ImageMagick (forrendering/create_kerr_images.sh)
Install Python dependencies:
uv sync- Generate camera positions:
uv run scripts/rendering/create_camera_trajectory.py- Render one frame per camera position:
uv run scripts/rendering/create_images_from_camera_positions.py- Build an MP4 from the rendered frames:
bash scripts/rendering/create_movie_from_images.shGenerate rays:
bash scripts/rays/create_rays_positions.sh schwarzschild
# or
bash scripts/rays/create_rays_from_camera.shThen render the animation:
uv run manim scripts/animate-rays/main.py AnimateRays- Creates
camera_positions.csvwith interpolated camera positions from hard-coded control points. - Edit
pointsandNin the script to change path shape and number of frames.
uv run scripts/rendering/create_camera_trajectory.py- Reads
camera_positions.csv. - Runs the Rust renderer for each row and writes frames to
movie/render-XXX.png. - Adjust
WIDTH,HEIGHT,CONFIG_FILE, andPOSITIONS_FILEin the script as needed.
uv run scripts/rendering/create_images_from_camera_positions.py- Uses
ffmpegto combinemovie/render-%03d.pngintomovie/output.mp4(30 FPS by default).
bash scripts/rendering/create_movie_from_images.sh- Sweeps Kerr spin parameter
afrom0.000to0.499. - Creates per-frame scene files in
kerr_images/, renders PNGs, annotates each frame, then buildskerr_animation.gif. - Optional first argument: custom render command (default:
cargo run --release --). - Optional grid overlay flags:
--grid/--no-grid--grid-size N--grid-width N --grid-height N
bash scripts/rendering/create_kerr_images.sh
# Example with binary and grid overlay:
bash scripts/rendering/create_kerr_images.sh "target/release/gr_raytracer" --grid --grid-size 40- Exports ray trajectories to
rays/by sweeping the initial ray position. - Usage:
create_rays_positions.sh <geometry> [shift] [command] <geometry>:schwarzschildorkerrshiftdefaults to0commanddefaults tocargo run --release --
bash scripts/rays/create_rays_positions.sh schwarzschild
bash scripts/rays/create_rays_positions.sh kerr 2.0- Exports rays from a fixed camera position while varying horizontal pixel coordinate.
- Writes CSV files to
rays/. - Optional argument: custom render command (default:
cargo run --release --).
bash scripts/rays/create_rays_from_camera.sh- Manim scene that reads
rays/*.csvand animates trajectories (AnimateRaysscene). - Config defaults are in
scripts/animate-rays/manim.cfg.
uv run manim scripts/animate-rays/main.py AnimateRays- Plots one or more trajectory CSVs with
x,y,zcolumns. - Draws a central sphere (
r=1) and supports clipping by--max-radius.
uv run scripts/plotting/plot_trajectories_3d.py rays/ray-0000.00.csv
uv run scripts/plotting/plot_trajectories_3d.py rays/ray-0000.00.csv --save trajectory.png --max-radius 15- 2D plot for multiple trajectories.
- Accepts CSVs with either:
r,phicolumns (polar data converted to Cartesian), orx,y,zCartesian data (plotsxagainstz).
uv run scripts/plotting/plot_planar_trajectories.py rays/ray-0000.00.csv rays/ray-0005.00.csv- 3D scatter plot of direction (
d_x1,d_x2,d_x3) and momentum (m_x1,m_x2,m_x3) fromrays.csv.
uv run scripts/plotting/direction_plotter.py- Generates checkerboard texture atlases in
resources/:celestial.pngsphere.pngdisk.png
uv run scripts/textures/create_uv_map.py