Let's talk about texture export formats


I wanted to do a quick comparison of the most common formats. Please feel free to add more context and discuss in the rest of the thread.

TGA : Personally I’ve been a TARGA fan for the longest time. It’s simple and straightforward, no weird shenanigans, not much to say about besides, if you’re in doubt just use TARGA. Only downside I can think of is that typically software (like Photoshop) requires you to explicitly define the alpha channel instead of being able to use the alpha of the canvas.

Pros:

  • Ridiculously easy to use.

Con:

  • Often uncompressed so it can take up a bit more space.
  • Need to explicitly define the alpha channel.

PNG : PNG is interesting, It’s technically lossless but has this quirk where, if you export an image with an alpha channel, it compresses out the rgb info where the alpha is 0. This can be nice if you need something in which alpha and color are linked like a logo. But for a lot of effects, you want the mask to be usable independently of the color information.
There’s also some weirdness with software offering a pre multiplied output, but honestly you’ll want to avoid that 99% of the time anyway.

Pros:

  • Typically compressed but still lossless, so often a bit lighter than targa (honestly we rarely care but yeah)
  • No need to explicitly define alpha channels
  • Widely used and supported

Cons:

  • Complex and quirky behavior when used with alpha channel
  • When already using targa (which most productions will be) introduces inconsistencies.

PSD: This one depends on the engine you use, but Unreal (and maybe even Unity) support psd as an import format(flattened result). This has some nice benefits. It means you only need to keep track of 1 source file and have that one be linked in your engine. Since we ship the BC textures we might not care about the fact that the psd is massive. However, even more so than PNG the actual imported result can be a bit unpredictable esp. when using alpha, so use with care.

Pros:

  • Non-destructive workflows are easier to setup since source file is linked directly

Cons:

  • Massive file size (but typically productions keep their source files around anyway in case they want to make adjustments or reuse it)
  • Sometimes behaves quirky with alpha info.

DDS: I guess we gotta talk about it. DDS essentially allows you to save block compressed(s3) textures. Personally I wish dds was better supported. Both dds import and export are rarely supported and even if they are they typically only have partial support. On the other hand, this is kinda the opposite of PSD, it creates a destructive workflow where the files you import in engine are already hyper compressed.

Pros:

  • More control to directly compress textures yourself instead of relying on the engine to do it for you.
  • Small file sizes.
  • Shipping memory cost is super obvious (cause you’re just going to ship the file you just created)

Cons:

  • Need everyone on production to be more aware of compression.
  • Destructive workflow

Jpg : Err, no.

20 Likes

TGA

The need to explicitly define the alpha can often be a Pro and not a Con, it just depends on the use case.

One other Con is once every 5 years or so Adobe decides to totally break TGA in Photoshop for a few weeks (or months). With the nature of Creative Cloud sometimes not allowing you to downgrade to an older version, this can completely prevent you from using TGA with alpha for a while.

PNG

“Weird quirks” are entirely solved by SuperPNG, which is what you should always use when saving or opening PNG files in Photoshop or applications that can use Photoshop format plugins. This is the “one true format” in my mind for SDR content.

Though there is one Con for this format in my mind. Because it is an explicitly (true lossless) compressed format, and a quite old format, it can take quite a long time to compress and open. It’s an explicitly single threaded operation that cannot be easily improved with multi-threading.

PSD

Alpha in PSD files is a nightmare if you want it to be a separate channel, because by default the official PSD reader fades transparency to white. In Unity they have code that tries to undo this, which works well enough most people don’t notice, but does degrade the quality of any semi-transparent values. This was removed for a little bit a few years ago due to pressure from Adobe, and then promptly re-added due to the backlash. This is explicitly done by Adobe to break other applications, as it does not affect Adobe’s first party software.

DDS

Biggest problem with DDS is if you need to support multiple platforms that don’t all support BCn formats. Even on console, you’re likely going to be using Oodle or BCPack and not straight BCn, so DDS is really only viable if you’re targeting PC only.

BMP

The forgotten format. Was the standard for ages! Technically supports 32 bit with alpha and higher bit depth! Except there’s more than one format for BMP, and almost nothing actually supports the 32bit or higher bit depth versions of the format. Also you need to remember what specific format it was saved in to open it correctly.

RAW

Like BMP, but even more fun confusing.

EXR

Trying to become the new defacto format. Kind of has for film when not using video formats. Supports a huge range of formats, including true floating point. Under-appreciated by game dev and often assumed to be always be linear HDR values which limits its usefulness outside of that use case.

HDR

EXR’s bastard sibling. Basically two jpg images in a trenchcoat. Avoid at all costs if it can be helped.

14 Likes

3 Likes

Agree, I was scraping the bottom of the barrel to not seem like a total tga fanboy.

I mean, I’m definitely not going to say it’s not complete ass to use TGA for things you want to have transparency. If you’re doing sprites, 100% they should be using PNG because the default behavior is the closest to what they actually want.

Now if only more people knew to check the “Alpha is Transparency” setting on Unity’s texture import settings to avoid halos on bilinearly filtered sprites. And if Unreal’s texture import handling scriptability wasn’t ass.

3 Likes

Am i the only one that uses TIF? :laughing:

What are the benefits of using TIF over for example PNG? I used it in the 90th for desktop publishing. I don’t see the point of it now though.

Targa is nice because it’s so primitive and I get full control over the alpha channel. PNG can destroy information where the alpha is zero so does Targa if compressed.

EXR is just nice and I can do whatever I feel like.

1 Like

There’s nothing inherently wrong with TIFF, and it has some interesting features that are underutilized that could make it an excellent format for game dev.

The fact it supports multiple layers of different format for one could allow you to have a single file that has albedo, alpha, metalness, smoothness, AO, and normals all in one texture, as separate layers that could then be packed as needed in the editor.

But, almost nothing supports that. You’re sometimes lucky if game dev tools understand separate alpha channels or 16bpc TIFF. I’ve also had some tools that crash if you use the wrong TIFF compression type. The compression types TIFF does use are also not explicitly designed for images, so it’s often less effective than even PNG, assuming you use compression at all. Though, personally I consider compression to be a negative for dev, even lossless compression. If I could save PNG with compression disabled I would.

So the problem with TIFF isn’t really anything with the format itself, but rather the inconsistent support it has. And if we ignore the multi layer support, it doesn’t offer any real benefits over PNG or EXR.

1 Like

TGA sounds like a useful format. It’s a shame that web browsers don’t support TGA, so I’m not sure if it can be used for browser games. Unless maybe the engine converts it at build/runtime?