Building a Rainy Night 3D City with AI Coding Tools: A Practical Engineering Guide
This article explains how to use AI coding tools to build a rainy night 3D city scene, using a late-night convenience store on a wet street as the example. It covers translating vague creative ideas into measurable specs, structuring the scene in layers, fixing proportion and composition issues, rendering wet-surface reflections and rain particles, setting a performance budget, adding interactive controls, and running a multi-turn human-AI workflow. Readers will find practical config examples, rain update and auto-degradation code, and a troubleshooting checklist for common visual and performance problems.
1. Introduction: Why a Rainy Night City Tests AI Coding Tools
In real-time rendering, a seemingly simple “rainy night convenience store” scene actually tests geometry modeling, materials and lighting, particle systems, post-processing, performance budgeting, and interaction design all at once. That makes it a strong benchmark for AI coding tools, for three reasons:
- Clear constraints: Scene elements (streets, storefronts, light boxes, rain streaks, reflective puddles) have well-defined boundaries and can be split into independent modules.
- Immediate feedback: Render results are easy to judge at a glance, so proportion errors, overexposure, and stuttering show up right away.
- Frequent iteration: Atmosphere-driven scenes need repeated tuning, which directly tests the “communication cost” of human-AI collaboration.
One pattern shows up repeatedly in practice: tasks like this rarely land perfectly on the first try. Proportion, performance, and detail usually take several rounds of conversation to converge. So the real value is not “generate a perfect result from one prompt,” but establishing a stable collaboration and engineering workflow.
2. Requirements: Turning a Vague Idea into an Executable Spec
The most common mistake when describing a scene in natural language is piling up adjectives. Words like “cozy,” “cyber,” and “atmospheric” put no real constraint on the rendering engine. It works better to break requirements into four measurable categories:
- Spatial specs: street width, building floors, storefront frontage, initial camera position and field of view.
- Lighting specs: key light color temperature, brightness range, light box emissive intensity, ambient light floor.
- Dynamic specs: rain particle count, fall speed, wind offset, ground ripple frequency.
- Performance specs: target frame rate, draw call limit, triangle budget, mobile fallback strategy.
Example requirements template:
Scene: a corner of a night city street, with a convenience store at the centerComposition: camera at a diagonal across the street, 45-degree field of view, horizon in the lower third of the frameLighting: cool blue ambient light + warm white storefront emissive + street lamp point light, avoid overall overexposureDynamic: moderate rain, streaks tilted along a fixed wind direction, puddles producing reflections and ripplesPerformance: 60fps target on desktop, automatically reduce rain count and post-processing quality on mobile
Writing the idea down as a spec is the single biggest step toward communicating more efficiently with AI coding tools.
3. Scene Layering: Using Engineering Structure Against One-Shot Instability
Generating an entire codebase in one shot often produces messy, hard-to-maintain structure. A safer approach is to ask the tool to output layer by layer and verify each layer:
- Base layer: renderer, scene, camera, responsive sizing, render loop.
- Geometry layer: street, sidewalk, building blocks, store body and shelf silhouettes.
- Material layer: roughness and reflectivity differences for asphalt, concrete, glass, and metal shutters.
- Lighting layer: ambient light, point lights, emissive light boxes, plus light falloff and shadow range.
- Dynamic layer: rain particles, ground ripples, subtle light box flicker.
- Post-processing layer: bloom, tone mapping, slight depth of field and vignette.
- Interaction layer: mouse-drag camera, scroll zoom, live parameter panel.
The benefit of layering: when proportions look wrong, you only adjust parameters in the geometry layer; when the frame rate drops, you only degrade the dynamic and post-processing layers, without rebuilding everything.
4. Proportion and Composition: Where Atmospheric Scenes Usually Fail
Most rainy night scenes fail not because they look plain, but because proportions are off. Common problems and fixes:
- Buildings too tall, breaking the sense of balance: fix street width as the base unit, then derive storefront size from “frontage roughly 1.2x the street width.”
- Camera too low, smearing rain into a blur: raise the camera and tilt slightly downward so rain streaks form layers in the frame.
- Light box too large, swallowing detail: keep the emissive area within one third of the storefront facade, leaving the visual focus on the entrance.
- No distant reference: add blurred building silhouettes in the distance to noticeably improve depth credibility.
A practical trick: expose all key dimensions as adjustable variables in the parameter panel, lock in the composition through live preview, then hardcode the values.
const config = {streetWidth: 8,shopWidth: 9.6,shopHeight: 4.2,cameraFov: 45,rainCount: 12000,bloomStrength: 0.6};
5. The Core of Rainy Night Texture: Light, Reflection, and Grain
Rainy nights look good essentially because wet surfaces stretch point lights into streak highlights. Key implementation points:
- Ground reflection: use a ground material with relatively high roughness but directional reflection, plus normal perturbation to create uneven water film.
- Layered lighting: cool ambient light as the base, warm storefront as the visual anchor, street lamps as rhythmic bright points.
- Rain streaks: use thin elongated triangles or line segments with a semi-transparent material, tilted along one consistent wind direction; random directions create a “snow” look.
- Ripples and splashes: simulate with a few looping expanding ring textures or vertex perturbation; keep the count low.
- Restrained bloom: excessive bloom destroys the light box structure, so pair it with threshold filtering so only highlights spill over.
Example rain update logic:
function updateRain(dt, wind) {const pos = rain.geometry.attributes.position;for (let i = 0; i < pos.count; i += 2) {let y = pos.getY(i) - speed * dt;let x = pos.getX(i) + wind * dt;if (y < 0) { y = height; x = resetX(); }pos.setY(i, y); pos.setY(i + 1, y + streak);pos.setX(i, x); pos.setX(i + 1, x);}pos.needsUpdate = true;}
6. Performance Budget: From “It Runs” to “It Runs Smoothly”
Atmospheric scenes easily lose control over particles and post-processing. Set the budget first, then write the implementation:
- Merge draw calls: combine static geometry into a few meshes instead of hundreds or thousands of separate draws.
- Particle alternatives: use semi-transparent cards or screen-space effects for mid and far rain, reserving real particles for the foreground.
- Resolution strategy: cap render resolution by device pixel ratio on mobile, and trim the post-processing chain as needed.
- Shadow discipline: only the key light casts shadows, with limited shadow range and map size.
- Frame rate fallback: monitor frame time and automatically reduce rain count and bloom quality above a threshold.
function autoDegrade(frameMs) {if (frameMs > 22 && rainCount > 4000) {rainCount = Math.floor(rainCount * 0.7);bloom.enabled = false;}}
7. Interaction and Tuning: Turning the Work into Something Playable
The difference between a demo and a piece is playability. Three types of interaction are recommended:
- Camera interaction: drag to rotate, scroll to zoom, with pitch limits to prevent going underground.
- Parameter panel: live-adjustable rain amount, wind direction, light box brightness, and bloom strength for fast trial and error.
- State switching: one-click switching among light, moderate, and heavy rain to show performance and atmosphere differences directly.
The parameter panel is not just a debugging tool; it is also the middle layer for communicating with AI coding tools: find satisfying values in the panel first, then have the tool write them back into the default config.
8. Human-AI Workflow: Multi-Turn Convergence Instead of One Draft
A stable workflow usually has five steps:
- Build the skeleton: get a minimal runnable scene first and confirm the render pipeline works.
- Add geometry: add buildings and streets block by block, solving one structural problem per round.
- Add atmosphere: bring in lighting, rain effects, and post-processing, then check the overall color.
- Tune performance: measure on the target device and trim according to the budget.
- Lock the config: write tuned parameters back into the code and clean up redundant logic and debug output.
When communicating, give verifiable criteria, such as “the light box should have no pure white dead zones” or “rain streaks should be distinguishable in the upper half of the frame.” These work far better than “make it more realistic.”
9. Troubleshooting Checklist
- Overall gray image: ambient light too strong or a poor tone mapping curve; lower the ambient light floor first.
- Ground looks like a mirror: roughness too low, missing water film perturbation.
- Rain looks like snow: random direction, speed too slow, particles too large.
- Sudden frame rate drop: post-processing chain too long or a spike in particle count.
- Odd proportions: no consistent base unit; anchor on street width and derive from there.
- Light box loses structure: bloom threshold too low; raise the threshold and lower the intensity.
10. Conclusion
Building a rainy night city with AI coding tools is never really about “generating code.” The hard part is translating aesthetic intent into engineering constraints while keeping the structure clear across many iterations. When requirements are measurable, the scene is layered, performance has a budget, and interaction is tunable, shipping a creative idea stops being luck and becomes a repeatable process. The same method applies to other real-time 3D work: build the skeleton first, add detail next, and close with budgets and criteria, so you can reliably deliver something that runs and is fun to play with.
