Building a Rainy Night City with AI Coding Tools: A Practical Guide
This article walks through building a rainy night city scene with AI coding tools, using it as a case study for turning creative ideas into runnable web prototypes. It covers breaking the scene into modules, writing structured prompts, implementing reflections, rain, fog and lighting, managing performance budgets, and iterating through small verifiable steps with an acceptance checklist.
1. Introduction: Why a Rainy Night City Tests AI Coding Tools
In 3D graphics and creative coding, a rainy night street scene is widely regarded as a difficult subject. It simultaneously tests geometric modeling, materials and lighting, particle systems, post-processing, and real-time performance control. When developers try to use AI coding tools to turn a mental image directly into a runnable web scene, they often find that the chance of getting it right in one pass is low: proportions, performance, and details all require repeated discussion and refinement.
This illustrates a core point: the value of AI coding tools is not “thinking for you” but “helping you try faster.” They compress the time from idea to runnable prototype down to minutes, letting developers focus their energy on aesthetic judgment and engineering trade-offs. Using the construction of a rainy night city as an example, this article abstracts a reusable methodology.
2. Requirement Breakdown: Translating “a City” into Engineering Language
In natural language, “a rainy night city” is vague, and a machine cannot understand it in one pass. The professional approach is to do a structured breakdown first, decomposing the image into several modules that can be implemented and accepted independently:
- Scene skeleton: ground, roads, building blocks, skyline, to establish scale and composition.
- Core focus: the convenience store as a “visual anchor,” serving as the narrative and light source center.
- Atmosphere system: rain, fog, wet ground reflections, neon and warm light contrast.
- Interaction layer: camera roaming, view switching, and playable detail feedback.
- Performance budget: polygon count, draw batches, particle count, resolution, and frame rate targets.
After the breakdown, define “acceptance criteria” for each module, for example whether building proportions match real street scale, whether rain is continuous without jumps, and whether low-end devices can maintain a playable frame rate. Setting acceptance criteria upfront is key to avoiding repeated rework.
3. Prompt Organization: Getting Stable, Runnable Code from the Model
Communicating with AI coding tools is essentially writing a “specification.” A high-quality prompt usually contains a four-part structure:
- Role and goal: make clear this is a single-page runnable scene based on a general-purpose 3D rendering library.
- Technical constraints: specify the rendering paradigm, coordinate system, unit scale, and performance limits.
- Module list: enumerate the breakdown above item by item, with priorities marked.
- Output format: require complete runnable code with comments on key parameters.
A sample prompt skeleton is as follows:
Goal: a single-page runnable 3D rainy night street scene with a convenience store, wet pavement, and rain.Constraints: right-handed coordinate system, 1 unit = 1 meter; street width 8 meters;building height 6~12 meters; particle limit 5000; target frame rate 60fps;no external large textures allowed.Modules: ground reflection, rain, fog, neon, warm light, camera roaming.Output: complete code + key parameter notes + list of adjustable items.
The benefit of this approach is that it turns “feel” into “measurable constraints,” which significantly improves the stability of model output and reduces rework rounds.
4. Implementation: Progressing Layer by Layer from Blocks to Atmosphere
4.1 Proportions and Composition First
Start with the simplest blocks to build the street and building masses, confirm perspective and scale, then move into details. The rule of thumb is “grayscale before materials; large forms before small parts.” Once proportions are wrong, all subsequent lighting and reflections will be distorted.
4.2 Reflection Logic for Wet Pavement
The core of the rainy night texture comes from ground reflections. The common approach is to use planar reflections or screen-space reflections as an approximation, combined with a roughness map to create the layered look of “patchy standing water.” Note that reflection intensity should be linked to light source brightness to avoid overall overexposure.
4.3 Layering Rain and Fog
Rain is not a single layer of particles, but a three-layer stack of “large near-field raindrops + mid-field rain streaks + distant fog.” Fog compresses depth of field, hides distant boundaries, and reduces rendering load, making it a win-win for both performance and aesthetics.
4.4 Light-Color Contrast and Visual Anchor
The convenience store uses warm white light, while the street uses cool neon; the warm-cool contrast naturally brings the focus forward. The number of light sources should be controlled, prioritizing a few main lights plus emissive materials to simulate lighting and reduce real-time lighting cost.
5. Performance and Engineering: Making It “Run” and “Run Well”
- Budget-driven development: set limits on polygon count, batches, particles, and resolution first, then write content.
- Instanced reuse: use instanced drawing for repeated objects (rain, windows, bollards) to reduce batches.
- Tiered degradation: dynamically adjust particle count and reflection quality based on device capability.
- Resource inlining: avoid large external dependencies to ensure the page is runnable and shareable as a single file.
To extend the work into an online project, you can combine general cloud capabilities: host static assets in object storage with a content delivery network for acceleration; deploy services on a container platform; and observe runtime status with logging and monitoring alerts. These are all industry-standard categories and do not involve any proprietary interfaces.
6. The Iteration Rhythm of Human-AI Collaboration
Efficient collaboration follows “small steps, changing only one thing per round”:
- The first round only confirms the skeleton and proportions;
- The second round adds reflections and main lighting;
- The third round layers in rain, fog, and warm-cool contrast;
- The fourth round handles performance degradation and interaction polish;
- Finally, review the acceptance checklist item by item.
Delivering a runnable intermediate product each round is key to controlling complexity. Replacing the expectation of “getting it right in one shot” with “verifiable progress” actually yields the highest collaboration efficiency.
7. Acceptance Checklist
- Proportions: whether street, building, and character scales are self-consistent;
- Atmosphere: whether rain is continuous, fog is natural, and reflections are believable;
- Performance: whether the target device frame rate and degradation strategy take effect;
- Interaction: whether camera and detail feedback feel smooth;
- Maintainability: whether parameters are centrally adjustable and comments are clear.
8. Conclusion
Building a rainy night city with AI coding tools, the real takeaway is not a piece of code but a method for engineering creativity: break down first, constrain next, then iterate, using acceptance criteria to drive every round of communication. Once this workflow runs smoothly, any idea in your mind can be quickly turned into a work that truly runs and can be played with.
