Contents

CustomMaterial.Program

An object that represents the backing shader compilation required for custom materials.

Declaration

final class Program

Overview

You can use this type to control when RealityKit compiles shaders, and to initialize CustomMaterial objects with more predicitable loading performance.

When initializing a CustomMaterial this way, a Program object is created first asynchronously, which is used to cache the material’s shader program so the CustomMaterial can be loaded immediately later.

For example:

// Initialize descriptor with desired properties
var descriptor = CustomMaterial.Descriptor()
descriptor.lightingModel = .unlit

// Create program object
let program = await CustomMaterial.Program(surfaceShader: surfaceShader,
                                           descriptor: descriptor)

// Create material (returns immediately)
let material = CustomMaterial(program: program)

Topics

Structures

Initializers

Instance Properties

See Also

Shaders