TGA & RAW( row /column major order) ??

Started by
2 comments, last by Max_Payne 19 years, 6 months ago
Hi Just a simple question i think I am going to implement parallax mapping once i get my new graphics card, so what i want to do is 1. LoadTGATexture 2. Associate .shader with the texture 3. if parallax mapping set alpha channel to parallax heightmap now the problem is as follows how are tga images and raw images stored in memory? row major order?

0  1  2  3
4  5  6  7
8  9  10 11
12 13 14 15

or column major order?

0 4  8 12
1 5  9 13
2 6 10 14
3 7 11 15

where is the top left vertex ?
http://www.8ung.at/basiror/theironcross.html
Advertisement
TGA images are stored on a per row basis. *However* image can be flipped vertically. Its actually an option in the image format. You can encode images both from top to bottom or from bottom to top... And even though most programs seem to output TGA files in bottom to top encoding, your loader should still make sure to support both (just load it in bottom to top order and flip it afterwards if the encoding of the image suggests otherwise). If you also code a function to save images to TGA, it does not matter what order you store the rows in, however, as long as you set the flag properly in your TGA header. Another important factor is that pixels are stored as BGR/BGRA, and not in RGB order, as the standards might seem to suggest.

For RAW images, I don't know, it sorts of depends on you... Sort of like a custom format. Personally, I don't use that format, because it doesnt make much sense to me. Might as well use TGA everywhere and have your image files be sort of self documenting, rather than being restricted to a fixed set of properties for your image files and having the loader sort of guess them.

Implementing support for 24/32 bit TGA is very simple anyhow, you shouldn't have any difficulty. I suggest you find the targa standard on wotsit.org, as it might help you. The only thing you might find weird is that many program don't seem to support an alpha map on TGA files. I believe photoshop 7 does, however.

Good luck with your project :)

Looking for a serious game project?
www.xgameproject.com
unfortunately photoshop doesn t offer the choice between bottom top and top bottom

but if it is row major i guess raw files would be row major as well so it doesn t matter
http://www.8ung.at/basiror/theironcross.html
Quote:Original post by Basiror
unfortunately photoshop doesn t offer the choice between bottom top and top bottom

but if it is row major i guess raw files would be row major as well so it doesn t matter


I have never heard of any format thats column major, so, yeah, it would be kind of surprising. It seems many image formats encode from bottom to top by default, so I wouldn't be surprised if most programs just encoded it bottom to top by default. Just try with photoshop and see.

But then again, I advise using TGA instead, its well supported and gives you better flexibility, and its not complicated at all to implement support for it. I mean, seriously. With RAW, you have to somehow assume that all textures are of a specific format, since the files carry no information about the image they store. While with TGA, you can store images of any width and height, up to 65535x65535, you can store images with or without an alpha map, or just in grayscale... You could even make your own extensions to support floating point colors if you wanted.

And just to make it clear, with TGA, the bottom-top/top-bottom encoding is no issue. The file header actually tells you how its stored, so you can load and store images in the way you want. The only risk is that some poorly written decoders could not support top-bottom encoding and just assume bottom-top (something to consider if saving TGA screenshots).

Looking for a serious game project?
www.xgameproject.com

This topic is closed to new replies.

Advertisement