Game Development Community

Texture Formats

by David Boston · in Game Design and Creative Issues · 07/24/2007 (7:06 pm) · 3 replies

I've searched high and low and not found the answers I'm looking for...

If I understand it right, a jpg file and a png file should take the same amount of texture memory though the jpg will typically take less disk space due to the lossy compression scheme it uses.

Several places I've read that you should use jpg wherever you don't need alpha (except for terrain) and can live with the image degradation.

What I haven't found any reference to at all is the use of indexed color in png files. If you switch to a 256 color index it drops the file size dramatically while not losing pixels. Is it possible and/or adviseable to use such an indexed mode if the color quality allows? Will the footprint in texture memory be the same regardless? Will there be a processing hit due to the indexing?

Any help on this would be greatly appreciated.

Marnoch

About the author

Recent Threads


#1
08/05/2007 (1:35 pm)
Well, no, there shouldn't be. The image file types are determined not too much by the engine, but by the 3D driver (OpenGL, Direct3D) that you use, both of which have the ability to load indexed-color PNG files in their included extension libraries (GLX or D3DX). They may take about a millisecond more time to load, because the indexes of each texture have to be interpreted, but once that is done, the computer's memory should have the same image stored in it, with maybe a bit more memory taken up for the index. But I really don't know much on that subject, most of this is guesswork.

And besides, why aren't you using Targa (*.tga) ? It's much better at compression, has a single 8-bit Alpha channel as well as 32-bit RGB channels, and it doesn't have artifacts, despite its compression level. It also loads at a relatively fast rate, and is probably the most common game texture filetype. I believe that Torque can use them.
#2
08/05/2007 (2:25 pm)
All textures occupy the same amount of space on Video Ram unless they are DDS - AFAIK.

TGA is not supported by Torque.
#3
08/05/2007 (3:25 pm)
Note that if you want to save on diskspace for textures with an alpha channel,
you can use jpg instead of png - the trick is you have to provide a second jpg which is the alpha channel.
so if your color texture is foo.jpg, the alpha texture would be foo.alpha.jpg and the engine automatically loads it.

as mentioned above, they'll use up the same memory unless texture comression is turned on on the card.