Mipmapping and Anisotropic Filtering in glTF Engines

In modern glTF rendering pipelines, mipmapping and anisotropic filtering work in tandem to eliminate texture aliasing and preserve surface sharpness across varying viewing distances and angles. While standard mipmapping prevents shimmering and improves GPU cache efficiency by downsampling textures into isotropic pre-filtered levels, it introduces severe blurring when surfaces are viewed obliquely. High-end glTF engines resolve this by utilizing anisotropic filtering to sample non-square footprints across these generated mip chains, ensuring that physically based rendering (PBR) material maps retain high-frequency detail without inducing performance-degrading memory stalls.

The Role of Mipmapping in glTF Assets

glTF 2.0 models rely heavily on PBR texture sets, including base color, normal, roughness, metallic, and ambient occlusion maps. When an object recedes into the distance, a single screen pixel covers multiple texels. Without mipmapping, point-sampling these areas triggers high-frequency spatial aliasing (shimmering).

Mipmapping resolves this by generating a chain of progressively downscaled versions of the texture—each level half the resolution of the previous one. High-end engines calculate screen-space derivatives (\(\frac{\partial uv}{\partial x}\) and \(\frac{\partial uv}{\partial y}\)) to determine the rate of texture coordinate change relative to screen pixels. The GPU then selects the mip level where the texel-to-pixel ratio is roughly 1:1, or blends between the two closest levels using trilinear filtering (LINEAR_MIPMAP_LINEAR).

The Isotropic Bottleneck

Standard trilinear mipmapping assumes a uniform, isotropic projection: the footprint of a pixel in texture space is approximated as a square. However, 3D scenes frequently feature surfaces viewed at steep, grazing angles—such as floors, walls, and terrain.

At oblique angles, the footprint of a pixel projected onto the texture stretches into an elongated ellipse. Standard mipmapping must choose between two suboptimal compromises based on the screen-space derivatives:

  1. Selecting the major (longer) axis: The engine samples a lower-resolution mip level to prevent aliasing along the elongated axis, resulting in extreme blurriness across the perpendicular axis.
  2. Selecting the minor (shorter) axis: The engine preserves detail across the narrow axis, but severe undersampling and aliasing occur along the elongated axis.

How Anisotropic Filtering Modulates Mip Selection

Anisotropic filtering (AF) modifies the hardware sampler's behavior by treating the pixel footprint as an ellipse rather than a circle or square.

When a glTF engine enables anisotropic filtering—typically via graphics APIs using extensions like EXT_texture_filter_anisotropic in WebGL, Vulkan, or Direct3D—the sampling pipeline changes:

  1. Calculating the Degree of Anisotropy: The sampler calculates the ratio of the major axis to the minor axis of the projected pixel footprint. This ratio is clamped by the engine's maximum anisotropy setting (commonly 4×, 8×, or 16×).
  2. Shifting to Higher Mip Levels: Instead of sampling a blurred, low-resolution mip level determined by the major axis, the sampler selects a higher-resolution mip level determined by the minor axis.
  3. Multi-Tap Sampling Along the Line of Anisotropy: Because using a higher-resolution mip level would normally introduce aliasing along the major axis, the sampler takes multiple trilinear samples (taps) along the major axis of the ellipse and averages them.

By taking multiple samples along the axis of stretching, anisotropic filtering reconstructs the true footprint of the pixel, keeping the texture sharp in the direction of the steep viewing angle while preventing aliasing across the perpendicular axis.

glTF Implementation Considerations

High-end glTF runtimes implement this interaction with several engine-level optimizations:

  • PBR Map Fidelity: Roughness and normal maps are particularly sensitive to filtering. Standard isotropic blur on an oblique plane softens normal vectors and artificially broadens microfacet distributions, corrupting specular highlights. Anisotropic filtering ensures roughness and normal calculations remain physically accurate at grazing angles.
  • Texture Compression (KTX2 / Basis Universal): Modern glTF workflows often distribute textures using KTX2 containers with Basis Universal (ETC1S or UASTC) compression. Engines decompress these formats directly into hardware-native formats (such as BCn or ASTC) with precomputed mipmaps. The anisotropic sampler operates directly on these compressed blocks in GPU cache, minimizing memory bandwidth spikes from multi-tap sampling.
  • Sampler Override Configurations: The core glTF 2.0 specification defines basic sampler parameters (magnification, minification, and wrapping), but does not expose an explicit field for anisotropic levels. Advanced engines (such as Babylon.js, Three.js, and Filament) enforce sensible defaults—often exposing an engine-level setting to override the glTF sampler state and apply 4× to 16× anisotropy globally or selectively on diffuse and normal channels.