<!--
{
  "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>

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

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

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

A set of types that material parameters can use.

### Accessing the program

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

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



---

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)