Mipmapping is a technique where a high-resolution texture is downscaled and filtered so that each subsequent mip level is a quarter of the area of the previous level. This means that the texture and all of its generated mips requires no more than 1.5 times the original texture size.
Mipmaps can either be hand-generated by an artist or computer-generated, and are uploaded to the GPU. The GPU then selects the optimal mip for the sampling being performed. Sampling from the smaller mip level helps to minimize texture aliasing, maintain the definition of textures on surfaces, and prevent the formation of moiré patterns on distant surfaces.
Caution must be taken when storing multiple successive mipmap levels within a single texture atlas, as visual problems can arise when foveated rendering is used.
Foveated rendering uses eye-tracking to display higher-quality graphics where the user is currently looking. Image quality can be greatly reduced outside the gaze of the fovea.
Problems arise when one tile is rendered at the native resolution, but the neighboring tile is rendered at one-quarter resolution. This means that the neighboring tile samples the texture from the mipmap two levels lower.
One resulting problem occurs during sampling. For example, when a texel is blurred with its neighboring texels during texture filtering and can wrongly bleed in color from the neighboring levels in the texture atlas.
As a result, two neighboring pixels which are in separate tiles, that lie in two differing foveated regions, exhibit a color differential. Extending the edge of the texture to create an isolation gap between entries into the atlas solves this problem.
Implementing mipmapping in Unity
The automatic generation of mipmaps is turned on for textures in the Inspector window.
To enable mipmap generation:
- Select a texture within the Assets section of the Project window to open the Texture Inspector window.
- Enable the Generate Mip Maps option.