<!--
{
  "availability" : [
    "iOS: 15.0.0 -",
    "iPadOS: 15.0.0 -",
    "macCatalyst: 15.0.0 -",
    "macOS: 12.0.0 -",
    "tvOS: 26.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "RealityKit",
  "identifier" : "/documentation/RealityKit/CustomMaterial/GeometryModifier",
  "metadataVersion" : "0.1.0",
  "role" : "Structure",
  "symbol" : {
    "kind" : "Structure",
    "modules" : [
      "RealityKit"
    ],
    "preciseIdentifier" : "s:17RealityFoundation14CustomMaterialV16GeometryModifierV"
  },
  "title" : "CustomMaterial.GeometryModifier"
}
-->

# CustomMaterial.GeometryModifier

The custom material’s optional shader function that can manipulate an
entity’s vertex data.

```
struct GeometryModifier
```

## Overview

A geometry modifier is an optional Metal function that you can use with
custom materials. Use a geometry modifier to change vertex data, such as
vertex position, color, or texture coordinates. For example, offsetting
a vertex’s position changes the size and shape of the entity for
rendering only. If your custom material has a geometry modifier,
RealityKit’s custom material vertex shader calls it once for each vertex
in the entity. Changes that your geometry modifier makes are transient
and don’t affect the vertex positions of the original [`ModelEntity`](/documentation/RealityKit/ModelEntity).

Here’s a simple example of a geometry modifier that offsets the vertex
positions along the z-axis based on the elapsed time:

```cpp
#include <metal_stdlib>
#include <RealityKit/RealityKit.h>
using namespace metal;

[[visible]] void myGeometryModifier(realitykit::geometry_parameters
params) {
    float3 zOffset = float3(0.0, 0.0, params.uniforms().time() / 50.0);
    params.geometry().set_world_position_offset(zOffset);
}
```

For more information on creating custom materials and writing shader
functions, see
[Modifying RealityKit rendering using custom materials](/documentation/RealityKit/modifying-realitykit-rendering-using-custom-materials).

## Topics

### Creating geometry modifier objects

[`init(named: String, in: any MTLLibrary)`](/documentation/RealityKit/CustomMaterial/GeometryModifier/init(named:in:))

Creates a geometry modifier object from a named function in a Metal
library.

### Accessing geometry modifier properties

[`var name: String`](/documentation/RealityKit/CustomMaterial/GeometryModifier/name)

The name of the geometry modifier function.

[`var library: any MTLLibrary`](/documentation/RealityKit/CustomMaterial/GeometryModifier/library)

The Metal library that contains this surface shader function.

### Initializers

[`init(named: String, in: any MTLLibrary, constantValues: MTLFunctionConstantValues)`](/documentation/RealityKit/CustomMaterial/GeometryModifier/init(named:in:constantValues:))

Creates a geometry modifier with the specified function constant values.

## Relationships

### Conforms To

[`Hashable`](/documentation/Swift/Hashable)

[`Equatable`](/documentation/Swift/Equatable)

[`SendableMetatype`](/documentation/Swift/SendableMetatype)

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

[`Sendable`](/documentation/Swift/Sendable)

---

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)