Search Unity

Orion Attack for iPad - Unity3D mobile Optimization case study

Discussion in 'Made With Unity' started by FiveFingers, Oct 5, 2013.

  1. FiveFingers

    FiveFingers

    Joined:
    Oct 15, 2009
    Posts:
    541
    Someone might find this info useful so I post this recent interview I released to some journalist here in Italy,
    this was quick translated, apology for any mistake it might contain. I took only the techie question relative and interesting for other Unity3D users. Find more info and play a web demo at: www.orionattack.com


    IJ: Interviewer Journalist
    FF: Five Fingers

    [...]

    IJ: First of all, why YATD ? Why another Tower Defense game (yet) ?

    FF: Well, we loved the genre on iPad since tower madness was out, and we always thought that was the best TD game out there. Tower Madness was the only real-time 3D tower defense game at that time, that featured hundreds of walking creeps on screen. We always wondered how could they do that. Considering on iPad1 over 30-60 drawcalls would kill the rendering. So for joke, we start working on a TD game with similar rules, trying to break the 1-drawcall-per-skinnedMesh limit.



    IJ: All that last part sounds a little techie to me, but to understand better, could you break this limit ?

    FF: Yes, but the way was: not-using the skinnedMesh renderer, basically, we decided to go for a frame-by-frame animation (like very old engine did in the past) with very few frames of animation for walk and for deth animations of the creeps. In this way we could batch into an atlas all the textures for all the creeps in the game. That dramatically improved the performance and increased the number of actual creeps on screen at the same time.



    IJ: Wow, that seems a pretty smart idea. What other kind of tricks or optimization did you implement, since we have seen this game is pretty rich, and runs smoothly on iPad1, iPad2, iPad3(retired from the market) and iPad4 retina display, how could you do that, since the hardware of iPad1 and iPad2 is so different, and iPad3 Retina Display hardware was not enough for rendering the same scene at 2048x1536 than iPad4, how could you get the game to run on all the iPad(s) out there ?

    FF: First things first. A thank comes first of all, thanks go to Ippokratis for the Batching Tool. A marvelous and useful tool, we had a lot of support and fix from the author while developing the game. We optimized, batched and batched more the whole UI into a single big texture atlas, all the levels, as we are Unity Free users, hence without automated Static Batching, and the props and whatever else is implied in the game is batched using this tool or directly in the graphics package (eg: all the creeps animations frames). A custom in-house frame by frame animator component animated the creeps frame by frame. But all those Unity3D optimizations were just not enough to make it run smoothly on all the devices. iPad1 and iPad4 are really different machines! We also would like to thanks Elias T. for the marvelous tropical plants batch and the maya ruins models as well as for the "running river" water Mobile Shader and the terrain meshes he provided



    IJ: Do you mind to share what kind of optimization did you take and if Unity3D or xCode native code was involved into this?

    FF: Well, of course we can't share the code, but it is simple enough for everybody to implement. We studied other iPad games cases and discovered that also other games was adopting this technique. But for iPad1, this technique was still not enough. We made a custom device-sniffer in Obj-C to get the precise device model at start, and modified the Unity Engine ApplicationController so that eg: on the iPad1, the video resolution was shrinked down to 0.75 (75%) of the 1024x768 (near to TV resolution) and on iPad3, that unfortunately had a not-proper hardware for the 3million pixels to fill, we had to make a cut of 1.5 of the Retina resolution, hence 1536x1152. On the iPad1 not only the video res was sized down, but we also had to fall back on OpenGL1, of course, and we studied some different effects and visuals to copy on this device to run with Vertex Lit basic shader.

    [...]


    Any question you might have is welcome.

    Regards,
    Tom
     
    Last edited: Oct 5, 2013
  2. elias_t

    elias_t

    Joined:
    Sep 17, 2010
    Posts:
    1,367
    Interesting.

    Could you elaborate more on the frame by frame method you used on the batched animated meshes?
     
  3. FiveFingers

    FiveFingers

    Joined:
    Oct 15, 2009
    Posts:
    541
    Hi Elias, yes, do you remember the good old method old engines used to make un-boned character animation? A sequence of static meshes, made appear and disappear. A custom unity component was getting all those batched meshes and animate "frames" over time by hiding and showing the static meshes in the object. Of course very few frames of animation were required for this game. 6 for walking, and 5 for dying. All that was done for the mobile. We planned to upgrade someday for a PC release.
     
  4. Ippokratis

    Ippokratis

    Joined:
    Oct 13, 2008
    Posts:
    1,521
    Hi Tom,
    Thanks for sharing your techniques and mentioning batching tools :)
    I purchased Orion Attack when it came out, played with it and it was fun.
    I have some suggestions :
    - Find a publisher. It is the second nice game you create and you see how hard it is to reach audience despite having a well made products.
    - Extract some functionality ( e.g. the obj c sniffer you mentioned ) from your game and sell it on the asset store.
    - Keep it up :)
     
    Last edited: Oct 12, 2013
  5. FiveFingers

    FiveFingers

    Joined:
    Oct 15, 2009
    Posts:
    541
    I am currently busy on a new paid project, but I will second that, and probably move the dev on the PC/MAC side as I got now Unity 4 Pro