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

    This article presents a practical workflow for using natural language to drive AI coding tools to build a runnable, interactive 3D rainy night city scene. It explains why this type of scene tests three boundaries of generative coding—spatial proportion consistency, real-time rendering performance, and the communication of visual details—and introduces a six-layer breakdown, a five-part prompt template, key practices for proportion, materials, lighting and weather, a performance budget table, and an iteration and acceptance checklist. Readers will learn how to turn vague aesthetic intent into measurable constraints for predictable results.

    1. Why a Rainy Night Convenience Store Is a Strong Test Case

    The core of this practice is not any specific tool, but a typical engineering question: how to use natural language to drive AI coding tools to produce a runnable 3D scene that people can explore and interact with. A rainy night city was chosen because it stresses three capability boundaries of generative coding at the same time.

    The first is consistency of spatial proportions. Street width, building floor height, sign dimensions, and the relative scale of people and vehicles are all immediately noticeable to the human eye if any of them is distorted. The second is the performance budget of real-time rendering. Rain streaks, wet-surface reflections, neon glow, and layered dynamic lights can easily cause the frame rate to collapse. The third is how well details can be communicated. Vague descriptions such as “make it wetter” or “make the neon cooler” need to be translated into explicit parameter ranges rather than random values.

    This article therefore does not revolve around any third-party product. Instead, it frames the problem as follows: how to establish a stable collaboration protocol with AI coding tools so that 3D scene generation moves from trial and error to predictable outcomes.

    2. Overall Approach: Break the Idea into Verifiable Intermediate Outputs

    Generating a complete scene in one shot has a high failure rate, mainly because the context becomes too long and constraints conflict with each other. A more reliable approach is to proceed in layers, with each layer producing an intermediate output that can be verified independently.

    A recommended six-layer breakdown:

    1. Skeleton layer: ground, roads, block outlines, the initial camera position, and the base fog setting.
    2. Massing layer: use simple geometry to define building volume, floor height, and the street width-to-height ratio.
    3. Material layer: wet and dry zones, roughness and metalness分区, and normal detail.
    4. Lighting layer: ambient light, a directional moonlight, emissive signs, and a small number of dynamic point lights.
    5. Weather layer: rain particle curtains, ground ripples, water streaks on glass, and volumetric fog.
    6. Interaction layer: walkthrough controls, view switching, a parameter panel, and performance toggles.

    Run verification immediately after each layer is completed to prevent errors from accumulating. In practice, the cost of repeated communication is concentrated mainly on two things: skipping layers and raising too many constraints at once.

    3. Prompt Engineering: Turning Vague Aesthetics into Explicit Parameters

    Output quality depends heavily on how structured the description is. A five-part template is recommended: role + goal + constraints + output format + acceptance criteria.

    Example prompt structure:

    1. Role: You are a senior real-time graphics rendering engineer.
    2. Goal: Build an interactive 3D scene of a rainy night street and a convenience store.
    3. Constraints:
    4. - Street width 8 units, building floor height 3.2 units, convenience store frontage 6 units;
    5. - Use only basic geometry and procedural materials; do not load external models;
    6. - No more than 4 dynamic lights; simulate the rest with emissive textures;
    7. - Target is real-time execution in the browser; expose a quality preset toggle.
    8. Output: A single runnable page file containing initialization, the render loop, and a parameter panel.
    9. Acceptance: The first screen runs; switching to low quality noticeably improves the frame rate; no console errors.

    There are four key techniques. First, replace adjectives with numeric ranges—for example, change “wetter” to “ground roughness 0.15 to 0.3, reflection intensity increased by 30%”. Second, explicitly state budget limits so the tool makes trade-offs within the constraints. Third, require adjustable parameters to be exposed, returning aesthetic decisions to the human. Fourth, change only one variable at a time to make regressions easier to locate.

    4. Scene Construction: Coordinating Proportion, Materials, and Light

    For proportion, establish a baseline of “eye height 1.6 units” first, then derive other scales from it. This effectively avoids scaling the whole scene up or down. The convenience store interior also needs a reserved shelf aisle width; otherwise the camera will clip through geometry and feel cramped when it moves inside.

    For materials, the key to a rainy night look is the division between wet and dry areas. Asphalt has low roughness and high reflectivity; sidewalk brick joints have slightly higher roughness; walls are wetter below the eaves. When generating procedurally, blend two sets of parameters using height and masks instead of applying one global setting.

    For lighting, follow the principle of “few but precise”: one low-intensity directional light shapes the silhouette, ambient light keeps shadows from going fully black, signs and light boxes carry the main visual focus through emissive materials, and dynamic point lights are reserved only for key areas near the camera. Glow intensity must be adjusted together with exposure, otherwise the rainy night will blur into a single mass.

    For weather, rain streaks should be implemented in layers: use thicker particles with a slight tilt in the foreground, replace distant rain with a low-density fog curtain, and animate ground ripples with a looping ripple texture. This balances visual credibility against controllable cost.

    5. Performance Budget and Optimization Checklist

    Ask the tool to output a budget table during the generation stage rather than fixing problems after the fact.

    Item Recommended Limit Optimization
    Dynamic lights 4 or fewer Replace with emissive materials, bake lighting
    Transparent particles 3000 to 6000 Layered density, distance culling
    Draw calls As low as possible Geometry merging, instanced rendering
    Texture size 1024 or 2048 for main textures Tiered loading, release on demand
    Post-processing Glow plus lightweight tone mapping Provide a quality toggle

    General optimization practices include: use instanced rendering to reuse repeated objects; cull distant detail by distance; merge static geometry to reduce draw calls; cap the pixel ratio; and provide low, medium, and high presets in the parameter panel so users can make their own trade-offs.

    6. Iteration and Acceptance: Turning Repeated Communication into a Process

    A stable collaboration rhythm is “small commits, single-variable changes, immediate acceptance”. Maintain an acceptance checklist: does the first screen run, is the console free of errors, are the proportions coherent, does the low-quality preset run smoothly, can the interaction be exited, and is the parameter panel adjustable.

    When a deviation appears, first identify the layer the problem belongs to: if it is massing proportion, go back to layer two; if it is surface quality, adjust the material parameters; if it is stuttering, check the budget table. Once the problem is located accurately, raise only one change request at a time, and the success rate improves significantly.

    For further engineering, dependencies can be installed and static hosting handled in a cloud build environment, page resources distributed through object storage, and load time and exceptions tracked with logging and monitoring alerts, forming a closed loop from generation to release. These capabilities belong to general cloud product categories and can be combined as needed.

    7. Conclusion

    The real difficulty of a rainy night city is not the amount of code, but the ability to translate aesthetic intent into measurable constraints. Once layered breakdown, structured prompts, explicit budgets, and single-variable iteration are done well, AI coding tools can reliably turn ideas into runnable, explorable real-time 3D works.