I have recently joined a small and new Unity R&D development team in a large cooperation.
For whatever reason, they like to use TGA textures, and I have been insisting to use PNG, especially as they are smaller in size therefore are faster for file transfers, and the fact they are using TGA with black as alpha, which does not bode well for Unity UI.
However I have been told the following by the designer:
“The PNG format is not a lossless format, actually the PNG compression is one of the worse compression among the image file formats. A png file it’s really small in terms of size but really bad in terms of quality. Targa is a lossless image file format and you’re right when you say it is less efficient., but with DXT5 compression within unity, which is an high quality compression, you get acceptable sizes and high quality too.”
And by the other Unity developer:
“PNG is generally fine but with alpha sensitive textures, TGA is the way to go as it stores alpha data to a greater degree of accuracy (particularly when it isn’t simple on-off opacity).”
I have tried to explain otherwise, but this has backfired as now the non-techie project manager now sees me as the one with less expertise as its 2 against 1 new-guy.
Even though this is more of office politic problem, I thought only guys in this forum may understand the technical details.
“PNG compression is one of the worse compression among the image file formats.”
“DXT5 compression within unity, which is an high quality compression”
PNG is worse than DXT5? What?
To my understanding, PNG is basically a zipped version of TGA; lossless zip-style compression over the raw pixels. You have to avoid settings like ‘discard colors if fully transparent’ though.
PNG can be “lossy”, not because of the image format itself, but because of how many image editors treat PNG saving and loading. Photoshop and Gimp by default change most of the fully transparent areas white, with seemingly random blocks of color, all for better compression, which is worse than all black for realtime art. They also open PNGs as a transparent layer instead of as a separate channel. I believe you can change both of those in Gimp, but you need SuperPNG (it’s free) for Photoshop. It’s also quite popular for PNG files used online to go through a palettizer or similar color reduction step, again for better compression, but leading to people assuming it’s the PNG format itself.
As for DXT5, it doesn’t matter what format the image is to begin with, that’s kind of the main compressed format PC GPUs use, so the TGA or PNG or even GIF is just going to get converted into it. Now that’s a pretty terrible compression format, worse than JPG at the same file size, but it’s what we have.
Personally I stick with TGAs over PNGs just because most image editors properly treat the alpha as a separate channel. Actually, these days I just use straight uncollapsed PSDs, computers are fast, storage is cheap, internet speeds are fast, and the working format is basically irrelevant to the final product download size or format or quality (as long as you don’t use JPG or GIF).
Also black for alpha is bad, even if they’re properly using a premultiplied shader with it, because DXT5 doesn’t compress the color and alpha in the same “layer” they won’t match properly and you’ll get black or bright fringing on all of your assets. Better to use vanilla alpha blending and bleed your colors on the alpha edges. BC7 is a better option for going the premultiplied route, but unless they’ve got some pressing need for it (like wanting the option to have additive glows and alpha blending in the same image) there’s not a good argument for using it with modern desktop GPUs.
Also @Zuntatos is right on in saying PNG is basically a TGA with zip compression, except PNG also supports 16 bits per channel images, either RGBA or single channel (greyscale).