ShaderGraphMaterial
A material that comes from a shader graph in a Reality Composer Pro project, or a MaterialX shader.
Declaration
struct ShaderGraphMaterialOverview
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
Initializers
Instance Properties
Instance Methods
Type Aliases
Type Methods
Enumerations
See Also
Shaders
Implementing adjustable materialDisplaying a stereoscopic imageShaderGraphMaterial.FaceCullingShaderGraphMaterial.TriangleFillModeModifying RealityKit rendering using custom materialsCustomMaterialCustomMaterial.SurfaceShaderCustomMaterial.GeometryModifierMaterialFunctionCustomMaterial.ProgramCustomMaterial.Program.DescriptorCustomShaderStage