<p>The rule is that to compute the next mipmap size, you divide by two and round down to the nearest integer (unless it rounds down to 0, in which case, it's 1 instead). For example, a 57x43 image would have mipmaps like:</p>

<pre><code>level 0: 57x43
level 1: 28x21
level 2: 14x10
level 3: 7x5
level 4: 3x2
level 5: 1x1
</code></pre>

<p>UV mapping, LOD selection, and filtering work just the same way as for power-of-two texture sizes.</p>

<p>Generating good quality mips for a non-power-of-two texture is a little trickier, as you can't simply average a 2x2 box of pixels to downsample in all cases. However, a 2x2 box filter wasn't that great to begin with, so using a better downsampling filter such as Mitchell-Netravali is recommended regardless of the texture size.</p>

CC BY-SA 3.0
2015-09-08T20:54:34.700Z
Is there disagreement between this answer and John Calsbeek's answer? Does the implementation match both descriptions? If not then it would be useful to have a reference for one or other (or both if they are two different techniques both in use).
trichoplax is on Codidact now
CC BY-SA 3.0
2015-09-06T05:18:09.663Z
2016-05-02T22:40:12.990Z
2016-05-02T22:40:12.990Z
Nathan Reed
<p>One way to think of it is that graphics cards often implement non-power-of-2 textures simply by padding them until they are a power of 2 in each direction. This makes most things "just work": tiling and hardware filtering, for example. The only thing that needs to change is the conversion from texture coordinates to image coordinates.</p>

<p>If implemented like that, it's obvious how to do mipmapping: nothing changes. Even if you have a GPU that supports non-power-of-2 textures without padding, the mipmap levels would end up with "padding". e.g. a 3x3 texture would have a 2x2 texture as lod 1.</p>

CC BY-SA 3.0
2015-09-08T20:55:10.693Z
Is there disagreement between this answer and Nathan Reed's answer? Does the implementation match both descriptions? If not then it would be useful to have a reference for one or other (or both if they are two different techniques both in use).
trichoplax is on Codidact now
CC BY-SA 3.0
2015-09-08T21:09:24.700Z
@trichoplax I think Nathan's assertion that "generating good quality mips for a non-power-of-two texture is a little trickier" makes our answers disagree at least slightly. That alone probably merits more elaboration.
John Calsbeek
CC BY-SA 3.0
2015-09-09T16:23:49.693Z
I think the problem here is that we're confusing the logical position of texels with their "physical" layout in memory. 1) Pixels are discrete items, i.e. you always need an integer dimension, and so down scaling an odd dimension means that we have to either round up or round down. Since we have to round up once we get to an Nx1 or 1xN texture, it makes sense to always round up.
2) When laid out in physical addresses, it is not uncommon to pad the texture out to some "convenient"  "stride" size. This may be done for 2 reasons: a) It may make HW cheaper & b) if a P.of.2, Morton order is easy.
Simon F
CC BY-SA 3.0
2015-09-05T22:42:13.970Z
2015-09-05T22:42:13.970Z
John Calsbeek
<p>I have heard that recent GPUs all support non-power-of-2 textures and all features just work. However, I don't understand how mip-mapping would work in such a scenario. Can someone explain?</p>

<texture>
How does mip-mapping work with non-power-of-2 textures?
ap_
# How does mip-mapping work with non-power-of-2 textures?

(Asked by: username_0 on 2015-09-05)

I have heard that recent GPUs all support non-power-of-2 textures and all features just work. However, I don't understand how mip-mapping would work in such a scenario. Can someone explain?

**Tags:** texture


---

## 2 answers

### Answer by username_1 on 2015-09-06. Score: 18 | Accepted answer

The rule is that to compute the next mipmap size, you divide by two and round down to the nearest integer (unless it rounds down to 0, in which case, it's 1 instead). For example, a 57x43 image would have mipmaps like:

```
level 0: 57x43
level 1: 28x21
level 2: 14x10
level 3: 7x5
level 4: 3x2
level 5: 1x1

```

UV mapping, LOD selection, and filtering work just the same way as for power-of-two texture sizes.

Generating good quality mips for a non-power-of-two texture is a little trickier, as you can't simply average a 2x2 box of pixels to downsample in all cases. However, a 2x2 box filter wasn't that great to begin with, so using a better downsampling filter such as Mitchell-Netravali is recommended regardless of the texture size.

> **Comments:**
> **username_2**: Is there disagreement between this answer and username_3 username_3's answer? Does the implementation match both descriptions? If not then it would be useful to have a reference for one or other (or both if they are two different techniques both in use).  

---

### Answer by username_3 on 2015-09-05. Score: 4

One way to think of it is that graphics cards often implement non-power-of-2 textures simply by padding them until they are a power of 2 in each direction. This makes most things "just work": tiling and hardware filtering, for example. The only thing that needs to change is the conversion from texture coordinates to image coordinates.

If implemented like that, it's obvious how to do mipmapping: nothing changes. Even if you have a GPU that supports non-power-of-2 textures without padding, the mipmap levels would end up with "padding". e.g. a 3x3 texture would have a 2x2 texture as lod 1.

> **Comments:**
> **username_2**: Is there disagreement between this answer and username_1 username_1's answer? Does the implementation match both descriptions? If not then it would be useful to have a reference for one or other (or both if they are two different techniques both in use).  
> **username_3**: @username_2 I think username_1's assertion that "generating good quality mips for a non-power-of-two texture is a little trickier" makes our answers disagree at least slightly. That alone probably merits more elaboration.  
> **username_4**: I think the problem here is that we're confusing the logical position of texels with their "physical" layout in memory. 1) Pixels are discrete items, i.e. you always need an integer dimension, and so down scaling an odd dimension means that we have to either round up or round down. Since we have to round up once we get to an Nx1 or 1xN texture, it makes sense to always round up. 2) When laid out in physical addresses, it is not uncommon to pad the texture out to some "convenient"  "stride" size. This may be done for 2 reasons: a) It may make HW cheaper & b) if a P.of.2, Morton order is easy.  

---

