skip to content

What is a mipmap chain, why do textured surfaces far from the camera need one, and what does it cost in memory?

level: juniorimportance: must knowfreq 72%

answer

  1. many texels squeezed into one pixel
  2. prefiltered copies, each half the size
  3. distant grout lines shimmer
  4. a geometric series of quarters

basics

~20 s

A mipmap chain stores a texture with successively halved, prefiltered copies down to 1x1. Distant surfaces sample the level whose texels match the pixel size, which suppresses shimmer and moire for about one third more memory.

solid answer

~50 s

When a surface is far away, one pixel covers many texels, but a lookup reads only a few of them, so a fine pattern such as the grout of a tiled stone floor is undersampled: it shimmers as the camera moves and forms moire. A **mip chain** precomputes the average: level 1 is half the width and height of level 0, level 2 half again, down to `1x1`. The GPU picks the level whose texel size roughly matches the pixel's footprint, so each lookup returns an already-filtered value, and neighbouring pixels read neighbouring texels, which helps the texture cache. Each level has a quarter of the texels of the one above, so the chain adds `1/4 + 1/16 + ... ≈ 1/3` to the base level's memory. Mips do nothing for magnification, where one texel covers several pixels; that case uses the base level.

go deeper

for a junior

Know what a mip level is, that each one halves width and height, that distant surfaces use coarser levels to stop shimmer, and that the whole chain costs about a third extra memory.

for a middle

Derive the one-third overhead from the geometric series and explain minification aliasing in sampling terms. Say why mips do nothing for magnification and how mip generation must handle sRGB colour and normal maps.

for a senior

Use mips as a diagnostic lens: shimmering floors, muddy distant textures and banding between levels each point at a different gap. Explain the cache and bandwidth benefit, not only image quality.

for a principal

Treat mip policy as a standard: which textures may skip a chain, which filter builds the levels, and how the extra third is counted in the texture budget for each platform.

## The problem: many texels, one pixel When a textured surface is close to the camera, each screen pixel covers less than one texel and the texture is **magnified**. When the surface recedes, each pixel's footprint on the texture grows until it covers many texels, and the texture is **minified**. A texture lookup reads only a handful of texels near the sample point, so under minification it ignores most of the texels the pixel actually covers. That is undersampling in the signal-processing sense: the texture holds detail at a higher frequency than the pixel grid can represent. The visible results are familiar: - **Shimmer** or crawling: as the camera moves slightly, each pixel lands on a different texel, so a fine pattern such as the grout lines of a tiled stone floor flickers from frame to frame. - **Moire**: a regular pattern sampled at a slightly different regular rate produces large false waves and swirls that are not in the texture. - **Cache misses**: neighbouring pixels read texels that are far apart in memory, so the texture cache keeps missing and bandwidth rises. ## What a mip chain is A **mip chain** (from the Latin *multum in parvo*, much in little) stores the texture several times. Level 0 is the original. Level 1 is half the width and half the height, each texel the filtered average of a 2x2 block of level 0. Level 2 halves again, and so on down to a 1x1 level. A 1024x1024 texture therefore has 11 levels: 1024, 512, 256 and so on down to 2 and 1. At sample time the GPU estimates how many texels one pixel spans, from how fast the texture coordinates change between neighbouring pixels, and picks the level where one texel is about one pixel. The averaging was done once, offline or at load, so each lookup returns a prefiltered value for the cost of reading a few texels. Neighbouring pixels now read neighbouring texels of a small level, which keeps the texture cache warm as a side effect. ## What it costs in memory Each level has a quarter of the texels of the level above, so the total is a geometric series: ``` total = base * (1 + 1/4 + 1/16 + 1/64 + ...) = base * 1 / (1 - 1/4) = base * 4/3 ``` A full chain adds about **one third** to the base level. A real chain stops at 1x1, so the exact figure is a hair under 4/3. | Texture | Base level | With full mip chain | |---|---|---| | 1024x1024, 4 bytes per texel | 4 MiB | about 5.33 MiB | | 2048x2048, 4 bytes per texel | 16 MiB | about 21.3 MiB | | 1024x1024, block-compressed at 4 bits per texel | 512 KiB | about 683 KiB | Block-compressed formats encode 4x4 blocks, so levels smaller than 4x4 still occupy one whole block each; that adds a few bytes and leaves the one-third rule intact in practice. ## What mips do not fix - **Magnification.** When one texel covers several pixels there is nothing finer to choose, so the base level is used and the result looks blocky with nearest filtering or soft with bilinear. The missing detail has to come from elsewhere, such as a higher-resolution texture or a detail texture layered on top. - **Blur at grazing angles.** A floor seen almost edge-on has a footprint that is long in one screen direction and short in the other. One mip level can match only one of them, and the selection takes the coarser one to avoid aliasing, so the far floor smears. Anisotropic filtering addresses that. - **Lines between levels.** Choosing a single level per lookup produces visible bands where the chosen level changes across a surface; blending two adjacent levels (trilinear filtering) hides them. ## Building good mip levels How the levels are generated matters as much as having them: 1. **Average in linear light.** Colour textures are usually stored sRGB-encoded. Averaging the encoded numbers darkens fine contrasting detail, so decode to linear, filter, and re-encode. 2. **Consider a better kernel than a 2x2 box** when quality matters; a wider, slightly sharpening filter keeps distant textures from looking muddy. 3. **Renormalise normal maps.** Averaging unit normals produces shorter vectors; either renormalise them, or keep the shortened length as a measure of how bumpy the area was. 4. **Watch non-power-of-two sizes.** Each level rounds its dimensions down, so the chain still ends at 1x1, but the 2x2 averaging no longer lines up exactly with the level above. Textures that are never minified, such as a full-screen background always drawn at its native size, can skip the chain and save the third. Anything that can appear smaller on screen than its native size needs one.

  • Why not sample the base level with bilinear filtering for distant surfaces and skip mipmaps?
    Bilinear filtering reads four texels. If a distant pixel covers a 16x16 block of texels, the lookup ignores 252 of them, so the result depends on exactly where the sample lands: the pattern aliases, shimmers as the camera moves and produces moire. Reads also scatter across memory and miss the texture cache. A mip level of matching size has already averaged that block.
  • How should the mip levels of an sRGB colour texture be generated?
    Decode each texel to linear, filter in linear, then re-encode to sRGB. Averaging the encoded values directly darkens fine contrast: a black-and-white checker averages to an encoded 0.5, which is about 0.21 in linear light instead of 0.5, so the distant checker looks too dark.
  • When is it reasonable to ship a texture without a mip chain?
    When it is never minified on screen, such as a full-screen background drawn at native size or a render target used once at full resolution. Dropping the chain saves about a third of its memory. If it can ever be drawn smaller, it will shimmer and read memory less coherently, so the saving is rarely worth the risk.

A printed road atlas carries a street map, a city map and a country map. Zoomed out, you switch to the simpler pre-drawn map instead of squinting at every street; zoom in past the street map and there is no finer page to turn to.

  • Mipmaps make textures sharper when the camera is close to them.
  • A full mip chain doubles a texture's memory.
  • The mip level is picked from the distance to the camera alone.
  • Mipmaps are only a performance optimisation, not an image-quality feature.
  • Averaging sRGB-encoded texel values directly gives correct mip colours.