TGA vs PNG (for textures)

PNG

  • Smaller file size (lossless compression)
  • Less control over transparency since it’s not stored as a separate channel.
  • Modifying transparency is a pain in the *** in PS.

TGA

  • Larger file size (uncompressed)
  • Full control over transparency, since it has a discrete alpha channel.
  • Modifying transparency is easy in PS.

TIFF

  • Large-Small File size (can use compressed or uncompressed, lossless)
  • Full control over transparency, due to discrete alpha channel.
  • Modifying transparency is easy in PS.

PSD

  • Usually, huge file size (contains all info as layers, as well as channels for each layer).
  • Full control over everything, if it’s a layer.

^ The only differences that matter.

Compression and size makes no difference whatsoever to your runtime game speed, since everything is uncompressed then converted to DXT/BC7/RGBA format anyway when imported. TGA is the preferred format for most people since it has a discrete alpha channel that you can bring into something like PS and modify it there, and since it’s uncompressed it’s also faster to open and save (not that that’s an issue for modern PC’s usually), AND textures can be rebuilt faster in UE4.

File size only makes a difference to the amount of space your EDITOR project takes up on disc, NOT the packaged game. For consistencies sake, I’d stick to TGA personally, but TIFF is a good format if your conscious of source control / disk space.

Also on the “pro” side of TGA:
It only has a simple 18 byte header. So its a nice format for creating custom texture creating/editing tools…

I prefer to avoid alpha channels where possible, because they get their own unique compression while RGB gets combined together.
Resulting in an alpha channel taking up the same amount of space/memory as RGB combined.

for that reason I tend to combine three Alpha channels into a new RGB texture. (or if I dont need metal, put the mask in the M of RMA)
that can actually save quite a bit of size over the course of a project.

that said, if I do need a very crisp grayscale or mask, I use the alpha channel.
Occasionally I even save a seperate grayscale or mask with the alpha-only compression, removing the RGB info so if I do need to use the grayscale/mask in multiple materials, it doesn’t need to load useless RGB info.

2 Likes

Somewhat related:
Is it possible to have uncompressed textures in a cooked build?

yes.
there are uncompressed options.

However that has the drawback that you use up one more texture sampler node.
Especially in layered materials I tend to use the alpha channel.

1 Like

as a vfx guy, thats the least of my worries hehe.
but yea, from a layered material pov I can fully understand that problem.

Sort of incorrect (there is really no difference in the Pixel Quality between TGA and PNG thank you for the correction), there are options to not do so but also BCn has compression techniques associated with them that record the texels in a texture. So in essence whether the texture is TGA, PSD, TIF, PNG, JPG or whatever the texture quality, texture size, and pixel depth are what is important. This Does have a large input into what it used in VRAM…think unoptimized texture fill rates.

The argument here is TGA vs PNG in game dev…UE4 more specifically. If you have good textures then you will get good compression in the BCn with little to no artifacts. When you have a large game being designed then having TGA or PSD as your bulk of textures then space is simply being wasted for no reason. TGA still has a place but just not the bulk of the textures.

I’d really like to hear the reasoning behind this - it’s the first I’ve heard of it.

1 Like

Runtime does not know what format texture was before it’s converted to UASSET. Only difference is that TGA has better alpha support. So if that alpha channel is used for roughness or specular then it might affect.

1 Like

The TGA image file format does support compression.
But whether UE4 supports the compressed TGA format I have not tested it.
TGA compression is lossless RLE (run length encoded). So it typically doesn’t offer much compression in size unless the image has large regions of the same pixel values.
PNG compression is lossless DEFLATE (similar to Zip). So it typically can compress complex images fairly well.
Both image formats are not relevant to what actually ends up in-game, as the bitmap image from the graphics file is converted for use in the engine.
There are some variations between the two image formats for support of pixel types and alpha channels.

I know that UE4 will export textures in the Targa format. So that would give me more reason to believe in using it for my textures. However, I wouldn’t make that my sole argument.

As the title says, I have to convert thousands of image files TGA to PNG, I was looking for something which can do it automatically but it must also allow me to keep “created, modified, accessed date/time” from the original file.

I know IrfanView can do this without problem but I noticed that the output file size is still a little big.

Then, I discovered PngOptimizer, I must say that it is very simple and fast and compresses more respect to IrfanView but unfortunately, PngOptimizer seems that it does not allow me to keep the original date info.

At the moment I do not know what else to look for / to do.

Do you have any suggestions? Any help is appreciated.

Thank you! =)