Mipmapping and anisotropic texture filtering
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.
Also known as trilinear filtering, EWA filtering, mip chain
In the family Materials, BRDFs & texturing, texture filtering
Where it runs
Built inOfficial add-onPluginNone foundNot researched
| Engine | Support | How |
|---|---|---|
| three.js r187 | Built in | texture.anisotropy = renderer.capabilities.getMaxAnisotropy() docs |
| Babylon.js 9.38.0 | Built in | texture.anisotropicFilteringLevel = 16 docs |
| Godot 4.7 | Built in | BaseMaterial3D.texture_filter = TEXTURE_FILTER_LINEAR_WITH_MIPMAPS_ANISOTROPIC; Project Settings > Rendering > Textures > Default Filters > Anisotropic Filtering Level docs |
| Unity | Built in | Texture Import Settings > Generate Mip Maps, Aniso Level; Texture.anisoLevel docs |
| Unreal 5.7 | Built in | Texture Editor > Level of Detail > Mip Gen Settings (TMGS_*) and Filter (Anisotropic / r.MaxAnisotropy) docs |
| Blender 5.2 | Built in | Preferences > Viewport > Textures > Anisotropic Filtering docs Viewport only. |
| WebGPU W3C | Built in | GPUSamplerDescriptor: mipmapFilter: 'linear', maxAnisotropy: 16 docs Mip chain generation is manual (no built-in generateMipmaps). |
| Metal | Built in | MTLSamplerDescriptor.maxAnisotropy; MTLBlitCommandEncoder.generateMipmaps(for:) docs |
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 choose it
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
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) or Basis Universal / KTX2 supercompression so the mip chain stays small. Prefer Toksvig normal-map filtering or Normal distribution filtering for specular antialiasing 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.
Field marks
- 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
Presets
Mipmapping & Anisotropic Filtering — blurry isotropic trilinear mips (left) vs crisp multi-tap anisotropic filtering (right)
{
"P_ANISO_TAPS": 8,
"P_TEX_FREQ": 1.6,
"P_CAM_PITCH": 0.22,
"P_SPLIT": 0.48
}Show GLSL (104 lines)
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.
Measured GPU weight & timing
| Preset | GPU | Weight / p50 / p95 | Method |
|---|---|---|---|
| mipmapping-anisotropic-filtering-live | Tesla T4 1920x1080 | 2.64× baseline (light) · 0.087 ms / 0.091 ms | opengl-timer-query · 32 frames · GPU Weight Atlas · Colab T4 sweep |
| mipmapping-anisotropic-filtering-live | NVIDIA L4 1920x1080 | 2.28× baseline (light) · 0.036 ms / 0.038 ms · 2.4× faster on L4 | opengl-timer-query · Cross-architecture validation |
| mipmapping-anisotropic-filtering-live | NVIDIA A100-SXM4-40GB 1920x1080 | 1.90× baseline (feather) · 0.055 ms / 0.055 ms · 1.6× faster on A100 | opengl-timer-query · Cross-architecture validation |
Lineage
From the citation graph (Crossref reference lists): its primary source cites Environment mapping, cubemaps and skyboxes; cited by Anisotropic Kuwahara filter, Histogram-preserving blending (stochastic texturing), Percentage-Closer Filtering.
Crosses
- Toksvig normal-map filtering: Mipped normal-map lengths shrink with distance; Toksvig converts that loss into extra roughness at each level.
Sources
- primaryLance Williams (1983). Pyramidal parametrics. ACM SIGGRAPH Computer Graphics.Verified via crossref · 2026-11-29doi:10.1145/964967.801126
- primaryNed Greene, Paul Heckbert (1986). Creating Raster Omnimax Images from Multiple Perspective Views Using the Elliptical Weighted Average Filter. IEEE Computer Graphics and Applications.Verified via crossref · 2026-11-29doi:10.1109/mcg.1986.276738
- tutorialMatt Pharr, Wenzel Jakob, Greg Humphreys. Image Texture (pbrt-v4). pbr-book.org.Verified via live page · 2026-11-29