- Home /
The question is answered, right answer was accepted
How to increase performance with a lot of meshes (and large meshes)?
Hi
I would like to know if there is any way to increase performance when the scene contains a lot of meshes, with a lot I mean a couple of thousand. But of course they are not all in the rendering frustum. The size of the objects can be everything from 0.1 0.1 0.1 to 1000 1000 1000. But like I said there will only be a quite small amount of the objects rendered... But what about the other objects? Not only do they slow down the time to load the level (although the time to load the level is quite fast), but might cause lag while playing the game. So if there are any ways to increase performance when it comes to meshes, I would appreciate if you would post your solution here. Even if you only know a little bit, you're welcome to post solution as well.
Size of object doesn't matter. But the number of vertices and tris does.
I know that, but I was wondering if there is a "hidden gem" that could make it even faster. If it can go faster then I don't see any problem with that, as long as it doesn't affect the quality. I have a very good computer so it is fast already. This question was a little bit off-topic... But I'll be fine with it as it is now.
Answer by flamy · Jul 04, 2012 at 09:05 AM
First of all number of objects doesnt matter much compared to the draw calls you are getting in your game. You have to control the draw calls. Dynamic batching can be applied in this case by using same material for multiple objects(note that there should be no animation and the size of mesh should be small)
if the dynamic batching doesnt work, you can use static batching by marking the object as static, this could be useful for big objects, but needs a Unity PRO license. And you can find the static check box in the inspector at the top right.
Batching: Static batching and Dynamic batching.
if the objects cannot share the same material or texture, you can always do that from code by combining different textures and form a single one and assigning it to a material tht will be shared by different objects. For more assistance on this check this funciton. Also check the below forum links, Optmize a game in unity
http://answers.unity3d.com/questions/276212/what-is-the-simple-way-of-applying-texture-atlas-t.html, Optmize a game in unity and you can find several other links to get a more clear idea on this.
other than batching you can check for costly shaders that is attached to the objects (especial reflective shaders since number of objects are high).
If you are having textures or a audio files attached to a script using editor, try to avoid them and load it using Resources.Load function. Because the texture or audio file attached to the object will remain in memory until the game object or script instance is deleted.
If you are using OnGUI more, avoid drawing objects that doesnt need update multiple times per frame like label, or a plain texture and enclose in a if loop like the below,
if(Event.current.type == EventType.Repaint)
{
}
These are the general optimization techniques i follow. It is hard to tell more since you didnt post any thing related to memory usage, draw calls or a profiler screenshot.
anyway check this link Optmize a game in unity for more info.
Follow this Question
Related Questions
Editor lags when coming out of play mode...? 0 Answers
Re-meshing Static Objects as one mesh? 1 Answer
Random lag spikes any time processor intensive tasks a scene 0 Answers
Android Performance REALLY Laggy 2 Answers
Terrible Lag When Starting a Scene Which Eventually Resolves Itself... Graphics Card Issue or Unity? 1 Answer