Hello Guest

Author Topic: Reducing file size of atlases (without compression)  (Read 8221 times)

haxx0rz

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 5
    • View Profile
Reducing file size of atlases (without compression)
« on: June 18, 2012, 10:31:12 am »
Hello!

I'm currently working with 2d Toolkit on Unity and I noticed that Unity labels the filesize of the atlas (32bit) as 5.3mb, but when I view the file size of the atlas on Windows Explorer, it's a lot smaller (around 1mb for my assets). What's disturbing is that Unity still exports the atlases as the same size as they appear in Unity aside from their smaller filesize counterpart.

Is there a certain way where I can further reduce the filesize of the atlases aside from compressing? (because I wish to keep them as 32 bits)

Thanks!

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: Reducing file size of atlases (without compression)
« Reply #1 on: June 18, 2012, 01:09:44 pm »
A quick bit of info on why and how the numbers vary.

What Unity shows you in the size of the asset in memory, not on disk. An uncompressed texture HAS to be uncompressed in memory.
A 1024x1024 32 bit RGBA image with mipmaps - 1024x1024x4 x 1.33333333 = 5.3MB
Note: you can turn off mip maps if you don't need them and save the 1.333333 bringing the texture down to 4MB.

The file on disk is a PNG. A png uses zlib compression and some optional transforms per scanline to keep the size down - its lossless compression is useless outside disk storage. The size of the PNG has no bearing to the size of an image, eg. empty images will compress better than images full of content.

Unity performs some form of compression when building the asset (you can check this by looking at the asset size in the editor output log, and comparing with the final assets), and performs REALLY aggressive compression when saving a webplayer. I don't believe there is a way to chose what kind of compression is performed. Can't remember off hand what kind of compression is performed and where, though :(

haxx0rz

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 5
    • View Profile
Re: Reducing file size of atlases (without compression)
« Reply #2 on: June 28, 2012, 06:22:42 am »
I see, thanks for the info unikron! :). I've applied them I shaved off a good 70MB from our file size! (from 420MB to 350MB)

I do have another concern though, while I was able to shave off some file size, I'm having a few crash issues on the iPad1. I'm working towards a full 32-bit game for the iPad 1 and 2, and while it does run on iPad 2 (with a few occassional lags), it seems to crash occassionally on iPad 1 due to memory warnings.

I've searched around and it seems there aren't much discussions out there for 32 bit images running for the iPad1. Is it really recommended to build at PVRTC 4 format for iPad 1? I was comparing some assets and found them to become quite blurry/pixelated when I compressed them to PVRTC, and I was really hoping to make the game look as clear as possible.

I hope you can help out again, thanks! :)

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: Reducing file size of atlases (without compression)
« Reply #3 on: June 28, 2012, 10:19:28 am »
Have you tried the 16-bit dithered modes? That could shave a bit more memory off, if the quality loss is acceptable - in a lot of cases it might be. You'll need to switch that in the sprite collection settings, not the texture itself - Unity doesn't dither by default when in 16 bit mode and most of the time the results look poor and more or less unusable.

You don't have to do this on all your atlases, just the ones which you can get away with.