When you focus on one thing, you forget about another…
So. I feel like a broken record anytime I talk about Draw Calls on here, because it seems like I mention them at least once per blog post. So let’s talk about something a little different: polygons.
Now, while draw calls may be a little more on the abstracted side of things, polygons are something that most people have their head wrapped around, and game designers are trained to make the poly count as low as possible, without sacrificing too many details. However, on mobile, there’s a weird balance that we need to master: quality of models vs art that is too heavy for the tablet or phone to handle.
For a while now, we’ve been so focused on draw calls, and we thought that lowering the draw calls was our only concern in terms of optimization to make the game playable. However, we’ve come to realize that it’s more than just draw calls: it’s also the poly count. Between our higher-poly-than-needed models, how many models are visible at once, lack of using Unity’s LOD feature (which means we’re keeping high-poly models on screen at all times), and our shader which requires multiple copies of each models in the scene, we’ve run into a performance wall. During playtests, the game runs at as low as 8 FPS, and the game frequently hard-crashes after any extended play.
To figure out where things are going wrong, I went through and disabled folders of game objects to see where all the polys were coming from.
To start things off, let’s look at the whole scene, which clocks in at 367.6k Tris and 248 draw calls. Both of these numbers are obscenely high.
Next up, the scene without the characters. This dramatically brings the stats down to 73.9k Tris and 39 draw calls. This means ~80% of the entire scene’s poly and draw call counts come solely from the characters.
Next, removing one of our prop sprite sheets, which includes the bar, pipes, and table. This drops it to 64.7k Tris and 25 draw calls. Not a huge difference in comparison to the characters, but still quite significant.
Another prop sheet, including one of the most used props used throughout our scenes: the stool. This brings things down to 52.3k Tris, and 22 draw calls.
This is the highest poly count prop sheet, dropping things to 21.2k Tris and 19 draw calls. We also use the bottles and mugs quite religiously in every scene we have.
This is the most minor of the prop sheet poly counts, bringing things down to 20.3k Tris and 16 draw calls.
Another mid-range poly count sheet, bringing things down to 9.1k Tris and 13 draw calls.
And finally, the vents. 1.4k Tris and 9 draw calls. Not a huge difference when compared to other prop sheets, but since it is JUST the vents, it’s definitely a lot.
So wait. Wait. Wait… Why is there 1.4k Tris when only the floor is visible?
With the floor hidden, we’re reduced to Unity’s most basic form, with 2 Tris and 1 draw call. So that means the floor is using 1.4k Tris and 8 draw calls? The floor is a basic plane, the hell is up with that? Well, I found that we had an extra copy of the floor we didn’t need anymore, but that still left 700 unaccounted-for Triangles.
Through this exercise, I discovered something I didn’t expect: Unity’s primitive plane has 700 triangles. Upon discovering this, I turned around, opened Maya, and immediately exported a 2 Triangle plane to use on all my scenes.
Why you would ever need a 700 Tri plane is beyond me.
So, after all is said and done, what does this all mean? What did we find out from this? And where do we go from here?
- Character mesh polys need come down. WAY DOWN. And they need to be merged meshes to put the nail in the metaphorical draw call coffin. Tre just completed the new meshes for the characters, and brought them down by 90%. He also went ahead and redid the rig, and used the same rig between all characters. This will reduce the CPU power needed to render the animations, since he got rid of a lot of controls and joints we didn’t need, on top of reducing the amount of influences on each joint. However, this also means that all animations need to be done from (pretty much) scratch, since the old rigs are not being used anymore.
- Props in general need to come down in poly count, but most importantly the props we use most: bottles, stools, tables, etc. All of the props are getting a poly-reduction pass now, and Keren has given me some lower poly models to start plugging in.
- Never use a primitive Unity plane unless you, for some reason, want the most detailed floor plane ever.
- Live lights (aka, lights that aren’t just baked into your scene) use one draw call PER MESH they’re affecting. As such, they increase in an exponentially increasing rate. Less draw calls to begin with, the fewer draw calls will be created from lights in the scene.
So hopefully this post was helpful to people who are looking to optimize their games. Since my role of producer is beginning to require my time to create game websites, online presences, etc., I’ll probably begin posting about the other projects I’ve been working on, not just SoulFront.
But until next time, stay classy.