Building a 3D Rainy Night City Scene Using AI Coding Assistants
Creating a 3D rainy night city scene involves complex visual and technical challenges, from spatial organization and atmospheric rendering to performance constraints. This article explores a practical workflow for using conversational AI coding tools to build such scenes. It covers defining acceptance criteria, establishing a minimal render loop, designing a cohesive visual system for materials and lighting, balancing rain effects with performance, managing a performance budget, and adding interactivity. By treating AI as a conversational engineering collaborator, developers can incrementally build, test, and optimize a stable, playable 3D prototype.
Building a 3D Rainy Night City Scene Using AI Coding Assistants: A Practical Path from Idea to Runnable Prototype
A rainy night city is a typical 3D scene topic characterized by “strong visual atmosphere, long technical pipeline, and obvious performance constraints.” It involves spatial organization of buildings, roads, and convenience stores, as well as rendering challenges like raindrops, puddle reflections, neon lights, fog, and nighttime illumination. It also includes engineering constraints such as real-time frame rates, resource loading, and interactive responses. Conversational AI coding tools can significantly shorten the time from idea to a runnable prototype, but this does not mean a single prompt can deliver the final product. A more reasonable approach is to treat the tool as a “conversational engineering collaborator.” Through requirement decomposition, incremental implementation, performance budgeting, and acceptance criteria, you can gradually converge the picture in your mind into a stable, playable scene.
1. Define Acceptance Criteria First, Not Code
Many failed prototypes stem from overly vague requirements, such as “make a rainy night city.” Such descriptions cannot be directly translated into engineering tasks. A more effective approach is to first define verifiable goals: Is the perspective first-person walking or top-down roaming? Do core visual anchors include a convenience store, street, streetlights, and awnings? Is the rain effect screen-space rain lines or 3D raindrops? Do you need puddle reflections? Is the target device a desktop browser or mobile? What is the acceptable minimum frame rate and loading time?
It is recommended to break down the requirements into three layers. The first layer is the “runnable skeleton,” including the camera, scene, render loop, and basic interaction. The second layer is the “visual system,” including materials, lighting, fog, rain effects, and color management. The third layer is “engineering optimization,” including instancing, level of detail (LOD), texture compression, post-processing downgrade, and resource release. Each layer should have clear acceptance conditions, such as “the camera can move without passing through walls,” “the number of raindrops maintains a stable frame rate on the target device,” or “the convenience store lightbox is readable at night but does not bloom excessively.”
AI coding tools are well-suited to translate these constraints into modular tasks. Rather than asking for a complete project at once, ask the tool to generate a minimum runnable version first, then iteratively add rain, lighting, and interaction. This makes it easier to locate issues and aligns with the real development pace.
2. Build a Runnable Skeleton: Let the Scene “Stand” First
The first step in a 3D scene is not piling on details, but establishing a stable spatial skeleton. You can have the tool generate a generic render loop: initialize the canvas, create the scene and camera, set up basic lighting, register window resize events, update state in the animation loop, and render. At this stage, keep dependencies minimal and code paths shortest to ensure every subsequent visual module can be independently mounted and rolled back.
// Pseudocode: Minimal render skeletonconst scene = createScene();const camera = createPerspectiveCamera({ fov: 60, near: 0.1, far: 500 });const renderer = createRenderer({ antialias: true });function resize() {const { width, height } = getViewportSize();camera.aspect = width / height;camera.updateProjectionMatrix();renderer.setSize(width, height);}function tick(dt) {updateControls(dt);updateRain(dt);updateLights(dt);renderer.render(scene, camera);requestAnimationFrame(tick);}
During the skeleton phase, pay special attention to proportions. The realism of a rainy night city largely depends on scale consistency: door height, streetlight height, road width, awning projection, and convenience store sign size should all match daily experience. Distorted proportions will make subsequent materials and lighting look increasingly “fake.” Therefore, place simple boxes early on as scale references, such as a human height of 1.7 meters, a door height of 2.2 meters, and a lane width of 3 to 3.5 meters. AI coding tools can quickly generate these references, but whether the scale meets expectations still requires manual observation and multiple rounds of communication.
3. Build the Visual System: Co-design Materials, Lighting, and Color
The visual core of a rainy night scene is not a single special effect, but the synergy of materials, lighting, and color management. In a low-ambient-light night environment, the warm light inside the convenience store, the cold light of the street, neon signs, and puddle reflections form layers together. If you only increase brightness, the image easily becomes gray; if you only increase contrast, dark areas easily lose detail. A more reliable strategy is to establish a layered system of “basic ambient light + main light source + local point/area lights + emissive materials” and control highlight overflow.
For materials, roads, walls, awnings, and glass should have different roughness and reflection characteristics. Puddles should not simply be made into mirrors; instead, they should form a fragmented feel through roughness disturbance, normal variation, and local reflection. Convenience store glass needs to balance internal visibility with external reflection to avoid a complete loss of spatial sense caused by full transparency. AI tools can generate material parameters based on descriptions, but the values still need to be adjusted based on visual feedback. For instance, adjusting roughness from 0.1 to 0.35 might be more effective than adding more models.
For lighting, it is recommended to first determine the brightness relationship of “visual focus—transition zone—background zone.” The convenience store can be slightly brighter as a visual anchor, the midground street should remain readable, and the distant background should have its contrast suppressed by fog. All lights should have reasonable attenuation ranges and intensity caps to avoid performance degradation caused by unnecessary full-scene point lights. Color management should uniformly calculate in linear space and display in output space to avoid inconsistent brightness responses across different materials.
4. Implement Rain Effects: Balance Visual Density and Performance Cost
The rain effect is key to the rainy night atmosphere, but it is also the module most likely to cause performance fluctuations. Common implementations include screen-space rain lines, particle raindrops, instanced geometry raindrops, and multi-layer overlays. Screen-space solutions have low cost but weak spatial sense; 3D instanced raindrops have strong spatial sense but high overhead when quantities are large; multi-layer rain curtains can balance close-up rain lines and distant rain fog, but require control over transparent blending and overdraw.
// Pseudocode: Update logic for instanced raindropsconst rainCount = 6000;const rain = createInstancedRain(rainCount);function updateRain(dt) {for (let i = 0; i < rainCount; i++) {const p = rain.getPosition(i);p.y -= rain.speed[i] * dt;if (p.y < rain.groundY) {p.y = rain.topY;p.x = rain.randomX();p.z = rain.randomZ();}rain.setPosition(i, p);}rain.commit();}
Rain effect optimization should prioritize: limiting the number and lifecycle of raindrops; using instancing to reduce draw calls; making raindrops follow a local area around the camera rather than covering the entire city; controlling blending order and overdraw for transparent materials; and reducing raindrop density or switching to screen-space rain lines on mobile. Rain sounds, lightning, and ground ripples are enhancements that should be added only after the base frame rate is stable.
5. Performance Budget: Turn “Runs” into “Stably Playable”
Performance issues in 3D projects are usually not single-point bottlenecks, but the combined effect of draw calls, triangle count, texture bandwidth, transparent overdraw, and post-processing overlays. It is recommended to set a performance budget early in the project: target frame rate, maximum draw calls, maximum texture memory usage, and acceptable first-screen loading time. Every time a visual module is added, its impact on frame rate and loading time should be recorded.
The recommended optimization order starts with high-yield, low-risk actions: merge static geometry, use instanced rendering for repeated objects, set LOD for distant views, compress textures and limit resolution, disable updates and rendering for invisible objects, and lower post-processing resolution or disable certain post-processing on low-performance devices. For expensive effects like rain, fog, and reflections, provide quality tiers rather than just “all on” or “all off.”
AI coding tools can help generate performance monitoring code and downgrade logic, but performance data must be tested on target devices and browsers. You cannot assume performance meets standards just because the code looks “lightweight.” The trade-offs between scale, performance, and detail require continuous communication and adjustment by developers based on visual feedback.
6. Interaction and Playability: Turn the Scene from a “Screenshot” to a “Work”
The difference between a runnable work and a static render lies in interaction. Basic interactions include camera roaming, perspective limits, simplified collisions, mobile touch adaptation, and pause/resume. Further lightweight interactions can include opening/closing an umbrella, automatic convenience store doors, light switches, and rain intensity adjustment. Interaction design should serve the scene’s atmosphere rather than stacking features.
Camera control needs to limit pitch angle and movement range to avoid clipping and dizziness; collisions can use simplified bounding boxes instead of complex physics; mobile should adjust movement speed, sensitivity, and render quality. All interaction states should be decoupled from the animation loop to prevent input events from directly triggering re-renders. For playability, it is recommended to set a clear “experience path”: enter from the street, pass by the convenience store, observe the rain curtain and puddles, and then return to the distant view. This allows users to perceive spatial layers rather than wandering aimlessly in the scene.
7. Collaborative Iteration: Smart Tools Need “Verifiable Feedback”
The advantage of conversational AI coding tools lies in rapid generation and modification, but effective collaboration relies on verifiable feedback. Each round of communication should provide as much as possible: the current phenomenon, expected effect, reproduction steps, performance data, screenshots, or error messages. For example, “the raindrops are too dense, causing mobile frame rate to drop; I want to keep close-up rain lines but reduce distant density” is easier to translate into engineering changes than “the rain looks bad.”
It is recommended to use small-step commits: first generate the skeleton and run it, then add lighting, then add rain effects, then optimize performance, and finally do interaction and acceptance. Keep a rollback version at each stage to avoid making it hard to locate issues caused by one massive change. Code generated by AI tools should be manually reviewed, focusing on resource release, event unbinding, loop boundaries, transparent sorting, and mobile compatibility.
8. Acceptance Checklist and Summary
The final acceptance can revolve around the following checklist: Is the scene scale consistent? Does the convenience store form a visual focus? Are the rain effects stable across different viewing angles? Do the dark areas at night retain details? Does the frame rate reach the target? Is it operable on mobile? Is the resource loading time acceptable? Do the interactions have clear boundaries? Does the code have quality downgrade and resource release capabilities?
Overall, AI coding tools are very suitable for quickly turning ideas like a rainy night city into runnable prototypes, providing high-frequency iteration support for materials, lighting, rain effects, and interaction. However, it is not a “one-click output” replacement. A truly playable work still requires developers to continuously oversee scale, performance budgets, detail levels, and acceptance criteria. Placing the tool within an engineering workflow of “rapid prototyping + manual review + incremental optimization” is the only way to ensure the rainy night city in your mind lands stably.
