---
id: "toksvig-mipmapping"
title: "Toksvig normal-map filtering"
domain: "materials"
stage: "material"
realtime: "realtime"
platforms: [webgl2, webgpu, desktop-gpu, mobile-gpu, unity, unreal, godot, blender]
year_introduced: 2005
inputs: [normals, texture]
outputs: [texture, material-params]
style: "both"
dynamic: "both"
cost: "cheap"
authority: "Toksvig, 2005"
url: "https://texelatlas.vercel.app/t/toksvig-mipmapping/"
sources_verified_at: "2026-11-29"
---
# Toksvig normal-map filtering (Toksvig, 2005)

> Mipmapping a normal map shortens the averaged normal; Toksvig turns that shortening into extra roughness so minified bumpy surfaces blur their highlight instead of shimmering.

## Reach for it when

- normal-mapped highlights shimmer in the distance
- mip levels lose roughness from averaged normals
- specular sparkle on minified bump maps
- cheap baked fix for specular aliasing
- bumpy surfaces should blur out far away

## How it works

Averaging unit normals over a texel footprint produces a vector of length less than 1, and the shorter it is, the more the underlying normals disagree. Toksvig observes that for a Gaussian-like spread of normals the length encodes variance, and that the Blinn-Phong highlight over that distribution equals a broader lobe. So he adjusts the specular exponent by a factor ft = |Na| / (|Na| + s (1 - |Na|)) where s is the exponent. Modern variants apply the same idea to GGX by adding variance to roughness squared. The correction is either baked into per-mip roughness (or gloss) maps at texture-authoring time, or computed from the fetched normal's length when normal maps are stored unnormalised.

## When to use it

Choose it as a cheap baseline for stopping specular shimmering on normal-mapped surfaces under minification. Prefer [Normal distribution filtering for specular antialiasing](https://texelatlas.vercel.app/t/normal-distribution-filtering.md) or [LEADR mapping](https://texelatlas.vercel.app/t/leadr-mapping.md) when you also need correct handling of the visible-slope distribution (LEADR) or per-pixel variance filtering with screen-space derivatives. Needed whenever [Normal mapping with MikkTSpace](https://texelatlas.vercel.app/t/normal-mapping-mikktspace.md) is used with glossy materials.

## Cost

cheap — Baked into mip chain, or one length computation per pixel.
Measured GPU Weight: 12.88× baseline (moderate) — 0.4236 ms median / 0.4287 ms p95 on Tesla T4/PCIe/SSE2 @ 1920x1080 (opengl-timer-query).
Ada L4 scaling: 9.36× baseline (moderate) — 0.1489 ms median (2.84× faster on L4).
Ampere A100 scaling: 7.72× baseline (moderate) — 0.2222 ms median (1.91× faster on A100).

## Failure modes

- Needs unnormalised normals in mips; normalised DXT/BC5 normals lose the length information
- Assumes isotropic Gaussian normal spread, so directional grooves lose their stretched highlight
- Only affects specular, not diffuse brightness changes with scale
- Roughness bake must be redone if texture is retiled or rescaled

## Engine support

- unreal: builtin — `Texture Editor > Composite Texture > CompositeTextureMode = CTM_NORMAL_ROUGHNESS_TO_ALPHA (converts normal-map mip variance into roughness)` (evidence: https://dev.epicgames.com/documentation/en-us/unreal-engine/python-api/class/CompositeTextureMode, checked 2026-12-01)

## Dataflow

- Inputs: normals, texture
- Outputs: texture, material-params
- Platforms: webgl2, webgpu, desktop-gpu, mobile-gpu, unity, unreal, godot, blender

## Presets

### Toksvig filtering of a sub-pixel bump normal field: aliased (left) vs filtered (right) (glsl-fragment; rendered 2026-11-29)

```json
{
  "SHININESS": 90,
  "BUMP_FREQ": 420,
  "BUMP_AMP": 0.55
}
```

```glsl
// Toksvig specular antialiasing. A sphere with a very high-frequency bump normal field (sub-pixel period).
// Left: Blinn-Phong on the single pixel-centre normal: highlights sparkle/alias.
// Right: the 4x4 footprint average normal (what a mip would store) is shorter than 1; Toksvig
// ft = |N| / (|N| + s (1 - |N|)) shrinks the exponent so the highlight blurs instead of sparkling.
const float SHININESS = 90.0;
const float BUMP_FREQ = 420.0;
const float BUMP_AMP = 0.55;

vec3 bumpNormal(vec2 fc, out bool hit) {
  vec2 uv = (fc - 0.5 * iResolution.xy) / iResolution.y;
  vec3 ro = vec3(0.0, 0.0, 4.0), rd = normalize(vec3(uv, -2.4));
  float b = dot(ro, rd); float h = b * b - dot(ro, ro) + 0.64;
  hit = h > 0.0; if (!hit) return vec3(0.0, 0.0, 1.0);
  vec3 p = ro + rd * (-b - sqrt(h)); vec3 n = normalize(p);
  vec3 t1 = normalize(cross(n, vec3(0.0, 1.0, 0.2))), t2 = cross(n, t1);
  return normalize(n + BUMP_AMP * (sin(BUMP_FREQ * p.x + 3.0 * p.y) * t1 + sin(BUMP_FREQ * 1.3 * p.y - 2.0 * p.x) * t2));
}
void mainImage(out vec4 fragColor, in vec2 fragCoord) {
  vec3 v = vec3(0.0, 0.0, 1.0);
  vec3 l = normalize(vec3(-0.4, 0.5, 0.8));
  vec3 hv = normalize(l + v);
  bool hit; vec3 n0 = bumpNormal(fragCoord, hit);
  vec3 col = vec3(0.03) + 0.04 * (fragCoord.y / iResolution.y);
  if (hit) {
    vec3 avg = vec3(0.0);
    for (int j = 0; j < 4; j++) for (int i = 0; i < 4; i++) {
      bool hh; avg += bumpNormal(fragCoord + (vec2(float(i), float(j)) - 1.5) * 0.25 * 4.0 / 1.0 * 0.5, hh);
    }
    avg /= 16.0; float len = length(avg);
    bool left = fragCoord.x < 0.5 * iResolution.x;
    vec3 n = left ? n0 : normalize(avg);
    float s = left ? SHININESS : SHININESS * len / (len + SHININESS * (1.0 - len));
    float norm = (s + 8.0) / 25.13;
    float nl = max(dot(n, l), 0.0);
    col = vec3(0.35, 0.12, 0.1) * nl + vec3(1.0) * norm * pow(max(dot(n, hv), 0.0), s) * nl * 0.9;
  }
  if (abs(fragCoord.x - 0.5 * iResolution.x) < 1.0) col = vec3(1.0);
  col = col / (1.0 + col);
  fragColor = vec4(pow(col, vec3(1.0 / 2.2)), 1.0);
}

```

Attribution: written for this index

## Lineage

- extended by [LEADR mapping](https://texelatlas.vercel.app/t/leadr-mapping.md)
- extended by [Normal distribution filtering for specular antialiasing](https://texelatlas.vercel.app/t/normal-distribution-filtering.md)

## Combination ideas

- [Toon highlights that do not sparkle](https://texelatlas.vercel.app/ideas/variance-aware-toon-bands/)

## Sources

1. [primary] Michael Toksvig (2005) Mipmapping Normal Maps. Journal of Graphics Tools. https://doi.org/10.1080/2151237x.2005.10129203 (verified via crossref on 2026-11-29)

## Cite this entry

Texel. "Toksvig normal-map filtering." https://texelatlas.vercel.app/t/toksvig-mipmapping/ (accessed 2026-12-01).
