Building a 3D Rainy-Night City Scene with AI Coding Tools

    This article walks through a practical workflow for building a 3D "rainy-night convenience store" scene—complete with dynamic rain, neon lighting, and wet-ground reflections—using AI-assisted coding tools. It covers how to break down visual goals into technical requirements, generate a working WebGL scene skeleton from natural-language prompts, iterate through conversational refinement, optimize rendering performance, craft atmosphere with lighting and post-processing, and add basic interactivity. The core takeaway: AI coding tools are a powerful lever for rapid prototyping, but understanding the underlying 3D rendering principles remains essential for effective debugging and optimization.

    Building a 3D Rainy-Night City Scene with AI Coding Tools

    Creating a rainy-night city with dynamic rainfall, neon lights, and reflective wet ground sounds like a complex 3D programming task. Traditionally, it required solid graphics fundamentals, familiarity with a rendering engine, and a lot of math-heavy code. Today, however, AI coding tools let developers describe what they want in natural language, quickly obtain runnable starter code, and then refine the result through multi-turn conversation. Using a “rainy-night convenience store” scene as a working example, this article lays out a practical method for building 3D scenes with AI coding tools.

    1. Requirements Breakdown: Visual and Technical Elements of a Rainy-Night City

    Before writing any code, break the picture in your head into executable technical requirements. A rainy-night city typically includes: street and building silhouettes, a convenience store glowing with warm light, falling rain, puddle reflections on the ground, glowing street lamps and signage, and an overall cool-toned night sky. Each element maps to a concrete technical module:

    • Buildings and streets: 3D geometry modeling, materials and textures, ambient lighting.
    • Rain: a particle system or line-segment system with a large number of moving objects.
    • Lighting and reflections: point lights, spotlights, planar reflections or screen-space reflections.
    • Atmosphere: fog, color grading, and bloom post-processing.

    Performance must also be considered upfront. Rain particles, light counts, and shadow maps are all performance killers, so the requirements stage should define a clear balance between visual quality and frame rate.

    2. Quickly Generating the Base 3D Scene Skeleton

    The first step with an AI coding tool is to give it a clear, complete description of the requirement. For example: “Generate a WebGL-based 3D scene containing a convenience store building, a street, street lamps, and rain particles, with a freely rotatable camera.” The tool will return code covering scene initialization, a render loop, and basic interaction.

    The base architecture typically includes: creating the scene object, creating a perspective camera, creating the WebGL renderer, handling window resizing, and adding an animation loop. Illustrative code:

    1. // Initialize scene, camera, and renderer (illustrative)
    2. const scene = createScene();
    3. const camera = createCamera(60, window.innerWidth / window.innerHeight, 0.1, 1000);
    4. const renderer = createRenderer({ antialias: true });
    5. renderer.setSize(window.innerWidth, window.innerHeight);
    6. document.body.appendChild(renderer.domElement);
    7. // Animation loop
    8. function animate() {
    9. requestAnimationFrame(animate);
    10. updateRain();
    11. renderer.render(scene, camera);
    12. }
    13. animate();

    The initial code usually runs, but the result may be rough. At this point, there’s no need to rush into hand-writing every detail—keep refining through conversation. For example: “The store’s sign should emit warm yellow light; add a point light and an emissive material.” Or: “Raindrops should create splash ripples when they hit the ground; implement this with short-lived particles.” Descriptions like these help the tool understand your artistic intent and generate the corresponding configuration code.

    3. Conversational Iteration: Continuously Fixing Proportions, Performance, and Details

    In practice, you almost never get it right on the first try. Common problems include: buildings with wrong proportions, intersecting objects, camera clipping, too many particles causing lag, rain falling in unnatural directions, and lights that are too bright or too dim. Each of these can be resolved through dialogue:

    • For proportion issues: “Adjust the convenience store’s dimensions to match the street width.”
    • For performance issues: “Reduce the rain particle count to one third while increasing each particle’s size to maintain visual density.”
    • For detail issues: “Give the ground a wet, reflective look using a dark gray material with a specular map.”

    After every change, run and verify immediately. This “describe–generate–verify–describe again” loop is smoother than traditional hand-coding because the tool handles boilerplate and API configuration, letting you focus on design decisions.

    4. Performance Optimization: Keeping the Scene Smooth

    Performance optimization is critical for a rainy-night scene. In WebGL, every object corresponds to a draw call, and a particle system may need to handle thousands of independent instances. Left unchecked, the animation will visibly drop frames. Useful strategies include:

    • Merge geometry: combine static buildings and street parts into a few meshes to reduce draw calls.
    • Use instanced rendering: render rain particles as instances—generate minimal geometry and control each particle’s position and size in the shader.
    • Limit light count: simulate ambient lighting with a small number of point lights, and use emissive materials instead of real light sources where possible.
    • Lower shadow resolution: keep shadow maps modest in size and shrink the shadow range appropriately.
    • Add fog: fog masks distant objects, enhancing the rainy-night mood while reducing the rendering load of far-away geometry.
    • Control particle lifecycles: recycle raindrops promptly once they land to avoid accumulation.

    A simple rain update logic can be sketched like this:

    1. function updateRain() {
    2. for (let i = 0; i < rainDrops.length; i++) {
    3. rainDrops[i].y -= speed * deltaTime;
    4. if (rainDrops[i].y < 0) {
    5. resetRainDrop(rainDrops[i]); // Reset to the top
    6. }
    7. }
    8. }

    With an AI coding tool, logic like this can be generated and dropped into existing code quickly. But developers still need to understand the nature of performance bottlenecks—otherwise they can’t issue the right optimization instructions.

    5. Building Atmosphere: Light, Shadow, and Moisture

    The emotional impact of a rainy-night city comes mainly from lighting contrast: the cold blue night sky and rain curtain against the warm yellow glow of the convenience store. Three approaches help achieve this:

    1. Lighting layout: place a warm point light at the store’s lightbox, spotlights at the street lamps, and use a cool ambient light as the overall base.
    2. Materials and reflections: use a high-gloss material for the road surface with normal maps to simulate puddle textures; set ad signage materials to emissive to strengthen visual focal points.
    3. Post-processing: apply bloom so neon lights get a soft halo; if the engine supports it, add slight chromatic aberration and vignetting for a cinematic feel.

    The rain itself also needs layering. Set up multiple particle groups at different depths: nearby rain streaks move slightly faster with higher opacity, while distant rain is finer and more transparent, creating spatial depth. Ground splash ripples can be done with short-lived small rings or grayscale textures—keep the count low.

    AI coding tools depend heavily on clear descriptions for this kind of detail work. For example:

    • “Add a randomized horizontal wind speed to the rain so it looks more natural.”
    • “Set the store sign’s emissive color to warm orange and add bloom.”
    • “Add a roughness map to the ground material so reflections concentrate in the puddles.”

    6. Interaction and Playability: Making the Scene Explorable

    Visuals alone aren’t enough—a runnable piece benefits from interactivity. You can add mouse-drag camera rotation, keyboard-based walking, or click-to-open doors. AI coding tools can quickly generate framework code for event binding, collision detection, and animation state machines.

    For example:

    1. // Mouse drag to control the camera view (illustrative)
    2. canvas.addEventListener('pointerdown', startDrag);
    3. canvas.addEventListener('pointermove', onDrag);
    4. canvas.addEventListener('pointerup', endDrag);

    You can also add a “rainy night mode” toggle button that lets users switch rain intensity and lighting strength, further boosting playability. These interactions aren’t complex, but they do need repeated testing. AI coding tools can rapidly generate logic prototypes, cutting down repetitive coding time.

    7. Conclusion: The Tool Is a Lever, Not a Replacement

    The biggest gain from building a rainy-night city with AI coding tools isn’t “one-click generation”—it’s a more efficient development workflow: turn ideas into concrete requirement descriptions, let the tool handle repetitive code generation, and then have the developer verify and tune the results. This approach is especially well suited to quickly validating ideas, building demo prototypes, and learning the 3D rendering pipeline.

    That said, be clear-eyed about the limits: tools can’t replace an understanding of underlying principles. When performance problems appear, or when the visual style misses expectations, you still need to know why in order to issue effective fix instructions. So treat the AI coding tool as a “fast-coding partner,” and keep practicing the skills of breaking down requirements, locating problems, and iterating on optimizations. That way, every “rainy-night city” you build will become more realistic—and run more smoothly.