Building a Rainy Night City Scene with AI Coding Tools
This article explains how to use AI coding tools to build a real-time rainy night city scene, focusing on the engineering workflow rather than raw code generation. It covers turning creative ideas into a structured scene checklist, using layered prompts instead of long natural-language descriptions, and making key rendering tradeoffs for reflections, transparency, and particle systems. It also details quantitative performance budgeting, a debug loop based on measurable feedback, and a final acceptance checklist for scale, lighting, performance, interaction, and compatibility.
1. Why a Rainy Night City Is an Ideal Test of AI Coding Ability
The rainy night theme often shows up in real-time 3D demos not simply because it looks good, but because it stresses nearly every fragile part of the rendering pipeline at once: alpha blending, dynamic lights, particle systems, post-processing, material reflections, and instanced drawing of many small objects. A sunny white-box scene can run with basic lighting alone, but a rainy night scene quickly slides into three typical failure states—washed out, muddy, and dirty—if it lacks unified color management and an exposure strategy.
So when you try to turn an idea like a “rainy night convenience store” into a runnable piece with AI coding tools, the real test is not whether the model can write hundreds of lines of rendering code in one shot. It is whether the developer can translate a vague aesthetic request into machine-executable constraints. The “not getting it right in one pass” mentioned in the original experience is a direct reflection of this translation loss: wrong proportions, tight performance, and missing detail are often not a lack of generation ability, but a lack of measurable acceptance criteria in the requirement description.
2. Breaking the Idea into an Executable Engineering Structure
1. Write a Scene Checklist Before Writing Code
Before any generation action, produce a structured checklist with at least four categories of information:
- Spatial scale: street width, building floor height, convenience store frontage and depth, and the proportions between characters and shelves;
- Lighting setup: key lights (signage, light boxes), fill lights (street lamps, car headlights), and ambient light (night sky);
- Material categories: wet asphalt, tiled ground with a water film, glass, metal shutters, and plastic packaging;
- Dynamic elements: rain streaks, ripples in ground puddles, flickering signs, and pedestrian silhouettes.
The value of this checklist is that it turns a subjective word like “atmosphere” into verifiable items. Each later generation round can then make a targeted fix on one item in the checklist instead of rewriting everything.
2. Replace Long Natural Language with Layered Prompts
In practice, pasting a long description all at once often leaves the model unable to grasp the key points. A more stable approach is layered description in a fixed order: camera and composition → subject and proportions → materials and lighting → dynamics and interaction → performance constraints. Example:
Camera: fixed position, slightly low angle, 35-degree front-side view toward the store entranceSubject: single-story convenience store, 6 m frontage, 8 m depth, 2.2 m door heightMaterials: wet, highly reflective ground; semi-transparent glass with slight smudgesLighting: warm white light box as key light, cool blue ambient fill, no strong shadowsDynamics: moderate rain, droplets sliding down the glass, fine ripples in puddlesConstraints: keep draw calls under 120, usable at 30 FPS on mobile
A fixed order significantly reduces back-and-forth rework, because the model is less likely to miss key constraints when the description goes from structure to detail.
3. Key Tradeoffs at the Rendering Level
1. Reflections and Wetness: Prefer “Approximate” over “Physically Correct”
The most striking element of a rainy night is ground reflection. In engineering, there is usually no need for strict physical simulation; instead, use planar or screen-space reflections combined with a roughness map for an approximation. If performance is tight, it can degrade to “reflection decals + fade mask,” which still holds up visually. The key is to make reflection intensity and roughness adjustable parameters so they can converge dynamically against the frame-rate budget.
2. Transparency and Blending Order
Glass, rain curtains, and light-box halos are all semi-transparent. They are the most likely to cause sorting errors and over-blending that leads to overexposure. A unified strategy is recommended: put semi-transparent objects in a separate layer, disable unnecessary depth writes, and use additive blending for halos with a limited layer count. A practical approach is to hard-code the halo layer count as a constant, avoiding infinite-blending loops in generated code.
3. Controlling the Cost of Particle Systems
Rain streaks are usually implemented with many thin instances or line segments. What really determines performance is not the upper limit on count, but the update method: evaluating raindrop positions in the shader as a time-based function saves a large amount of per-frame CPU computation. Example code:
// Loop falling based on time in the vertex shader, avoiding per-frame CPU array updatesfloat y = mod(position.y - uTime * uSpeed, uHeight);vec3 p = vec3(position.x, y, position.z);
This idea of “moving logic into the GPU” is the dividing line for whether a long-shot rainy night scene can run stably.
4. Quantitative Management of the Performance Budget
Do not wait until the visuals are done to measure frame rate. Set a budget table at the start, for example with upper limits on draw calls, total triangle count, number of transparent layers, number of post-processing passes, and VRAM usage. After each generation round, check each item; if over budget, first downgrade the least sensitive item (usually distant detail and reflection precision).
Post-processing in particular needs restraint. Bloom, tone mapping, and slight chromatic aberration together are enough to carry the night tone; adding depth of field and motion blur on top usually yields little benefit for a clear cost. Mobile scenes can keep only tone mapping and lightweight bloom.
5. The Interaction and Debug Loop
Playability comes from a few but clear interactions: warm light leaking through the door gap when it opens, a sensor light turning on as you approach, and clicking the sign to switch colors. In implementation, abstract these interactions into a three-part set of “trigger + state variable + transition curve,” avoiding hard-coding logic into the render loop.
For debugging, build a “reproducible minimal case.” When one generation round produces distorted proportions, do not vaguely say “optimize it again”; instead, point to the specific object and expected value, for example “the shelf height should be 1.8 m, currently about 2.6 m.” Measurable feedback can improve convergence speed several times over.
6. Delivery Acceptance Checklist
- Proportions: the proportional relationships among characters, door, and shelves are correct;
- Lighting: key and fill light layers are distinguishable, with no large dead-black or overexposed areas;
- Performance: frame rate meets the target device, and draw calls are within budget;
- Interaction: all trigger states can be reset with no residual state;
- Compatibility: composition and UI stay within bounds after window resizing.
7. Conclusion
Building a rainy night city with AI coding tools is never really about the amount of code, but about the ability to engineer aesthetic intent. Once the scene is broken into a checklist, prompts are layered, performance is quantified, and feedback is measured, “repeated communication” turns from a drain into a convergence process. This is the most worthwhile methodology to take away from this kind of practice: letting creativity land in a verifiable way instead of staying in descriptions.
