NPOT Texture

From OpenGL.org
Jump to: navigation, search
Non-Power-Of-Two Textures
Core in version 4.4
Core since version 2.0
ARB extension GL_ARB_texture_non_power_of_two

An NPOT Texture is a texture whose dimensions are not powers of 2 (Non-Power-Of-Two). In earlier hardware, there was a requirement that the dimensions of a texture were a power of two in size. NPOT textures are textures that are not restricted to powers of two.

Usage

Using this is easy; simply pass arbitrary sizes to the various glTexImage* functions. These will work for any kind of texture, from cubemaps to array textures.

While modern hardware no longer has the power-of-two limitation on texture dimensions, it is generally a good idea to keep using power-of-two textures unless you specifically need NPOTs. Mip-mapping with such textures can have slightly unintended consequences, compared to the power-of-two case.

Render targets are a common format where you want to have a specific, arbitrary size for your textures.

Compression

Most of the non-generic compressed texture formats are based around 4x4 blocks of pixels. While it is possible to have arbitrary sizes of these textures, you generally should keep them at a multiple of four in size.

Older hardware

The R300 and R400-based cards (Radeon 9500+ and X500+) are incapable of generic NPOT usage. You can use NPOTs, but only if the texture has no mipmaps.

NV30-based cards (GeForce FX of any kind) are incapable of NPOTs at all, despite implementing OpenGL 2.0 (which requires NPOT). It will do software rendering if you try to use it.

All newer hardware can handle NPOTs of any kind perfectly.

Rectangle Textures

Rectangle textures have never had a power-of-two restriction. However, they take texture coordinates in texture space rather than normalized texture coordinates like other kinds of textures. These have their uses, but they have fallen out of favor with the advent of generic NPOT textures.