Building a Rainy Night City Scene with AI Coding Tools: A Practical Guide

    This article presents a practical methodology for using AI coding tools to build a rainy night city scene in a 3D web environment. It explains how to split the work into four layers—scene skeleton, atmosphere, details, and performance/interaction—and converge layer by layer with clear acceptance criteria. You will learn how to write structured prompts using a role, goal, constraints, and acceptance format, lock down scale with a centralized config, implement rain, wet reflections, fog and glow within a strict performance budget, and turn repeated AI conversations into a controlled three-round iteration. It also covers common pitfalls and how to avoid them.

    1. Background and Problem Definition

    In 3D web scenes, themes like a “rainy night convenience store” are attractive because they combine challenges in three dimensions at once: visual atmosphere (rain, fog, wet reflections, neon glow), spatial scale (street width, building height, prop dimensions), and runtime performance (many semi-transparent particles, dynamic lights, post-processing). A traditional workflow requires developers to build geometry, tune materials, and write lighting and post-processing pipelines by hand—a slow process with a high cost of trial and error.

    Over the past couple of years, AI coding tools (AI-assisted development environments with code generation and multi-turn conversation) have been widely used for rapid prototyping. In practice, however, there is a shared understanding: it is not a matter of “describe once, get it right once.” It is closer to pair programming with a partner who needs explicit constraints. This article abstracts that process into a general methodology, with the focus remaining on how to use AI assistance to quickly build a rainy night city.

    2. Overall Technical Roadmap

    Break the task into four layers and converge layer by layer, rather than asking the model to output all the code at once:

    1. Scene skeleton layer: ground, roads, building blocks, camera, and basic lighting;
    2. Atmosphere layer: rain particles, fog, wet reflections, neon, and glow;
    3. Detail layer: signs, shelves, doors and windows, puddles, wires, and clutter;
    4. Performance and interaction layer: rendering budget, instancing, frustum culling, roaming, and interaction.

    Each layer should have clear acceptance criteria before moving to the next. The benefit is that when the visuals look “wrong,” you can quickly tell whether it is a scale problem, a material problem, or a performance problem, instead of guessing blindly across thousands of lines of code.

    3. Structuring Prompts and Requirements

    When communicating with AI coding tools, vague adjectives are the biggest enemy of convergence. Use a structured description of “role + goal + constraints + acceptance”:

    1. Role: You are a senior Three.js scene developer.
    2. Goal: Generate a rainy night convenience store streetscape that can be explored with the keyboard.
    3. Constraints:
    4. - Use WebGLRenderer with ACESFilmicToneMapping enabled;
    5. - Building height is about 3.2 units, street width 8 units, convenience store frontage 6 units;
    6. - Rain uses Points with a custom Shader, with a configurable count;
    7. - All materials use MeshStandardMaterial, with roughness/metalness explicitly specified;
    8. - Target fewer than 200 draw calls per frame.
    9. Acceptance: The page runs directly with no console errors, and the frame rate is displayed in the top-right corner.

    This turns “does it feel right” into “are the parameters satisfied,” which noticeably improves the usability of the model’s output. The original point that “scale, performance, and details require repeated communication” is essentially the lack of these quantifiable constraints.

    4. Scale and Composition: The Most Overlooked Source of Failure

    The most common failure in rainy night scenes is not that it “looks bad,” but “distorted scale”: doors too short, signs too large, raindrops looking like snow. Lock down the base unit at the prompt stage, and have the model output an adjustable parameter table:

    1. const CONFIG = {
    2. streetWidth: 8,
    3. buildingHeight: 3.2,
    4. shopFrontage: 6,
    5. rainCount: 12000,
    6. fogDensity: 0.035,
    7. cameraHeight: 1.6
    8. };

    With constants managed centrally, you only need to change values later to fine-tune the composition, avoiding a full rewrite each time. For composition, use a “low camera position + one-point perspective,” letting wet reflections carry the lower half of the frame and neon carry the upper half.

    5. Key Implementation Points for Rainy Night Atmosphere (General Approach)

    • Rain: use Points with a shader that offsets vertices by time in the vertex stage, avoiding the CPU cost of updating many particles every frame;
    • Wet reflections: a common approach is planar reflection or a simplified version of screen-space reflection, combined with high-roughness textures to create a “wet but not mirror-like” look;
    • Fog and glow: exponential fog unifies spatial depth, while bloom post-processing handles neon spill;
    • Light budget: strictly control the number of dynamic point lights, and make up the rest with emissive materials and baked-feeling ambient light.

    Illustrative code (structure only, not a specific product API):

    1. const rainGeo = new THREE.BufferGeometry();
    2. rainGeo.setAttribute('position', new THREE.BufferAttribute(positions, 3));
    3. const rainMat = new THREE.ShaderMaterial({
    4. uniforms: { uTime: { value: 0 }, uSpeed: { value: 18.0 } },
    5. vertexShader: `...`, fragmentShader: `...`
    6. });

    6. Performance Budget and Engineering Constraints

    Set a budget at the prototype stage, or frame rate will inevitably drop once details pile up. Recommendations:

    • Set upper limits on draw calls and triangle count; when exceeded, merge geometry or switch to instancing first;
    • Use instanced rendering for repeated props (shelves, awnings, barricades);
    • Disable unnecessary shadow casting, keeping shadows only for the main light;
    • Provide quality presets, automatically lowering particle count and post-processing on low-end devices.

    Write these into the prompt constraints so the model actively makes trade-offs instead of piling on effects.

    7. Iteration Workflow: Turning “Repeated Communication” into Controlled Convergence

    A three-round approach is recommended:

    1. Round one: get only the skeleton and camera running, and confirm it works;
    2. Round two: add atmosphere, and confirm scale and light direction;
    3. Round three: fill in details and performance switches.

    At the end of each round, do a “runnability acceptance” check: no errors, interactive, parameters adjustable. If a round fails, roll back only that layer instead of rewriting everything. This is the key to locking uncertainty in a cage.

    8. Common Pitfalls and How to Avoid Them

    • Asking for too many effects at once, causing code to conflict;
    • Not specifying units and coordinate conventions, so the model invents its own scale;
    • Ignoring the budget for mobile and low-end devices;
    • Post-processing conflicting with transparency sorting and causing flicker, which requires explicitly specifying render order.

    9. Conclusion

    Building a rainy night city with AI coding tools is valuable not because of “one-sentence generation,” but because it quickly turns creativity into a runnable, playable engineering prototype, then pushes it toward stability with structured constraints and layered iteration. Master these three things—constraints first, layered acceptance, and iteration within budget—and you can reliably land the rainy street corner in your mind inside the browser.