AI Coding Practice: Building a Rainy Night City with Natural Language

    This article walks through building a rainy night city scene with an AI coding assistant, showing how to turn a vague creative idea into explicit engineering constraints. It covers decomposing the requirement into measurable parameters, iterating in layers through prompts, calibrating scale with real-world references, managing real-time rendering budgets, and adding narrative details and interaction. Readers will find a reusable workflow for collaborating with AI models on graphics projects, where humans define constraints and acceptance criteria while the model produces runnable implementations.

    1. From One Sentence to a Runnable Scene: The Real Problem

    “Build a rainy night city” sounds like a visual task, but in engineering terms it couples three things: credible geometric proportions, a real-time rendering performance budget, and narrative density in atmospheric details. Using an AI coding assistant—a tool with code generation and multi-turn conversation capabilities—to build it is not a matter of getting a finished product from a single prompt. It is a process of gradually converging a fuzzy image into explicit constraints.

    The original practice reached a simple conclusion: it rarely works in one shot; proportions, performance, and details all require repeated discussion. This points to the core of human-AI collaborative coding—models are good at producing structurally complete code under given constraints, but the constraints themselves must be defined and calibrated by people.

    2. Requirement Breakdown: Translating “Rainy Night” into Engineering Parameters

    Before starting, break the literary description into a measurable checklist. This is the key factor that determines how much rework follows.

    • Spatial scale: One main street + shops on both sides + a convenience store as a visual anchor. A unified convention such as “1 unit = 1 meter” must be defined, otherwise door frames, steps, and signs generated by the model will drift in proportion.
    • Camera and viewing distance: A third-person low-altitude view, where nearby rain streaks and ground reflections are visible, and distant boundaries are hidden by fog.
    • Lighting structure: Night ambient base light (low-intensity ambient light) + warm key light from the convenience store + colored point lights from signs + intermittent highlights from car headlights and street lamps.
    • Weather layer: Rain curtain, puddle reflections on the ground, water streaks on glass, and occasional lightning fill light.
    • Performance ceiling: Target frame rate, maximum draw batches, and acceptable polygon count.

    The purpose of this checklist is to turn “looks good” into “acceptable and verifiable.” When the model outputs a scene with distorted proportions, you can immediately identify a missing scale convention rather than vaguely saying “change it again.”

    3. Prompts and Iteration: Making Multi-Turn Dialogue Actually Converge

    Multi-turn generation often fails to hit the target in one step because the initial prompt mixes in too many undefined items. A more reliable approach is to proceed in three layers.

    Layer 1: Skeleton. Only ask for a minimal runnable structure, without pursuing details.

    1. // Pseudocode: establish scale and loop first
    2. const UNIT = 1; // 1 unit = 1 meter
    3. scene.fog = new FogExp2(0x0a0f18, 0.035);
    4. addGround(120, 120); // main street scale
    5. addShop({ w: 6, h: 3.2, d: 4 });// convenience store anchor

    Layer 2: Proportion calibration. Have the model output a table of key dimensions instead of directly piling up models. The human eye is extremely sensitive to “doors too short, steps too high.” Once dimensions are made explicit, fine-tuning only requires changing a few constants.

    Layer 3: Atmosphere and interaction. Only now introduce details such as rain, reflections, flickering signs, and pushing the door open to enter the convenience store, and state performance constraints at the same time (for example, “render rain streaks with a single instanced draw batch, not one object per raindrop”).

    A practical technique is to change only one dimension per turn: adjust proportions this turn, lighting next turn, and rain effects the turn after. Mixing changes makes regression issues hard to attribute.

    4. Proportions: Credibility Comes from Reference Objects

    Rainy night scenes often suffer from “every object is right, but the whole looks fake.” The root cause is usually a lack of reference. There are three solutions:

    1. Establish a human-scale reference: door height about 2.1 meters, step height about 0.15 meters, and the bottom edge of signs at least 2.5 meters above the ground.
    2. Unify the grid and snapping: align walls, floor tiles, and curbs to a fixed module to avoid visual “seam noise.”
    3. Obscure the distance with fog and depth of field: distant areas do not need detailed modeling; exponential fog eats up the boundaries, saving performance and looking more like a rainy night.

    5. Performance: Budget Awareness for Real-Time Scenes

    Rainy night themes are naturally “expensive”: semi-transparent rain curtains, reflective ground, and multiple light sources. Cost control usually starts from these points:

    • Instanced drawing: thousands of rain streaks should share one geometry and material, submitted in batches via instance transforms.
    • Layered rain curtain: use short line segments in the foreground to convey speed, and patches or full-screen post-processing in the background to convey density, avoiding solid rain across the whole scene.
    • Trade-offs for reflections: the wet look of the ground can be approximated with roughness maps and elongated highlights, rather than enabling real-time reflections for every floor tile.
    • Light source count control: the more dynamic lights, the higher the shading cost; leave decorative glow to emissive materials and post-processing bloom.
    • Adjustable quality tiers: make rain volume, reflection intensity, and bloom radius parameters so the scene can degrade on lower-performance devices.

    An illustrative parameter panel:

    1. const quality = {
    2. rainCount: 6000, // number of instances
    3. reflection: 0.6, // ground reflection intensity
    4. bloom: 0.8, // bloom radius
    5. pixelRatioCap: 1.5 // resolution cap
    6. };

    6. Detail Narrative: Giving the Scene Traces of Life

    The appeal of a rainy night city comes from inconsistency in details: mist on the inside of the convenience store glass, a cardboard box soaked by the doorway, one corner of a sign flickering due to poor contact, and the reflection of a distant traffic light broken up by raindrops. These details do not need complex models; textures, emissive materials, and simple animations are enough. It is recommended to explicitly require “at least three asymmetric traces of life” in the prompt, to avoid the model producing a “model street” that is perfectly mirrored left and right.

    7. Interaction and Playability

    “Playable” means the scene needs feedback: clicking to push the door open, warm light spilling onto the wet ground when approaching, and rain sound changing with distance. In engineering terms, make these event-driven state switches rather than stuffing logic into the render loop, which significantly reduces later maintenance costs.

    8. Consolidating the Collaboration Method

    Abstract this practice into a reusable workflow: image → parameter checklist → skeleton code → single-dimension iteration → performance tiers → detail narrative → interaction feedback. The human value is concentrated in defining constraints and acceptance criteria, while the model’s value lies in quickly producing structurally complete, runnable implementations. When it comes time to publish the work, static assets can be hosted on object storage, paired with a content delivery network to reduce loading latency; if leaderboards or saves are added later, introduce a cloud database and container platform to carry server-side logic, with logging services and monitoring alerts to observe online performance. These are all general cloud capability categories that can be combined as needed.

    9. Conclusion

    Building a rainy night city with an AI coding tool—the real difficulty is never “can’t write a Three.js scene,” but whether you can translate aesthetic judgment into explicit constraints and make trade-offs among proportions, performance, and details. Once you master this method, turning ideas in your head into runnable, playable works is just disciplined iteration, round after round.