AI-Assisted Real-Time 3D Scene Development: A Rainy Night Town Case Study
This article explains how to turn a broad “rainy night town” idea into a runnable, testable real-time 3D scene with AI coding assistance. It covers acceptance criteria, requirement decomposition, parameterized scene architecture, wet-night materials and lighting, proportion and camera calibration, performance budgets, quality degradation, and multi-round iteration. Readers will learn how to use AI-assisted coding for scene skeletons, configuration panels, and debugging code while keeping visual judgment and performance decisions under developer control.
1. From Idea to Engineering: Define the “Rainy Night Town” as an Acceptance Target
“Building a rainy night town” sounds like a complete visual project, but the first step is not to pile up models and effects immediately. The practical first step is to narrow the idea into a runnable, playable, and iterable engineering target. Using a “rainy night convenience store” as an example, a reasonable scope is a single street-block segment: a convenience store front, street, streetlights, puddles, rain streaks, light mist, several static props, and a controllable camera with limited interaction. The first version should not aim for an entire city. It should first validate the visual direction, proportion relationships, and performance baseline.
Acceptance targets should also be quantified in advance. Visually, the warm and cool light relationship should be clear, the wet ground should feel reflective, and the rain and fog layers should not blur into one another. From an engineering perspective, the first screen should load, interaction should not block, and the scene should degrade across different resolutions. For performance, define general budgets first: for example, target a stable 60 fps on desktop and use 30 fps as the minimum on mobile. Draw calls, transparent particle counts, texture sizes, and dynamic shadows all need upper limits. AI coding assistance is well suited to generating scene skeletons, parameter panels, and debug code quickly, but it cannot replace human aesthetic judgment or automatically guarantee reasonable performance. Therefore, the more engineering-oriented the requirement description is, the more usable the generated result will be.
2. Requirement Decomposition: Turn Natural Language into a Scene Checklist
For AI coding assistance to be effective, vague descriptions must first be broken into structured checklists. The decomposition can follow five layers:
- Scene layer: ground, building blocks, convenience store front, shelf silhouettes, streetlights, vehicles or trash bins, and other low-poly props.
- Visual layer: low-saturation night base tone, warm convenience store light, cool streetlight light, wet-surface highlights, rain streak direction, and near-to-far fog layering.
- Performance layer: static geometry merging, repeated prop instancing, texture atlases, transparent particle limits, shadow strategy, and reflection degradation.
- Interaction layer: orbit camera, pitch limits, rain intensity adjustment, quality preset switching, pause, and camera presets.
- Acceptance layer: initial load time, frame time, memory usage, mobile degradation, interaction response, and visual consistency.
Each layer needs communicable parameters. For example, do not just say “make the rain heavier.” Say “increase near-field rain streak density, keep the far field sparse, keep the total particle count within budget, and automatically halve it on mobile.” Do not just say “make the convenience store brighter.” Say “increase the emissive intensity of the storefront sign, but do not raise ambient light globally, so the rainy-night contrast is preserved.” This makes multi-round communication reproducible and makes it easier to compare the benefit of each round of changes.
3. Scene Architecture and Parameterized Skeleton
It is recommended to build a gray-box scene first, then gradually replace materials and lighting. Use a unified coordinate system where “1 unit is approximately 1 meter.” A door is about 2.4 meters high, the convenience store front is about 6 meters wide, the street is about 8 meters wide, and the camera eye height is about 1.6 to 1.7 meters. Parameterized configuration turns proportion adjustments into communicable data instead of repeated manual code edits.
CONFIG = {unit: 1,storefront: { width: 6, height: 3, depth: 4 },street: { width: 8, length: 60 },camera: { fov: 60, eyeHeight: 1.65, near: 0.1, far: 200 },rain: { count: 1200, maxCount: 3000, speed: 8 },quality: "auto"}function buildScene() {city = createGroup("city")store = createGroup("storefront")props = createGroup("props")effects = createGroup("effects")city.add(buildGround(CONFIG.street))store.add(buildStoreShell(CONFIG.storefront))props.add(buildStreetLights())effects.add(buildRain(CONFIG.rain))scene.add(city, store, props, effects)}function animate(time) {delta = time - lastTimeupdateRain(delta, CONFIG.rain)updatePuddles(camera)renderer.render(scene, camera)requestAnimationFrame(animate)}
The key point of the pseudo-code above is not the specific interfaces, but the layered approach: static city, convenience store, props, and effects are organized separately so they can be toggled and optimized independently. Proportions, rain amount, and quality presets all live in configuration, so later communication can be validated by changing only parameters. Quality presets can degrade automatically based on frame time: reduce particles first, then lower reflection resolution, and finally disable dynamic shadows. This avoids obvious visual breaks at the first sign of performance pressure.
4. Rainy Night Visuals: Coordinating Materials, Lighting, Rain, Fog, and Reflections
The difficulty of a rainy night scene is that “wet, dark, bright, and foggy” must exist at the same time. For lighting, ambient light should remain low intensity. The convenience store should use warm emissive materials and local point lights to create a visual anchor, while streetlights use cooler light to create contrast. Dynamic shadows should not be excessive; static scenes can prioritize baked or simplified shadows. For materials, wet ground can approximate puddles through lower roughness, normal perturbation, and low-cost reflection. Convenience store glass can use an emissive texture with slight transparency, but the number of transparent layers must be controlled. Rain streaks should use particles or strips with a unified direction and a slight offset relative to the camera. Fog should use exponential fog or distance fog so the near field stays clear and the far field fades out.
wetGround.material = {roughness: 0.25,metalness: 0.05,normalScale: 0.4,reflectionMode: "lowCost"}storeSign.material = {emissiveIntensity: 2.0,color: warmWhite}scene.fog = {mode: "exponential",density: 0.015}rainSystem = {count: CONFIG.rain.count,size: 0.02,opacity: 0.35,direction: normalize(vec3(0.2, -1, 0.1))}
Visual consistency matters more than any single effect. Warm convenience store light, cool streetlight light, rain streak highlights, and puddle reflections should be organized around the same color-temperature logic. If every material is highly reflective, the image becomes a “plastic night city.” A recommended order is gray-box proportions first, then lighting zones, and finally rain, fog, and reflections. Validate only one type of problem per round.
5. Proportion, Composition, and Playability Calibration
Proportion is one of the most underestimated parts of real-time 3D scenes. If the door is too tall, it looks like a warehouse. If the street is too wide, the scene loses its small-town feel. If the camera eye height is wrong, the convenience store appears distorted. Use door height, shelf height, and streetlight spacing as references. First fix the scale where 1 unit is approximately 1 meter, then calibrate perspective with camera FOV and eye height. For composition, the street can serve as a leading line, the convenience store front as the visual anchor, and foreground puddles and near-field rain streaks as depth layers. The interactive camera should limit pitch angle to avoid clipping through the ground or looking up too far. Providing three presets—“street view,” “storefront close-up,” and “rainy night wide shot”—can lower the barrier to play.
Playability does not need to be complex, but it should provide feedback. A rain intensity slider, quality preset switch, time pause, and camera presets are all low-cost, high-perception interactions. Every interaction should be immediately visible, while automatic degradation provides a fallback so that users do not freeze the scene after manually raising parameters too high.
6. Performance Budgets and Optimization Strategies
Performance optimization should start with a budget, not with fixing stutter after it appears. General recommendations include controlling draw calls and using instancing for repeated streetlights and props; merging static geometry to reduce material switches; compressing textures as needed and avoiding multiple oversized images; controlling transparent rain streak and glass overlay layers; using low-resolution or local approximations for reflections; and reducing particle counts and disabling or shrinking dynamic shadows on mobile. Automatic degradation logic can be added to the code:
function checkPerformance(frameTime) {if (frameTime > 33 && quality > LOW) {quality -= 1applyQuality(quality)}}function applyQuality(level) {rain.count = level === HIGH ? 3000 : level === MID ? 1500 : 600shadows.enabled = level === HIGHreflection.scale = level === HIGH ? 0.5 : 0.25}
At the same time, monitor frame time, draw calls, memory, and initial load time, rather than only checking whether the scene opens. Keep versions and parameters for each iteration so you can determine whether an optimization is effective.
7. Multi-Round Communication and Iteration Process
This type of scene is rarely finalized in a single generation. Proportions, performance, and details require repeated communication. An efficient process is: first round, generate the gray box and parameter skeleton; second round, calibrate proportions and camera; third round, handle lighting and material zones; fourth round, add rain, fog, and reflections; fifth round, implement performance degradation and interaction; and finally, run regression against the acceptance checklist. For each round, use a format such as “phenomenon + expectation + constraint + acceptance.” For example: “Rain streaks on mobile are too dense and frame time increases. The expectation is to preserve near-field layering while reducing the total amount. The constraint is not to add new transparent layers. Acceptance is frame time returning within budget.” AI coding assistance can quickly provide candidate implementations and parameter adjustments, but final trade-offs still need to be made by developers based on visual and performance judgment. It is this loop of “fast generation, human calibration, and regeneration” that turns the rainy night town in your mind into a work that actually runs and can be played with.
