---
id: "mipmapping-anisotropic-filtering"
title: "Mipmapping and anisotropic texture filtering"
aliases: [trilinear filtering, EWA filtering, mip chain]
domain: "materials"
stage: "material"
realtime: "realtime"
platforms: [webgl2, webgpu, desktop-gpu, mobile-gpu, cpu, unity, unreal, godot, blender]
year_introduced: 1983
inputs: [texture, uv-atlas]
outputs: [texture]
style: "both"
dynamic: "both"
cost: "cheap"
authority: "Williams, 1983"
url: "https://texelatlas.vercel.app/t/mipmapping-anisotropic-filtering/"
sources_verified_at: "2026-11-29"
---
# Mipmapping and anisotropic texture filtering (Williams, 1983)

> Texture minification fundamentals: a prefiltered mip pyramid chosen by screen-space derivatives (bilinear, trilinear), then anisotropic sampling that takes several taps along the footprint's long axis, with EWA as the high-quality reference.

## Reach for it when

- textures shimmer and sparkle in the distance
- ground texture blurry at grazing view angles
- moire patterns on checkerboard or fine patterns
- need to choose trilinear versus anisotropic sampling
- alpha tested leaves vanish when far away

## How it works

A mip chain stores the texture at half resolution repeatedly, each level a box or better prefiltered average. At shading time the hardware measures how many texels fall inside one pixel from the UV derivatives and picks level lambda = log2 of that footprint size; trilinear filtering blends the two nearest levels. The catch is that a pixel footprint on a receding floor is a long thin ellipse, while the mip level is sized for the long axis, so everything gets blurred in the short direction. Anisotropic filtering instead picks the level from the short axis and takes N taps spread along the long axis (N capped at 2x to 16x). Heckbert's elliptical weighted average fits an ellipse in texture space and sums texels with a Gaussian-like weight, the quality reference that hardware approximates. Compute-shader or ray-traced renderers must supply their own derivatives or ray differentials since implicit derivatives only exist in fragment quads.

## When to use it

Always enable mipmaps on sampled colour textures; add 8x-16x anisotropy for ground, roads and walls seen at grazing angles. Use [Block texture compression (BC7 / ASTC)](https://texelatlas.vercel.app/t/block-texture-compression.md) or [Basis Universal / KTX2 supercompression](https://texelatlas.vercel.app/t/basis-universal-ktx2.md) so the mip chain stays small. Prefer [Toksvig normal-map filtering](https://texelatlas.vercel.app/t/toksvig-mipmapping.md) or [Normal distribution filtering for specular antialiasing](https://texelatlas.vercel.app/t/normal-distribution-filtering.md) for normal maps and roughness, because plain averaged normals lose specular energy. Prefer virtual texturing or manual LOD when streaming matters more than filtering. For lookups inside ray-tracing shaders, compute ray differentials explicitly.

## Cost

cheap — Hardware sampler cost; anisotropy multiplies texture taps and bandwidth by up to the max ratio.
Measured GPU Weight: 2.64× baseline (light) — 0.0868 ms median / 0.0912 ms p95 on Tesla T4/PCIe/SSE2 @ 1920x1080 (opengl-timer-query).
Ada L4 scaling: 2.28× baseline (light) — 0.0362 ms median (2.4× faster on L4).
Ampere A100 scaling: 1.9× baseline (feather) — 0.0547 ms median (1.59× faster on A100).

## Failure modes

- Textures not generated or non-power-of-two edge cases leave shimmering at distance
- Premultiplied alpha or sRGB data averaged in the wrong space darkens or tints lower mips
- Alpha-tested foliage fades out in higher mips unless alpha coverage is preserved
- Normal maps averaged naively flatten and remove highlights, see toksvig-mipmapping
- Anisotropic filtering cannot fix derivative problems such as non-uniform control flow, producing seams at discontinuities
- Tiled atlases bleed neighbour tiles into lower mips without gutters

## Engine support

- babylonjs: builtin — `texture.anisotropicFilteringLevel = 16` (evidence: https://github.com/BabylonJS/Babylon.js/blob/9.38.0/packages/dev/core/src/Materials/Textures/baseTexture.pure.ts, checked 2026-12-01)
- blender: builtin — `Preferences > Viewport > Textures > Anisotropic Filtering` (evidence: https://docs.blender.org/manual/en/5.2/editors/preferences/viewport.html, checked 2026-12-01) — Viewport only.
- godot: builtin — `BaseMaterial3D.texture_filter = TEXTURE_FILTER_LINEAR_WITH_MIPMAPS_ANISOTROPIC; Project Settings > Rendering > Textures > Default Filters > Anisotropic Filtering Level` (evidence: https://github.com/godotengine/godot/blob/4.7.2-stable/doc/classes/BaseMaterial3D.xml, checked 2026-12-01)
- metal: builtin — `MTLSamplerDescriptor.maxAnisotropy; MTLBlitCommandEncoder.generateMipmaps(for:)` (evidence: https://developer.apple.com/tutorials/data/documentation/metal/mtlsamplerdescriptor.json, checked 2026-12-01)
- threejs: builtin — `texture.anisotropy = renderer.capabilities.getMaxAnisotropy()` (evidence: https://github.com/mrdoob/three.js/blob/r187/src/textures/Texture.js, checked 2026-12-01)
- unity: builtin — `Texture Import Settings > Generate Mip Maps, Aniso Level; Texture.anisoLevel` (evidence: https://docs.unity3d.com/6000.0/Documentation/ScriptReference/Texture-anisoLevel.html, checked 2026-12-01)
- unreal: builtin — `Texture Editor > Level of Detail > Mip Gen Settings (TMGS_*) and Filter (Anisotropic / r.MaxAnisotropy)` (evidence: https://dev.epicgames.com/documentation/en-us/unreal-engine/texture-format-support-and-settings-in-unreal-engine, checked 2026-12-01)
- webgpu: builtin — `GPUSamplerDescriptor: mipmapFilter: 'linear', maxAnisotropy: 16` (evidence: https://www.w3.org/TR/webgpu/, checked 2026-12-01) — Mip chain generation is manual (no built-in generateMipmaps).

## Dataflow

- Inputs: texture, uv-atlas
- Outputs: texture
- Platforms: webgl2, webgpu, desktop-gpu, mobile-gpu, cpu, unity, unreal, godot, blender

## Presets

### Mipmapping & Anisotropic Filtering — blurry isotropic trilinear mips (left) vs crisp multi-tap anisotropic filtering (right) (glsl-fragment; rendered 2026-11-30)

```json
{
  "P_ANISO_TAPS": 8,
  "P_TEX_FREQ": 1.6,
  "P_CAM_PITCH": 0.22,
  "P_SPLIT": 0.48
}
```

```glsl
const float P_ANISO_TAPS = 8.0; // P Anisotropic Taps [2.0, 16.0, 2.0]
const float P_TEX_FREQ = 1.60; // P Tile Frequency [0.8, 3.0, 0.1]
const float P_CAM_PITCH = 0.22; // P Grazing Pitch [0.08, 0.45, 0.02]
const float P_SPLIT = 0.48; // P Trilinear / Aniso Split [0.0, 1.0, 0.02]

// Analytically band-limited procedural texture at a given isotropic mip level 'lod'
vec3 evalTexMip(vec2 p, float lod) {
  float blur = exp2(max(lod, 0.0)) * 0.065;
  // Checkerboard filtered via analytical box/Gaussian attenuation per harmonic
  vec2 s = sin(p * 6.2831853);
  float att1 = exp(-blur * blur * 18.0);
  float att2 = exp(-blur * blur * 65.0);
  float chk = 0.5 + 0.5 * clamp((s.x * s.y) * 6.0, -1.0, 1.0) * att1;

  // Fine architectural grout lines & calibration target rings inside each tile
  vec2 f = fract(p) - 0.5;
  float r = length(f);
  float ring = exp(-pow((r - 0.26) / max(0.032 + blur * 0.4, 0.01), 2.0)) * att2;
  float lines = (exp(-pow(abs(f.x) / max(0.018 + blur * 0.35, 0.01), 2.0))
               + exp(-pow(abs(f.y) / max(0.018 + blur * 0.35, 0.01), 2.0))) * 0.5 * att2;

  vec3 tileA = vec3(0.14, 0.20, 0.28);
  vec3 tileB = vec3(0.84, 0.82, 0.76);
  vec3 base = mix(tileA, tileB, chk);
  base = mix(base, vec3(0.96, 0.44, 0.14), clamp(ring, 0.0, 1.0));
  base = mix(base, vec3(0.12, 0.78, 0.88), clamp(lines * 0.75, 0.0, 1.0));
  return base;
}

vec3 aces(vec3 x) {
  x = max(x, 0.0);
  return (x * (2.51 * x + 0.03)) / (x * (2.43 * x + 0.59) + 0.14);
}

void mainImage(out vec4 fragColor, in vec2 fragCoord) {
  vec2 uv = (fragCoord - 0.5 * iResolution.xy) / iResolution.y;
  float sx = fragCoord.x / max(iResolution.x, 1.0);
  float split = clamp(P_SPLIT, 0.0, 1.0);
  bool useAniso = sx >= split;

  float freq = clamp(P_TEX_FREQ, 0.5, 4.0);
  float pitch = clamp(P_CAM_PITCH, 0.06, 0.55);
  int taps = int(clamp(floor(P_ANISO_TAPS + 0.5), 2.0, 16.0));

  // Camera skimming low over an infinite textured corridor floor
  vec3 ro = vec3(0.28 * sin(iTime * 0.35), 0.52, iTime * 0.65);
  float cp = cos(pitch), sp = sin(pitch);
  vec3 rd0 = normalize(vec3(uv.x, uv.y, -1.35));
  vec3 rd = vec3(rd0.x, rd0.y * cp - rd0.z * sp, rd0.y * sp + rd0.z * cp);

  vec3 sky = mix(vec3(0.74, 0.82, 0.92), vec3(0.14, 0.28, 0.54), smoothstep(-0.02, 0.42, rd.y));
  vec3 col = sky;

  if (rd.y < -0.002) {
    float t = -ro.y / rd.y;
    vec3 p = ro + rd * t;
    vec2 texUV = p.xz * freq;

    // Analytical screen-space footprint Jacobian (dUV/dx, dUV/dy) via adjacent ray differentials
    vec2 duvX = vec2(1.0 / max(iResolution.y, 1.0), 0.0);
    vec2 duvY = vec2(0.0, 1.0 / max(iResolution.y, 1.0));
    vec3 rdX0 = normalize(vec3(uv.x + duvX.x, uv.y, -1.35));
    vec3 rdX = vec3(rdX0.x, rdX0.y * cp - rdX0.z * sp, rdX0.y * sp + rdX0.z * cp);
    vec3 rdY0 = normalize(vec3(uv.x, uv.y + duvY.y, -1.35));
    vec3 rdY = vec3(rdY0.x, rdY0.y * cp - rdY0.z * sp, rdY0.y * sp + rdY0.z * cp);

    vec2 pX = (ro + rdX * (-ro.y / min(rdX.y, -0.001))).xz * freq;
    vec2 pY = (ro + rdY * (-ro.y / min(rdY.y, -0.001))).xz * freq;
    vec2 ddx = pX - texUV;
    vec2 ddy = pY - texUV;

    float lenX = length(ddx);
    float lenY = length(ddy);
    float majorLen = max(lenX, lenY);
    float minorLen = max(min(lenX, lenY), 1e-5);
    vec2 majorAxis = (lenX >= lenY) ? ddx : ddy;

    if (!useAniso) {
      // Isotropic trilinear mipmap: picks LOD from major axis -> wipes out sharp detail along minor axis!
      float isoLod = log2(max(majorLen * 14.0, 1.0));
      col = evalTexMip(texUV, isoLod);
    } else {
      // Anisotropic filtering: chooses LOD from minor axis and integrates N taps along major axis
      float maxAniso = float(taps);
      float ratio = min(majorLen / minorLen, maxAniso);
      float anisoLod = log2(max((majorLen / max(ratio, 1.0)) * 14.0, 1.0));
      vec3 acc = vec3(0.0);
      for (int i = 0; i < 16; i++) {
        if (i >= taps) break;
        float fi = (float(i) + 0.5) / float(taps) - 0.5;
        acc += evalTexMip(texUV + majorAxis * fi, anisoLod);
      }
      col = acc / float(taps);
    }

    // Subtle distance aerial fade
    float fog = 1.0 - exp(-t * 0.042);
    col = mix(col, sky, clamp(fog, 0.0, 1.0));
  }

  float sep = smoothstep(0.0035, 0.0008, abs(sx - split));
  col = mix(col, vec3(0.95, 0.97, 1.0), sep);
  fragColor = vec4(pow(clamp(aces(col), 0.0, 1.0), vec3(1.0 / 2.2)), 1.0);
}
```

Attribution: MIT — written for this index.

## Combines with

- [Toksvig normal-map filtering](https://texelatlas.vercel.app/t/toksvig-mipmapping.md): Mipped normal-map lengths shrink with distance; Toksvig converts that loss into extra roughness at each level.

## Sources

1. [primary] Lance Williams (1983) Pyramidal parametrics. ACM SIGGRAPH Computer Graphics. https://doi.org/10.1145/964967.801126 (verified via crossref on 2026-11-29)
2. [primary] Ned Greene, Paul Heckbert (1986) Creating Raster Omnimax Images from Multiple Perspective Views Using the Elliptical Weighted Average Filter. IEEE Computer Graphics and Applications. https://doi.org/10.1109/mcg.1986.276738 (verified via crossref on 2026-11-29)
3. [tutorial] Matt Pharr, Wenzel Jakob, Greg Humphreys Image Texture (pbrt-v4). pbr-book.org. https://www.pbr-book.org/4ed/Textures_and_Materials/Image_Texture (verified via http on 2026-11-29)

## Cite this entry

Texel. "Mipmapping and anisotropic texture filtering." https://texelatlas.vercel.app/t/mipmapping-anisotropic-filtering/ (accessed 2026-12-01).
