---
title: "distortionEffect(_:maxSampleOffset:isEnabled:)"
framework: swiftui
role: symbol
role_heading: Instance Method
path: "swiftui/visualeffect/distortioneffect(_:maxsampleoffset:isenabled:)"
---

# distortionEffect(_:maxSampleOffset:isEnabled:)

Returns a new visual effect that applies shader to self as a geometric distortion effect on the location of each pixel.

## Declaration

```swift
func distortionEffect(_ shader: Shader, maxSampleOffset: CGSize, isEnabled: Bool = true) -> some VisualEffect

```

## Parameters

- `shader`: The shader to apply as a distortion effect.
- `maxSampleOffset`: The maximum distance in each axis between the returned source pixel position and the destination pixel position, for all source pixels.
- `isEnabled`: Whether the effect is enabled or not.

## Return Value

Return Value A new view that renders self with the shader applied as a distortion effect.

## Discussion

Discussion For a shader function to act as a distortion effect it must have a function signature matching: [[ stitchable ]] float2 name(float2 position, args...) where position is the user-space coordinates of the destination pixel applied to the shader. args... should be compatible with the uniform arguments bound to shader. The function should return the user-space coordinates of the corresponding source pixel. important: Views backed by AppKit or UIKit views may not render into the filtered layer. Instead, they log a warning and display a placeholder image to highlight the error.

## See Also

### Applying other effects

- [blur(radius:opaque:)](swiftui/visualeffect/blur(radius:opaque:).md)
- [layerEffect(_:maxSampleOffset:isEnabled:)](swiftui/visualeffect/layereffect(_:maxsampleoffset:isenabled:).md)
