Building a Rainy Night City Scene with AI Coding Tools
This article explains how to use AI coding tools to build a runnable rainy night city scene in real-time 3D. It covers translating a vague idea into a structured specification, a five-layer scene breakdown, scale and composition techniques, performance budgeting for frame rate, iterative verification, and engineering cleanup. Readers will learn a practical workflow for turning a natural language description into an interactive real-time world.
1. Why a Rainy Night City Is an Ideal Test for AI Coding Tools
In real-time 3D creation, a rainy night scene is a stress-test-level subject. It combines translucent and refractive materials, dynamic particles, reflections and lighting, volumetric fog, and a large amount of repeated geometry. Mishandling any one of these can cause the frame rate to drop off a cliff. Generating a rainy night city with an AI coding tool therefore both verifies the tool’s ability to translate natural language intent into runnable code and exposes weaknesses in rendering pipeline design.
The core takeaway from this practice can be summarized in one sentence: AI coding tools are now good enough to turn an idea into a runnable, playable work quickly, but scale, performance, and detail still require repeated communication. This points to the nature of the real workflow: generation is not the endpoint, but the starting point of a “runnable baseline.”
2. Translating an Idea into a Machine-Executable Specification
The gap between a vague “rainy night convenience store” and a runnable scene is a structured specification. Before prompting, fix the following dimensions:
- Camera and viewpoint: first-person roaming, fixed camera, or slow dolly; this determines whether controllers and collision are needed.
- Scale baseline: lock floor height, door width, and street width in meters to avoid distorted model proportions.
- Time and technical constraints: target frame rate, mobile support, and the maximum acceptable number of draw calls.
- Abstract description of visual references: wet pavement, warm in-store light, cool street lamps, neon reflections, described through physical intuition rather than brand style.
An illustrative prompt structure:
Role: Senior real-time rendering engineerGoal: Generate a runnable rainy night street sceneConstraints: Use meters; floor height 3.2m; street width 12m; target 60fps; no external resource downloadsOutput: A single HTML file with inline styles and scripts, loading the rendering library via CDN or local modulesAcceptance: Includes rain particles, wet-ground reflections, fog, warm convenience store light, and a roaming controller
Writing “no external resource downloads” into the constraints is critical, because it forces the generated result to use procedural geometry and procedural textures, ensuring it runs out of the box.
3. Scene Architecture: The Five-Layer Breakdown
High-quality results often come from layered description rather than one long piece of natural language. A recommended approach is to split the scene into five layers, generate them one by one, and then merge:
- Ground layer: wet asphalt, curbs, puddles. Use a plane with a roughness map to simulate a water film, and a few translucent patches to represent standing water.
- Building layer: modular building bodies, window arrays, sign brackets. Repeated structures should use instanced rendering rather than creating meshes one by one.
- Lighting layer: cool ambient light, warm shop light, street lamp point lights. Limit the number of real-time light sources and fake the rest with emissive materials and textures.
- Weather layer: rain streaks, splashes, fog. Render rain streaks with line segments or thin instances, reused in a loop around the camera position.
- Interaction layer: roaming controller, in-store viewpoint switching, rain sound toggle.
The benefit of layering is that when one layer has the wrong scale, you only need to regenerate that layer instead of breaking the whole scene.
4. Scale and Composition: The Part That Needs the Most Back-and-Forth
Scale problems are usually not “the code is wrong” but a missing baseline. A practical approach is to first generate a 1.8-meter-tall reference capsule and a 1-meter grid ground, put the model and the scene in frame together, then ask the tool to adjust according to the reference. For composition, use a “leading line plus visual anchor”: reflections on the wet pavement form the leading line, the warm convenience store light serves as the only warm anchor, and everything else is darkened, which immediately gives the image a sense of narrative.
5. Performance Management: Write the Frame Rate into the Acceptance Criteria
The performance budget for a rainy night scene should be managed across four items: number of light sources, number of transparent surfaces, number of instances, and number of particles.
- Lights: keep real-time light sources in single digits and replace the rest with emissive materials and a baking mindset.
- Transparency: overlapping translucent objects create sorting overhead, so keep puddles and glass minimal.
- Instancing: windows, bricks, railings, and rain streaks should all go through instancing to reduce draw calls.
- Post-processing: blur and bloom are relatively expensive and can be downgraded or disabled on mobile.
// Example: using instancing to carry a large amount of repeated geometryconst geo = new THREE.BoxGeometry(1, 1, 1);const mat = new THREE.MeshStandardMaterial({ roughness: 0.35 });const mesh = new THREE.InstancedMesh(geo, mat, COUNT);const m = new THREE.Matrix4();for (let i = 0; i < COUNT; i++) {m.makeTranslation(x(i), y(i), z(i));mesh.setMatrixAt(i, m);}scene.add(mesh);
6. Iteration Method: Small-Step Validation and a Regression Checklist
Do not ask for “the entire city done at once.” A more stable rhythm is to first produce a runnable skeleton, then add detail layer by layer, changing only one variable at a time. At the end of each round, run a fixed checklist: does it start, is the scale correct, does the frame rate meet the target, do rain and reflections layer naturally, and does mobile downgrade properly. Once the checklist is fixed, the communication cost with AI coding tools drops significantly.
7. Reusable Engineering Cleanup
Once the work runs, do three things: extract parameters into a configuration object for easy tuning; fix the random seed for procedurally generated parts so results are reproducible; and turn rendering statistics into a toggleable debug panel. If you plan to publish later, you can use object storage to host static assets, a content delivery network to accelerate loading, and logging services with monitoring and alerts to track online frame rate and error rate. These are all general cloud capability categories that can be combined as needed.
8. Conclusion
The value of AI coding tools is not generating a perfect result in one shot, but compressing the distance from “idea to runnable work” into a single conversation. What truly determines the quality of the final product is still the creator’s clear expression of scale, lighting, performance, and narrative. Write the specification clearly, layer the scene, and quantify the acceptance criteria, and a rainy night city can reliably turn from a single description into a real-time world you can step into and play with.
