Skip to content
Menu
Mob City
  • Home
  • Contact
  • About
Mob City

Modular building graphics

Posted on July 5, 2025

Creating realistic, varied buildings for a city simulation game presents unique challenges. How do you generate hundreds of unique structures without manually crafting each one? How do you ensure they feel authentic while maintaining performance? I’ll show you my attempt at solving this problem.

At its core, every building in my game is constructed from modular components that stack together like digital LEGO blocks:

  • Ground Floor: The foundation containing entrances and street-level details
  • Floors: Repeatable middle sections that can stack multiple levels high
  • Roof: The crowning piece that completes the structure
  • Basement: Hidden interior revealed when buildings become transparent
  • Windows: Procedurally lit windows that bring buildings to life

Each component is a separate texture that gets intelligently combined during building construction. The magic starts with how I organize the building assets on disk:

assets/buildings/commercial/
├── 1x1/
│   ├── ground/
│   │   ├── 1_outd=0,0_ind=0,0.png
│   │   └── 2_outd=1,0_ind=0,0.png
│   ├── floor/
│   │   ├── 1.png
│   │   └── 2.png
│   ├── roof/
│   │   ├── 1.png
│   │   └── 2.png
│   └── window/
│       └── 1_12~34,56~78.png
└── 3x3/
    ├── ground/
    ├── floor/
    └── roof/

Ground floor textures embed critical metadata:

  • 1_outd=0,0_ind=0,0.png means texture #1 with outside door at (0,0) and inside door at (0,0)
  • 1_12~34,56~78.png means window texture #1 with lit windows at positions (12,34) and (56,78)

All building textures get packed into a high-performance texture atlas system

When spawning a building, the Building class orchestrates the entire construction. Here’s a quick snippet of floor construction

Each time Building object is created, it randomizes its look from basement to the amount of floors.

At the moment, I haven’t generated enough images to significantly increase variety, but there are enough to see the system working as intended.

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Recent Posts

  • Modular building graphics
  • Lit up mode in night time
  • Night mode (tinting with shaders)
  • Traffic system and cars
  • Animation
©2025 Mob City