Android "Evolution": how it was

    Hello! My name is Alexander Grishin, I work in the IT-Territory studio (Mail.Ru Group) as a testing specialist. I’m developing the Android version of Evolution: The Battle for Utopia. iOS-audience with interest met the novelty in the spring of this year, and we are already preparing for the first impressions of Android-users. In the article I will talk about how we ported the game to Android and what difficulties and nuances we encountered in the process.

    "Evolution" on iOS

    If you look at mobile games in general, now there are few projects on the market like Evolution - large, complex, costly, requiring a large team for development. Creating games with so many mechanics, each of which, in fact, is a separate mini-game, is a long and painstaking process: you need not only to make them, but then also connect them, grind to each other, make sure that everything works together as it should and caused the user interest, not perplexity. Such games are few even on iOS, for which studios are more willing to create games, and almost none on Android.

    Lyrical digression
    Evolution was released in Russia on January 31, 2014, on March 19 it was presented to a world audience at the Game Developers Conference, which was held this spring in San Francisco, and on April 2 an international release took place. The game entered the top ten best games for the iPad in 30 countries - and this despite the fact that the "Evolution" entered the market almost simultaneously with the Hearthstone studio Blizzard Entertainment, which fans were looking forward to. Today, more than 73,000 players from 198 countries enter the game every day. More than 41% of the players live in Russia, more than 20% - in the USA, another 5.7% are in the UK.

    Complex variety

    Android is a specific platform. To begin with, iOS has only five screen resolutions, which, of course, makes application development easier. With Android, the number of permissions goes to hundreds, if not thousands. From a technical point of view, when drawing a graphical interface for this platform, it is tied to the corners. But sometimes they stretch it, and do not draw a pixel into a pixel - for example, backgrounds, why graphics suffer or proportions are violated. In iOS, we always know how our picture will look; everything is far from simple in Android.

    On the Android device market, there are a lot of different models with different performance, but at the same time it is easier to control the installation on various devices; for example, in iOS, it’s difficult to limit the devices on which the application can run. You can note in the application description that the fourth-generation iPhone does not support it. At the same time, it runs on these devices, you can play it, but, in principle, no one guarantees that it will not fly out or do anything else not according to plan. In Android, you can specify specific devices for which a person downloads the game, and upload many distributions for different graphic chips.

    For iOS, we post one single distribution. Some post two, one for tablets and one for smartphones. Android needs various distributions that are assembled depending on the chip, texture compression, and other parameters. In some games, it is necessary to make about 5-6 different assemblies, which, of course, complicates the process of deploying the application. When several distributions are made for different GPUs, we upload them to Google Play; when the client downloads the application, the digital store itself selects the build for the device’s GPU and issues it.

    All iPhone graphics chips belong to the same PowerVR family, so we can always accurately predict game performance. On Android, there are four common graphics chips that work in completely different ways. We were faced with the fact that the application on this platform was so slow that we had to redo the shaders, reduce their quality or even turn them off. In Android, the speculator is considered in the vertex shader, and in iOS - in the pixel shader. So we used the standard method of increasing productivity at the cost of some image degradation - transferring calculations from the pixel shader to the vertex one.

    Another difficulty we encountered when porting Evolution: Android does not have an alpha-channel texture compression format compatible with all devices (ETC1 (4bit) vs PVRTC4 / 2 (4/2 bit with alpha). Uncompressed textures are not only an extra waste of memory and an increase in the size of the application, but also a longer loading of the application, and loss of performance. From a technical point of view, the lack of compression of textures with an alpha channel is a very, very big limitation of the Android platform. The OpenGL ES 2.0 graphics API standard. single ET format C1, which is already outdated and does not contain an alpha channel. On iOS there is a very good graphics chip: in addition to the fact that textures with it take up less memory, they also load faster. When you overload scenes with a lot of textures in the game, on iOS it happens instantly but on Android with a noticeable delay, which in our case reached up to 1.5 seconds. Alas, I had to work with what is, or use compression formats specific to a particular hardware platform: PVRTC, DXT, ATC, ETC. In principle, Android developers plan to solve the compression problem with the alpha channel in the following OpenGL ES 3.0 standard: there will appear a good advanced compression format (ASTC), and it will immediately become easier for everyone to live.

    These are the main difficulties when porting an application from iOS to Android. There were other problems, such as the size limit of an APK. For Android, this figure is 50 Mb, while on iOS restrictions exist only for cellular downloads. The iOS version of the game is a single file of approximately 420 MB in size; on Android, the game is divided into a small APK file, which subsequently downloads the large OBB file in which the game is located. However, Unity does most of the work for you.

    How was it with us

    We can say, historically, that we primarily develop the game for Apple devices and then port it. Of course, you can develop a game for two platforms at once, or for three. “Juggernaut: Revenge of Sowering”, for example, we also released just under the desktop MAC or OSX.

    Porting from iOS to Android is greatly simplified if the game is made under Unity. Simply run it on a new platform - and immediately it becomes obvious where you need to go through the file and what needs to be done to make the result look normal. If the game is not under Unity, then I have bad news: in fact, you will have to write it again.

    It took us about two months to port the Evolution to Android. As I said, the game is very complex, both for development and porting. The fact is that it combines several different gameplay. Characters move around the map, fight monsters, solve riddles - each of these classes has its own interface, its own mechanics. And, of course, all this stuff is loaded right during the game session - that is, it was important for us that Evolution continued to “fly” after being transferred to a new platform.

    The biggest problem we encountered was sustaining the same battle performance that the iOS game had. To achieve this, we wrote new shaders that gave the necessary speed boost, slightly degrading the picture. We even managed to save the “honest” shadows from the characters! It was practically not necessary to remake graphic assets (scenes, models, animations).

    The second large (and even more time-consuming) part of the work is the 2D part of the game, which in Evolution is even larger than 3D. Thousands of Android screen resolutions (against just a few on iOS) and the lack of such a wonderful texture compression format as PVRTC (available on any iOS device) lead to a lot of painstaking work. There are dozens of screens, backgrounds, flip book animations (flip book) and thousands of sprites packed in dozens of atlases in Evolution. Then I had to compress something, stretch something, repack something.

    With all the changes that the graphics undergoes during porting, the weight of the game changes - for the worse for Android. On iOS, graphics are compressed 8 times. There is absolutely wonderful PVRTC4 algorithm, which allows you to make very decent 4-bit quality from 32-bit graphics with an alpha channel. Since not all graphics on Android can be compressed as efficiently as on iOS, it takes up more disk space.

    Many where manual tuning was required; in spite of the fact that we chose a certain general solution, we had to finish a lot of things with our hands. For example, the already mentioned problem with different screens: I had to take into account this feature of Android and somehow solve the situation. Of course, I did not have to rewrite everything for every possible screen. On iOS, we had only two scales, both multiples of two - that is why we did not have any problems with the violation of proportions and blurry graphics. As a rule, Android takes a certain average resolution, and everything else is scaled for it. Changing the resolution primarily affects the two-dimensional chart: we have various interface elements, buttons, and so on. I had to sort through these details manually, pinch textures, resize graphic elements in the main interface.

    In total, we made four distributions for Evolution. However, later we had to abandon one of them - the game does not yet support Tegra. In general, porting to Tegra, especially from older generations, is an adventure. As a rule, when people can port a graphically intensive 3D game to Tegra, they then go somewhere to a professional conference and make a report about it. This is a jewelry and specific work, when a developer achieves an increase in fps from 10 to 30, simply by changing the order in which different objects are drawn on the screen.

    Modern mobile GPUs aerial view

    All GPUs presented on the mobile market work a little differently. They can be divided into 3 classes: tile-based deferred rendering (TBDR) - PowerVR; tile-based rendering (TBR) - Adreno, Mali and immediate mode rendering (IMR) - Tegra.

    PowerVR with its TBDR is the most different from IMR, which is a common desktop solution. PowerVR works like this: it splits the entire screen into small tiles of 16x16 pixels in size and draws all the geometry that fell into this tile there. This happens in ultrafast memory inside the chip. During the drawing process, it discards all pixels that will not be visible in the final picture (for example, blocked by other opaque objects), and then textures and calculates the lighting only for those pixels that are exactly visible on the screen. Today it is one of the most economical and fastest solutions, and although it has its own set of shortcomings, from the point of view of mobile game developers it is the most optimal. Of the obvious advantages, he very quickly makes alpha blending, antialiasing, filtering textures and completely insensitive to the order of rendering of opaque objects, mip mapping, and so on, and the wonderful compression format PVRTC further reduces the memory load. In other words, developers do not need to optimize anything particularly - you just need to stick to a certain budget for the number of vertices, not to abuse transparency and not to use the alpha test, which breaks the whole TBDR process.

    IMR draws everything using only approximate optimizations for clipping invisible surfaces (Early Z-cull), therefore it is very sensitive to the rendering order of opaque objects. Unity here, unfortunately, cannot help anything - the developer must figure out which objects on the stage will occupy more screen space, and tell Unity to draw them first (render queue). Since all pixels are obscured, pixel shaders get more work done.

    TBR chips work in much the same way as IMR, but split the screen into tiles to reduce memory load.

    NVIDIA continues to release new types, Tegra K1 will be coming soon, so this is quite an interesting direction, but, unfortunately, there is a completely different approach, and because of this there will still be some difference when porting. From the small details: for example, if you disable mipmap on all textures in iOS, then performance drops by 2-3 fps. If you do this on Android, then performance drops by an order of magnitude. There are a lot of these subtleties: if you are going to optimize the game for each of the chips, then be ready to study thick optimization manuals from manufacturers, long profiling and experiments. Someone does this work and then reads the report at the conference; we decided not to dig so deep, but simply chose the list of devices for which we were going to develop distributions, tested the result and uploaded successful versions to the store. Alas, not every owner of Android-devices will be able to play "Evolution", but we "covered" the maximum possible number of devices. In total, the game supports approximately 1,000 Android mobile devices.

    That’s the whole story. Thank you for your attention, if you have questions - ask in the comments, I will answer them with pleasure.

    Also popular now: