Skip to main content

Stupid Question: Why powers of two?

Submitted by jwalduck on
Forum

In all the references to image maps I see requirements for 256, 512, 1024 etc. All powers of 2.

Why is this? Is it imposed by the game engines? If so is it all of them or just some? Is it a memory thing?

Submitted by Wizenedoldman on Thu, 05/02/04 - 3:16 AMPermalink

It all stems from computers running on a binary number system (I hope you know what that means). The reason textures are usually restricted to squares that are whole binary numbers (best way I can think of saying it, eg. 2 to the power of 9= 512) is that computers find it a lot easier to process them this way. I'm not too sure on the theory behind it all, and any stabs in the dark I take would probably be misguided, but I hope this gives you a start.

Submitted by jwalduck on Thu, 05/02/04 - 4:10 AMPermalink

Thanks, but that doesn't really answer my question. I know why at their lowest levels computers use binary, but application software abstracts us from that low level.

What I would like to know is why in the specific case of 3D image maps these limits are in place.

Submitted by Aven on Thu, 05/02/04 - 4:20 AMPermalink

If memory serves me correctly, all graphics cards from the GeForce 3s up can support non-squared textures. I'm pretty sure that it does come with a preformance hit though.

The programmers may be a little better suited to handle this one :)

Submitted by J I Styles on Thu, 05/02/04 - 4:32 AMPermalink

the reason behind it is purely efficiency - the binary system dictates that it can send through so many bits (8 iirc) of data in one packet; when conforming to the power of 2, so when it's called, it doesn't have to do more transfers than is necessary because it's just below, or just above that data range. In the end it can have a fairly nasty knock-on effect with transfer bandwidth speeds, and also in most all game cases if a texture isn't a power of 2 it'll be resized onboard to make it that before passing it down the pipeline (which results in some poor handling, sampling, and quality issues).

Submitted by davidcoen on Thu, 05/02/04 - 9:34 AMPermalink

for example, if you do something like support 'mirroring' of textures in the hardware, you need to be doing mathamatical manipulation of the texture coordinates, and if you can just do it in some binnary shifts, it is a lot easier than hold number, add number, subtract, change sign.....

this i guess gets more relevant for doing mipmapping, but i dont know for certain what hardware support has been done for mipmapping.

yes, cards may do nonpower2 sizes, but internally, it probablt is putting them onto powerof2 texture memory anyrate....

Posted by jwalduck on
Forum

In all the references to image maps I see requirements for 256, 512, 1024 etc. All powers of 2.

Why is this? Is it imposed by the game engines? If so is it all of them or just some? Is it a memory thing?


Submitted by Wizenedoldman on Thu, 05/02/04 - 3:16 AMPermalink

It all stems from computers running on a binary number system (I hope you know what that means). The reason textures are usually restricted to squares that are whole binary numbers (best way I can think of saying it, eg. 2 to the power of 9= 512) is that computers find it a lot easier to process them this way. I'm not too sure on the theory behind it all, and any stabs in the dark I take would probably be misguided, but I hope this gives you a start.

Submitted by jwalduck on Thu, 05/02/04 - 4:10 AMPermalink

Thanks, but that doesn't really answer my question. I know why at their lowest levels computers use binary, but application software abstracts us from that low level.

What I would like to know is why in the specific case of 3D image maps these limits are in place.

Submitted by Aven on Thu, 05/02/04 - 4:20 AMPermalink

If memory serves me correctly, all graphics cards from the GeForce 3s up can support non-squared textures. I'm pretty sure that it does come with a preformance hit though.

The programmers may be a little better suited to handle this one :)

Submitted by J I Styles on Thu, 05/02/04 - 4:32 AMPermalink

the reason behind it is purely efficiency - the binary system dictates that it can send through so many bits (8 iirc) of data in one packet; when conforming to the power of 2, so when it's called, it doesn't have to do more transfers than is necessary because it's just below, or just above that data range. In the end it can have a fairly nasty knock-on effect with transfer bandwidth speeds, and also in most all game cases if a texture isn't a power of 2 it'll be resized onboard to make it that before passing it down the pipeline (which results in some poor handling, sampling, and quality issues).

Submitted by davidcoen on Thu, 05/02/04 - 9:34 AMPermalink

for example, if you do something like support 'mirroring' of textures in the hardware, you need to be doing mathamatical manipulation of the texture coordinates, and if you can just do it in some binnary shifts, it is a lot easier than hold number, add number, subtract, change sign.....

this i guess gets more relevant for doing mipmapping, but i dont know for certain what hardware support has been done for mipmapping.

yes, cards may do nonpower2 sizes, but internally, it probablt is putting them onto powerof2 texture memory anyrate....