Recreating Key Lento from GTA VI in Blender with Python
2026-12-04
After reading ben3d's breakdown of GTA VI's graphics pipeline, I wanted to build a partial recreation of Key Lento from GTA VI's Leonida Keys and step through the same eight rendering stages in Blender 5.3 and Cycles. The constraint I set for myself was simple: apart from small CC0 decorative props from Poly Haven, nothing would be modeled by hand. Every structure, bridge, shoreline, boat, tree, and light would come from Python scripts.
The interactive showcase—with the 60-second film, stage build-up cut, interactive eight-pass stepper, raw-vs-graded sliders, and all 20 1440p stills—is live at gta6.dhaiwat.com, and the full script pipeline is on GitHub.
Building the assets from Python
Generating a whole coastal environment with Claude Code agents falls apart quickly if each script invents its own coordinates, units, or material names. Before writing any geometry, I pinned down a single written contract (SCENE_SPEC.md): meters everywhere, sea level at z = 0, the highway centerline along y = 0, an analytic elevation curve road_z(x) climbing from 2.0 m on land to a 9.0 m bridge crest, shoreline polygons, lighting presets, and naming conventions for collections and lights.
From that spec, fourteen standalone generator scripts (build_terrain.py, build_highway.py, build_viaduct.py, build_shop.py, build_dock.py, build_houses.py, build_marine.py, build_palms.py, build_vegetation.py, and so on) each build a self-contained .blend library from an empty scene, render multi-angle previews, and iterate until the silhouette and surface weathering hold up. Every emissive material multiplies its strength by a shared LIGHTS_ON node and every light object lives in an LGT_* collection, so flipping between midday and dusk is a single switch during assembly.
assemble.py pulls all fourteen libraries into scene/keys_scene.blend, places boats, props, power lines, and cameras, runs the scatter passes, and audits the finished scene for floating or buried objects. The assembled file holds 2,104 objects, 69,985 mesh instances, and roughly 1.50 billion rendered triangles.
Terrain, water, and vegetation
One NumPy height function defines both limestone keys, the dredged boat basin, the 6.5 m deep main tidal channel, the bay-side seagrass flats, and the ocean sandbar spit. Generating the terrain mesh, the closed water mesh, and all land-cover shading masks from that same function keeps shorelines crack-free without manual sculpting:
- Adaptive terrain mesh: 2.07 million triangles with 0.31 m edge spacing around the hero cameras, stepping coarser out toward the horizon keys.
- Physical water absorption: A single closed 1.23M-triangle water mesh with IOR 1.33 refraction and a real absorption volume inside. Because red wavelengths attenuate over 20× faster than blue, white carbonate sand shifts naturally through pale aqua and turquoise into deep channel blue. An FFT wave-spectrum slope tile layered onto the displaced mesh breaks low sunlight into wind-ruffled glitter.
- Mask-driven Geometry Nodes scatter: 56 base foliage models (44 coastal plants and 12 palms) are instanced across ~67,000 points driven by elevation and shoreline masks, with per-instance scale, tilt, and hue/value variation so the mangrove belts and roadside scrub stay within 24 GB of unified memory.
Skies, lighting, and trade-offs
Each camera renders across three distinct setups: midday (58° sun), golden hour (7° sun over the bay), and blue-hour dusk (−5° sun with 121 emissive neon tubes, festoon bulbs, street lamps, and area fixtures switched on). By day, the sky is a Poly Haven CC0 photograph with its sun painted out so a calibrated 0.55° sun lamp casts crisp contact shadows under palm fronds that soften with distance. Golden hour and dusk use procedural gradient skies with three cirrus layers and an earth-shadow / Belt of Venus twilight band.
A few things looked worse when simulated physically and were cut on purpose. I generated and tested volumetric OpenVDB cumulus clouds, then dropped them because they read as synthetic in wide aerial shots. Seabed caustics stayed as a procedural pattern in the sand shader rather than refractive photon paths, and selected 2K texture maps were halved during assembly to keep peak render memory comfortable on a 24 GB MacBook Pro.
Post-processing and remote GPU rendering
Every camera renders raw to a compact multilayer EXR rather than baking the grade into the render. Blender writes data passes (depth, normals, roughness) as float32 even when half-float is selected, inflating a 2560×1440 EXR to ~137 MB; a post-write compaction script rewrites those data passes to half-float and brings files down to ~68 MB. A headless compositor then applies exposure trim, energy-conserving bloom, sun flare, halation, selective cyan-teal saturation, split toning, vignette, and luminance-weighted grain in scene-linear space before AgX—taking 1.9 seconds per 1440p frame and outputting all eight cumulative render stages for the interactive breakdown and build-up film.
Local 1440p stills took 87–313 seconds per frame on an M4 Pro (Metal). At 55.5 seconds per 1080p frame, rendering the 60-second film (1,464 frames including dissolve handles, 128 samples, physical motion blur) on the laptop alone would have taken ~23 hours. Instead, I wrote a small SSH/rsync kit in scripts/remote/ to bundle dependencies, assign whole unstarted shots to two rented RTX 4090s (avoiding mixed device noise inside a shot), and verify Metal-vs-OptiX parity across three reference frames within ±1% per channel. The 4090s ran at 8–10 seconds per frame per card, finishing the main film in 1 hour 56 minutes—$5.72 in total GPU rental including the extra build-up passes and tests.