ATF textures already contain a lot of compression: DXT, ETC, or PVRTC texture compression plus JPEG-XR and LZMA for good measure. What more can we do? As it turns out, we can drastically reduce the file size by simply applying Zlib or LZMA compression to the files. Read on for some samples with file size breakdowns.

Last week’s article showed some examples of ATF compression on three different types of textures: a leaf with alpha, a wizardess 3D character, and a VGA palette made up of a bunch of solid color squares. See the article for full details, but in a nutshell there were some very bad cases of file size bloat. An ATF of the VGA palette with all three sub-formats and mip maps turned on went from a 4 KB PNG file to a 500 KB ATF. So let’s see what happens if we compress each of ATF files from last week’s article:

VGA Palette
FILE ORIGINAL ZLIB LZMA ZLIB PERCENT LZMA PERCENT
All 524500 95687 57679 81.76% 89.00%
AllNoMip 393316 49537 29101 87.41% 92.60%
DXT 174876 19653 9899 88.76% 94.34%
DXTNoMip 131172 7676 4053 94.15% 96.91%
ETC 174876 21492 13235 87.71% 92.43%
ETCNoMip 131172 7864 5166 94.00% 96.06%
PVR 174948 53503 34429 69.42% 80.32%
PVRNoMip 131172 32223 20078 75.43% 84.69%

DefaultVGAPalette Graph

Leaf
FILE ORIGINAL ZLIB LZMA ZLIB PERCENT LZMA PERCENT
All 218683 97430 87756 55.45% 59.87%
AllNoMip 163931 67064 60564 59.09% 63.06%
DXT 87499 36401 32795 58.40% 62.52%
DXTNoMip 65627 25124 22476 61.72% 65.75%
ETC 87499 35454 32369 59.48% 63.01%
ETCNoMip 65627 24165 22190 63.18% 66.19%
PVR 43867 23731 21839 45.90% 50.22%
PVRNoMip 32859 17304 16003 47.34% 51.30%

Leaf Graph

Wizardess
FILE ORIGINAL ZLIB LZMA ZLIB PERCENT LZMA PERCENT
All 524500 318466 268123 39.28% 48.88%
AllNoMip 393316 221058 185053 43.80% 52.95%
DXT 174876 102556 85441 41.36% 51.14%
DXTNoMip 131172 72127 59922 45.01% 54.32%
ETC 174876 93301 79958 46.65% 54.28%
ETCNoMip 131172 63118 53560 51.88% 59.17%
PVR 174948 118660 101036 32.17% 42.25%
PVRNoMip 131172 84982 71751 35.21% 45.30%

Wizardess Graph

Applying these compression algorithms results in a wide range of effectiveness. In the worst-case scenario (wizardess PVRTC-only with mip maps) we only got 32.17% compression with Zlib. In the best-cast scenario (VGA palette DXT-only with no mip maps) we got 96.91% with LZMA! On average, Zlib compressed by 61.02% and LZMA compressed by 67.36%. LZMA was also always better than Zlib. There is a bit of a tradeoff of CPU versus file size here since LZMA is quite a bit slower than Zlib.

So why would you not always compress your ATF files? Well, it does take a little bit of time to decompress the data, but it’s probably worth your while for a 61-67% average file size savings. Honestly, I’m a little baffled as to why Adobe doesn’t do the Zlib compression for you, especially considering that they’ve already applied LZMA and JPEG-XR compression. If anybody has any idea why they don’t Zlib compress automatically or perhaps have spotted a bug in the data, post it in the comments! You’re essentially left with three options:

  • Don’t compress and suffer the extra file size, but maximize CPU performance
  • Compress with Zlib and get a good file size savings, but take a small CPU hit
  • Compress with LZMA and get even better file size savings, but take a bigger CPU hit