Broadphase realtime occlusion optimization part 01

preview_player
Показать описание
Unity requires that occluders be static edit-time data which doesn't work for a fully procedurally generated world. So for this game we're going to have to introduce some custom collision schemes.

Luckily the game is a 3d grid and we traverse between floors so there's some specific things we can take advantage of to help improve rendering performance.

This first broadphase pass simply arranges all the lights and meshes into per-floor arrays of meshrenderer arrays after generating the world. At runtime we check the players cell y coordinate and hide all geo/lights that are more than N floors away from the players floor. We only run the occlusion code if the player's cell changed on the y-axis.

The main issue is right now because I have N set to 1 you can see some pop in. The plan to fix that is to render a few extra cells on the y-axis past N around the player if they are in a cell adjacent to a chute or staircase. This way I can fix the issue without having to render too much extra redundant data.

Rough numbers

Before
- approx 31k batches
- shadow casters : ~25k
- cpu main : ~40msec
- render thread = ~17.5msec

After
- approx 4k batches
- shadow casters : ~3k
- cpu main : ~20msec
- render thread = ~7msec
Рекомендации по теме
welcome to shbcf.ru