---
title: CustomMaterial
framework: realitykit
role: symbol
role_heading: Structure
path: realitykit/custommaterial
---

# CustomMaterial

A material that works with custom Metal shader functions.

## Declaration

```swift
struct CustomMaterial
```

## Mentioned in

Modifying RealityKit rendering using custom materials

## Overview

Overview Custom, or programmable, materials allow you to leverage RealityKit’s existing shader pipeline to render physically based or unlit materials that support custom Metal shader functions. These functions modify how RealityKit renders an entity. Custom materials support two different types of custom Metal shader functions: geometry modifiers and surface shaders. Use a _surface shader _to calculate or specify all the material attributes that RealityKit uses to render your entity, such as baseColor, normal, and roughness. A geometry modifier can offset the position of an entity’s vertices to change the size and shape of an entity. It can also change other per-vertex data, such as vertex color and UV texture coordinates, which define how RealityKit maps textures on to the model. important: For the Metal API documentation for custom material shader functions, see the Metal RealityKit APIs PDF. For more information on creating custom materials and writing shader functions, see Modifying RealityKit rendering using custom materials.

## Topics

### Creating custom materials

- [init(from:geometryModifier:)](realitykit/custommaterial/init(from:geometrymodifier:).md)
- [init(from:surfaceShader:geometryModifier:)](realitykit/custommaterial/init(from:surfaceshader:geometrymodifier:).md)
- [init(surfaceShader:geometryModifier:lightingModel:)](realitykit/custommaterial/init(surfaceshader:geometrymodifier:lightingmodel:).md)
- [init(program:)](realitykit/custommaterial/init(program:).md)

### Setting the core properties

- [baseColor](realitykit/custommaterial/basecolor-swift.property.md)
- [roughness](realitykit/custommaterial/roughness-swift.property.md)
- [metallic](realitykit/custommaterial/metallic-swift.property.md)
- [normal](realitykit/custommaterial/normal-swift.property.md)
- [emissiveColor](realitykit/custommaterial/emissivecolor-swift.property.md)
- [ambientOcclusion](realitykit/custommaterial/ambientocclusion-swift.property.md)
- [specular](realitykit/custommaterial/specular-swift.property.md)
- [clearcoat](realitykit/custommaterial/clearcoat-swift.property.md)
- [clearcoatRoughness](realitykit/custommaterial/clearcoatroughness-swift.property.md)
- [clearcoatNormal](realitykit/custommaterial/clearcoatnormal-swift.property.md)

### Controlling opacity

- [opacityThreshold](realitykit/custommaterial/opacitythreshold.md)
- [blending](realitykit/custommaterial/blending-swift.property.md)

### Setting shader properties

- [program](realitykit/custommaterial/program-swift.property.md)
- [custom](realitykit/custommaterial/custom-swift.property.md)
- [lightingModel](realitykit/custommaterial/lightingmodel-swift.property.md)
- [withMutableUniforms(ofType:_:)](realitykit/custommaterial/withmutableuniforms(oftype:_:).md)
- [withMutableUniforms(ofType:stage:_:)](realitykit/custommaterial/withmutableuniforms(oftype:stage:_:).md)

### Modifying texture coordinates

- [textureCoordinateTransform](realitykit/custommaterial/texturecoordinatetransform-swift.property.md)
- [secondaryTextureCoordinateTransform](realitykit/custommaterial/secondarytexturecoordinatetransform.md)

### Culling unnecessary polygons

- [faceCulling](realitykit/custommaterial/faceculling-swift.property.md)

### Setting depth testing properties

- [readsDepth](realitykit/custommaterial/readsdepth.md)
- [writesDepth](realitykit/custommaterial/writesdepth.md)

### Applying post-lighting shading

- [CustomMaterial.PostLightingShader](realitykit/custommaterial/postlightingshader.md)

### Classes

- [CustomMaterial.Program](realitykit/custommaterial/program-swift.class.md)

### Structures

- [CustomMaterial.AmbientOcclusion](realitykit/custommaterial/ambientocclusion-swift.struct.md)
- [CustomMaterial.BaseColor](realitykit/custommaterial/basecolor-swift.struct.md)
- [CustomMaterial.Clearcoat](realitykit/custommaterial/clearcoat-swift.struct.md)
- [CustomMaterial.ClearcoatNormal](realitykit/custommaterial/clearcoatnormal-swift.struct.md)
- [CustomMaterial.ClearcoatRoughness](realitykit/custommaterial/clearcoatroughness-swift.struct.md)
- [CustomMaterial.Custom](realitykit/custommaterial/custom-swift.struct.md)
- [CustomMaterial.CustomMaterialTexture](realitykit/custommaterial/custommaterialtexture.md)
- [CustomMaterial.EmissiveColor](realitykit/custommaterial/emissivecolor-swift.struct.md)
- [CustomMaterial.GeometryModifier](realitykit/custommaterial/geometrymodifier.md)
- [CustomMaterial.Metallic](realitykit/custommaterial/metallic-swift.struct.md)
- [CustomMaterial.Normal](realitykit/custommaterial/normal-swift.struct.md)
- [CustomMaterial.Opacity](realitykit/custommaterial/opacity.md)
- [CustomMaterial.ResourceStorage](realitykit/custommaterial/resourcestorage.md)
- [CustomMaterial.Roughness](realitykit/custommaterial/roughness-swift.struct.md)
- [CustomMaterial.Specular](realitykit/custommaterial/specular-swift.struct.md)
- [CustomMaterial.SurfaceShader](realitykit/custommaterial/surfaceshader.md)

### Instance Properties

- [triangleFillMode](realitykit/custommaterial/trianglefillmode-swift.property.md)

### Type Aliases

- [CustomMaterial.FaceCulling](realitykit/custommaterial/faceculling-swift.typealias.md)
- [CustomMaterial.Texture](realitykit/custommaterial/texture.md)
- [CustomMaterial.TextureCoordinateTransform](realitykit/custommaterial/texturecoordinatetransform-swift.typealias.md)
- [CustomMaterial.TriangleFillMode](realitykit/custommaterial/trianglefillmode-swift.typealias.md)

### Type Properties

- [supportsMutableUniformsResources](realitykit/custommaterial/supportsmutableuniformsresources.md)

### Enumerations

- [CustomMaterial.Blending](realitykit/custommaterial/blending-swift.enum.md)
- [CustomMaterial.LightingModel](realitykit/custommaterial/lightingmodel-swift.enum.md)

## Relationships

### Conforms To

- [Material](realitykit/material.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](realitykit/shadergraphmaterial.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.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)
