Dynamic SDF Rendering for Automated Video

Overview

  • Project: Automated Video Generation Pipeline
  • Status: Active — evaluation phase
  • Concept: “Geometry as code” — entire 3D scenes defined by mathematical functions in text files

Why SDFs for Automation

AdvantageRelevance
Version control friendlyScene is kilobytes of GLSL code, diffable via Git
Procedural generationInject variables (time, audio, text) directly into rendering equations
AI-compatibleClaude/Gemini can generate/debug GLSL faster than manipulating binary 3D files

Technical Architecture

Core: Raymarching via GLSL Fragment Shader

Instead of rasterizing triangles, shoot a ray per pixel and step along it querying the distance field. Dynamic via uniforms:

  • uniform float iTime; — animation
  • uniform vec3 iAudioLow; — audio reactivity
  • uniform float iDeformStrength; — shape modulation

CLI Renderer: glslViewer

Headless mode rendering piped directly to FFmpeg:

glslViewer scene.frag --headless --width 1920 --height 1080 \
  | ffmpeg -f rawvideo -pixel_format rgba -video_size 1920x1080 -i - output.mp4

Python Orchestration

  1. Accept input data (e.g., project completion %)
  2. Modify GLSL file or pass data as uniforms
  3. Trigger render command
  4. Merge output with audio tracks

Use Cases

Status Visualizers

3D fluid containers filling based on project data. SDF boolean intersection between Box (container) and Plane (liquid level) with smooth minimum blending.

Audio-Reactive Backgrounds

Domain repetition via modulo operator creates infinite fields of pulsing shapes. Feed audio amplitude into SDF sphere radius.

Morphing Logos

Linear interpolation between distance functions: mix(sdSphere, sdBox, 0.5 + 0.5*sin(time)) — logo morphs between shapes representing different apps.

  • Language: GLSL (OpenGL Shading Language)
  • Editor: Neovim with glsl-analyzer LSP
  • Preview: glslViewer (live coding, updates on save)
  • Reference: Inigo Quilez (iq) — foundational SDF documentation