View Full Version : calculating textures
08-10-2003, 09:10 PM
I've been wondering, how do you figure out how many textures you can have visible at one time depending on the users 3d card?
Assume the card has 32 megs. If your textures are all 512x512 do you then multiply those pixels by 8 to get the total memory for each texture, then divide this into the memory on the 3d card? But doesnt the memory also have to support information for all the verts, etc? I guess there is a lot of guess work somewhere.
08-11-2003, 02:25 PM
I just ask my graphics programmer!
All kidding aside, yes depending on how your engine utilizes the card(s), verts and bones and other things can take up video mem.
The size of a 512x512 texture depends on a couple things, as far as I understand it.
1. Bit depth, like 1bit vs. 8bit vs. 32bit color.
2. Bitmap compression, like compressed DXT vs. uncompressed BMP.
A 32bit 512x512 uncompressed BMP will run around 1MB, while a compressed DXT in DXT5 format (alpha support) will run around 350KB.
Sorry can't remember the exact formula for calculating bitmap sizes...
08-13-2003, 08:33 AM
Fast way for Windows Bitmaps:
size_in_bytes = (((bit_depth*bitmap_width + 31) & (~31))/8)*bitmap_height;
08-13-2003, 02:21 PM
So let me see if I have this right... say I have a 32bit 512x256 bitmap in WinXP.
(((32 x 512 + 31) + (31)) /8) + 256 = 2311.75 bytes or 2.3KB?
Huh? I must be reading your notation wrong. What do "&" and "~" stand for?
08-14-2003, 06:46 AM
Yeah, the & and ~ are boolean ops used to align the pitch bytes (the number of bytes per scanline) to 32 bits since Windows
Bitmaps must be 32-bit aligned. But this is not reqired for 32 bit bitmaps since they are already 32-bit aligned and you can just use # of bytes = 4*width*height :P. But I use 24 and 8 bit bitmaps occassionally in my OpenGL apps and this formula works at all bit depths and it's fast.
pitch bytes = (((bit_depth*bitmap_width + 31) & (~31))/8)
# of bytes = (pitch bytes) x bitmap height
So pitch bytes = ((32*512 + 31) & (~31))/8
= (16415 & (~31))/8
= (16415 & -32)/8
= 16384/8 = 2048 bytes (note that 16384 % 32 = 0)
Then the #of bytes in the 512x256 bitmap are:
= pitch bytes x bitmap height
= 2048 bytes x 256
= 524288 bytes
= 512 KB
01-15-2006, 08:00 PM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.
vBulletin v3.0.5, Copyright ©2000-2015, Jelsoft Enterprises Ltd.