<!--
{
  "availability" : [
    "iOS: 8.0.0 -",
    "iPadOS: 8.0.0 -",
    "macCatalyst: 13.1.0 -",
    "macOS: 10.11.0 -",
    "tvOS: -",
    "visionOS: 1.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "Metal",
  "identifier" : "/documentation/Metal/MTLComputeCommandEncoder/setSamplerState(_:lodMinClamp:lodMaxClamp:index:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "Metal"
    ],
    "preciseIdentifier" : "c:objc(pl)MTLComputeCommandEncoder(im)setSamplerState:lodMinClamp:lodMaxClamp:atIndex:"
  },
  "title" : "setSamplerState(_:lodMinClamp:lodMaxClamp:index:)"
}
-->

# setSamplerState(_:lodMinClamp:lodMaxClamp:index:)

Encodes a texture sampler with a custom level of detail clamping, allowing compute kernels to use it for sampling textures on the GPU.

```
func setSamplerState(_ sampler: (any MTLSamplerState)?, lodMinClamp: Float, lodMaxClamp: Float, index: Int)
```

## Parameters

`sampler`

An [`MTLSamplerState`](/documentation/Metal/MTLSamplerState) instance to bind to the sampler argument table.

`lodMinClamp`

The minimum level of detail used when sampling a texture.

`lodMaxClamp`

The maximum level of detail used when sampling a texture.

`index`

The index in the sampler argument table to bind the sampler to.

## Discussion

Calling this method ignores the [`lodMinClamp`](/documentation/Metal/MTLSamplerDescriptor/lodMinClamp) and [`lodMaxClamp`](/documentation/Metal/MTLSamplerDescriptor/lodMaxClamp) properties of the sampler, using the provided levels of detail instead.

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)