1. Mipmap Basics
| Item | Description |
|---|---|
| Purpose | Pre-generate multiple lower-resolution versions of textures to reduce aliasing and moiré patterns during distant sampling, and improve cache hits and performance. |
| Pyramid Levels | If the original image size is , the -th level is usually , down to 1x1. |
| Storage Overhead | The total area of all levels is about of the original image (more precisely, ), so the total texture memory is about of the original image. |
2. Common Downsampling Algorithms
| Algorithm/Type | Approach | Advantages | Disadvantages/Notes |
|---|---|---|---|
| Box Filter (Mean/Box Filter) | Average every 2x2 pixels to generate the next level. Formula: | Simple, fast | Poor frequency roll-off, prone to aliasing; not smooth for high-frequency textures |
| Triangle/Bilinear Filter (Linear Kernel) | Downsample after low-pass filtering with linear weights, or use triangle kernel | Smoother than box, slightly better edge preservation | Slightly higher cost than box |
| Gaussian Filter | Apply Gaussian blur before downsampling | Closer to ideal low-pass, better anti-aliasing | Heavier computation, may blur details |
| Lanczos (Windowed sinc) | Resample using Lanczos kernel (commonly a=2 or 3) | Sharp and excellent anti-aliasing | Highest cost, may cause slight ringing |
| Mitchell-Netravali / Catmull-Rom (Cubic Family) | Resample with cubic convolution kernel | Good balance of sharpness and smoothness, moderate cost | Common in offline pipelines, texture baking |
| Gamma/Color Space Handling | Average in linear space to avoid darkening in sRGB. Process: sRGB → linear; filter/downsample; linear → sRGB. Alpha: use premultiplied alpha before filtering/downsampling. | Physically correct color | - |
| Normal Map Specific | Transform to tangent space unit vectors, accumulate then normalize, remap offset if needed. Can weight (e.g. Z or curvature) to reduce bias. | Physically correct normals | Cannot linearly average RGB normals |
3. Common Runtime Filtering Algorithms
| Algorithm/Type | Approach | Advantages | Disadvantages/Notes |
|---|---|---|---|
| Nearest Mipmap Nearest (MMN) | Selects the nearest mip level, uses nearest point sampling | Fastest | Blocky appearance |
| Nearest Mipmap Linear (NML) | Selects the nearest mip level, uses bilinear sampling | Smoother than MMN | May jump when switching levels |
| Linear Mipmap Nearest (LMN) | Samples two adjacent mip levels with nearest point, then linearly interpolates | - | Rarely used alone |
| Trilinear Filtering | Bilinear sampling on two levels, then linear interpolation by LOD fraction | Good balance, commonly default | - |
| Anisotropic Filtering | Multi-point sampling along major axis in oblique view, suppresses blur/flicker. With mipmap: each candidate mip level samples along anisotropic direction. Parameter: anisotropy level (e.g. 4x, 8x, 16x) affects quality and performance. | High quality for oblique views | Cost increases with level |
| LOD Control & Bias | Hardware estimates LOD by screen-space derivatives: . Bias can be added to control sharpness/noise tradeoff. | Adjustable sharpness | - |
4. Special Mipmap Variants
| Type | Description |
|---|---|
| Ripmaps | Independently downsample u and v to get a rectangular pyramid, suitable for strong anisotropic scaling. |
| Summed-Area Tables (SAT) | Used for fast box filtering and variable-size region averaging, high storage cost. |
| Sparse/Virtual Textures | Tile-based storage and on-demand loading of mip tiles. MegaTexture, Tiled Resources. |
| Specular/Gloss mip chain | Pre-filter roughness-related maps by physical model (e.g. prefiltered mipmap for environment reflection, BRDF-Convolved Env Map). |
| Alpha Coverage Preserving Mipmaps | Adjust alpha during downsampling of transparent textures to preserve coverage, reduce distant flicker. |
Common Issues
- Averaging in sRGB space: causes color shift and darkening.
- Directly averaging normal or specular roughness maps: leads to physical inconsistency.
- Not preserving coverage for transparent textures: distant flicker.
- Mipmap level boundary seams: handle wrap/clamp and border pixel copy during generation to avoid seams.