each color block is made up from ~1200 quads, so there are ~15,000 quads(separated into multiple gameobjects, so there are 15k+ Gameobjects in the scene), uses only 5 draw calls, wondering why my FPS only 12-13. What is slowing it down ?
GameObjects are heavy on resources. You shouldn’t be using them so heavily. At most I would recommend no more than one for each of the color blocks. They are entirely the reason your performance is that bad.
But when i turn my camera away from them, seeing nothing of them, i get ~40fps, all the gameobjects still there(in the scene). its still slow, but not ~12fps. I m doing this trying to understand what slow things down and try to learn how to avoid them.
It may be they’re being culled out prior to the stage where they cause problems. I don’t actually know how they’re handled internally, but I do know the performance problem involves them.
Any why low framerate questions should be replied with “show profiler” But agree with Ryiah’s suggestions.
Yes, I really should but most of the time it seems to revolve around GameObjects being used like this.
Really, Unity should be able to handle a few thousand draw calls and far more gameObjects. It’s probably transform that’s the cost penalty here since moving a child will evaluate everything including parents. Then there’s culling. Unity has a lot of scenegraph optimisations to do.
couldnt tell from the profiler, it says rendering take most of the “cpu time”, but im pretty sure it can do alot more tris and verts.
Tris and Verts only matter once you’re into the million mark on a modern desktop. It’s more about draw calls, optimisations etc
In the above shot it looks like a lot is saved by batching. If using static batching, you stress culling performance, which is why static batching is often best reserved for larger chunky pieces that should still cull. Dynamic batching can also suffer because preparing a dynamic batch still takes time.
Ideally just make a single mesh and it should run absolutely fine.
All things in moderation.
Ya, as a single mesh, i should be getting full FPS without any issue, but the purpose of this is, I want to know the limitation and avoid it in the future. At this moment, all i can say 15k GameObject is slowing things down, and 15K isnt alot, assuming 1 3D model has 100-200 smaller GameObjects, putting 100 of them on the scene will hit this limit.
GameObjects are CPU-side. Actual rendering is through the MeshRenderer component.
Yes, it is a lot.
One model does not have 100 to 200 smaller GameObjects. It only has one GameObject. GameObjects are not restricted to a single triangle or quad.
I dont understand how do you count, for example in this image below, how many gameobjects are in the scene ?
What on earth are you attempting to build? As a general rule the more things you put on the screen the simpler they have to be. Throwing hundreds or thousands of things on screen means each individual thing has to be simple.
Watch how RTS games do it. Each unit is very simple.
currently the problem happen even they arent on the screen, as long as those 15k items in the same scene(camera has nothing), fps drops too.
That isn’t remotely his bottleneck though. Putting thousands of things on screen with 100 polys each would probably perform pretty much the same as 1,000 polys each. Modern GPUs process this stuff at a frightening rate - the slow down comes from interrupting it or being slow to feed it.
Post profiler as anyone with a brain won’t help you further without it. Guessing this stuff is kind of dumb when you have hundreds of thousands of dollars of profiler engineering built into unity.
Oh ok
When i turn my camera away, im getting very high FPS in the statistics, but my code below only shows ~35FPS, when i delete all gameobjects on screen, i get 60FPS from the code.
void OnGUI() {
GUI.Label(new Rect(1, 1, 100, 20), (1f / Time.deltaTime).ToString());
}
I’m dying to throw some thought at this, but none of @narf03 's images are showing up for me.
You must have the same weird problem I do. Some sites, such as postimg.org, don’t show up in any browser for me except for Internet Explorer. I have a similar problem with Amazon and NewEgg. No idea why either.