View Full Version : Storage of 24 bit textures .... 32 bit aligned?
Are (non compressed) 24 bit textures stored in 32 bits in vid memory?
What I'm really asking is ... would storing an alpha component be free with respect to memory usage?
05-13-2002, 10:05 PM
I think that 24 bpp is converted to 32 bpp (where alpha is set to 2^n-1) for performance reasons (DWORD alignment).
16 bpp is kept 16 bpp but actual format is not realy known (5-6-5 or 5-5-5-1 and there are others)
Textures are kept as RGB for some but for others its BGR. BGRA or ABGR, RGBA or ARGB, ....
The usage of the alpha channel would be (more or less) free, yes. But only IF the implementation pads 24 bit images to 32 bit, but you never know if they do. You should look in some documentaion about your gaphics hardware and see if it says anything.
I guess then it's safe to go out on a limb and assume that both nvidia/ati would use 4 byte alignment. I have searched, but I can't find any info on this subject.
I've just had a thought. What do you reckon on storing a cheesy normal map in an alpha channel?
x = (bits 01 + 1) * 0.25
y = (bits 23 + 1) * 0.25
z = (bits 45 + 1) * 0.25
I think! I haven't thought that through in the slightest. It just occured to me.
Yeah, it would probably be safe to assume that both ATI and NVIDIA pads 24-bit textures.
About normals maps in the alpha channel, sure it would be possible to STORE it that way, but as far as I know, no pixel/vertex program today is capable if READING the normal. Could be possible to use the alpha channel as an index into a 1D texture, and let the RGB value in the 1D texture represent the normal, but I don't know.
05-14-2002, 12:41 PM
NVIDIA implementations (at present, at least) always pad 24-bit textures out to 32. In general, the fastest way to upload data to 32-bit textures is the same way as for 24-bit. So GL_BGRA/GL_UNSIGNED_BYTE (assuming little endian) is the way to go for both GL_RGBA8 and GL_RGB8.
05-15-2002, 01:04 AM
what do you mean by that? i should create a regular rgba texture, but specify a format of bgra in glTexImage2d?
In glTexImage2d the format parameter specifies the number of components (e.g. RGBA for 4 components) and the internalformat the way the data is arranged. So, store your texture values in BGRA order and specify BGRA for the internalformat.
Powered by vBulletin® Version 4.2.2 Copyright © 2016 vBulletin Solutions, Inc. All rights reserved.