Sign in to follow this  
AvengingBob

Square vs. Rectangular Textures

Recommended Posts

Hey, a quick question from an artist. I know you can load rectangular and square textures equally easy (provided they are power of two in dimensions). The thing that puzzles me is why the majority of game source art I've seen uses square instead of rectangular textures (i.e., the textures for Quake, Doom, Half-Life, etc,). Is there a particular reason this is done? I'd like to know, because our coder has been complaining about wasted space in our maps, and has suggested using a rectangular texture to save save. Thoughts? -AvengingBob

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
because many cards do not support rectanular textures, only squares and ^2

Share this post


Link to post
Share on other sites
I think that all 3D cards can do rectangular power of 2 textures, even a PS2 can...
IMHO, it's just an habit, when artists create texture they first create a square one and don't necessary change for rectangular afterward (they would have to remap 3D objet(s) by changing the texture).

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Uhh, mine doesnt
lots of older and low-end cards are Square Only

Share this post


Link to post
Share on other sites
I never wrote a software rasterizer, but I'm pretty sure that there are operations done faster if the texture is a power-of-two square.
Don't remember wich operation though...
On older card this lead to that standard, today it doesn't matter anymore.

Share this post


Link to post
Share on other sites
AFAIK, square power of two textures are used to texture 3D objects and rectangular or non power of two textures are used to do the GUI and the HUD. That's because rectangular textures have many limitations, like no mip-mapping and no repeat mode (at least in OpenGL).

Share this post


Link to post
Share on other sites
Quote:
Original post by deathkrush
That's because rectangular textures have many limitations, like no mip-mapping and no repeat mode (at least in OpenGL).
Ehm, do you have a source for this claim? Because I have none of such problems.
Are you sure you aren't confusing non-square with non-power-of-2?

Share this post


Link to post
Share on other sites
There should be no problems at all with rectangular textures, as long as the sides are a power of 2 in length. The extension allows non power of 2 textures. For all I know there may have been cards that required square textures, but if there are then I guess they don't fully support opengl 1.0 (and would be pretty darn old).

As for why it isn't done, I don't know, but I saw it done in unreal.

Share this post


Link to post
Share on other sites
Quote:
Original post by deathkrush
Like I said, the limitations are for OpenGL, according to this Nvidia extention and this ARB extension.

Quote:
From said link
OpenGL texturing is limited to images with power-of-two dimensions and an optional 1-texel border. NV_texture_rectangle extension adds a new texture target that supports 2D textures without requiring power-of-two dimensions.

So, the extension adds support for non-power-of-two textures like 69x42. It is an addition to an extension that already allows for non-POT, 2D, square textures like 45x45, hence the name NV_texture_rectangle.
And indeed:
Quote:
From said link
NPOTD textures may not use mipmap filtering.

Again: non-POT textures, so POT-rectangular textures are fine.

Of course, there may be some ancient cards (and especially their drivers) that require square textures, but they're probably so old they're not far from being excavated in archeological digs.

Share this post


Link to post
Share on other sites
Hello.

DaBono is correct. People here are confusing 'rectangular' textures and 'non power of two' textures, also 'rectangular' textures and the 'texture rectangle' extension in OpenGL. The rectangle extensions indeed have many limitations on them, however I do not think this is what the OP is referring to. If you use standard power of two on height and width for textures (eg. 256 x 64) you'll be just fine. There is a newer extension for OpenGL that allows non power of two textures. It is still generally recommended, however, that power of two textures be used, as there are certain optimizations that can be made for them, and only very recent video cards support that extension.

Now, on to the reason why square power-of-two textures are generally used. When generating mip-map levels with square textures, you get half the width and height for each level. For a non square texture, say 32 x 8, you get half of each until the smaller side reaches 1, where it stays at 1 pixel until the other side is at one. This means for the 32 x 8 texture you'd get mips as: 16x4, 8x2, 4x1, 2x1, and finally, 1x1. The most extreme case would be a 2048x1 texture, in which all mips would be halves in width and 1 pixel high. This leads to slightly suboptimal memory usage, and a perhaps bit of distortion at the lowest mip levels. Granted, it's usually not a large difference, so if they are deemed neccessary, by all means, use them. Also, on a slightly different note, cube map textures are required to have the same width and height.

HTH

-Jeremiah

Share this post


Link to post
Share on other sites
Anyway, to get back to the original question... I can't think of a general reason why square would be better than rectangular.

Keep in mind that the engines you listed are all related, so we aren't really talking about all games. Maybe it's just the convention for that particular line of engines and there is no real advantage. Maybe one of the tools expects square textures. Maybe it's because the texture coordinates go from 0 to 1 regardless of the shape of the texture. A square texture would give you square texels, and that made certain situations easier to deal with.

Some hardware (PS2, for example) prefer certain sizes and shapes, though I don't know of any that prefer square over rectangular.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this