Building a Rainy Night 3D City with AI Coding Tools
This article explains how to use AI coding tools to build a real-time 3D rainy night city scene for the web. It covers breaking a natural-language idea into engineering requirements, organizing the scene in decoupled layers, shaping the atmosphere through color contrast and reflections, and solving the two most common issues that come up during iteration: scale imbalance and performance bottlenecks. Readers will find a structured prompt example, sample pseudocode, a practical four-round iteration workflow, and a pre-delivery checklist for building a runnable, explorable scene.
1. Introduction: From One Idea to a Runnable Rainy Night Scene
In real-time 3D content creation, a “rainy night city” is a compelling subject: wet pavement reflects warm lights, fine rain falls diagonally across the camera, and distant shop signs blur through the rain. In the past, building such a scene required developers to handle modeling, materials, lighting, particle systems, and performance tuning all at once. Today, with intelligent coding tools, creators can describe their intent in natural language, have the tool generate code based on a general-purpose web 3D rendering framework, and then enter a loop of generate, run, observe, and refine.
It is worth stressing that these tools are not magic that produces a finished result from a single description. Proportions, frame rate stability, and level of detail usually take multiple rounds of communication and adjustment. From a neutral perspective, this article abstracts a reusable workflow that helps readers turn ideas in their heads into work that runs and can be played with.
2. Requirement Breakdown: Translating “Rainy Night City” into Engineering Language
A natural-language idea must first be broken down into computable, renderable objects before it can be implemented well. It helps to describe the scene along four dimensions:
- Space and composition: street direction, building height and spacing, initial camera position and view frustum.
- Lighting and atmosphere: main light direction, color temperature contrast (cool ambient light versus warm point lights), fog density and falloff.
- Dynamic elements: rain type (fine drizzle or large drops), fall speed and wind drift, ground splashes, sign flicker.
- Interaction and camera: mouse drag to rotate, scroll to zoom, automatic flythrough path.
Once the breakdown is done, hand a structured prompt to the coding tool, for example:
Build a real-time 3D rainy night street scene for the web:1) Wet asphalt ground with reflections and normal perturbation;2) Small 2-4 story buildings on both sides, a convenience store on the ground floor with a warm light box;3) Cool ambient light plus warm point lights for contrast;4) A particle system for diagonal fine rain, plus ground splashes;5) Camera at one end of the street, slightly looking down, supporting drag and zoom;6) Keep draw calls under control so it runs smoothly on an ordinary laptop.
The value of a structured prompt is that it translates aesthetic goals into rendering elements, reduces the room for the tool to guess, and lowers the rework rate from the start.
3. Scene Construction: Layering Is the Basis of Stability
A high-quality 3D scene usually follows a layered, decoupled organization that makes it easy to verify and replace one layer at a time:
- Terrain and street layer: assemble the road and curbs from simple geometry, settle the scale relationships first, then add detail.
- Building massing layer: combine boxes into building outlines and control the rhythm of heights so the skyline is not monotonous.
- Material and reflection layer: the wet look comes mainly from low roughness plus normal perturbation plus environment reflection, not simply from raising brightness.
- Lighting layer: a few key lights are enough to shape the mood; too many point lights quickly drive up rendering cost.
- Weather particle layer: rain, fog, and splashes are encapsulated separately so density and speed are easy to tune.
- Interaction layer: camera controls, automatic flythrough, parameter panel.
Illustrative code (pseudocode style, meant to show structure rather than specific APIs):
// Scene rootconst scene = createScene();// Layer containersconst layers = {ground: createGroup('ground'),buildings: createGroup('buildings'),lights: createGroup('lights'),weather: createGroup('weather')};Object.values(layers).forEach(g => scene.add(g));// Wet road: low roughness + normal perturbationconst wetRoad = createMesh(planeGeometry, wetMaterial({roughness: 0.15,normalScale: 0.6,envIntensity: 1.2}));layers.ground.add(wetRoad);// Lighting: cool ambient + warm point lightlayers.lights.add(ambientLight({ color: 0x223344, intensity: 0.6 }));layers.lights.add(pointLight({ color: 0xffbb66, intensity: 2.0, distance: 12 }));// Weather: diagonal fine rainlayers.weather.add(rainSystem({ count: 6000, speed: 18, wind: 0.3 }));
The direct benefit of layering: when proportions look off, you only adjust the building massing layer; when the frame rate is too low, you cut the weather particle layer and the number of lights first, without overturning the whole structure.
4. Atmosphere: Key Details Behind the Rainy Night Feel
What makes a rainy night moving comes down to two things: contrast and reflection.
- Color temperature contrast: cool ambient light (blue-cyan) against warm shop and street lights (orange-yellow) creates natural depth in the image.
- Reflections and streaks: wet ground stretches lights into vertical bands, and normal perturbation makes the reflections shimmer in small fragments.
- Fog falloff: exponential fog lets distant buildings fade into the rain, creating depth.
- Particle layering: near rain streaks are thicker and faster, the far rain curtain is finer and slower; two layers stacked together look more real.
- Dynamic accents: slight light box flicker and brief splashes where drops hit the ground noticeably improve the sense of readable everyday life.
A common mistake is raising overall brightness blindly. The right approach for a rainy night is to darken the environment and keep the highlights, letting the warm lights become the visual focus.
5. Performance and Scale: The Two Issues That Come Up Most in Iteration
In practice, rework tends to concentrate on two points:
- Scale imbalance: buildings that are too tall squeeze the street, while buildings that are too low lose the sense of pressure. Use a human scale as the reference (about 3 meters per floor) and scale up from there.
- Performance bottlenecks: too many draw calls, too many particles, too many lights, and overly large textures all lower the frame rate.
A practical optimization order:
- Merge static geometry to reduce draw calls;
- Use instanced rendering for repeated objects (rain drops, window panes, bollards);
- Limit the number of real-time lights and replace the rest with baked or approximated lighting;
- Adjust particle density and render resolution dynamically based on device capability;
- Offer quality presets and leave the choice to the user.
6. Human-AI Collaboration: Turning Back-and-Forth into Controlled Iteration
Stable output depends on process, not luck. A four-round iteration method works well:
- Round 1 (skeleton): confirm only composition, scale, and camera position, without chasing detail.
- Round 2 (atmosphere): settle color temperature, fog, and reflection strength.
- Round 3 (detail): add signs, wipers, splashes, and ground textures.
- Round 4 (performance and interaction): do instancing, quality tiers, and interaction polish.
Each round solves only one class of problem, and a rollback-able version is kept. For long-term accumulation, static assets can be managed with object storage, static asset loading can be accelerated with a content delivery network, and online frame rate and error rate can be tracked with logging and monitoring alerts. These are routine uses of general cloud capabilities rather than proprietary features of any single provider.
7. Acceptance Checklist and Common Pitfalls
Before delivery, check each item:
- Does the first screen finish loading within an acceptable time;
- Do mid- and low-end devices hold a playable frame rate;
- Does camera zoom clip through geometry or expose areas outside the scene;
- Do rain and fog block key visual focal points;
- Does interaction give clear feedback.
Common pitfalls include: stacking lights until the image turns gray, particles so large they look like snow, reflections so strong the ground looks like a mirror, and detail overload that collapses the frame rate.
8. Conclusion
Building a rainy night city with intelligent coding tools is essentially an exercise in engineering an aesthetic intent. The tool turns descriptions into code; the developer defines structure, controls scale, constrains performance, and guards the details. When the breakdown is clear enough and the iteration is restrained enough, the rainy street corner in your mind reliably becomes a real-time 3D work that runs and can be played with.
