Building a Rainy-Night 3D Scene With AI Coding Assistance: A Practical Walkthrough

    Turning a vague image in your head into a runnable scene on screen used to take days or even weeks of trial and error. With an AI coding assistant, that path from "imagination" to "playable" shrinks dramatically. This article walks through building a rainy-night urban scene in the browser with WebGL-based 3D rendering, covering the tech choices, a modular approach to the visuals, a practical collaboration workflow, common pitfalls, and a performance optimization checklist. You'll learn how to translate subjective aesthetic goals into concrete parameters, and why iterative, low-cost refinement matters more than expecting the AI to get everything right in one pass.

    1. From One Idea to a “Rainy-Night Town”

    When a blurry image surfaces in your mind—rain-soaked streets, the warm glow spilling out of a convenience store, slanting threads of rain—turning it into something that runs on screen used to require days or even weeks of back-and-forth debugging. Today, with an AI coding assistant, that path from “imagination” to “playable” is dramatically compressed. You describe your intent in natural language, the assistant generates a first-pass skeleton of 3D scene code, and then you keep refining and polishing it by hand.

    One thing worth clarifying: AI assistance does not get it right in a single shot. In real sessions, distorted proportions, sudden frame-rate drops, and missing details are routine. The core value isn’t making decisions for you—it’s driving the cost of each round of revision down to near zero. Understanding this is the prerequisite for using these tools effectively.

    2. Tech Choices: Why Browser-Based Real-Time 3D Rendering

    To build an atmosphere-heavy scene like a rainy night, the tech stack needs to satisfy three things at once: real-time rendering, easy iteration, and cross-platform access. A WebGL-based, in-browser 3D rendering library fits these needs well—nothing to install, just open a web page and it runs, which is naturally suited to fast trial and error and easy sharing.

    Its capabilities roughly cover:

    • Scene graph management: organizing geometry, lights, and cameras through a node tree;
    • Materials and lighting: physically based rendering, emissive materials, and multiple light sources;
    • Post-processing pipeline: enhancing visual quality with effects such as Bloom, tone mapping, and depth of field;
    • Animation and interaction: driving particles, camera fly-throughs, and other effects through a per-frame loop.

    For a rainy-night scene, “emissive materials + post-processing bloom” is the key to the neon halos, while “per-frame updates + a particle system” is the foundation for raindrops and ground reflections.

    3. Breaking the “Rainy-Night Convenience Store” Into Achievable Visual Modules

    A good scene isn’t generated in one shot—it’s decomposed into several modules that can be tuned independently. A useful way to split the work:

    1. Atmosphere and lighting. The core of a rainy night is “low ambient light + localized highlights.” Dim the ambient light, use warm emissive materials for the store interior and signage, use cool tones for street lamps, and build depth through the warm/cool contrast. The wet look of the ground depends on high-reflectance materials and mirrored light sources.

    2. Raindrop particles. Simulate falling rain with a large number of points or line segments, updating their vertical coordinate each frame and resetting them to the top after they land. The key here is to batch-update everything in a single loop rather than operating on objects one by one:

    1. // Example: batch-update raindrop positions to reduce per-object overhead
    2. const rainCount = 2000;
    3. const positions = new Float32Array(rainCount * 3);
    4. const speeds = new Float32Array(rainCount);
    5. function updateRain(delta) {
    6. for (let i = 0; i < rainCount; i++) {
    7. positions[i * 3 + 1] -= speeds[i] * delta; // fall along the Y axis
    8. if (positions[i * 3 + 1] < groundY) resetDrop(i); // reset once it hits the ground
    9. }
    10. geometry.attributes.position.needsUpdate = true; // upload to the GPU once
    11. }

    3. Ground reflections and mirror images. The specular reflection of a wet road can be achieved with a reflection camera or simplified mirrored geometry; when performance is tight, faking reflections with a texture plus a specular map is a more cost-effective compromise.

    4. Composition and proportions. Camera placement and the relative scale of buildings and props are where beginners most often stumble. It helps to define adjustable scale constants centrally in your parameters so you can iterate quickly.

    4. A Four-Step Workflow for Collaborating With an AI Coding Assistant

    The key to efficient collaboration is “cutting a big problem into small, verifiable steps.”

    Step 1: First get a minimal skeleton that runs. Have the assistant build a working version with just “ground + camera + render loop,” confirm the environment is set up correctly, and only then layer in content. This step validates the technical pipeline, not the visuals.

    Step 2: Ask incrementally, module by module. Instead of asking it to “build the whole scene at once,” ask for “add the convenience store building block first,” “then add the glowing sign,” “then bring in the rain.” Each module can run immediately and show its effect immediately.

    Step 3: Communicate problems in quantifiable language. Rather than “it looks weird,” say “the building height is about 3× that of a pedestrian—please compress it to 1.5×.” Translating subjective impressions into concrete parameters is the core technique for cutting down the number of back-and-forth rounds.

    Step 4: Handle performance as its own round. When the frame rate drops, tell the assistant the goal explicitly (for example, “hold 60fps on mobile”), and it will tend to reduce particle counts, merge meshes, and trim post-processing overhead.

    A reliable per-frame loop skeleton looks like this, where delta keeps animation speed consistent across different frame rates:

    1. let last = performance.now();
    2. function animate(now) {
    3. const delta = (now - last) / 1000; // in seconds, so speed is frame-rate independent
    4. last = now;
    5. updateRain(delta);
    6. updateCamera(delta);
    7. composer.render(); // render through the post-processing pipeline
    8. requestAnimationFrame(animate);
    9. }
    10. requestAnimationFrame(animate);

    5. Three Frequent Challenges and How to Handle Them

    Proportions. A 3D scene lacks real-world reference points, so AI-generated dimensions are often off. The fix is to introduce a “human scale” as a baseline object (such as a door frame or the relative height of a pedestrian) and have the assistant use it as an anchor to calibrate everything else.

    Performance. Rainy-night scenes are inherently “heavy”—lots of semi-transparent raindrops, emissive materials, and stacked post-processing can easily tank the frame rate. The recommended priority is: first cut particle counts and the number of transparency layers, then merge like meshes to reduce draw calls, and only last consider simplifying post-processing. To pinpoint the bottleneck, use the browser’s built-in performance panel to watch frame time and draw-call counts.

    Missing details. AI first drafts are often “close in form but lacking in spirit”—missing the weathered look of signage, puddles on the ground, water streaks on glass, and similar touches. These need to be filled in gradually, after the skeleton is stable, through multiple rounds of “be more specific” instructions rather than expecting a single generation to get them all.

    6. Performance Optimization Checklist

    Optimization Technique Benefit
    Particle scale Reduce raindrop count, shorten lifetime Cuts per-frame update and render cost
    Draw calls Merge static meshes, reuse materials and geometry Lowers CPU submission overhead
    Transparency sorting Reduce stacked transparent layers, avoid large transparent surfaces Eases the fill-rate pressure of overdraw
    Post-processing Enable bloom only when necessary, control resolution Lowers full-screen shading cost
    Resolution Dynamically downsample by device pixel ratio on mobile Keeps low-end devices smooth

    In practice, follow the order “correct first, then good-looking, then smooth“: first make the scene run with sensible proportions, then layer in atmosphere piece by piece, and finally optimize for the target devices. Diving into performance fine-tuning too early actually slows down overall progress.

    7. Summary

    Building a rainy-night 3D scene with an AI coding assistant is essentially a fast, collaborative co-creation between a person and AI. It lowers the barrier to realizing an idea dramatically, making “bring the picture in my head to life” achievable for the first time. What truly determines the quality of the work is still your understanding of the scene, your ability to break down problems, and your capacity to translate subjective aesthetics into precise parameters. When the tools are fast enough, the creator’s judgment becomes the scarcest competitive edge—and that is exactly where this kind of workflow is most worth practicing.