atlases with a lot of empty space - what can I do?

Discussion in 'Technical Discussion' started by amazingafternoon, May 15, 2016.

Tags:
  1. amazingafternoon

    amazingafternoon Boxer

    Joined:
    Sep 25, 2015
    Messages:
    84
    Likes Received:
    20
    Hi,

    So the atlases of my game have a huge amount of empty space that is not used for that reason i have 18 atlases and I believe that's why the game is not working on iPhone 4.

    Is there any way to make bb use this empty space?

    Thanks a lot for helping out :)
     
  2. heathclose

    heathclose Miniboss Boxer

    Joined:
    Jan 28, 2016
    Messages:
    1,810
    Likes Received:
    1,026
    go to view menu, atlases and choose optimize lower right
    Screen Shot 2016-05-15 at 4.52.51 PM.png
     
    amazingafternoon likes this.
  3. amazingafternoon

    amazingafternoon Boxer

    Joined:
    Sep 25, 2015
    Messages:
    84
    Likes Received:
    20
    Thanks @heathclose I had tried that but got no apparent changes then I realized the image was so big it didn't leave space for the next image that was also huge.

    Thanks for helping out!
     
  4. heathclose

    heathclose Miniboss Boxer

    Joined:
    Jan 28, 2016
    Messages:
    1,810
    Likes Received:
    1,026
    I would suggest whatever image you use, make a copy of it. Pull it into bb, and scale it to the desired size. Note the ratio. Delete it and remove unused objects. Open it in preview (or the Windows equivalent) and resize it using the percentages you noted. After that, drag the resized image into tinypng.com and you will have an image correctly sized and stripped down keeping your atlases only as big as needed and the final file size as small as possible. I remember your 80 some atlases post, and your improving with only having 18 in this game... but I bet you could get it under 5 if you follow the above procedure, and, you will cut your file size of the app by more than half just using tinypng.com, not to mention how much smaller correctly sized images would be anyways... Hope this helps! Can't wait to see more improvement! :)
     
    amazingafternoon likes this.
  5. Andy

    Andy Miniboss Boxer

    Joined:
    Sep 24, 2015
    Messages:
    2,152
    Likes Received:
    1,546
    FYI, tinypng makes absolutely no difference in the export size 99% of the time. Although it will reduce the size of you BBDOC.
     
    amazingafternoon likes this.
  6. heathclose

    heathclose Miniboss Boxer

    Joined:
    Jan 28, 2016
    Messages:
    1,810
    Likes Received:
    1,026
    Why wouldn't less data get exported at less data?
     
  7. Andy

    Andy Miniboss Boxer

    Joined:
    Sep 24, 2015
    Messages:
    2,152
    Likes Received:
    1,546
    No, it's not that simple, basically...

    1) All the images get combined into atlases. Any compression before this happens is almost useless. Not to mention degrading if it is lossy.
    2) If you want to affect the size of the binary package then you would need to use tinypng on the atlases after export.
    3) Xcode does some its own optimizations but I think we turn it off, not 100% sure.
    4) Even after all this it really only affects the size of the binary, and will decrease load times.
    5) When an image is loaded into memory on the device it takes the same amount of memory regardless of any compression.
    6) The main advantage of compression if to decrease load time at the expense of quality.
    7) So it's a judgement call. The compression would need to be done at the optimal time to have any desirable effect.

    So it's super important to understand 100% all the above info if you are going to take any advantage.
     
    trudnai and amazingafternoon like this.
  8. Andy

    Andy Miniboss Boxer

    Joined:
    Sep 24, 2015
    Messages:
    2,152
    Likes Received:
    1,546
    In addition here is what I would consider doing ONLY if there was a specific issue that I know it would help. I would not consider any of this if I hadn't fully optimized within BB app itself. None of these optimizations are going to help a much as fully optimizing within BB.

    1) Evaluate if lossless (not tinypng) compression of images before dropping in BB would help solve any specific pre-export issues.
    2) After export, evaluate if any lossless or lossy compression of atlases would help a specific issue.
     
    amazingafternoon likes this.
  9. heathclose

    heathclose Miniboss Boxer

    Joined:
    Jan 28, 2016
    Messages:
    1,810
    Likes Received:
    1,026
    Ok @Andy thx for that, I've been misunderstanding this whole time.. So @amazingafternoon the resize of images prior to import is probably your most important optimization
     
    amazingafternoon likes this.
  10. Andy

    Andy Miniboss Boxer

    Joined:
    Sep 24, 2015
    Messages:
    2,152
    Likes Received:
    1,546
    np, everyone seems to gloss over the technical details about this whenever I post them. Hopefully this time there is good detail that everyone can understand. ;-)
     
    amazingafternoon likes this.
  11. amazingafternoon

    amazingafternoon Boxer

    Joined:
    Sep 25, 2015
    Messages:
    84
    Likes Received:
    20
    Thanks @Andy & @heathclose you both rock! I will definitely resize them they are super giant images :D :D
     
  12. Qdeveloper

    Qdeveloper Avid Boxer

    Joined:
    Apr 25, 2016
    Messages:
    210
    Likes Received:
    76
    @Andy So resizing images will not improve or effect the game speed performance ? beside the loading and file size in general ?
     
  13. Andy

    Andy Miniboss Boxer

    Joined:
    Sep 24, 2015
    Messages:
    2,152
    Likes Received:
    1,546
    Image size is totally different. Smaller images will improve performance every time.

    EDIT: By smaller images I mean smaller dimensions... not the image file size. File size will make no difference.
     
    Qdeveloper likes this.
  14. trudnai

    trudnai Miniboss Boxer

    Joined:
    Sep 25, 2015
    Messages:
    1,235
    Likes Received:
    701
    Just for clarification: you have 3 sprites, all three looks same in size during game play.

    First is 100x100px and scale is 1:1
    Second is 1000x1000px downscaled to 10:1
    Third is 10x10px upscaled to 1:10

    Which one performs better during game play (I guess as per load time smaller dimension is better?) But in game play (runtime) I thought 1:1 is always better than any up or down scaling, right? Or it does not matter?

    And as a side question upscaling reduces image quality for obvious reasons but does downscaling increase that in any circumstances? Like designing your game for iPhone mainly but if you run it on iPad Pro for example or Apple TV or on desktop platforms...
     
    comicsmathias and Qdeveloper like this.
  15. Andy

    Andy Miniboss Boxer

    Joined:
    Sep 24, 2015
    Messages:
    2,152
    Likes Received:
    1,546
    The main blow to performance is how much space the image takes up on the atlas because it in turn takes up main memory (which is in short supply on mobile). Displaying it on the screen does not matter, they are all 100x100px in that case and perform the same.

    You know, I may have to take back what I have said in the past (downscaling does not matter)... If you use larger graphics let's say 2x, it MIGHT actually be better quality on higher resolution and larger screen devices. BUT I have not run any testing on this recently to check this theory. You would have to be super careful with this however, because you WILL kill performance on lower resolution devices.
     
    trudnai likes this.
  16. Christoph

    Christoph Miniboss Boxer

    Joined:
    Oct 4, 2015
    Messages:
    2,807
    Likes Received:
    2,309
    It seems that Buildbox needs to integrate a system that automatically creates 1x and 2x images, using them depending on the device the game is running. This would make everything much easier and look great on all devices.
     
    Benfont likes this.
  17. Andy

    Andy Miniboss Boxer

    Joined:
    Sep 24, 2015
    Messages:
    2,152
    Likes Received:
    1,546
    We still suggest using graphics as close to 1:1 ratio as possible. Then evaluate where you can upscale without quality loss. Using different sets of graphics has advantages and disadvantages. The main disadvantages are that it increases your binary size by quite a bit and uses a lot more main memory.
     
  18. trudnai

    trudnai Miniboss Boxer

    Joined:
    Sep 25, 2015
    Messages:
    1,235
    Likes Received:
    701
    Apple has that on-demand resource feature - have you guys explore that if that eases up this issue?
     
  19. Andy

    Andy Miniboss Boxer

    Joined:
    Sep 24, 2015
    Messages:
    2,152
    Likes Received:
    1,546
    A couple issues with something like that.

    1) It's an Apple only feature.
    2) Would only support iOS 9 forward

    The current state of things offers some good flexibility vs performance balance with a little bit of understanding and work. If you follow the 1:1 ratio rule then you don't really have to think about it. It you want to look at improving on that you can look at situations specific to your game that you can further tweak.

    Possibly we can look at having more resource management options in the future, but it's not something we are putting much attention towards at this time. The most important related feature on the table (no dates yet) is looking at how we can best accomplish more dynamic loading of resources.
     
    trudnai likes this.
  20. trudnai

    trudnai Miniboss Boxer

    Joined:
    Sep 25, 2015
    Messages:
    1,235
    Likes Received:
    701
    Thanks @Andy, all clear now
     

Share This Page