<!--
{
  "availability" : [
    "iOS: 18.0.0 -",
    "iPadOS: 18.0.0 -",
    "macCatalyst: 18.0.0 -",
    "macOS: 15.0.0 -",
    "tvOS: 26.0.0 -",
    "visionOS: 1.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "RealityKit",
  "identifier" : "/documentation/RealityKit/ShaderGraphMaterial",
  "metadataVersion" : "0.1.0",
  "role" : "Structure",
  "symbol" : {
    "kind" : "Structure",
    "modules" : [
      "RealityKit"
    ],
    "preciseIdentifier" : "s:17RealityFoundation19ShaderGraphMaterialV"
  },
  "title" : "ShaderGraphMaterial"
}
-->

# ShaderGraphMaterial

A material that comes from a shader graph in a Reality Composer Pro project, or a MaterialX shader.

```
struct ShaderGraphMaterial
```

## Overview

Use ShaderGraphMaterial when retrieving a shaders you build in Reality Composer
Pro’s shader graph. The following code demonstrates retrieving the first material
from an entity loaded from a Reality Composer Proj project and sets a new value for
one of its named parameters:

```swift
if var modelComponent = entity.modelComponent {
    modelComponent.materials = modelComponent.materials.map {
        guard var material = $0 as? ShaderGraphMaterial else { return $0 }
        if material.parameterNames.contains(myMaterialParameterName) {
            do {
                try material.setParameter(name: myMaterialParameterName,
                                          value: .float(isPowered ? 1.0 : 0.0))
            } catch {
                // Handle error.
            }
        }
        return material
    }
    entity.modelComponent = modelComponent
}
```

In addition to creating instances of `ShaderGraphMaterial` from Reality Composer Pro’s shader graph, you can also create them directly from Material X shaders.

You can also load shader graph materials directly from `.reality` files:

```swift
let shader = try! await ShaderGraphMaterial(named: "/Root/Glass", from: "Scene.usda")
```

For more information on using custom parameters in a `ShaderGraphMaterial`,  see
<doc://documentation.apple.com/documentation/visionos/implementing-adjustable-material-in-visionos>.

Create dynamic materials without Metal.

## Topics

### Shader Graph fundamentals

  <com://com.apple.documentation/documentation/shadergraph>

  <doc://com.apple.documentation/documentation/RealityComposerPro>

[`protocol Material`](/documentation/RealityKit/Material)

A type that describes the material aspects of a mesh, like color and
texture.

[`struct MaterialParameterTypes`](/documentation/RealityKit/MaterialParameterTypes)

A set of types that material parameters can use.

### Accessing the program

[`var program: ShaderGraphMaterial.Program`](/documentation/RealityKit/ShaderGraphMaterial/program-swift.property)

[`struct Program`](/documentation/RealityKit/ShaderGraphMaterial/Program-swift.struct)

### Initializers

[`init(materialXLabel: String, data: Data) async throws`](/documentation/RealityKit/ShaderGraphMaterial/init(materialXLabel:data:))

Loads a ShaderGraphMaterial from MaterialX data.

[`init(named:from:)`](/documentation/RealityKit/ShaderGraphMaterial/init(named:from:))

Loads a ShaderGraphMaterial from a named material within a USD file.

[`init(named: String, from: String, in: Bundle?) async throws`](/documentation/RealityKit/ShaderGraphMaterial/init(named:from:in:))

Loads a ShaderGraphMaterial from a bundle.

[`init(program: ShaderGraphMaterial.Program)`](/documentation/RealityKit/ShaderGraphMaterial/init(program:))

Create a ShaderGraphMaterial with an already initialized Program.
Use this method when you want to preload a library of shaders
and create instances of them quickly and synchronously via ShaderGraphMaterials at runtime.

### Instance Properties

[`var faceCulling: ShaderGraphMaterial.FaceCulling`](/documentation/RealityKit/ShaderGraphMaterial/faceCulling-swift.property)

A process in which the system specifies polygons to remove before
rendering a mesh using this material.

[`var parameterNames: [String]`](/documentation/RealityKit/ShaderGraphMaterial/parameterNames)

[`var readsDepth: Bool`](/documentation/RealityKit/ShaderGraphMaterial/readsDepth)

A boolean value that determines whether this material performs the depth test by reading RealityKit’s depth buffer.

[`var triangleFillMode: ShaderGraphMaterial.TriangleFillMode`](/documentation/RealityKit/ShaderGraphMaterial/triangleFillMode-swift.property)

The object that controls how RealityKit draws triangles.

[`var writesDepth: Bool`](/documentation/RealityKit/ShaderGraphMaterial/writesDepth)

A boolean value that determines whether this material writes its depth into RealityKit’s depth buffer.

### Instance Methods

[`func getParameter(handle: MaterialParameters.Handle) -> MaterialParameters.Value?`](/documentation/RealityKit/ShaderGraphMaterial/getParameter(handle:))

[`func getParameter(name: String) -> MaterialParameters.Value?`](/documentation/RealityKit/ShaderGraphMaterial/getParameter(name:))

[`func setParameter(handle: MaterialParameters.Handle, value: MaterialParameters.Value) throws`](/documentation/RealityKit/ShaderGraphMaterial/setParameter(handle:value:))

[`func setParameter(name: String, value: MaterialParameters.Value) throws`](/documentation/RealityKit/ShaderGraphMaterial/setParameter(name:value:))

### Type Aliases

[`typealias FaceCulling`](/documentation/RealityKit/ShaderGraphMaterial/FaceCulling-swift.typealias)

An alias for the cull mode object that’s appropriate for this material class.

[`typealias TriangleFillMode`](/documentation/RealityKit/ShaderGraphMaterial/TriangleFillMode-swift.typealias)

An alias for the triangle fill mode object that’s appropriate for this
material class.

### Type Methods

[`static func parameterHandle(name: String) -> MaterialParameters.Handle`](/documentation/RealityKit/ShaderGraphMaterial/parameterHandle(name:))

### Enumerations

[`enum Error`](/documentation/RealityKit/ShaderGraphMaterial/Error)

[`enum LoadError`](/documentation/RealityKit/ShaderGraphMaterial/LoadError)

## Relationships

### Conforms To

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

[`Material`](/documentation/RealityKit/Material)

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

---

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)