---
title: Adding mipmap filtering to samplers
framework: metal
role: article
role_heading: Article
path: metal/adding-mipmap-filtering-to-samplers
---

# Adding mipmap filtering to samplers

Specify how the GPU samples mipmaps in your textures.

## Overview

Overview By default, samplers sample data only from mipmap 0. If your texture contains more than one mipmap, and you want it to sample the lower-level mipmaps, you need to specify this behavior when you create the texture sampler. Create the sampler in your app If you’re creating an MTLSamplerState instance, create the MTLSamplerDescriptor instance and set its mipFilter property. The following code uses linear filtering for the minification and magnification filter, and uses linear filtering for mipmaps. This combination is usually called trilinear filtering. With this configuration, the GPU chooses the two mipmaps nearest in size and generates a sample by linearly filtering four pixels from each mipmap. Then it blends those two values with a linear interpolation to generate the final sample. Alternatively, any of these filters could filter from the nearest pixel, instead of a linear filter, resulting in fewer sampled pixels but lower quality. Ultimately, you need to decide the right tradeoffs between sampling performance and quality for your app. Create the sampler in your shader If you prefer to create samplers in your shader, specify the mipmap filtering there instead of in your app: constexpr sampler s(filter::linear, mip_filter::linear)

## See Also

### Texture mipmapping

- [Improving texture sampling quality and performance with mipmaps](metal/improving-texture-sampling-quality-and-performance-with-mipmaps.md)
- [Creating a mipmapped texture](metal/creating-a-mipmapped-texture.md)
- [Copying data into or out of mipmaps](metal/copying-data-into-or-out-of-mipmaps.md)
- [Generating mipmap data](metal/generating-mipmap-data.md)
- [Restricting access to specific mipmaps](metal/restricting-access-to-specific-mipmaps.md)
- [Predicting which mips the GPU samples with level-of-detail queries](metal/predicting-which-mips-the-gpu-samples-with-level-of-detail-queries.md)
- [Dynamically adjusting texture level of detail](metal/dynamically-adjusting-texture-level-of-detail.md)
