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

First attempt at building occlusion

Posted on December 7, 2024

In a big city full of multi-story buildings, pawns can walk between them. If they walk behind a building, the player won’t be able to see them, meaning they might miss them entirely or be unable to select them. This is a classic visibility problem. There are various solutions to it, but most of the time, game developers find a way to remove or fade out obstacles that cover important things.

The first step is identifying what should be occluded. In my case, that means marking buildings. This part is fairly intuitive: we get the world grid coordinates currently visible to the player. I’m using the same algorithm here that I use to determine which tiles should be rendered (i.e., the visible view port). For now, I’m marking just the tiles in the rough center of the view port.

Second, as I draw the buildings, I check if they are in the occluded view port area and if so, change the texture of the object (obj.occlude()):

The methodology is quite simple and I’m planning to change it later to be semi-transparent, rather than showing the “basement” of the building. But for now, the buildings simply disappear as you zoom in closer.

Leave a Reply Cancel reply

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

Recent Posts

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