---
title: "setSamplerState(_:lodMinClamp:lodMaxClamp:index:)"
framework: metal
role: symbol
role_heading: Instance Method
path: "metal/mtlcomputecommandencoder/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.

## Declaration

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

## Parameters

- `sampler`: An doc://com.apple.metal/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

Discussion Calling this method ignores the lodMinClamp and lodMaxClamp properties of the sampler, using the provided levels of detail instead.

## See Also

### Binding texture samplers

- [setSamplerState(_:index:)](metal/mtlcomputecommandencoder/setsamplerstate(_:index:).md)
- [setSamplerStates(_:range:)](metal/mtlcomputecommandencoder/setsamplerstates(_:range:).md)
- [setSamplerStates(_:lodMinClamps:lodMaxClamps:range:)](metal/mtlcomputecommandencoder/setsamplerstates(_:lodminclamps:lodmaxclamps:range:).md)
