iDevGames Forums
To use cTGA/TGA for textures? - Printable Version

+- iDevGames Forums (http://www.idevgames.com/forums)
+-- Forum: Development Zone (/forum-3.html)
+--- Forum: Graphics & Audio Programming (/forum-9.html)
+--- Thread: To use cTGA/TGA for textures? (/thread-5694.html)



To use cTGA/TGA for textures? - aarku - Mar 29, 2005 04:51 PM

Howdy,

I was considering mmap'ing cTGA or TGA or .dds (if I figure it out) textures to cut down on loading times. Right now I use either DevIL or QuickTime to load textures and could use a speed boost. I've read people on here say using TGA was bad. Why is that?

Aside: Here is a NeHe tutorial about 'em : http://nehe.gamedev.net/data/lessons/lesson.asp?lesson=33

-Jon


To use cTGA/TGA for textures? - Fenris - Mar 29, 2005 04:57 PM

The only drawback I can see with TGA is that it doesn't compress at all. For large textures, this might be a loss. If you have cartoonish or heavily alpha-masked textures, cTGA might be a good compression, since it does RLE. Some real-world benchmarks: El Ballo had terrible problems with loading times reaching upwards of 35 seconds. I'm loading 160 MB worth of textures at startup on Mac OS X, since I figured I might as well pull everything into memory and let the VM sort 'em out. With cTGA, I crunched the texture library down to below 80 MB, which ended up speeding the load times to below ten seconds.

TGA is superb for OpenGL, since you can just upload the pixel chunk onto the card as it is - no need to parse the actual pixels. If you don't have GL_BGRA you'll need to swizzle the pixels into RGBA, but most cards do BGRA. (Correct me if I'm wrong here - is that a driver issue rather a hardware issue?) For cTGA, you need to decompress the RLE stream, which is really quick.

I guess it comes down to what type of textures you're using - cTGA won't do squat with photorealistic surface textures for instance.


To use cTGA/TGA for textures? - arekkusu - Mar 29, 2005 05:23 PM

TGA's RLE compression is just awful. You're much better off using PNG if you want lossless compression. If you don't require an alpha channel, use JPG.

This has been discussed several times already. This post has some numbers.

[Edit:] Here's another old post with numbers.


To use cTGA/TGA for textures? - arekkusu - Mar 29, 2005 05:33 PM

All GPUs under OS X support RGBA and BGRA. The fast format for 32bit texture upload is GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV. It's up to you to pick an image library that formats the data in that order (QuickTime will, NSImage won't.)


To use cTGA/TGA for textures? - aarku - Mar 29, 2005 05:56 PM

arekkusu Wrote:TGA's RLE compression is just awful. You're much better off using PNG if you want lossless compression. If you don't require an alpha channel, use JPG.

This has been discussed several times already. This post has some numbers.

[Edit:] Here's another old post with numbers.

Like I mentioned above, I'm going for load times here, not file sizes. I understand that file sizes both compressed and uncompressed will be smaller for png24 and png. Is there any other reason besides file sizes?

-Jon


To use cTGA/TGA for textures? - arekkusu - Mar 29, 2005 06:20 PM

Your CPU is much faster than your disk drive. It takes longer to read 20 megs from disk than it does to read 2 megs and uncompress it.


To use cTGA/TGA for textures? - DoG - Mar 30, 2005 01:18 AM

Not even speaking about QT being optimised more than you'll ever be able to do so for your own code.


To use cTGA/TGA for textures? - aarku - Mar 30, 2005 03:35 AM

DoG Wrote:Not even speaking about QT being optimised more than you'll ever be able to do so for your own code.

That doesn't have much to do with what I asked. OK. A simple "No, the file size and its effects are the drawbacks," would be sufficient.

At any rate, I've got some stuff for dds textures so I'm going to mmap those and screw RLE TGA and TGA.

-Jon