Building a Rainy Night City with AI Coding Tools: A Practical Guide
This article explains how to build a rainy night city scene in the browser with Three.js using AI coding tools. It focuses on a repeatable workflow: breaking a vague creative idea into verifiable engineering constraints, generating a runnable scene in layers, validating results, and iterating across multiple rounds. You will learn how to structure prompts around scale, lighting, dynamic elements, and performance budgets, how to separate static geometry, particles, and lighting for easier debugging, and how to avoid common issues such as distorted proportions, plastic-looking materials, unconvincing rain, and frame rate problems.
1. Why a Rainy Night City Is a Good Test for AI Coding Tools
Building a rainy night city in the browser with Three.js may look like a visual topic, but it is a complete engineering exercise. It covers scene modeling, materials and lighting, particle systems, post-processing, interaction control, and performance budgeting at the same time. That makes it a good way to evaluate how AI coding tools perform in a real development workflow: whether they can interpret vague natural language descriptions, translate a mood into concrete technical parameters, and adjust proportions and performance based on feedback across multiple turns.
AI coding tools are not magic systems that produce a finished result from a single prompt. In practice, the first generation usually gives you a runnable skeleton, but problems appear soon after: off proportions, overly plastic materials, unreasonable rain density, and unstable frame rates. What really determines quality is whether the developer can break an aesthetic goal into verifiable engineering constraints and converge on the result through multiple rounds of communication. This article covers that workflow: decompose, generate, validate, and iterate.
2. Translating Ideas into Engineering Constraints: A Layered Prompt Structure
Vague creative descriptions are the biggest enemy of generation quality. A phrase like “a rainy night convenience store” carries too little information for a model. The effective approach is to split the requirements into layers and give verifiable constraints at each layer.
The first layer is the scene skeleton: street width, building height, the width and depth of the convenience store, and the height difference between the sidewalk and the road. The second layer is the visual tone: night ambient light intensity, main light position, color temperature contrast between neon and signage, and wet ground reflectivity. The third layer is dynamic elements: rain type (light rain or heavy rain), raindrop count range, wind offset, and puddle ripples. The fourth layer is interaction and performance: camera roaming mode, interactive objects, target frame rate, and device fallback strategy.
An example prompt structure looks like this:
Scene: night city street, convenience store on one side, low-rise buildings on the other.Scale: street width 8m, storefront width 6m, floor height 3.2m.Lighting: ambient light 0.15, main light is warm signage light at 3000K, ground reflectivity 0.6.Dynamic: medium-density rain, wind offset 15 degrees, puddle ripples triggered randomly.Performance: target 60fps on desktop, automatically reduce particle count and post-processing on mobile.
The value of this format is that every line can be validated. When the result does not match expectations, you can point to the specific layer that failed instead of saying something vague like “it feels wrong.”
3. Engineering Approach to Scene Layering
The complexity of a rainy night scene comes from combining static geometry, dynamic particles, and lighting reflections. Sensible layering significantly reduces debugging cost.
The static layer handles the street, building blocks, store shelves, and signage. Build the massing from simple boxes and planes, confirm the proportions first, then replace details step by step. Many proportion problems are not because the model cannot write the code, but because the prompt gives no clear dimensional anchors.
The dynamic layer handles rain, ripples, and steam. Rain is usually implemented with point sprites or instanced line segments; the key is reusing and culling them with the view frustum instead of creating a separate object for every drop. Ripples can be played randomly on the ground with a few ring textures, which costs far less than real fluid simulation.
The lighting layer is the core of the rainy night mood. Wet ground reflections do not require complex physics. A common approach is to give the ground material a higher roughness contrast and low-intensity ambient reflection, then add a few point lights to create highlights. The contrast between warm signage and street lights and the cool ambient light is the main source of the recognizable rainy night look.
4. Performance Budget: Set Constraints First, Then Details
Frame rate problems in rainy night scenes mostly come from blindly stacking particles and post-processing. The mature approach is to set a budget first and then work backward to the implementation.
Budget example (desktop):- Draw calls < 150- Rain particles < 20000- Keep only 1 full-screen post-processing pass- On mobile, reduce particle count to 30% and disable high-resolution reflections
In implementation, use instanced rendering to merge similar geometry first; move raindrop motion into the vertex shader to reduce per-frame CPU cost; use lower levels of detail for distant buildings. When the frame rate target is not met, reduce particles and post-processing before cutting geometry detail, because the former has less impact on the mood.
5. Multi-Round Iteration: Turning Back-and-Forth into a Controlled Process
The original text mentions that proportions, performance, and details need repeated communication, which is exactly the norm in real development. To improve iteration efficiency, structure the feedback for each round.
Round one confirms only the skeleton and proportions, without chasing details. Round two adds lighting and materials to confirm the mood direction. Round three introduces rain and ripples to observe the dynamic result. Round four runs performance stress tests and fallback. Round five adds interaction and camera movement. Solve only one class of problem per round, so that changing multiple variables at once does not make the cause impossible to locate.
When the result deviates from expectations, make feedback as measurable as possible: “lower building height by 20%,” “halve the raindrop count,” “increase sign brightness but avoid overexposure.” Measurable descriptions work far better than “make it more realistic.”
6. Common Pitfalls and How to Avoid Them
The first is distorted proportions. Without dimensional anchors, the model tends to produce a toy-like scene, so always give metric dimensions in the prompt. The second is plastic-looking materials. Night scenes should reduce highlight sharpness and add roughness variation. The third is rain credibility. Rain streaks that are too long look like scratches, and rain that is too dense blocks the subject, so combine them with wind direction and depth of field. The fourth is the balance between performance and image quality. Declare the target frame rate and fallback strategy during generation instead of fixing it afterward. The fifth is missing interaction. Playability comes from camera constraints and a few triggerable events, which must be stated explicitly in the requirements.
7. Conclusion
Building a rainy night city with AI coding tools is difficult not because of code generation, but because of requirement decomposition and iteration control. Translate the mood into four types of verifiable constraints: scale, lighting, particles, and performance. Converge layer by layer in small steps, and you can turn ideas in your head into runnable, playable work reliably. The same method applies to other real-time 3D scenes and has clear reuse value.
