Skip to main content

Do Game Textures Have to Be a Power of Two?

5 min read

Anyone preparing game images hears that textures should be a power of two: 64, 128, 256, 512, 1024 and so on. Yet an image like 300×200 often displays just fine, so it's unclear whether the rule is mandatory. This guide collects only what the official documentation says and what a test in a browser showed.

The term: NPOT

A size that isn't a power of two is called NPOT (non-power-of-two). If either the width or the height isn't a power of two, the texture is NPOT. It doesn't have to be square: 1024×512 is not NPOT, while 300×200 and 257×511 are.

WebGL1: allowed only under conditions

WebGL1, which many browser games use, has clear limits. According to MDN's guide to WebGL textures, WebGL1 can use NPOT textures only under these conditions:

  • Filtering must be NEAREST or LINEAR. Mipmaps (the smaller copies used at a distance) can't be generated.
  • The wrap mode must be CLAMP_TO_EDGE. Repeating a pattern, as for a brick wall, works only with power-of-two textures.
  • Without these settings, MDN says, every sample from an NPOT texture fails and comes back black instead of the texture's color.

Checked in Chrome

In Chrome launched with Playwright (NVIDIA GPU, through ANGLE's Direct3D 11 path), a texture filled with red was drawn and the center pixel was read back.

TextureSettingsWebGL1WebGL2
256×256repeat + mipmapsred (no mipmap error)red
300×200clamp to edge, no mipmapsredred
300×200repeatblack (0, 0, 0)red
300×200mipmapsblack, with INVALID_OPERATION from mipmap generationred (no error)

Drawing the same brick pattern repeated three times across and down makes the difference visible.

Three renders of the same brick pattern repeated 3×3. In WebGL1 the 256×256 texture shows the repeating bricks, in WebGL1 the 300×200 texture renders as solid black, and in WebGL2 the 300×200 texture repeats normally

Asking WebGL1 to repeat the 300×200 texture turned the whole area black. No error message appears; it simply draws black, which can take a while to track down if you don't know the cause.

WebGL2: no restriction in this test

The WebGL 2.0 specification states that it is derived from OpenGL ES 3.0. As the table shows, WebGL2 in the same Chrome handled the 300×200 texture correctly with both repeat and mipmaps. That result comes from one browser and one GPU, though. A project that also has to run on WebGL1 still needs to respect the limits above.

Multiples of 4: the rule for block-compressed textures

Separate from powers of two, compressed textures have their own rule. GPU block compression (BC1 to BC5, the DXT family) splits the image into 4×4 pixel blocks. Microsoft's Direct3D block compression documentation therefore says a block-compressed texture must be a multiple of 4 in all dimensions. The same page explains that when smaller mipmap levels, such as those of a 60×40 texture, stop being multiples of 4, the memory is padded up to a multiple of 4.

WebGL follows suit. The WEBGL_compressed_texture_s3tc extension specification says an INVALID_OPERATION error is generated when the width or height isn't a multiple of 4. Here is what happened uploading DXT1 data in Chrome:

SizePower of two?Multiple of 4?WebGL1WebGL2
256×256yesyesOKOK
300×200noyesOKOK
30×30nonoINVALID_OPERATIONINVALID_OPERATION
64×30nonoINVALID_OPERATIONINVALID_OPERATION

300×200 isn't a power of two, but it is a multiple of 4, so it uploaded as a compressed texture; 30×30 failed. "Power of two" and "multiple of 4" are different conditions. They're often mentioned together only because every power of two from 4 upward is also a multiple of 4.

How Unity and Godot handle it

  • Unity: the Importing Textures page says sizes should ideally be a power of two on each side, and textures don't have to be square. NPOT sizes can be used, but they generally take slightly more memory and might be slower for the GPU to sample, and if the platform or GPU doesn't support NPOT, Unity scales and pads the texture up to the next power of two. The page suggests using NPOT sizes mainly for GUI. The Non Power of 2 import setting can also resize on import; in the documentation's example, a 257×511 texture becomes 256×512 with To nearest, 512×512 with To larger and 256×256 with To smaller.
  • Godot: the Importing images page recommends power-of-two sizes for 3D textures but says they aren't required, and that non-square sizes such as 1024×512 are fine. The same page notes that mipmaps increase memory usage by roughly 33%.

Both engines land on "recommended, not required". Letting an engine resize the texture can change its proportions (257×511 to 512×512, for instance), so sizing images yourself before import makes the result easier to predict.

So how should you size them?

  • Tiled textures (floors, walls) and 3D textures with mipmaps: use powers of two. WebGL1 requires it, and Unity and Godot recommend it.
  • Images that will become compressed textures: make the width and height at least multiples of 4.
  • UI, icons and single 2D sprites: NPOT is usually fine on WebGL2 and current engines, though a consistent size across a set makes them easier to manage.
  • If you don't want to stretch the image, enlarge only the canvas. Placing a 300×200 image on a 512×256 canvas makes it a power of two. The pixel count goes from 60,000 to 131,072, more than double, so an uncompressed RGBA texture would need that much more memory by the same arithmetic.

In this site's converter, choose Set exact size (for example 512×256) and the fit method "Keep original size + center" to widen the canvas without touching the image. To shrink or enlarge while keeping the shape, use "Keep ratio + fill the margins". Converting a whole batch to one size is covered in Unifying Image Sizes for Games, and packing several frames into one image is what the sprite sheet splitter and packer is for.

Convert WebP to PNG Convert JPG to PNG

The test setup and methods are described in how the measurements on this site were made.

More guides