<!--
{
  "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/ShaderFunction",
  "metadataVersion" : "0.1.0",
  "role" : "Structure",
  "symbol" : {
    "kind" : "Structure",
    "modules" : [
      "SwiftUI"
    ],
    "preciseIdentifier" : "s:7SwiftUI14ShaderFunctionV"
  },
  "title" : "ShaderFunction"
}
-->

# ShaderFunction

A reference to a function in a Metal shader library.

```
@dynamicCallable struct ShaderFunction
```

## Topics

### Creating a shader function

[`init(library: ShaderLibrary, name: String)`](/documentation/SwiftUI/ShaderFunction/init(library:name:))

Creates a new function reference from the provided shader
library and function name string.

### Configuring a function

[`var library: ShaderLibrary`](/documentation/SwiftUI/ShaderFunction/library)

The shader library storing the function.

[`var name: String`](/documentation/SwiftUI/ShaderFunction/name)

The name of the shader function in the library.

[`func dynamicallyCall(withArguments: [Shader.Argument]) -> Shader`](/documentation/SwiftUI/ShaderFunction/dynamicallyCall(withArguments:))

Returns a new shader by applying the provided argument values
to the referenced function.

## Relationships

### Conforms To

[`SendableMetatype`](/documentation/Swift/SendableMetatype)

[`Sendable`](/documentation/Swift/Sendable)

[`Equatable`](/documentation/Swift/Equatable)

---

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)