Why GemCraft 2 will not use the new Stage3D API

First of all, a great thanks to all of you who sent me your wishes and suggestions for GC2! There were many great ideas worth adding to either the upcoming sequel or a later chapter. More details on the new features of GC2 will come in a later post as soon as I have screenshots to show how they’ll look and work.

I wanted this post to bring good news about how lightning fast GC2 will be, with the new Stage3D API introduced in the recently released Flash Player 11, but my test results were quite disappointing.

If you’re not into the tech details behind GC (and Flash games in general), don’t waste time on reading the whole post, here is the bottom line:
-GC2 will stay with the software rendering used in GCL.
-Instead of using the 3D API with false hopes to boost performance, I’ll make technical and gameplay tweaks as well as giving more options to simplify the visuals (you’ll be able to turn off almost everything not necessary for gameplay to gain more performance with lots of monsters on scene).

So, about those tech details:

Flash Player, developed by Adobe (Adobe bought Macromedia, the company originally developing it, years ago), is infamous for being slow and lagging when it comes to graphics, although it has gone through lots of improvements lately.

There is a new addition in the recently released Flash Player 11, the Stage3D API, a set of tools that allows Flash developers to use GPU for rendering graphics, instead of the CPU. Unlike the CPU that is a general “Jack of all trades” processing unit, the GPU is a processor designed to work with 3D graphics data, performing far better in that kind of task than the CPU.

GemCraft, being a Flash game, and giving the player the possibility to face thousands of monsters (each having its own tiny piece of graphics on the screen simultaneously), can lag horribly, so I was looking forward to try the new Stage3D capabilities of FP11.

With 3D, I don’t mean GemCraft should, or ever would be a game running in 3D perspective view, the whole thing is about displaying the plain 2D graphics with the GPU’s superior performance.

Finally FP11 was released, as well as a framework called Starling, an open source toolkit that made it relatively easy to use Stage3D, while mostly retaining the display object hierarchy system used by Flash Player’s core language, ActionScript 3.0 (the way GemCraft works, so I didn’t have to build everything up from scratch), and without learning and understanding how working with 3D goes on a deeper level (like using matrix transformations or opcodes).

So, having my development environment upgraded to meet the challenge (FP 11 debug player, FDT 5 free edition + Flex SDK 4.5.1, Flash CS5.5 (this latter was a waste of money for me, I thought it would add FP 11 to CS5, but it didn’t, plus it came with a DVD which I don’t have in my PC anymore, and it also had a DVD copy protection, so I had to use Daemon Tools to install my legally bought software, thanks Adobe), I spent a week on migrating from the old 2D to the brand new 3D method.

My first finding was that when I reached a certain number of monsters (about 3.000), the 3D code reached its resource limits and the game crashed. It could have been the result of not disposing the graphics of dead monsters, but if the game would have such a (low) limit, I’m sure it would be reached in a week after release by a hardcore GC player. I reached it in a minute (ok, I was cheating), so this issue alone could be a decisive point not to use Stage3D, but it’s not why I abandoned the 3D idea in the end.

What shocked me is that the performance boost was nowhere near what I was hoping for.
I compared the old GCL software rendering and the new Starling Stage3D mode on 2 PCs, my current desktop and my old notebook.

Test sample:
Starting 100 waves of armored monsters (~2100 monsters) (50 waves on the slow notebook (~950 monsters)) in a row, info panels turned off, low rendering quality, all vfx off, no window resizing (so no full screen), measuring the total time until the 100th (50th) wave started.

Test PCs:
Desktop: Intel core i7, 6 GB RAM, Vista Home Basic 64 bit, NVidia GeForce GTX 295 (2×896 MB)
Notebook: Intel core 2 duo, 2 GB RAM, Intel Graphics Express 950 (no dedicated memory), Vista Home Premium 32 bit

Results:
Desktop: Starling version finished at 75% the software time (33% performance boost) (old software mode: 1m 24s, Starling mode: 1m 03s)
Notebook: Starling finished at 236% the software time (58% performance drop) (software mode: 1m 19s, Starling mode: 3m 07s !)

I’m sure there could have been some ways to improve the 3D performance, but I can say the same about the 2D code, so I don’t think these figures could be made much better.

Making games in Flash means making games for a wide range of pcs, most of them not having 3D cards that run the latest shiny AAA titles, many of them are office or school pcs and notebooks, so I had a decision made easy here: stay with the plain 2D mode, and find ways to improve the performance without any 3D API magic.

What these improvements could be:
-Info panels made the game lag badly – the main problem was that all the text in them was rendered over and over 30 (or rather less) frames per sec. Making a bitmap from the info panel should give it a huge boost. Also, info panels could be able to be delayed, so when you move over the scene with the mouse, it won’t show all the info panels for the gems and buttons you don’t want to see.
-Naturally there will be less monsters of the scene. Using gem bombs to summon more monsters will give less extra monsters, but they will get stronger than in GCL. Nevertheless, summoning will still be (or will be even more) rewarding as it was in GCL.
-Many other texts (wave stones, mana count), as well as the gems, were vector-based. Converting them to bitmaps could speed things up further.
-There will be a much more flexible (change anything you want) and wider (from show almost nothing to have all the bells and whistles) way to set performance vs visual details (the options screen will be multi-tabbed to give room for setting all the details).
-Not showing all the monsters when they are too crowded (e.g. why draw all of them when there are 30 standing on a single tile?), or if that would look weird, some other way to show simplified monsters when there are lots of them.

While this 3D experiment was a dead end, Flash is without doubt a great platform to make web based (or even desktop) games, and I’m sure Adobe will improve the 3D capabilities of the player, so maybe later I’ll give it an other try, but for GC2, I’ll stay with what worked with GCL and bring the best out of the good old 2D way.

This entry was posted in Uncategorized. Bookmark the permalink.

Comments are closed.