<!--
{
  "availability" : [
    "iOS: 27.0.0 -",
    "iPadOS: 27.0.0 -",
    "macCatalyst: 27.0.0 -",
    "macOS: 27.0.0 -",
    "tvOS: 27.0.0 -",
    "visionOS: 27.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "RealityKit",
  "identifier" : "/documentation/RealityKit/PortalMaterial/Program-swift.struct/init(descriptor:)",
  "metadataVersion" : "0.1.0",
  "role" : "Initializer",
  "symbol" : {
    "kind" : "Initializer",
    "modules" : [
      "RealityKit"
    ],
    "preciseIdentifier" : "s:17RealityFoundation14PortalMaterialV7ProgramV10descriptorA2E10DescriptorV_tYaKcfc"
  },
  "title" : "init(descriptor:)"
}
-->

# init(descriptor:)

Compiles a program from the given descriptor.

```
init(descriptor: PortalMaterial.Program.Descriptor) async throws
```

## Parameters

`descriptor`

A configuration that pairs a shader graph
with initial input values and function constant values.

## Discussion

Compilation translates the descriptor’s shader graph into a Metal
function library, bakes in the descriptor’s function constant values,
and links the result into a [`PortalMaterial`](/documentation/RealityKit/PortalMaterial)-compatible artifact.
The work is asynchronous; build programs once during scene setup
and reuse them across every material that needs them.

> Throws: An error if the shader graph is invalid, if a required
> built-in portal asset can’t be located, or if shader compilation
> fails.

---

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)