- Home /
Huge city, how to split it up for best performance?
I'm building a huge city(about the size of most of manhattan), however there are only 65 townhouses, 53 skyscrapers, 27 industrial buildings and 17 unique "landmark" buildings. except the "landmarks", all the buildings are repeated over and over, but in a confusing pattern to make it harder to remember each building. The streets are pretty low poly too.
I'm have pro and I'm using occlusion culling.
how should I group the parts for best performance?
Edit: What I'm really asking for here is modelling help: how large should each group/part be and what should be grouped together. I'm still undecided whether to make each building as a separate mesh or make whole city blocks as one mesh:/
Here's an example:
Answer by Jordi-Bonastre · Jul 24, 2015 at 01:11 PM
Take a look to this part of the Manual. It could help you
http://docs.unity3d.com/Manual/OptimizingGraphicsPerformance.html
http://docs.unity3d.com/ScriptReference/Camera-layerCullDistances.html
Thanks. Is it best to have each building as one object(with box collider) or entire blocks as one object?
You should use the profiler to check the performance, but I think that it should be better entire blocks. If you prefer to assign a box/mesh collider to every building I think that a good idea would be enable/disable the box collider with a script similar to this pseudocode:
if(my distance to the camera > X) disable my collider else enable my collider
thats a good idea for sure, I'm gonna try that. I but even if I have one collider for each block, should each house be an individual object or should the entire block be one mesh?
You could have a root node for the mesh and multiple childs for the colliders. I send you attached a screenshot.
I would actually argue against using whole blocks.
Just use the couple models you have and make sure all instances of that mesh are referencing the same mesh in the project window.
That way there should not be a need to load many different models onto the graphics card - ins$$anonymous$$d just all your variations. Then the GPU should be able to use references and avoid hogging too many resources.
Then again, CryEngine works like this, not sure about Unity in this case.
Answer by reddead12 · Jul 24, 2015 at 07:49 PM
you can dowload a Combined mesh script asset from the asset store, Personally my favorite cause it automaticly makes it a shared material though its costs money: https://www.assetstore.unity3d.com/en/#!/content/8748
you can also try to make your own combine mesh and material script
Or you can use the default methods to optimize performance, Some Usefull Links: http://gamedev.stackexchange.com/questions/64492/how-to-opitimize-shadows-in-unity-3d OR http://answers.unity3d.com/questions/482381/what-are-causes-of-overhead-in-profiler.html OR http://answers.unity3d.com/questions/37293/general-ways-to-optimize-frame-rate.html
Thank, many helpful links there, basically what I'm asking for is modelling guidelines. I need to know how to split up and/or group the model to make it run efficiently.
Edit: Occlusion culling+the setup with entire city blocks + a UnityCar gives me 4440 drawcalls and a s$$anonymous$$dy 89-90 fps.and thats without disabling colliders. However that is with all render textures disabld. I'm hoping diabling colliders will boost fps further so I can run real time reflections without too much lag:)
Answer by Wolfdog · Jul 25, 2015 at 12:07 PM
A few tips:
Use textures to "fake" detail. From the images you provided, it's clear that you're going to paint in the windows and stuff. Instead of having a texture for a wall, and another texture for a window which is going to be painted over the wall, have 1 texture for the wall with the windows already on.
All vertices will count. Even cutting down on a few vertices on each model will improve performance dramatically. Also, keep it as low poly as possible (eg. avoid round edges).
Also, when it comes to colliders, I'm against the use of mesh colliders (unless they're convex). use box colliders for the general outline of the building and then smaller box colliders for the most important details.
I hope that what I said makes sense.
No, no, no, you misunderstood, those buildings are already done and fully textured. I just turned them off for the screenshots ;) I also limited the texture size for all the textures in the import settings to 512 which I think improved the fps a little aswell.
When it comes to colliders, for this test I did'nt use box colliders (altough I prefer using them)I made an object containting separate simple,4-faced meshes/boxes(no top or bottom) representing each entire city block and not each building. And checked "generate colliders" in the import settings, giving each of those "city block objects" a mesh collider and of course no mesh renderers. I would guess those mesh colliders, as they only have a few polys each, are pretty much the same processing cost as box colliders? anyways thanks for your tips:)
Btw: When I disable colliders depending on the player position, should I do it in Update or Late Update?
oh, sorry about that.
I believe that disabling the colliders will use more CPU power than simply leaving them on.
Do not do it every frame.
If I had to do what you're trying to do, I would have a timer which checks and disables colliders every 5 seconds or so.
Oh, thanks, well in that case I guess I'll leave them on, but if I choose to do it, should I do it in Update or Late Update?
It doesn't really matter, because it happens every frame anyway. I personally would do it is Late Update, because it isn't too important to the gameplay. That's just my preference though.