Hello! One of the levels in our game is in a huge city. We’ve modelled a lot of buildings and everything looks great but there’s some questions I couldn’t find the answers to regarding the import in Unity. So let’s say we have 30 different skyscraper buildings and we have placed them to form a city. We’ve also duplicated them several times in order to make the city bigger. Now, if we import them as different objects we can use occlusion culling and hide all buildings that can’t be seen, which is great but there’s an issue - the lightmapping. When we bake the map it takes really long and because there’s a lot of sepparate game objects Unity creates a lot of lightmap files. So we ended up with separated buildings and 500 MB of lightmaps which I guess will not only take lots of disk space but also a lot of RAM. Our current approach is to segment the city and make each segment with buildings one object. Of course each segment has about 60K polys.
So my question is: is this a good approach or should we work on something else?
In my opinion you shouldn’t lightmap the whole city, because it takes too much space/ memory… so I suggest 2 possibilities, pick one if you want:
simple: use realtime shadows on poly-reduced version of the buildings
simple again but different: position your sunlight very high so that a big building’s shadow can’t “hit” another building beside it, and then lightmap each “city-block” (1 building + 1 part of road/ ground around the building) separately, you’ll end up with your 30 city-blocks, correctly lightmaped that you can arrange like you want…
I’m also working on a 3d city algorithm, I would say: try to use “object pools” (as I read somewhere) :
-you have a stock of “only” 100 buildings and then display and recycle only those needed in the camera view. the concept is to be able give the illusion of an infinite city with only a small amount of models/ objects, (by recycling every time)
Hi, thanks for the reply!
About your first suggestion: We are waiting for funding and still don’t own Unity pro but what do you mean to use realtime shadows on models with reduced polycount ? We need the buildings detailed. Maybe I’ve understood you wrong.
About the second suggestion: That’s actually pretty neat. The only problem that comes to mind is that the ground shadows won’t copy but I guess I can bake the scene with all buildings and later delete most of the buildings and their lightmaps, keeping only the main objects that are different.
I was thinking about a way to improve performance with real-time shadows by using a more simple object that only cast shadows, but that is not visible ( not sure if it’s actually feasible, maybe with shaders or unity renders functions…) the scene would also feature your high detailed buildings but those can only receive shadows… just a basic idea…
you should make “city- blocks” : your buildings always features a part of ground /roads around them… then the whole city block is lightmaped, make sure the shadows are on the ground and not projected further than your road around nor on another building that would be beside (with a high sun) …
…but that’s a solution only for a flat city… think “modular”… blocks would then match each other like a puzzle and shadows would look coherent.
Right! Well that’s a way to do it. However we don’t have ground elements along with the building objects. I guess I could also use a really low res lightmap and make the shadow distance bigger. That too can be a solution I hope.