Game Development Community

2^n * 2^n textures

by Abraham Martin Exposito · in Technical Issues · 05/17/2010 (2:41 pm) · 5 replies

Hi!
Is important to Torque X 2D to use 2^n * 2^n textures for better performance?

#1
05/26/2010 (7:51 am)
I'm 99.9% sure that you always want to use power of 2 textures. If you dont, it will simply "round them up". so you would then be wasting space. For example, if you made a 220*400 texture, it would simply round it up to 256*512 at runtime. Therefore you have just wasted space and memory.

I could be wrong, but I think that is how it works. It is always just a good idea to use power of 2 in textures in game engines.
#2
05/26/2010 (8:19 am)
That's correct. The best practice is to use power of 2 textures.
#3
05/26/2010 (8:26 am)
OK!

one more question:

A 256x512 texture is more efficient than a 512x512 one? I though that a NxN texture is more efficient than a MxN texture. Am I right?

Imagine that I have a 100x1024 texture. Obviously, in the point of view of the memory usage, is better 128x1024 than 1024x1024, but... which has better performance?
#4
05/26/2010 (9:37 am)
to try to get as simple as possible.

if you have 1 1024*1024 texture as your base. a single 512*512 is 1/4th the memory usage. so 2 512*512 textures would be half the memory.

"Imagine that I have a 100x1024 texture. Obviously, in the point of view of the memory usage, is better 128x1024 than 1024x1024, but... which has better performance? "

a 128*1024 is still a power of 2, it is just not squared. so yes, a 128*1024 is going to be far less memory (1/8) than a 1024*1024. i am not sure which platform you are on or what kind of game you are trying to make, but i will say one thing that i have learned in my years of development.

people try to use a higher res texture than they need to far too much. think about it, if your resolution for playing a game is 1024*768, and you use a 1024*1024 texture on an item that is using up 1/10th of the screenspace, that is....well, its just silly.

do some tests. take an object and make 4 variants of it. now make 4 different textures, 1024, 512, 256, and a 128. place each on one of the 4 objects, run your game. see how much of a difference they make. i am guessing not much (not like we are making call of duty or gears of war here).

hope that helps
#5
05/26/2010 (10:54 am)
I'm making a 2D beat'em up game using TorqueX 2D. The game will accept a full HD res (1920x1080), so the hi-res textures are justified ;)

I will take your advice, testing different res. textures is the better way to check the performance differences.