- Home /
Low Performance when drawing many objects
I'm making a demo where there is a stadium filled with supporters (fans, audience, as you wish). I've been having performance issues with this, so I ended up making each supporter as a billboard, that is, a rectangle formed by 2 triangles. I even took out the texture, so it's a stadium filled with 10.000 white rectangles.
When they are disabled I get 60fps, enabled I get 35fps, a 41.6% fall.
Rendering Profiler doesn't show many differences between supporters on/off (using the default 'fastest' configuration). Triangles count and draw calls almost don't change, batched comes from zero to 3550. However, CPU Profiler indicates that the performance fall comes from rendering.
I instantiate those rectangles in the Start method of script like this:
var go = (GameObject) Instantiate(audience, position, rotate);
I'm using the Difuse shader.
What is causing this, or how could I investigate further?
Although your question is quite old, I would wish to know whether you ended up solving the performance problem and how. $$anonymous$$y guess from your question is that you were suffering from performance in the Drawing phase of the rendering, since you said that draw calls were already low.
Answer by Eric5h5 · Feb 01, 2012 at 08:36 PM
Having 10000 individual objects will kill the framerate, yes (whether they have a texture or not will make little or no difference). You probably have vsync on, so it's likely the performance drop is greater than 41.6%. Rather than separate objects, it should be just one object, like a particle system.
Although this answer is some years old, I would like to further question: but in that case of merging all objects into one, wouldn't the change to be expected be in drawcalls? The OP already had low drawcalls due to Unity's batching.
Answer by anszwa · Feb 01, 2012 at 08:52 PM
Create an empty game object and put the single objects in it, maybe seperate them in a couple of groups in order of which objects you can see at the same time on screen. Then assign the "combine children" script, which you can get at standard assets-scripts, on the empty game objects, which has the effect that all children of it get combined to one mesh at game start. so you only have one draw call at each group which is much better for performance.
@anszwa Thank you for explaining this procedure, I didn't know it, but I already had a low draw call count, Unity seems to have made a smart batching system to lower draw calls of similar objects. In my tests you can see batched co$$anonymous$$g from zero to 3.5k, making draw count be almost the same with/without the audience. Anyway, I used the combine script and had no performance improvement.
Can you upload your project, so that we can have a look on the problem?