Unity 3D vs libgdx: 2D performance



Did you read my previous post about 2D frameworks for Unity 3D? I was curious how their performance compares to my favourite framework for game development: libgdx.

Again, I tested everything on my Xperia Play (on iOS you'd get roughly similar performance using an iPhone 4). My test consists of a single background sprite (640x960 px, static) and three animated sprites (all frames were packed into a single atlas texture to reduce draw calls).
Every touch spawned 10 sprites, every second touch spawned another 100 sprites (randomly selected from these three types). Sprites go from the top of the screen to the bottom of it and are deactivated and reused later (except for the libgdx test, read below). Here are the results:

Sprite countOrthello 2Dex2DSpriteManager 1SpriteManager 2libgdx
5057 fps60 fps60 fps60 fps60 fps
10018 fps60 fps60 fps60 fps60 fps
1506 fps58 fps60 fps60 fps60 fps
2004 fps52 fps60 fps60 fps60 fps
3001 fps35 fps60 fps58 fps60 fps
5001 fps22 fps58 fps52 fps60 fps
10001 fps11 fps45 fps39 fps60 fps
1500-6 fps33 fps-59 fps
2000-4 fps26 fps-43 fps
3000--17 fps-33 fps

It's worth noting that the libgdx version was built in a rush and I didn't try very hard to optimize it (the sprites aren't even deactivated/reused, because LAZY). Still, the performance is pretty great - that's one of the reasons why I love libgdx!

Comparison of 2D frameworks for Unity 3D

Unity 3D becomes a weapon of choice of many game developers. Amount of Unity-powered games is growing rapidly especially on mobiles. As the name implies, Unity 3D is suited better for 3D games and the vanilla editor is not a good tool to make 2D games. But there are a lot of frameworks that try to tackle this problem; let's see what they're worth!


Orthello 2D (Free/$35)

It has a free version (with quite a lot of features) and a Pro version. I tested the Free version.
The good: Orthello comes with loads of handy classes. You can import texture sheets and atlases easily, create animated sprites, tween their parameters, check collisions and input... All with just a Free version! It's well documented, with a nice user guide.
The bad: Orthello's performance is... Well, bad. Very bad. Apart from this it imposes some restrictions (e.g. you have to use an orthographic camera, you should create sprites from pre-made prefabs etc.). It loses a lot of flexibility because of this.


ex2D ($25/$35)

ex2D will set you back $25/$35 (depends on whether you purchase from the Asset Store or directly from authors), but there is a free evaluation version available.
The good: ex2D provides a few tools for creating atlases and sprite animations. You'll be using them straight in the Unity editor, and you'll like them 'cause they're good. I liked the whole workflow for ex2D and I set up my test fastest using this library.
The bad: Documentation is a little bit lacking and contains a lot of grammar errors.


SpriteManager 1 (Free)

This is a free and minimal sprite library. The only thing it does is rendering sprites and sprite animations. It is also the fastest one.
The good: great performance! SM consists of 3 classes, which aren't even MonoBehaviours. I liked the flexibility that comes from it.
The bad: SM consists of 3 classes, so yeah, you'll be coding a lot of things yourself. The lack of atlas importer hurts the most (you have to type in UVs for every sprite in the atlas...).


SpriteManager 2 ($149)

It's a developed version of SpriteManager 1, armed with tools for creating atlases and animations.
The good: the performance is still great, it's almost as flexible as SM1 too. But you can use simple atlas and animation editors this time around!
The bad: it still just renders sprites; if you need collision/input handling, scrolling backgrounds etc., you'll have to code it. And while the editors do the job, they're a little bit rough. SM2 is rather expensive.


2D Toolkit ($65)

I don't own it and unfortunately there is no free version, so I couldn't test it!


Performance

I'm mostly interested in mobile performance. I tested all of these frameworks on my Xperia Play (on iOS you'd get roughly similar performance using an iPhone 4). My test consists of a single background sprite (640x960 px, static) and three animated sprites (all frames were packed into a single atlas texture to reduce draw calls).
Every touch spawned 10 sprites, every second touch spawned another 100 sprites (randomly selected from these three types). Sprites go from the top of the screen to the bottom of it and are deactivated and reused later. Here are the results:



Sprite countOrthello 2Dex2DSpriteManager 1SpriteManager 2
5057 fps60 fps60 fps60 fps
10018 fps60 fps60 fps60 fps
1506 fps58 fps60 fps60 fps
2004 fps52 fps60 fps60 fps
3001 fps35 fps60 fps58 fps
5001 fps22 fps58 fps52 fps
10001 fps11 fps45 fps39 fps

In my opinion you should choose between SpriteManager and ex2D. Both SpriteManagers are very fast and very flexible. It's up to you how you extend it for the needs of your game. If you don't care about money, buy SM2 and save yourself coding a read-sprite-from-atlas tool. I'd recommend ex2D for less experienced programmers. ex2D's excellent tools will get you up and running in no time, performance is sufficient and the framework itself is pretty cheap.
Now go and make some games!

Powered by Blogger