Benchmarking LLM Code Generation and 3D Rendering: Where Photorealistic Lighting Falls Short
This article examines two practical benchmarks for evaluating code-generating models: an animated SVG of a pelican riding a bicycle, and a pure-code rendering of afternoon interior lighting. It explains why the SVG task still works as a regression test, how to verify offline self-containment, the tradeoffs between real-time rasterization, CPU path tracing, and hybrid rendering, and why lighting transitions decide the outcome. It also provides reusable validation scripts, prompt templates, a three-layer evaluation set, and engineering recommendations for reproducible testing.
1. Why “Draw a Pelican Riding a Bicycle” Is Still a Useful Benchmark
In the capability map of generative models, SVG animation generation is a classic problem that keeps getting reused. Its value has nothing to do with whether the picture looks good; it compresses four classes of constraints at once: structured output (closed tags, correct namespaces), geometric reasoning (two wheels must be tangent to the ground, the frame must connect), a time dimension (the animation must actually move), and an interaction dimension (parameters must be controllable). If any one of them fails, the scene collapses immediately.
Early on, the output was completely unusable. Today most models produce something structurally sound, so the benchmark’s discriminating power has genuinely declined. It is still good material for regression testing: cheap, objectively judged, and easy to automate. A workable checklist looks roughly like this:
1. Structural validity: the XML parses, with no unclosed tags2. Geometric plausibility: equal wheel diameters, sensible wheelbase, pedals coaxial with the crank3. Animation validity: transform/animate elements exist and the timeline is self-consistent4. Interaction completeness: speed, play/pause, and day/night toggle controls all work5. Offline self-containment: no external fonts, images, or scripts; runs with the network down6. Acceptable performance: first-frame time, DOM node count, and repaint frequency within budget
In testing, one strong output was a pelican in a red hat riding along a coastline: the wheels kept spinning, the scarf streamed backward, and three controls were provided for pausing, adjusting cadence, and switching between day and night. After raising the speed to 1.75x and exporting it as a standalone file, the animation still ran smoothly in a fully disconnected environment. This point is often overlooked, yet it determines whether the artifact can go into production.
2. Offline Self-Containment: The Most Underrated Engineering Advantage of SVG
Many teams focus only on “does it look right” and ignore the delivery format. The core advantage of vector animation is self-containment: geometry, styling, and scripts all live in a single text file, with no network dependency and no runtime environment dependency. The size is typically on the order of tens of KB, and it can be embedded directly into documents, emails, or offline demos.
In engineering terms, it is worth adding an automated check that turns “can it run offline” into a measurable metric:
import re, xml.etree.ElementTree as ETdef check_svg(path):src = open(path, encoding="utf-8").read()ET.fromstring(src) # structural validityexternal = re.findall(r'(?:href|src)="(https?://[^"]+)"', src)has_anim = "<animate" in src or "<animateTransform" in srcreturn {"external_refs": external, "has_animation": has_anim,"size_kb": round(len(src.encode())/1024, 1)}
As long as external_refs is non-empty, the artifact degrades to a static image under an isolated network. The rule is simple, but it filters out a large number of pseudo-artifacts that merely “look like they run.”
3. Photorealistic Lighting in Pure Code: The Difficulty Is Physics and Noise, Not Syntax
The second test raises the difficulty by an order of magnitude: draw a scene of interwoven afternoon light and shadow using code alone, without calling any assets. This kind of task tests not API recall but understanding of the rendering equation and engineering patience.
Three implementation routes are common in the industry, each with clear tradeoffs.
- Real-time rasterization: build the scene with a graphics API such as WebGL, assemble walls, floors, and furniture from triangles, and approximate shadows with Shadow Mapping or screen-space techniques. The advantage is output in seconds and interactivity; the drawback is the absence of global illumination, so contact shadows and penumbra regions tend to look wrong.
- Pure CPU path tracing: hand-write ray casting, material sampling, and Monte Carlo integration in a language such as C++, accumulating samples over a long time until noise converges. The advantage is physical correctness and natural light-to-dark transitions; the drawback is high implementation complexity and render times measured in hours.
- Hybrid route: use real-time preview to lock in composition, then render the final frame offline. This is the most common compromise in production.
The minimal skeleton of a path tracer can be summarized as “camera emits - intersect - sample - recurse.” Pseudocode:
Color trace(Ray r, Scene& s, int depth) {if (depth > kMaxDepth) return Color(0);Hit h = s.intersect(r);if (!h.hit) return s.background(r);Color em = h.mat.emission;Color albedo; Normal n; s.sample(h, albedo, n); // diffuse/specular samplingRay next = h.point + n * 0.001f; // avoid self-intersectionreturn em + albedo * trace(next, s, depth + 1);}
What really determines the quality of the finished image is a handful of easily overlooked details:
- Sampling and denoising. Monte Carlo variance falls linearly with sample count, and dark regions and indirect-light areas need multiples of that count; only with stratified sampling and reconstruction-based denoising can it converge in acceptable time.
- Color gamut and tone mapping. Compute in linear space, output to sRGB, and pair it with a soft tone-mapping curve; only then do window-side highlights avoid clipping and indoor shadows avoid crushing to black.
- The “area feel” of the light source. The sharpness of window-pane projections depends on the light’s angular size. Real afternoon sunlight is close to a parallel light, so edges should soften slightly; hard black edges usually mean it was treated as a point light.
- Materials and contact shadows. The floor inlay needs texture and roughness variation, and the potted plant needs subsurface scattering plus two-sided leaf scattering; without contact shadows, objects look like a “freshly built set” with an obvious floating feel.
4. Why Evaluations Are Always Decided at Light-to-Dark Transitions
Put the two routes side by side and the gap does not appear in “did it draw a room.” It appears in whether the transition from the bright window side to the dark interior is continuous. Three quantifiable dimensions sit behind this.
- Dynamic range and transition smoothness: run block statistics over the luminance histogram and check whether adjacent block means show a break.
- Residual noise: compute local variance in flat wall regions; high variance indicates too few samples or over-smoothed denoising.
- Physical consistency: whether shadow direction matches the light source, whether occlusion relationships are correct, and whether reflections satisfy the angle of incidence equals the angle of reflection.
A lightweight automated scoring idea:
def block_luma_gap(img, grid=8):h, w, _ = img.shapemeans = [[img[i*h//grid:(i+1)*h//grid,j*w//grid:(j+1)*w//grid].mean()for i in range(grid) for j in range(grid)]means.sort()return max(b - a for a, b in zip(means, means[1:]))
The smaller block_luma_gap is, the more continuous the luminance distribution. It cannot replace human review, but it is enough to stop degraded versions with “local overexposure plus crushed blacks” in regression testing.
5. Reproducible Prompts and Evaluation Set Design
For evaluation conclusions to be credible, the variables must be controlled. Split the prompt into three parts - goal, constraints, and acceptance criteria - and fix the random seed and runtime environment.
Goal: draw an afternoon indoor lighting scene with code, without referencing any external assetsConstraints: single-file delivery; compute in linear space; the light source has an area sizeAcceptance: window-pane projection edges soften slightly; wall luminance forms a continuous gradient; the floor has contact shadows
Build a three-layer evaluation set to go with it: a structural layer (does it parse, does it run offline), a physical layer (luminance gradient, noise, occlusion consistency), and an aesthetic layer (blind scoring by multiple people, taking mean and variance). Only when all three layers pass is it “usable”; when only the aesthetic layer passes, it usually means the model is “guessing the picture” rather than “computing the physics.”
6. Engineering Recommendations
- Prefer vector or single-file delivery formats, and write offline self-containment into the acceptance checklist.
- Layer the rendering tasks: real-time preview for interaction and composition confirmation, offline rendering for the final output, with both sharing the same scene description.
- Put long-running renders into an asynchronous task queue, store intermediate artifacts and final outputs in object storage, and track failure rates and duration distributions with logging and monitoring alerts, with a container platform hosting the stateless front-end preview service.
- Maintain a version mapping between prompts and artifacts, so any conclusion can be traced back to the specific input and environment.
- If you use cloud compute, tier it as “elastic instances for preview, high-compute instances for final renders” to avoid paying offline rendering costs for interactive debugging.
7. Conclusion
The dividing line in code generation capability has shifted from “can it generate” to “can it compute correctly.” Vector animation tests structure, geometry, and self-containment; pure-code photorealistic rendering tests physics, sampling, and color management. When evaluating, decompose subjective aesthetics into measurable luminance gradients, noise levels, and occlusion consistency, then add offline runnability as a hard metric. Hard-code this set of criteria into CI, and the gains and regressions from model iterations both become visible in time.
