Building a Rainy Night Scene with AI Coding Tools: A Practical Guide
This article walks through building a real-time rainy night convenience store scene with the help of AI coding tools. It explains a five-layer construction approach, how to turn aesthetic goals into engineering constraints through prompt design, and why scale and proportion are the most common source of rework. It also covers rain, fog, wet-ground reflections, and neon implementation, along with performance budgets, small-step iteration, common pitfalls, and a final acceptance checklist.
1. The Gap Between a Mental Image and a Runnable Scene
In real-time 3D creation, the most time-consuming part is often not writing code, but translating a vague image in your head into a description a machine can execute. Take a typical scene like a “rainy night convenience store”: it involves building proportions, street scale, rain particles, wet-ground reflections, neon glow, volumetric fog, and camera movement all at once. When building from scratch, developers have to switch back and forth between modeling, materials, lighting, post-processing, and performance tuning. A single wrong judgment at any stage can make the scene “look off,” yet the cause is hard to pinpoint immediately.
The value of AI coding tools is that they compress this chain: you describe your intent in natural language, the tool generates an initial code skeleton, and the developer constrains and corrects it with engineering practices. It is worth stressing that this does not guarantee a perfect result on the first try. Imbalanced proportions, performance bottlenecks, and missing details are the norm. What really determines output quality is whether the developer can translate “something feels wrong” into “a parameter is wrong.”
2. Overall Technical Approach: Build the Scene in Layers
It is best to split the scene into five layers and converge on them one by one, avoiding a single massive, uncontrollable code generation:
- Scene skeleton layer: ground, road, building blocks, camera, and render loop.
- Scale and proportion layer: use real-world units as the baseline and lock in floor height, door width, and street width.
- Atmosphere layer: fog, rain, wet-ground reflections, ambient light, and neon emission.
- Detail layer: signs, shelves, glass, puddles, and rain ripples.
- Performance layer: draw call merging, particle count budget, and resolution and post-processing trade-offs.
Each layer should have clear acceptance criteria before moving to the next, so that communication with the tool has an anchor.
3. Prompt Design: Translate Aesthetic Needs into Engineering Constraints
A vague “make it look good” cannot drive code generation; it must be turned into quantifiable constraints. A reusable prompt structure looks like this:
Role: Senior real-time rendering engineerGoal: Generate a runnable, interactive rainy night convenience store street sceneConstraints:- Use meters as the unit; floor height 3.2m, door width 1.2m, street width 8m- Rain uses GPU particles, capped at 20000, avoid creating objects every frame- Ground uses a low-roughness material plus screen-space reflections to approximate wet ground- Neon uses an emissive material with lightweight bloom post-processing- Output must include a default camera slowly pushing forwardAcceptance: Target 60fps, draw call count must be printable for inspection
The key is three points: clear units, clear limits, and clear acceptance. Without limits, the generated result is often unusable in terms of performance; without acceptance criteria, iteration loses direction.
4. Scale and Proportion: The Most Common Source of Rework
Proportion problems almost always appear, usually because generated code defaults to “arbitrary units,” making buildings look like toys and streets like corridors. Engineering recommendations:
- First create a constant configuration section to manage all scale parameters centrally, so they can be adjusted at once;
- Calibrate with a reference object, such as a 1.7-meter human placeholder or a standard door height as a visual ruler;
- Adjust the camera field of view and height together; too high looks like a sandbox model, too low loses the depth of the street.
Example configuration:
const SCALE = {floorHeight: 3.2,doorWidth: 1.2,streetWidth: 8.0,cameraHeight: 1.65,fov: 55};
Once scale is managed centrally, communicating with the tool only requires saying “change the floor height to 3.0 and narrow the street to 6.5,” avoiding a full rewrite of the code.
5. Key Points for the Rainy Night Atmosphere
The texture of a rainy night comes from “contrast,” not “brightness.” Follow these practices:
- Rain: use a single buffered geometry to carry all raindrops, and offset their fall based on time in the shader stage, avoiding per-frame instantiation;
- Wet ground: lower ground roughness and add normal perturbation; screen-space approximation is enough for reflections, no need for physical accuracy;
- Fog: use exponential fog rather than linear fog, so distant neon fades naturally;
- Neon: emissive intensity and bloom threshold must be tuned in pairs, otherwise the whole screen easily washes out to white;
- Color: use cool blue as the base, with a small amount of warm orange as the visual focus, creating the warm-cool contrast unique to a rainy night.
6. Performance Budget: Turn “It Runs” into “It Runs Smoothly”
Most failures in real-time scenes are not logic errors but budget overruns. Set the budget before writing effects:
| Item | Suggested Budget | Notes |
|---|---|---|
| Rain particles | 10,000–20,000 | Diminishing returns beyond this |
| Draw calls | Keep in the hundreds | Merge static geometry |
| Post-processing | No more than 2–3 | Prioritize bloom and tone mapping |
| Pixel ratio | Cap at 1.5–2 | Avoid overloading high-DPI screens |
You should also build simple frame rate and draw call printing into the code, making performance an observable metric rather than a matter of feel.
7. Detail Iteration: Use “Small-Step Validation” Instead of “Getting It Right in One Pass”
Details must be advanced in batches. The recommended rhythm is: first confirm the blocks and camera, then add large-area materials, and finally add small elements like signs, shelves, and puddle ripples. Change only one variable per round, for example “only adjust sign brightness” or “only increase the number of ground puddles.” This way, if the image degrades, you can attribute the cause immediately. If you use an AI coding tool with fast response, you can make continuous fine adjustments in the same conversation round, but you should still keep the single-variable principle.
8. Common Pitfalls and How to Avoid Them
- Unit confusion: unify to the metric system and configure centrally;
- Object explosion: route all repeated elements through instancing or merging;
- Reflections too strong: adjust reflection intensity and roughness together;
- Bloom out of control: raise the threshold and lower the intensity;
- Camera clipping: add a minimum height and collision bounds for the camera;
- Generated code too long: split files by module, and generate and replace block by block.
9. Acceptance Checklist
- Does it run at a stable frame rate;
- Do the proportions match real-world scale;
- Are rain, fog, and reflections clearly layered;
- Are there obvious clipping and flickering;
- Is the code modular and are parameters centralized;
- Can more details be added without breaking the overall structure.
10. Conclusion
Using AI coding tools to turn ideas into runnable work, the core skill has shifted from “writing every line by hand” to “defining constraints, setting budgets, and validating quickly.” When developers translate aesthetic judgment into quantifiable parameters and acceptance criteria, building a rainy night town turns from repeated back-and-forth into a reproducible, iterable engineering pipeline.
