Download

Texture File Format and Resolution

Hi everyone.

I did do some searching and maybe I am using the search facility incorrectly but I was unable to find a definitive answer.

Basically I would like to know the following:

  1. What is the best file format to use for model textures?
  2. What is the best resolution to use for model textures?
  3. What file format should the normal map be?
  4. What file format should the diffuse map be?

For instance, one of my models … the normal map is 19 MB and the specular map is 9 MB but the diffuse image is also only 9MB. Granted this is a 4096x4096 texture stored in TGA 8BIT format … is this the right format to use?

Any guidance or assistance or pointing in the right direction will be greatly appreciated.

Thanks

1: I use either PNG or TGA
2: Depends on the object, rarely does anyone use something above 1024x1024
3: Same deal, PNG or TGA
4: Same deal, PNG or TGA

Source file size isn’t going to be what the file size is in the engine, it depends on whatever compression format is used in the engine

  1. I personally just use tga
  2. I mostly use 512x512 textures + as darthviper mentioned rarely anyone uses something above 1024x1024 -> the resolution always depends on your model

I could be wrong but my understanding is that format doesn’t really matter as far as the engine is concerned (as long as you are using a lossless format), meaning that whatever format you bring in it’s going to convert it to the data/format the engine reads. So basically it comes down to whether you want to use compression to save hard drive space, though this might increase import times as unreal has to uncompress it first, or leave it uncompressed with faster import times but much greater disk space.

They handle alphas a bit differently, since PNG has transparency and TGA has a regular alpha channel, which means you can fill in the empty space with a specific color or something. With PNG UE4 will fill in the empty space background with something.

Always? It doesn’t when I’m importing textures for UMG… empty space stays empty space. Unless you meant to say that you can simply see through it, to whatever UE4 has rendered behind it?

In a PNG when you have transparency there is nothing in the transparent areas in the RGB channels, so when it gets imported to UE4 it has to put something there, it still uses the transparency as the alpha, but it has to have something filling the RGB channels. Some programs will copy the pixels on the edge of the image and just extend them to fill the empty space, but some just put white there, which can be bad and cause white edges when using transparency.

I was thinking at render time… understood properly now. Experienced this myself and had to tweak a few textures to fix it… now I know why. :slight_smile:

Ahhhhh … now it explains why my splattermaps for my terrains come out looking a little freaky … I thought it had something to do with World Machine. 8-}

@all: Thank you very much for the information, this has cleared it all up for me now. I will stick to using TGAs and will just reduce my textures down to 1024x1024. Thanks again everyone … onward and upward now. 8-}

PNG files, alpha, and Photoshop

Regarding the PNG’s not supporting alpha properly…

It is my understanding that the problem is specifically a Photoshop bug, and not actually a problem due to the PNG format itself. It is possible, using software other than Photoshop, to produce a PNG with an alpha that works exactly the same way as a TGA’s alpha. Most compositing programs, such as Nuke, handle PNGs with alpha just fine. In those programs, you can throw any information you like into the PNG alpha channel, and not risk loosing either the alpha or color information.

However, opening a PNG file in Photoshop, that has color patches where the alpha is black, will result in a loss of those areas of color, when you save the file back out. Saving any PNG from Photoshop causes similar problems. (See more technical info below if interested.)

Because Photoshop is such a staple in the industry, the best course of action for working with Photoshop and widely supported image formats for games seems to be, if you want low disk space size of source art:
-PNG files for images without an alpha channel
-TGA files for images with an alpha channel

(TIFF has reasonably wide support as well, and has better compression than TGA but not as good as PNG)

Here’s a visual demonstration of the problem, with images you can download to test yourself if you like:

http://www.teaching3d.com/examples/png_bug_from_photoshop/

and the actual demo image:

Additional technical information:

Essentially the problem comes down to the fact that you have no way of controlling the color channel information that gets saved into fully transparent pixels in Photoshop. Photoshop, unlike most high end compositing software, internally treats transparency as something different than alpha. Photoshop will fill the color channel with white in most places where the alpha is black. (I think it’s likely that this is because Photoshop still assumes it is working on “white” paper, so instead of empty transparent pixels being black in the color channels, they are white, there, instead.)

Normally, the primary reason to use a PNG instead of a TGA, is that the PNG images are drastically smaller on disk, so the source art is more efficient even if the in-engine art is the same size (eg in texture memory). In cases where textures have any chunks of solid color in any of the channels, or certain types of gradients, the file size on disk difference can be huge. It is quite dependent on the visual content of the image.

When using other software together with Photoshop the I’ve written custom code to fix this problem. The resulting PNGs will work fine in many programs, but not in Photoshop, and unfortunately, not in Unreal 4 either. In my opinion it’s a bug in both Photoshop and Unreal 4, probably not noticed because so many users of Unreal 4 use Photoshop. (I say bug in Unreal 4 because it looses information that I can prove is present in the same PNG file by opening it in other viewers.)

Adobe seems to have no plans to fix the problem, even though game artists have known about this and complained about it for the past 15 years. Open EXR had the same problem when it was introduced, but enough people complained and now you get a choice as to how Photoshop should function when you open an EXR with an alpha channel.

@Joetainment: Thanks for the awesome information.

The only Nuke I have been able to find is this: http://www.thefoundry.co.uk/products/nuke/ … is this the right version?

Re: Nuke

Yes, that’s the “Nuke” I was talking about. It’s just one of many applications that actually handle alpha channels properly, unlike Photoshop. (The level of control in software like tends to be very precise and technical.)

Keep in mind, that even if you make PNG files that are perfect and that have all the channels exactly as you want them, it still won’t help with Unreal because Unreal won’t import them properly. I do however use PNG sequences frequently for lossless compression of renders for VFX compositing. In many cases OpenExr is a superior replacement, but there are still cases where PNG is useful.

At Vanarts, which is a school I teach at, we tell students to use png files (which are very efficient on disk) for game engine textures without alpha, and tga files for textures with alpha. We use those formats since both Unreal and Photoshop work well with them. Both texture formats are easy to export from your PSD files. (We occasionally use other formats but only when there is some kind of special need for HDR or something, and only if we know the software pipelines and game engines being used are compatible with the other formats.)

Btw, I have some free and useful scripts for Photoshop which help to save PNG and TGA files from PSD files. The script will automatically save to a file in the same folder and with the same name, but with a different extension. The user simply runs one of several scripts based on which format is wanted. I usually make actions that run the scripts when I push hotkeys (eg F11 and F12), which saves a lot of time. In case the scripts are useful to anybody, they are free here…
http://www.teaching3d.com/resources/joecc_photoshop_scripts/joecc_photoshop_scripts__current.zip

@Joetainment: Thanks for those scripts, greatly appreciated. I am actually going to put your advice in to my teams Best Practices documentation. 8-}

Thanks to everyone who responded, I am starting to get the hang of it all now, has taken a bit of a change of mindset to move from Torque 3D to Unreal Engine 4 … but I am very glad I made the switch. Thanks again.