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

    This article explains how to use AI coding tools to build a real-time 3D rainy night convenience store scene in a web browser. Instead of sending every requirement at once, it recommends a layered workflow—skeleton, blockout, materials, atmosphere, interaction, and optimization—where each layer stays runnable, screenshot-friendly, and easy to roll back. It covers how to turn visual ideas into measurable prompt constraints, how to fix proportions before adding detail, how to tune wet-surface reflections and lighting contrast, how to handle rain particles and puddle ripples, and how to treat frame rate as a hard limit with quality presets. A three-round review checklist and common pitfalls are included to help developers ship a stable, single-file scene.

    1. Background and Problem Definition

    In day-to-day 3D web development, the most time-consuming part is often not writing code. It is translating a vague mental image into clear technical constraints. Take a rainy night convenience store as an example. The scene involves building masses, glass and wet-ground reflections, volumetric fog, rain particles, neon and sign glow, street props, and pedestrian paths. If you hand all of these requirements to an AI coding tool in one shot, the result is usually “it runs, but it is wrong”: distorted proportions, plastic-looking materials, a sudden frame rate drop, and piled-up details with no sense of hierarchy.

    The core question of this article is therefore: how to use AI coding tools in an engineering way so that creative ideas are reliably turned into a runnable real-time 3D piece. It is worth stressing that the strength of these tools is not one-shot perfection. It is “quickly produce a runnable skeleton, then converge on details through repeated conversation”. Setting your expectation to collaborative iteration is the first step toward better efficiency.

    2. Overall Technical Roadmap

    Use a “generate in layers, accept layer by layer” approach rather than generating a complete project at once:

    1. Skeleton layer: initialize the renderer, scene, camera, lighting, and main loop, and fix the coordinate system and units (for example, 1 unit = 1 meter).
    2. Blockout layer: use simple geometry to establish the proportions of the street, the store body, the awning, and the storefront header.
    3. Material layer: introduce physically based materials, roughness/metalness, normals, and environment reflections to build a contrast between wet ground, glass, and metal.
    4. Atmosphere layer: fog, tone mapping, bloom, rain particles, ground ripples, and neon.
    5. Interaction layer: camera roaming, rain intensity control, light switches, and a performance toggle.
    6. Optimization layer: instancing, culling, resolution scaling, and fallback strategies.

    Every layer should be runnable, screenshot-able, and rollback-able. That way the conversation with the tool revolves around clear goals instead of repeatedly overturning work in the dark.

    3. Prompting and Communication Strategy

    High-quality output comes from high-quality constraint descriptions. A reusable prompt template looks like this (illustrative):

    1. Goal: single-page real-time 3D scene, convenience store on a rainy night street corner.
    2. Units: 1 unit = 1 meter; street width 6m, storefront 8m wide, 5m deep, eave height 3.2m.
    3. Camera: starts across the street, eye height 1.6m, 35-degree field of view, drag to roam.
    4. Lighting: cool ambient light + warm storefront light + emissive signage; night, low illumination.
    5. Materials: wet ground (low roughness, reflective), semi-transparent glass, brushed metal.
    6. Performance: stable on a mid-range laptop, configurable particle count, low/medium/high tiers.
    7. Delivery: a single HTML file with no external assets; key parameters grouped into a config object.

    The key point is to translate aesthetic demands into measurable parameters (dimensions, angles, illumination, roughness, particle caps, target frame rate) and to state constraints explicitly (single file, no external assets, configurable parameters). When the output deviates, correct it with contrastive feedback, for example: “the door frame is about 20% too tall; set the eave height to 3.2m and keep the awning overhang at 1.2m”, rather than vaguely saying “the proportions are off”.

    4. Proportion and Space: Get the “Does It Look Right” Part First

    The human eye is extremely sensitive to proportion. Build a white-model blockout first and calibrate it with screenshots: street width drives perspective tension, storefront width and eave height set the rhythm of the streetscape, and the awning overhang affects how rain and light are occluded. Ban details at this stage so that detail cannot hide proportion errors. A simple example of centralized parameter management:

    1. const CONFIG = {
    2. unit: 1, // 1 unit = 1 meter
    3. streetWidth: 6,
    4. shop: { width: 8, depth: 5, eaveHeight: 3.2, awning: 1.2 },
    5. camera: { height: 1.6, fov: 35 },
    6. rain: { count: 12000, speed: 18, wind: 0.15 },
    7. quality: 'medium' // low | medium | high
    8. };

    5. Materials and Lighting: Where the Rainy Night Look Comes From

    The core of a rainy night mood is high-contrast reflection under low illumination. The ground needs low roughness and environment reflections to read as wet; glass should be semi-transparent with a slight smudge normal; the metal awning and roller shutter use brushed textures with moderate metalness. For lighting, use cool ambient light to hold down overall brightness, add warm storefront light and emissive signage as visual anchors, then layer in bloom so the light sources “spill”.

    Use a filmic tone mapping curve to avoid blown-out highlights. Fog should deepen the scene exponentially, but it must work together with light attenuation, otherwise you get the problem of “fog eating the signage”. The most common failure at this stage is “all materials are correct but the image looks washed out”, usually caused by ambient light that is too strong and insufficient contrast. Lower the ambient light and raise emissive intensity first.

    6. Rain and Details: Particles, Ripples, and Rhythm

    Drive rain streaks with instancing or shaders instead of creating objects every frame. Make the count configurable and tie it to the quality tier. Ground ripples can be simulated with a few looping decal animations, focusing on the look of reflections being “shattered”. Details should be few and precise: one rain-soaked cardboard box, one reflective floor tile, one flickering tube light beats ten meaningless props. Details exist to guide the eye, not to fill the frame.

    7. Performance and Stability: Treat Frame Rate as a Hard Constraint

    Most real-time 3D performance problems come from overdraw and excessive transparency. Strategies include reusing geometry and materials, merging static objects, instancing particles and props, culling by distance, limiting stacked transparent layers, and applying resolution scaling on high-DPI screens. Always provide quality tiers:

    1. const QUALITY = {
    2. low: { rain: 4000, shadows: false, dpr: 1.0 },
    3. medium: { rain: 12000, shadows: true, dpr: 1.5 },
    4. high: { rain: 24000, shadows: true, dpr: 2.0 }
    5. };

    Also cap the time step in the main loop so physics and particles do not “jump” when you return from a background tab.

    8. Iteration Rhythm and Acceptance Checklist

    A “three-round iteration” method works well: round one accepts proportion and camera only; round two accepts materials and lighting; round three accepts rain effects, details, and performance. At the end of each round, take a screenshot and compare it against the target image to build traceable feedback. The checklist can include: storefront width and eave height error, initial camera composition, whether wet reflections are readable, whether signage is overexposed, whether the low tier is usable, and whether the single file runs offline.

    9. Common Pitfalls and How to Avoid Them

    • Asking for too much at once: leads to messy structure and makes problems hard to locate.
    • Describing feelings without parameters: output becomes highly random.
    • Ignoring units and coordinates: adjustment cost explodes later.
    • Losing control of transparency and particles: frame rate falls off a cliff.
    • Details before proportion: the largest amount of rework.

    10. Conclusion

    Treat AI coding tools as efficient collaborators that need clear constraints, and move forward in a layered, acceptance-driven, rollback-friendly way. A seemingly complex scene like a rainy night town can then be delivered reliably as a runnable, playable piece. What really decides success is not whether the tool “can do it”, but whether the developer can translate both aesthetics and performance into clear engineering language.