Skip to content

Tech Art & Optimization

Nichita Cebotari edited this page Nov 27, 2025 · 11 revisions

Overview

While the City Planner and Architect systems handle the logic and geometry, the visual fidelity and performance of the simulation rely on a robust Technical Art pipeline.

This section details the shader solutions for procedural geometry, the material workflow, and the optimization strategies implemented to maintain real-time frame rates with high object counts.

Key Technologies: Unity Shader Graph, HLSL, Static Batching, GPU Instancing.


1. The "Procedural UV" Solution (Triplanar Mapping)

A major challenge in procedural generation is UV mapping. Since the building footprints (and therefore roof/pavement meshes) are generated dynamically with irregular shapes and sizes, standard UV unwrap techniques result in severe texture stretching or misalignment.

The Shader Graph Approach

To solve this, I implemented a Triplanar Mapping solution using Unity Shader Graph.

  • Logic: Instead of relying on mesh UVs, the shader projects textures based on the world-space position of the fragments.
  • Implementation: The shader samples the texture three times (X, Y, Z axes) and blends them based on the surface normal.
  • [cite_start]Result: Roof tiles, cobblestones, and brickwork maintain a consistent physical scale regardless of how large, small, or distorted the underlying procedural mesh becomes[cite: 77].

[INSERT IMAGE HERE: A side-by-side comparison. Left: Standard UVs (Stretched). Right: Triplanar Shader (Correct).]


2. Material & Asset Pipeline

[cite_start]To achieve the specific 18th-century Parisian aesthetic, the system uses a modular asset library created by Environment Artist Stefani Badzheva[cite: 53, 131].

  • [cite_start]Substance Workflow: Materials were authored in Substance Designer, exposing parameters for dirt and weathering to break up visual repetition[cite: 55].
  • Texture Atlasing: Where possible, modular elements share texture atlases to reduce draw calls and material swaps.
  • LOD Groups: High-fidelity props (like the ironwork balconies) are heavy on geometry. [cite_start]I implemented aggressive LOD (Level of Detail) Groups to cull these details at a distance, preserving the silhouette while saving vertex processing costs[cite: 124].

3. Performance Optimization

Generating a city involves creating thousands of GameObjects. Without optimization, this would cripple the CPU. I implemented a multi-layered optimization strategy:

A. Draw Call Reduction

  • Static Batching: The CitySectorGenerator automatically flags generated buildings as Static immediately after generation. [cite_start]This allows Unity to batch non-moving geometry into fewer draw calls[cite: 126].
  • GPU Instancing: For repeated modular props (like chimney pots and window frames) that share materials, GPU Instancing is enabled to render identical meshes in a single pass.

B. Shadow Caster Optimization

Shadow casting is one of the most expensive rendering operations.

  • Problem: Initially, the scene had over 20,000 individual shadow casters, causing massive performance drops.
  • Solution: I tuned the shadow settings and disabled shadow casting on small, non-essential details (like small facade ornaments).
  • Result: Reduced shadow casters to approximately 1,000, significantly improving the frame rate without a noticeable loss in visual quality.

C. Mesh Optimization

To handle complex geometry, I integrated the Mesh Optimizer package (based on zeux/meshoptimizer). [cite_start]This tool strips unnecessary vertex data and optimizes the index buffer for better GPU cache locality[cite: 133, 155].

[INSERT IMAGE HERE: A screenshot of the Unity Frame Debugger or the 'Stats' window showing the reduced Draw Call count]


4. Visual Effects

To add life to the static geometry, simple particle systems were integrated into the generation logic.

  • [cite_start]Chimney Smoke: When a chimney prefab is instantiated by the CornerGenerator, it can optionally spawn a lightweight smoke particle system, adding atmospheric depth to the roofline[cite: 121].
  • Post-Processing: The scene utilizes a custom Volume profile with Fog and Color Grading to unify the procedural elements with the skybox.

End of Documentation.

Clone this wiki locally