Building a 3D Rainy Night Convenience Store Scene with AI-Assisted Programming
This article explores the practice of building a 3D rainy night convenience store scene using AI-assisted programming. It covers how to break down creative ideas into clear specifications, establish a stable workflow with AI coding assistants, and implement key technical aspects such as unified coordinates, rain particle effects, night lighting, and performance optimization. By following a layered approach and iterative verification, developers can efficiently transform a concept into a runnable prototype while managing common issues like scaling and transparency rendering.
I. Why Choose This Topic
A rainy night convenience store is an excellent subject for practicing 3D scene building. It features limited scene elements, concentrated light sources, and typical visual factors like rain screens, reflective ground, and neon signs, covering multiple aspects including modeling, lighting, particle effects, and interaction. For developers, it serves as a good sample to test whether the pipeline from “idea to runnable prototype” is smooth.
II. Requirement Breakdown: Write Specifications First
Creative ideas are often vague, such as “it should feel like a rainy night.” Feeding this directly to any tool will yield unpredictable results. A more reliable approach is to write a brief specification first, including the following:
- Spatial Scale: Store width, depth, height, and the width of the street in front. You can reference common dimensions of real convenience stores; there is no need to be accurate to the centimeter.
- Perspective: First-person roaming or a fixed camera. The perspective determines the camera height and visible range.
- Essential Elements: Signboard, glass door, shelves, checkout counter, street lights, puddles on the ground, and rain screen.
- Interaction: Whether movement is allowed, and whether there are interactions like opening/closing doors or turning lights on/off.
- Performance Goals: Target devices and acceptable frame rate ranges.
The clearer the specification, the fewer communication rounds will be needed later.
III. Workflow for Collaborating with AI Coding Assistants
AI coding assistants excel at quickly translating text descriptions into code skeletons, but they cannot directly perceive the proportions and visual feel in your mind. Therefore, collaboration requires a stable rhythm.
3.1 Layered Requirements
Do not request the generation of the complete scene all at once. You should proceed layer by layer: first build the ground and the building shell, then add doors, windows, and signboards, followed by interior furnishings, and finally handle the rain effect and lighting. Verify each layer individually so that when issues arise, you can quickly locate the cause.
3.2 Prompt Structure
It is recommended that each prompt contains four parts: current goal, key conventions in existing code, the scope of modifications for this round, and acceptance criteria. For example: “Only modify the rain effect, keep the camera and building coordinates unchanged, raindrop density should be adjustable. Acceptance criteria: the rain screen covers the store entrance area.” This phrasing reduces the assistant’s tendency to alter unrelated code.
3.3 Verification in Each Round
After each generation, run the code first, then check against the specification using screenshots or screen recordings. When deviations are found, describe the specific phenomena, such as “the entrance proportion is too large, about three times the height of the shelf,” which is much more effective than vaguely saying “it doesn’t look good.”
IV. Technical Highlights of Scene Building
4.1 Unified Units and Coordinates
Adopt the same length unit for the entire scene, such as 1 unit equals 1 meter, and note this in the code comments. Set the center of the ground as the origin, with the vertical direction as the Y-axis. Once the scale is unified, all models, light positions, and camera positions have a common reference.
4.2 Building and Store Structure
Walls, columns, and signboards can be combined using basic geometries, with details added through textures. Doors and windows should use transparent materials, paying attention to the render order of transparent objects. For shelves, you can create a single unit first and then duplicate and array it to reduce repetitive modeling workload.
4.3 Implementing the Rain Effect
There are three common approaches:
- Particle System: Use a large number of small line segments or points to represent raindrops, updating their positions every frame. It is straightforward to implement and suitable for small to medium-scale rain screens.
- Texture Scrolling: Scroll a rain texture on a transparent plane. It has a low computational cost and is suitable for distant views or background layers.
- Shader Implementation: Calculate raindrop movement within the shader. It offers good performance but has a higher debugging threshold.
The following sample code only illustrates the position update logic, and the values are examples:
// Example: Periodic update of raindrop positionsfunction createRainDrops(count, area) {const drops = [];for (let i = 0; i < count; i++) {drops.push({x: (Math.random() - 0.5) * area.width,y: Math.random() * area.height,z: (Math.random() - 0.5) * area.depth,speed: 8 + Math.random() * 6});}return drops;}function updateRainDrops(drops, area, deltaTime) {for (const d of drops) {d.y -= d.speed * deltaTime;if (d.y < 0) {d.y = area.height; // Reappear from the top after hitting the ground}}}
Raindrops only need to be rendered within the vicinity of the store. Particles outside this range can be excluded from drawing, which not only saves computation but also prevents visual clutter.
4.4 Night Scene Lighting
The atmosphere of a rainy night mainly comes from the lighting. It is recommended to control the number of light sources and base the scene on one or two main color tones. For example, use warm lights indoors and cold lights for the street to create contrast. Indoor lighting can use point lights or spotlights, while signboards can use emissive materials without adding extra light sources. Mild fog can enhance the depth of the scene. The reflection on puddles can be simulated using general methods like environment mapping or screen space reflection (SSR), with the specific effect adjusted according to device performance.
4.5 Materials and Details
The wetness of the ground can be achieved by reducing roughness and enhancing specular reflection. Adding slight reflection and transparency to the glass door will make the image more convincing. Small objects like beverage bottles, magazines, and price tags can be done with small models or textures; they determine the realistic vibe of the scene.
V. Performance Optimization
The more complete the scene, the greater the performance pressure. The following are common and effective practices:
- Merge static geometries to reduce the number of draw calls.
- Use instanced rendering for repeated objects (like products on shelves).
- Control texture sizes; use smaller textures for non-focus objects.
- Limit the range and resolution of real-time shadows; only enable shadows for key light sources.
- Use simplified models for distant objects, or hide them based on distance.
- Make the rain particle count an adjustable parameter to balance effects and performance across different devices.
Before optimizing, use profiling tools to identify the bottleneck before deciding which part to modify. Blind optimization often only improves secondary aspects.
VI. Common Issues and Troubleshooting
- Scaling Issues: Check if the unit convention is unified, and verify using references like door height.
- Rain Screen Looks Like Flickering Noise: Appropriately increase the length of raindrops, reduce speed variance, and give the raindrops a slight wind tilt.
- Transparent Objects Rendering Incorrectly: Adjust the render order, or render transparent objects last.
- Image Looks Grayish or Too Dark: Check the color space and exposure settings to ensure clear light and dark layers in the night scene.
VII. Conclusion
The key to completing a 3D scene with AI assistance lies in breaking down vague creative ideas into verifiable specifications and advancing in small iterative steps. Proportions, performance, and details usually require multiple rounds of adjustment, which is a normal development process. The three principles—unified units, layered prompting, and per-round verification—can help developers quickly turn an idea into a runnable, experienceable work.
