A Technical Practice Guide to Pure-Code Visual Short Films
This guide explains how to treat fully code-generated video as a hard test of multimodal models and coding tools: zero external assets, reproducible source, exportable files, SDF and fractal scenes, physics-inspired looks, particles, HDR post, procedural audio, performance fallbacks, and delivery standards.
1. Why “video from code only” is a hard test of model capability
When you evaluate a multimodal foundation model or an intelligent coding tool, UI demos and marketing copy are weak evidence. A more discriminative test is a tightly constrained, objectively checkable task: no external images, video, or audio; no generative media APIs; every frame and every sound must be synthesized from code; and a playable file must actually be exported.
The task is hard for three reasons. First, it compresses aesthetics into engineering: whether it looks great can wait; whether it runs, reproduces, and exports is a binary result. Second, it demands long context and multi-file coordination—shaders, scene graphs, particles, audio synthesis, and transcode scripts are coupled, and one inconsistent interface fails the run. Third, it is extremely sensitive to hallucination: invented library APIs or parameters fail on the first execution.
This article does not review any specific product. It abstracts the task into a reusable technical practice framework.
2. Translate “wow” into an acceptably constrained spec
Vague prompts such as “make a cool film” almost always produce weak delivery. Effective prompts state six constraint classes explicitly:
- Asset constraints: zero external assets and zero generative media API calls.
- Generation constraints: only math functions, fractal iteration, particle systems, shaders, procedural textures, and procedural audio.
- Reproducibility constraints: full source, a locked dependency list, run commands, and render/export commands.
- Artifact constraints: a real video file or complete frame sequence, plus how to assemble MP4/GIF.
- Environment constraints: for browser graphics, a single-page entry and offline run path; for scripts, environment setup and commands.
- Degradation constraints: a performance budget and fallbacks, not only an ideal-machine implementation.
Add a delivery format (concept, technical approach and hard parts, file layout, run commands, artifact naming, self-score). Acceptance boundaries become clear. A structured spec cuts rework by limiting free-form invention to where it belongs: visual concept and narrative rhythm.
3. Five layers of the technical approach
1. Geometry and scene: SDFs and fractals
A common choice for procedural scenes is the signed distance field (SDF): a function of nearest surface distance, intersected with ray marching. Boolean ops, smooth blends, and infinite scale are cheap—good for organic and fractal forms. Hybrid fractal SDFs typically fuse primitives (sphere, box, torus, octahedron) with a smooth-min operator, then add domain repetition and iterative folding for self-similar detail.
// Sketch: smooth blend + domain fold + fractal foldfloat smin(float a, float b, float k){float h = clamp(0.5 + 0.5*(b-a)/k, 0.0, 1.0);return mix(b, a, h) - k*h*(1.0-h);}float map(vec3 p){float d = 1e9;for(int i=0;i<6;i++){p = abs(p) - 0.35; // foldp.xy *= rot(float(i)*0.7); // rotate per iterationd = smin(d, length(p)-0.28, 0.25); // smooth blend}return d;}
Hard parts are step-size safety and normal estimation: steps that are too large cause tunneling and noise; too small collapses performance. Central-difference normals need an offset matched to scene scale, or distant surfaces show moiré.
2. Physics-inspired looks: gravitational lensing and accretion disks
An economical way to get an “epic” look is to borrow visual signatures of real physics. Lensing can be approximated by bending rays in a strong-field region, with deflection related to mass and impact parameter. An accretion disk can use polar density and temperature, Doppler brightening/darkening on opposite sides, and gravitational-redshift dimming. A few dozen lines of math can produce images that do not look like obvious “procedural” artifacts.
3. Particles: instancing and temporal consistency
Large particle counts (tens of thousands of instances) work well when driven by a curl noise field: divergence-free motion avoids unphysical sources and sinks and reads more like fluid. Engineering points: instanced draw, attributes precomputed into textures, and fixed-timestep integration. Temporal consistency matters more than single-frame quality; flicker and popping ruin the piece immediately.
4. Render pipeline: anti-flicker bloom and tone mapping
HDR needs a full path: HDR target → luminance threshold → multi-level downsample blur for wide glow → temporal anti-flicker (dither/stabilization) → tone map → color-space convert. Prefer filmic or ACES-style curves over linear clipping that blows highlights to dead white. Light post (vignette, chromatic aberration, grain) also hides banding and reduces flicker.
5. Procedural audio and A/V lock
Audio is also asset-free: stacked oscillators, noise shaping, envelopes, and filter sweeps for low rumble and high grain, rendered at a fixed rate (e.g. 48 kHz) to a waveform file. Reliable sync is to drive visuals from the audio envelope: map low-frequency energy to camera shake and bloom, high-frequency energy to particle brightness, so every render stays locked.
4. Performance budget and fallbacks
State a budget explicitly, e.g. 1080p/30fps with 33 ms GPU per frame, split roughly: SDF intersection 40%, particles 20%, bloom 20%, tone map and post 10%, headroom 10%. Fallbacks should be switchable in stages:
- Drop to 720p, keep frame rate.
- Lower ray-march step caps; halve particle instances.
- Single-level bloom blur.
- Drop domain-repeat layers; use a baked noise texture.
- Extreme case: offline render—no realtime requirement; output a frame sequence and transcode.
Offline render is the most important safety net: it turns “realtime performance” into “total render time” and almost always delivers.
5. Engineering delivery and reproducibility
Suggested layout and naming:
project/├── index.html # single-page entry (runs offline)├── src/scene.glsl # scene and materials├── src/post.glsl # post and tone mapping├── src/audio.js # procedural audio├── deps.lock # locked dependencies and versions├── render.sh # render commands└── frames/f_00000.png # frames, zero-padded to six digits
Zero-padded names keep sequence order. Put export commands in a script, not only in docs, so copy-paste runs. Reproducibility is simple: in a clean environment following the docs, two renders should match frame hashes (disable randomness or use a fixed seed).
6. Evaluation dimensions and cloud-side engineering
Self-score on a five-point scale across six dimensions: visual impact, technical complexity, code quality, reproducibility, performance and stability, narrative completeness. “Truly code-only” and “reproducible” should be veto items.
When scale exceeds a single machine, generic cloud building blocks help: a container platform to parallelize render jobs, object storage for frames and masters, a message queue for dispatch and collection, logging and monitoring/alerts for failed frames and latency. Baidu AI Cloud provides these general-purpose categories so a one-off creative script can become a durable render pipeline.
7. Common pitfalls
- Mockups or pseudocode instead of a runnable implementation.
- Unlocked third-party versions and environment drift.
- Peak single-frame quality at the cost of temporal flicker.
- No fallbacks; low-end devices go black.
- Independent random audio and video so sync never holds.
- Quietly filling assets with generative APIs, violating the zero-asset rule.
The ceiling of a pure-code visual piece is aesthetic; the floor is engineering discipline. Clear constraints, layered pipelines, stated budgets and fallbacks, and frozen reproduce commands are what make intelligent coding tools produce striking results consistently.
