Building a Rainy Night City Scene with AI Coding Tools

    This article explains how to use AI coding tools to build a real-time rainy night city scene, focusing on the engineering challenges that make this scenario a strong test of spatial scale, performance budgeting, and detail organization. It covers translating creative ideas into structured prompts across scene, subject, interaction, and constraint layers; anchoring proportions with physical reference constants; achieving convincing rain through density distribution, motion, and ground feedback rather than particle count; using low ambient light and localized highlights for atmosphere; setting performance budgets before visual effects; and running small, verifiable iteration loops. Readers will find practical code snippets, common pitfalls, and a checklist-driven workflow for turning an idea into a runnable, playable result.

    1. Why a Rainy Night City Is an Ideal Test for AI Coding Tools

    At the intersection of 3D graphics and front-end engineering, a rainy night scene is widely regarded as a stress test. It involves large numbers of semi-transparent particles, dynamic reflections, contrast control under low light, and batch management of dense geometry. If any part is handled poorly, the flaws show immediately: rain streaks look like white noise, ground reflections blur into a smear, and distant buildings flicker.

    For this reason, when developers use AI coding tools to turn an idea into a runnable project quickly, a rainy night city efficiently reveals the model’s real level in three areas: sense of spatial scale, performance budget awareness, and organization of detail layers. It is not a show-off challenge but a comprehensive engineering exercise.

    One expectation should be set in advance: this kind of generation rarely gets everything right on the first attempt. Disrupted proportions, performance bottlenecks, and missing details are normal. What truly determines output quality is the number of communication rounds between the developer and the tool, and the precision of the descriptions.

    2. Translating an Idea into a Structured, Machine-Executable Description

    A vague request such as “I want a rainy night convenience store” places almost no constraint on a generative model. A reusable approach is to break the idea into four layers:

    1. Scene layer: city scale, block layout, weather, time of day, and overall color tendency.
    2. Subject layer: the convenience store as the visual anchor, with clear volume, frontage, sign placement, and window proportions.
    3. Interaction layer: whether the camera is free-roaming or fixed, whether clicking is allowed, and whether collision constraints are needed.
    4. Constraint layer: target frame rate range, acceptable polygon budget, and whether post-processing is allowed.

    A sample prompt structure can be written as:

    1. Scene: a city side street on a rainy night, flanked by 3-6 story mixed-use buildings
    2. Subject: a corner convenience store, single story, large floor-to-ceiling windows, warm white interior light
    3. Mood: cool blue ambient light plus warm interior glow, reflections on wet pavement
    4. Interaction: first-person roaming, keyboard movement, mouse look, wall collision
    5. Constraints: runs in real time in the browser, prioritize smoothness, rain as a particle system

    The value of this format is that aesthetic goals and engineering constraints sit in the same description, giving the model a basis for trade-offs instead of producing a version that looks good but cannot run.

    3. Proportions: Most Rework Comes from a Lost Sense of Scale

    The most common failure of generative tools is not ugly modeling but broken scale: doors twice the height of a person, steps nearly half a meter thick, signs hanging at the height of a third floor. The solution is to give the model a physical anchor.

    • Use the human body as a reference: specify a floor height of about 3 meters, a door height of about 2.1 meters, and a step height of about 0.15 meters.
    • Calibrate with familiar objects: shelf height, drink cooler width, floor tile edge length.
    • Set the grid before the details: confirm block length and building spacing first, then discuss awnings and light boxes.
    1. // Manage scale with centralized constants for easy global tuning
    2. const SCALE = {
    3. floorHeight: 3.0,
    4. doorHeight: 2.1,
    5. stepHeight: 0.15,
    6. sidewalkWidth: 2.4,
    7. roadWidth: 7.0
    8. };

    Extracting scale into constants rather than scattered magic numbers is key to staying in control across multiple rounds with the tool. Change one dimension at a time and observe the visual feedback, avoiding large simultaneous adjustments that make problems impossible to locate.

    4. Rendering Rain: Particle Count Does Not Equal Realism

    A common beginner mistake is maxing out the rain, which collapses the frame rate without improving the look. Realism in a rainy night comes from three cooperating factors:

    • Density distribution: sparse, distinguishable streaks nearby, with fog darkening the distance overall, rather than uniform density everywhere.
    • Motion quality: a slight tilt in the fall, combined with a wind vector, avoiding the mechanical feel of perfectly vertical lines.
    • Ground feedback: splashes, water film, and ripples, which are more effective than adding more streaks.
    1. // Example: reuse particles in a buffer to avoid frequent object creation
    2. const rainCount = 6000;
    3. const positions = new Float32Array(rainCount * 3);
    4. for (let i = 0; i < rainCount; i++) {
    5. positions[i * 3] = (Math.random() - 0.5) * 60;
    6. positions[i * 3 + 1] = Math.random() * 25;
    7. positions[i * 3 + 2] = (Math.random() - 0.5) * 60;
    8. }
    9. // Each frame, update only the Y component and wrap around to control per-frame work

    The engineering point is to allocate particle data once during initialization and only update values and wrap positions at runtime. Never create new objects inside the loop, or garbage collection jitter will show up directly as dropped frames.

    5. Lighting and Reflections: The Real Source of the Rainy Night Mood

    A rainy night looks good essentially because of a high-contrast structure of low ambient brightness and high local brightness. Practical configuration strategies include:

    • Push ambient light very low so the world leans cool blue, avoiding an overall washed-out gray.
    • Make the store interior the only strong light source, using warm color temperature and ground reflections to create a focal point.
    • Give wet pavement higher roughness contrast and moderate reflection to produce elongated highlight bands.
    • Use emissive materials for signs and light boxes so they do not participate in actual lighting calculations, saving cost.
    1. const ambient = new THREE.AmbientLight(0x223355, 0.35);
    2. const shopLight = new THREE.PointLight(0xffd9a0, 2.2, 18, 2);
    3. shopLight.position.set(0, 2.6, 0);
    4. scene.add(ambient, shopLight);

    It is worth stressing that the number of light sources and shadow maps are the main performance costs. A safe practice is to let only one or two key lights cast shadows, disable shadows on the rest, and use light falloff and fog to fill in the layers.

    6. Performance Budget: Put “Can It Run” Before “Does It Look Good”

    The prerequisite for a project’s value is that it can be played smoothly. Set the budget in this order:

    1. Target frame rate: use a stable 60 FPS on desktop as the baseline, allowing fluctuation but not sustained drops below 45 FPS.
    2. Draw batches: merge repeated elements (windows, railings, awnings) with instanced rendering.
    3. Geometry precision: express distant buildings with low-poly models plus textures, without investing in subdivision.
    4. Restrained post-processing: prioritize bloom and tone mapping, avoid stacking multiple full-screen blurs.
    5. Resolution strategy: cap the pixel ratio to prevent render area from getting out of control on high-DPI screens.
    1. renderer.setPixelRatio(Math.min(window.devicePixelRatio, 1.5));

    Also, always provide observability: frame rate display, draw call counts, and total scene triangle count. Optimization without measurement is just guessing.

    7. Iteration Methodology: Turning Multiple Rounds into a Converging Process

    Efficiency when working with AI coding tools depends on whether you can build a small, verifiable loop:

    • Solve one problem per round, for example, “fix only the door-to-person proportion first.”
    • Run immediately after each round and judge results by the image rather than by words.
    • Keep intermediate versions you can roll back to, so a good result is not destroyed by later changes.
    • Manage remaining items with a checklist: advance the proportion, performance, and detail tracks in parallel but accept them separately.

    The order for advancing the detail layer also matters: silhouette and massing first, then materials and lighting, and only last the touches like sign text, ground water stains, and trash bins. Reversing the order leads to piling refined details onto the wrong large-scale structure.

    8. Common Pitfalls and Corrections

    • Pitfall 1: Trying to generate a complete finished product in one pass. Correction: deliver in four stages: scene, subject, mood, and interaction.
    • Pitfall 2: Expressing a rainy night through rain volume. Correction: express it through contrast, reflections, and fog, keeping rain restrained.
    • Pitfall 3: Ignoring scale constants. Correction: manage scale parameters centrally and adjust one variable at a time.
    • Pitfall 4: Adding effects before testing performance. Correction: set the frame rate budget first, then decide the effects ceiling.
    • Pitfall 5: Doing visuals without interaction. Correction: complete collision and camera constraints in the same batch as the visuals.

    9. Conclusion

    Building a rainy night city with AI coding tools is never really about writing a particular effect. The real difficulty is translating aesthetic intent into an engineering description with constraints, and staying in control and verifiable across multiple rounds. When scale has anchors, rain has layers, light has hierarchy, performance has a budget, and iteration has a checklist, an idea in your head can reliably become a project that truly runs and can be played. This method is not limited to rainy night scenes; it applies equally to any creative engineering work that needs real-time rendering and rapid validation.