Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Need serious help regarding texture resolution and overall optimization on mobile.

Discussion in '2D' started by Aladine, Dec 4, 2016.

  1. Aladine

    Aladine

    Joined:
    Jul 31, 2013
    Posts:
    194
    Hi everyone,

    i've been working on this mobile game for about a year now, and we'll very close to the end but we're started to face many problems.

    Mainly Crashes and HUGE size for a 2D game (on iOS only).


    please take a look at this editor log


    As you saw there the Textures size in near 800mb, which is HUGE for a 2D mobile game.

    And the main reason we're having this is because the artists made all the game assets to look great for a 1080p screen, so whenever they are working on something, the start a 1920x1080 canvas and start drawing.

    This is my first experience working with artists on a game like this so i really didn't thought its gonna be a problem, specially that the first builds where around 30mb on Android and ~80mb on iOS which was ok.

    But the game kept getting bigger and bigger, specially on iOS (it's still ~100mb on Android) but also these huge texture size is causing some crashing in some levels on iOS too, so we really need to fix this.

    Obviously the must-do solution is reducing the Texture size, and i've been trying to do that in unity by changing the texture import setting and we kinda reached a bottleneck of a certain quality that we can't go under and the game is still **HUGE**, so we're thinking about re-drawing some of the graphics assets, for that i need to know what we should keep in mind when making this, that 1080p canvas approach was a bad idea right ? what should i tell the artists to do instead ?

    any other advice is more than welcomed.

    Thank you

    UPDATE !!

    i was looking at the important part of the editor log and am already seeing some **VERY** surprising results, see that big 63mb png file ? i didn't knew it even existed, we are using a tool called GAF that basically let unity play .SWF files, for some reason, importing the "Transformation.swf" animation resulted in creating a 4074x4074 uncompressed texture! same thing goes for that 33mb texture.

    And that is ONLY for the lightning effects of this Gif , those 2 seconds of blue lines is costing us 96.3MB o_O !!



    And the whole reason we used Gaf is because of the moon in the background of this gif:


    The source of that animations are 2 .PNG, each one is 4800x2880 (i know that's ridiculous) but that is because they are set to Sprite-Multiple, where each of these images contain 60 sprites, and each sprite is 480x480.

    When we were using the 2d unity animator for that animation, the game kept crashing on iPhone, so we started using GAF, and since then i've been using it for all the game animations except for the ones that require the "Animation Tree" feature.
     
    Last edited: Dec 4, 2016
  2. JC_SummitTech

    JC_SummitTech

    Joined:
    Nov 1, 2016
    Posts:
    78
    I don't work with ios much, but...
    1- look at assets compression, when you look at a texture properties, you should see a max size and compression type.
    2- I hope you don't mean all textures are 1920x1080 no matter how small the actual image is, but if you meant that, make sure the texture size is as small as possible, and if possible, atlas your textures in a nice 1024x1024 or 2048x2048 atlas.
    3- reconsider the way you are rendering. do you need that 1024x400 texture of a wall, or could you just use a 128x128 and tile it?
    Without seeing the actual assets it's a bit hard to comment more, but 800mb for a 2d mobile game does sound a bit heavy.
     
    Aladine likes this.
  3. Aladine

    Aladine

    Joined:
    Jul 31, 2013
    Posts:
    194

    Your 3rd point is very important, the way am making all the platforms now is by place sprites next to each other like this (i removed the one in between so you can see the real size)


    It would be great if i can just have a tiling solution for this, do you have any idea that might help ?

    Also i think its important to say that i am not using any "unity made Atlas" except for the spritesheet that artist export, other than that every image is a standalone PNG or PSD, is that a problem ?
     
  4. JC_SummitTech

    JC_SummitTech

    Joined:
    Nov 1, 2016
    Posts:
    78
    I'm trying to understand what I'm looking it...
    In that screenshot, we see your scene view, right?
    And the stuff in the selection box is all 1 image?

    If so, it's horrible performance-wise.
    If your platforms are all rectangles (no slopes) tiling a texture should be very simple. Just set a texture and adjust the tiling.
    I don't know how you generate the terrain, but if it's not procedurally generated or anything, it can be done manually with minimal effort.
    Also, I don't know if you are familiar with POT vs NPOT textures, but you want those images to be as close as possible and under a POT value. Making an atlas is as simple as assigning an atlas to your textures in the inspector.
    I would strongly advise against using PSD (mostly because I would expect it to import layer data and such? I don't know... I never even tried loading a psd in unity) as for PNGs, if you have no transparency, make sure to save as 24bits instead of 32 to save 1/4th of the space.
     
    Aladine likes this.
  5. Aladine

    Aladine

    Joined:
    Jul 31, 2013
    Posts:
    194
    This is a one single image :

    It's resolution is 56x256, for that particular "theme" (planet) there is 4 other images like this, and 2 others for the left and right border.
    To make a ground or a platform or a roof, i place these images one next to the other, put them all under one parent, and add a collider to that parent.

    Initially the game was fully procedural, but now i am making the levels manually but with a "trick" that allow me to make it faster :


    I design the level layout using "blank" sprite, then a script will run check the size and position of these objects and add the correct graphics and colliders

    All i know is that unity can compress POT texture way better than NPOT, which will result in a better looking yet smaller
    textures. correct ?

    By atlas you mean lots of texture put together in a single image file right ? so basically every image set to Sprite/Multiple is an Atlas ? is that what i should do now ? pack my images together in one POT image file then separate them using the sprite packer ?

    Thank you
     
  6. JC_SummitTech

    JC_SummitTech

    Joined:
    Nov 1, 2016
    Posts:
    78
    Quick GPU 101 to explain all that
    When you draw stuff, you send 2 things to your GPU. coordinates(mesh), and texture data.
    A GPU can only really deal with texture sizes that are a power of two (POT) anything else gets padded. Unity handles that transparently, but you still lose performances.
    Another problem is pipeline stalling. Uploading a texture to GPU is a slow operation. While you do it, you can't really draw anything else, so the GPU needs to wait for it to finish. Even worse, is swapping textures.
    That's why atlases are popular. By bundling images together, you can upload one big image, and then use it to draw a ton of stuff at once, minimizing texture uploads.

    As far as I know, the sprite packer is a glorified Atlas, so if you are using it, you should be fine.

    Neat trick with the platforms and colliders. This seems like a very elegant way of doing things, I don't see any issue with that texture, the size makes a lot of sense, especially if it's in an atlas/sprite sheet. If it is not i would recommend making it 64x256 but that's minor.

    The image should take about 42k uncompressed 8bits per channel, make that x5 that's still less than 1 mb, so that's clearly not where your problem is.
     
    Aladine likes this.
  7. Aladine

    Aladine

    Joined:
    Jul 31, 2013
    Posts:
    194
    Thanks man i really didn't know that part, but i knew all the rest.

    I updated the original post, please take a look at the disaster we had in our project, we have 17 Textures that are mainly UI stuff that doesn't even appear for more than ~5 seconds in the game, these 17 textures weight 289.3mb :O !! that's 41% of the project size :/
     
  8. JC_SummitTech

    JC_SummitTech

    Joined:
    Nov 1, 2016
    Posts:
    78
    Yeah but that swf anim does look sharp! :p
    Glad you found your issue :)
     
  9. Aladine

    Aladine

    Joined:
    Jul 31, 2013
    Posts:
    194
    It doesn't look shart in that gif at all lol
    but yeah i confirm that the only advantage of using that plugin is to reduce the artist works, so instead of having them export every frame from Flash then pack in it one spritesheet, they just give me the .swf and gaf do the rest, it does ZERO quality magic.
    Which it made me think of something that really surprises me, Why does game engines doesn't have default support for Vector arts ? i know that the main reason is that A LOT of the games art simply cannot be made in a Vector graphic software, but for the rest of the games that can be made, why does a game engine like unity doesn't have default support for SVG files ? (am aware of the few unpopular assets that do that)
     
  10. Aladine

    Aladine

    Joined:
    Jul 31, 2013
    Posts:
    194
    Hey man sorry to re-awake this thread again, but do you have any clue why my Android build is ~80Mb while the iOS one is +700Mb ?? and this was always the case since 6 months ago, i don't have any specific settings for iOS or Android, the entire assets use the default setting for everything. thanks
     
  11. JC_SummitTech

    JC_SummitTech

    Joined:
    Nov 1, 2016
    Posts:
    78
    I would say since your android build exceeds the apk limitation, the data is put in a second file called obb if I remember correctly.
    I know very little about ios unfortunately so I can't comment. it might have a much better default compression?

    As for what you asked about engines supporting vector art... you can look up scaleform. I don't think it's free, but AAA games use it to make their UI in flash ;)
     
  12. Aladine

    Aladine

    Joined:
    Jul 31, 2013
    Posts:
    194

    No there is no .OBB file, the WHOLE game is 80mb while on iOS is like x10 time bigger, i've done some research and it seems that the best format for iOS is PVRTC and to have that the texture need to be POT, which is something that we are clearly missing in our game, so that's what am working on now.

    Thanks for letting me now about Scaleform, never heard of it before :)
     
  13. JC_SummitTech

    JC_SummitTech

    Joined:
    Nov 1, 2016
    Posts:
    78
    To make it easier on you you can atlas your textures, they will "become" POT
     
  14. Aladine

    Aladine

    Joined:
    Jul 31, 2013
    Posts:
    194
    I am "POTing" them manually now, "Atlasing" them wont allow me to see the final size after compressing plus its just better to have one single file like the image below rather than have every single element on its own !POT file, some of them where even duplicated