Platform SDK: DirectX

What Is a Mipmap?

A mipmap is a sequence of textures, each of which is a progressively lower resolution representation of the same image. The height and width of each image, or level, in the mipmap is a power of two smaller than the previous level. Mipmaps do not have to be square.

A high-resolution mipmap image is used for objects that are close to the viewer. Lower-resolution images are used as the object moves farther away. Mipmapping improves the quality of rendered textures at the expense of using more memory.

Direct3D represents mipmaps as a chain of attached surfaces. The highest resolution texture is at the head of the chain and has, as an attachment, the next level of the mipmap. That level has, in turn, an attachment that is the next level in the mipmap, and so on down to the lowest resolution level of the mipmap.

The following set of illustrations shows an example. The set of bitmap textures represents a sign on the side of a container in a 3-D, first-person game. When created as a mipmap, the highest-resolution texture is first in the set. Each succeeding texture in the mipmap set is a power of 2 smaller in height and width. In this case, the maximum-resolution mipmap is 256 pixels by 256 pixels. The next, texture is 128x128. The last texture in the chain is 64x64.

This sign would have a maximum distance from which it is visible. If the player begins far away from the sign, the game would display the smallest texture in the mipmap chain, which in this case the 64x64 texture.

As the player moves the point of view closer to the sign, progressively higher-resolution textures in the mipmap chain are used.

The highest-resolution texture is used when the user's point of view is at the minimum allowable distance from the sign.

This is a computationally lower-overhead way of simulating perspective effects for textures. Rather than render a single texture to many resolutions, it is faster to use multiple textures at varying resolutions.

Direct3D is able to assess which texture in a mipmap set is the closest resolution to the desired output and map pixels into its texel space. If the resolution of the final image is between the resolutions of the textures in the mipmap set, Direct3D can examine texels in both of the mipmaps and blend their color values together.

If you want your application to use mipmaps, it must build a set of mipmaps. For details, see Creating a Set of Mipmaps. Applications apply mipmaps by selecting the mipmap set as the first texture in the set of current textures. For more information, see Multiple Texture Blending.

Next, your program must set the filtering method that Direct3D uses to sample texels. The fastest method of mipmap filtering is to have Direct3D select the nearest texel. Use the D3DTFP_POINT enumerated value to select this. Direct3D can produce better filtering results if your application uses the D3DTFP_LINEAR enumerated value. This will select the nearest mipmap, then compute a weighted average of the texels surrounding the location in the texture to which the current pixel maps.