Code-Generated Visuals: A Technical Path for Using LLMs to Rebuild Presentations
This article breaks down how to turn presentations into programmable, real-time rendered scenes driven by large language models. It covers a four-layer architecture, prompt-to-constraint compilation, cinematic camera and transition techniques, procedural audio, interaction state machines, performance budgets, accessibility, and evaluation, showing how teams can reliably turn "stunning" demos into deliverable systems.
1. The Engineering Problem Behind the Buzz
A recent demo—described as entirely code-generated, interactive, and featuring cinematic camera work—sparked wide discussion. Stripping away the specific product and the hype, it raises a general engineering question: can the medium of a presentation shift from a stack of static slides to a programmable, real-time rendered, interactive scene timeline?
Traditional presentation tools are built around the slide: slides are connected by transitions, elements are text boxes, charts, and images, and the output is a static raster or simple vector. A code-driven approach replaces that core abstraction with scene + timeline + render loop, where a page is just an interval on the timeline. This shift yields three direct benefits:
- Expression expands from 2D layout to 3D space, camera movement, and particle systems;
- Interaction expands from “click to advance” to “select any object and intervene at any moment”;
- Asset dependency shifts from external images/video to procedural generation, giving tighter control over size, licensing, and consistency.
It is worth stressing that these capabilities do not depend on visual generation models. The large language model outputs structured code and parameters; the actual frames are drawn by the browser or a rendering engine. Understanding this is the prerequisite for reproducing the effect.
2. Overall Architecture: Four Decoupled Layers
Split the system into four layers that communicate through explicit data contracts, avoiding coupling “content” and “rendering” in one giant file.
- Content layer: a structured script (JSON/YAML) describing chapters, key points, data, and narration.
- Director layer: the model compiles the script into a “shot list,” deciding each shot’s duration, camera position, focus object, and transition type.
- Rendering layer: a general-purpose 3D/vector rendering library draws frame by frame, managing geometry, materials, lighting, and post-processing.
- Interaction and audio layer: ray picking, state machine, timeline control, and procedural audio synthesis.
A sample script structure:
{"title": "Seven Stages of the Intelligence Explosion","duration": 42,"scenes": [{"id": "s1", "type": "camera_flythrough", "focus": "earth", "hold": 6},{"id": "s2", "type": "data_growth", "focus": "chart", "hold": 8}],"transitions": [{"from": "s1", "to": "s2", "kind": "dolly_zoom", "ms": 900}]}
The director layer’s shot list is closer to executable instructions:
const shots = [{ scene: 's1', camera: { from: [0, 2, 12], to: [0, 1.2, 6], ease: 'inOutCubic' } },{ scene: 's2', camera: { from: [0, 1.2, 6], to: [3, 3, 9], ease: 'outExpo' }, transition: 'dolly_zoom' }];
3. Prompts and Compilation: Turning “Taste” into Verifiable Constraints
The most instructive part of the original is that the prompt specified no visual style or assets—only the goal, mood, and degree of freedom. In engineering terms, this “open-ended authorization” can be split into three constraint types that balance surprise with control:
- Goal constraints: topic, audience, duration, and required information points;
- Style range: offer 2–3 acceptable aesthetic directions rather than a single answer, e.g., “minimal grid / deep-space realism / retro terminal”;
- Hard constraints: performance budget (target frame rate, max triangle count), accessibility (contrast, minimum font size), and no external assets.
A reusable prompt skeleton:
You are a presentation director and graphics engineer. Compile the following into an interactive real-time scene.Topic: {topic}; duration: {seconds}; audience: {audience}Choose a style within this range: {style_a | style_b | style_c}Hard constraints: target {fps}fps; no external assets; audio synthesized in code; provide a fallback path.Output: scene list + shot list + resource budget table + interaction notes.
The key engineering habit is to have the model produce a resource budget table before writing rendering code, explicitly quantifying “triangle count, texture size, particle count, number of post-processing passes,” so performance problems surface at compile time rather than at runtime.
4. Rendering and Transitions: Making Camera Language Computable
The cinematic feel comes from three things: continuous camera movement, reasonable depth of field and motion blur, and “match cut” transitions. All can be parameterized:
- Camera work: define camera paths with spline curves and control acceleration/deceleration with easing functions to avoid the mechanical feel of linear motion;
- Depth of field and blur: simulate a real lens with focus distance and aperture, and approximate motion blur with accumulated sampling;
- Transitions: use the “selection box” from office software as a visual motif, scaling the selected object from text → chart → planet → the entire frame, forming a narrative thread of “the slide rewriting itself.”
function easeInOutCubic(t) { return t < 0.5 ? 4*t*t*t : 1 - Math.pow(-2*t + 2, 3) / 2; }function sampleCamera(shot, t) {const k = easeInOutCubic(Math.min(Math.max(t, 0), 1));return lerpVec(shot.camera.from, shot.camera.to, k);}
5. Procedural Audio: Keeping Picture and Sound from the Same Source
Without external audio assets, you can synthesize with general audio interfaces: use oscillators to generate a harmonic pad, use noise and envelopes to simulate whoosh transition sounds, and use a beat grid to align transition moments to bar lines. The engineering key is a unified clock: the render timeline and audio scheduling share the same time base to avoid audio-visual drift.
function whoosh(ctx, at, dur = 0.45) {const src = ctx.createBufferSource();src.buffer = noiseBuffer(ctx, dur);const filter = ctx.createBiquadFilter();filter.type = 'bandpass';filter.frequency.setValueAtTime(400, at);filter.frequency.exponentialRampToValueAtTime(4000, at + dur);const gain = ctx.createGain();gain.gain.setValueAtTime(0.0001, at);gain.gain.exponentialRampToValueAtTime(0.25, at + dur * 0.4);gain.gain.exponentialRampToValueAtTime(0.0001, at + dur);src.connect(filter).connect(gain).connect(ctx.destination);src.start(at);}
6. Interaction Design: From Page Flipping to “Intervenable Time”
Once a presentation becomes an interactive virtual space, interaction design must answer three questions: when can the user intervene, what state does the intervention change, and how do they return to the main line. The recommended approach is to maintain an explicit state machine: playing / paused / inspecting / free_camera. In any state, selecting an object only changes the “focus and camera target” and does not rewrite the script data, ensuring the presentation can be “recalled” at any time.
const State = { PLAYING:'playing', PAUSED:'paused', INSPECT:'inspecting', FREE:'free_camera' };function onPick(obj, state) {if (state.mode === State.PLAYING) state.mode = State.PAUSED;state.focus = obj.id;state.mode = State.INSPECT;}
7. Performance Budget and Fallback
The biggest risk in real-time rendering is device variance. Write the budget in at design time and adapt at runtime:
- Budget example: target 60fps, main scene within 80k triangles, within 5k particles, no more than 3 post-processing passes;
- Adaptation: when frame time exceeds budget consecutively, disable motion blur, lower sampling, then switch to a vector fallback version;
- Resource strategy: prioritize procedural geometry, generate textures on demand and cache them, and avoid building all scenes at once.
function adapt(perf, quality) {if (perf.avgFrameMs > 22 && quality > 0) return quality - 1;if (perf.avgFrameMs < 14 && quality < 2) return quality + 1;return quality;}
8. Accessibility and Engineering Delivery
Showing off must not come at the cost of readability. Hard constraints should include: body text and background contrast no lower than general accessibility recommendations, a minimum font size, disableable motion (respecting the system’s reduced-motion preference), keyboard operability, and a purely static export for printing and email distribution. On the engineering side, put the “script—shot list—render package” under version control, use automated screenshots for visual regression, and use frame-time distributions for performance regression.
On deployment and operations, you can close the loop with general cloud capabilities: use object storage to host build artifacts, a content delivery network to reduce first-screen latency, a container platform to run the build pipeline, logging and monitoring/alerting to track render error rates and frame-time metrics, and a message queue to decouple “generation tasks” from “rendering tasks.” These are all common industry categories; choose based on your own scale and compliance requirements.
9. Evaluation: Does “More Stunning” Equal “More Effective”?
Build a three-dimensional evaluation: expressiveness (do camera work and transitions serve the information), clarity (can key information be recognized within 3 seconds), and robustness (is it still readable on low-end devices and with motion disabled). Introduce small-scale user testing that records time-to-first-understanding and recall accuracy, rather than looking only at visual scores.
10. Conclusion
What is truly reusable from this much-discussed work is its methodology: treat the presentation as a programmable real-time system, drive the shot list with a structured script, generate picture and sound with code, ensure robustness with budgets and fallback, and hold the line with accessibility. The large language model plays the compiling role of “director + graphics engineer,” while the frames are always produced by a general rendering pipeline. Master this layered, constraint-driven approach, and teams can build their own interactive presentation generation capability on general cloud infrastructure such as Baidu AI Cloud, reliably turning “stunning” into “deliverable.”
