---
title: ShaderGraphMaterial
framework: realitykit
role: symbol
role_heading: Structure
path: realitykit/shadergraphmaterial
---

# ShaderGraphMaterial

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

## Declaration

```swift
struct ShaderGraphMaterial
```

## Overview

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: 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: 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

- [Reality Composer Pro](realitycomposerpro.md)
- [Material](realitykit/material.md)
- [MaterialParameterTypes](realitykit/materialparametertypes.md)

### Accessing the program

- [program](realitykit/shadergraphmaterial/program-swift.property.md)
- [ShaderGraphMaterial.Program](realitykit/shadergraphmaterial/program-swift.struct.md)

### Initializers

- [init(materialXLabel:data:)](realitykit/shadergraphmaterial/init(materialxlabel:data:).md)
- [init(named:from:)](realitykit/shadergraphmaterial/init(named:from:).md)
- [init(named:from:in:)](realitykit/shadergraphmaterial/init(named:from:in:).md)
- [init(program:)](realitykit/shadergraphmaterial/init(program:).md)

### Instance Properties

- [faceCulling](realitykit/shadergraphmaterial/faceculling-swift.property.md)
- [parameterNames](realitykit/shadergraphmaterial/parameternames.md)
- [readsDepth](realitykit/shadergraphmaterial/readsdepth.md)
- [triangleFillMode](realitykit/shadergraphmaterial/trianglefillmode-swift.property.md)
- [writesDepth](realitykit/shadergraphmaterial/writesdepth.md)

### Instance Methods

- [getParameter(handle:)](realitykit/shadergraphmaterial/getparameter(handle:).md)
- [getParameter(name:)](realitykit/shadergraphmaterial/getparameter(name:).md)
- [setParameter(handle:value:)](realitykit/shadergraphmaterial/setparameter(handle:value:).md)
- [setParameter(name:value:)](realitykit/shadergraphmaterial/setparameter(name:value:).md)

### Type Aliases

- [ShaderGraphMaterial.FaceCulling](realitykit/shadergraphmaterial/faceculling-swift.typealias.md)
- [ShaderGraphMaterial.TriangleFillMode](realitykit/shadergraphmaterial/trianglefillmode-swift.typealias.md)

### Type Methods

- [parameterHandle(name:)](realitykit/shadergraphmaterial/parameterhandle(name:).md)

### Enumerations

- [ShaderGraphMaterial.Error](realitykit/shadergraphmaterial/error.md)
- [ShaderGraphMaterial.LoadError](realitykit/shadergraphmaterial/loaderror.md)

## Relationships

### Conforms To

- [Material](realitykit/material.md)
- [Sendable](swift/sendable.md)
- [SendableMetatype](swift/sendablemetatype.md)

## See Also

### Shaders

- [Implementing adjustable material](visionos/implementing-adjustable-material-in-visionos.md)
- [Displaying a stereoscopic image](visionos/displaying-a-stereoscopic-image-in-visionos.md)
- [ShaderGraphMaterial.FaceCulling](realitykit/shadergraphmaterial/faceculling-swift.typealias.md)
- [ShaderGraphMaterial.TriangleFillMode](realitykit/shadergraphmaterial/trianglefillmode-swift.typealias.md)
- [Modifying RealityKit rendering using custom materials](realitykit/modifying-realitykit-rendering-using-custom-materials.md)
- [CustomMaterial](realitykit/custommaterial.md)
- [CustomMaterial.SurfaceShader](realitykit/custommaterial/surfaceshader.md)
- [CustomMaterial.GeometryModifier](realitykit/custommaterial/geometrymodifier.md)
- [MaterialFunction](realitykit/materialfunction.md)
- [CustomMaterial.Program](realitykit/custommaterial/program-swift.class.md)
- [CustomMaterial.Program.Descriptor](realitykit/custommaterial/program-swift.class/descriptor-swift.struct.md)
- [CustomShaderStage](realitykit/customshaderstage.md)
