- Home /
PNG vs TGA Which Should I Use
My Texture Size differs while using different formats. For Example Both are same texture with dirrent formats (.tga) file size is 16 MB (.png) file size is 7 MB
I want to know if is use .png file format can I reduce the game size or .tga will also give the same result (regarding storage size)
Can anyone help me?
Answer by Bunny83 · Jul 28, 2018 at 05:59 PM
Well first of all why would anyone nowadays use targa to store images? It's either uncompressed or only run length encoded and depending on the image content that might not help at all. PNG is a lossless image format with much better compression.
However if you want to use TGA, just use it because it doesn't affect the build size at all. Unity stores the images in an appropriate hardware supported texture format for the given build platform. If the texture is compressed at all and which max resolution it should have can be changed at the import settings of each texture.
Can you explain me why this option is for ? . I want to know whether it will reduce memory on storage or in ram? .
Uhm have you missed my second paragraph? If you have you may want to re-read it again, carefully and also read the linked documentation page. Again, the texture source file you put into a Unity project is not the one included in the build. The textures are converted into an appropriate format for the build target platform. So it doesn't matter for the build what the source format is. You can use B$$anonymous$$P, PNG, TGA, PSD, ...
why would anyone nowadays use targa to store images
See my answer, there are cases where TGA will be better suited than PNG, since PNG is not truly lossless
Answer by mabulous · Nov 24, 2020 at 01:04 PM
There is one very good reason to use TGA over PNG:
most PNG compressors set the RGB component of completely transparent pixels to either complete black or complete white, which is fine so long as:
the alpha component is actually used as transparency
there is no filtering applied
However, depending of how the images get filtered when downsizing, the RGB part of those completely transparent pixels may be accessed and affect the RGB value of filtered pixels that are not completely transparent, and then you'll see strange dark or bright edges.
Also if you use the alpha channel for something else than transparency (like reflectivity or self illumination or something like that) then obviously this is not going to work well with regular PNG compressors. In these cases TGA will yield the desired results.
This is, however, fault of the PNG compressor, not the PNG format. I agree, that this can be a pain in the ass though. Anyway, aren't there better alternatives than Targa? Tiff maybe? This seems to be a very common struggle