<!--
{
  "availability" : [
    "iOS: 17.0.0 -",
    "iPadOS: 17.0.0 -",
    "macCatalyst: 17.0.0 -",
    "macOS: 14.0.0 -",
    "tvOS: 17.0.0 -",
    "visionOS: 1.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "SwiftUI",
  "identifier" : "/documentation/SwiftUI/GraphicsContext/Filter/distortionShader(_:maxSampleOffset:)",
  "metadataVersion" : "0.1.0",
  "role" : "Type Method",
  "symbol" : {
    "kind" : "Type Method",
    "modules" : [
      "SwiftUI"
    ],
    "preciseIdentifier" : "s:7SwiftUI15GraphicsContextV6FilterV16distortionShader_15maxSampleOffsetAeA0G0V_So6CGSizeVtFZ"
  },
  "title" : "distortionShader(_:maxSampleOffset:)"
}
-->

# distortionShader(_:maxSampleOffset:)

Returns a filter that applies `shader` as a geometric
distortion effect on the location of each pixel.

```
static func distortionShader(_ shader: Shader, maxSampleOffset: CGSize) -> GraphicsContext.Filter
```

## 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.

## Return Value

A new filter that applies the shader as a
distortion effect.

## 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.

---

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)