Welcome!

Think Labs is an ongoing effort by Seven2 to provide research and educational opportunities in the web development and mobile field. To see what we’ve been cookin’ up, check out our blog postings.

Created by
Seven2 Login

Categories
Tags
Team Think Labs | Unity Performance Quick Tips: Draw Calls, Triangles, + more
4011
single,single-post,postid-4011,single-format-standard,ajax_fade,page_not_loaded,,,wpb-js-composer js-comp-ver-4.2.3,vc_responsive
1

Unity Performance Quick Tips: Draw Calls, Triangles, + more

Unity is currently one of the leading choices for mobile game development. It’s fast performance, and scalability make it an amazing game engine. However, if you’re going to develop for mobile, one of you major hurdles is going to be optimizing performance, and one major performance killer in Unity is not limiting your draw calls and triangles. Most of what I’m going to go into applies to 2D games but the principles carry over to 3D games as well.

What the smelly heck is a “draw call”?

1

Draw calls indicate how many texture draws your gpu has to display. The more textures you display the more draw calls you will have. This can hog you gpu and cause your frame rate to drop or even crash your game if draws are to high.

If you’re wanting to support iPhone/touch 4th gen and up you can usually push 60-100 depending on the circumstances. Obviously shooting for the lowest amount possible is always the safer bet.

Batching / Atlases

Screen Shot 2013-06-24 at 11.34.58 AM

Not to worry though, this is where batching is you best friend. You can batch draw calls by sharing the same material across multiple objects. In the case of 2D unity games, I use a tool called ex2D to batch my animation textures and static textures into sprite atlases. An atlas is basically a texture sheet with multiple textures in it. You can then have a Game Object that reads the offsets on the atlas and knows which “frame/texture” to display. So say you had a 30 frame sprite animation, you will cut down what would be a high number of draw calls down to one draw call.

Alpha Overdraw

Alpha overdraw is another consideration when developing in Unity. Alpha overdraw happens when objects with a transparent shader are in front of other objects. If more than one transparent objects overlap, this will take up another draw call.

Triangles or “Tris”

Triangles are the geometry of your 3D models. When making 2D games this is less of a concern given that you are not using complex 3D models. But this also another area where you can take a performance hit. One practice that some 2D games do is to use planes to attach their 2D textures to because they are a flat model. However the downside to the native Unity planes is that they actually contain multiple triangles.

quad-vs-plane

I recommend making a Quad model in blender or another 3D program instead. This will only have 1 face as opposed to the high number of a plane. However another advantage to ex2D is that you don’t even need to worry about this, it’s built sprite objects come pre setup like this for you.

Conclusion

Hopefully some of these quick considerations will help you better understand what can cause some of those headache inducing performance bottlenecks (at least from a visuals standpoint).