CustomMaterial.GeometryModifier
The custom material’s optional shader function that can manipulate an entity’s vertex data.
Declaration
struct GeometryModifierOverview
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.
Here’s a simple example of a geometry modifier that offsets the vertex positions along the z-axis based on the elapsed time:
#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.
Topics
Creating geometry modifier objects
Accessing geometry modifier properties
Initializers
See Also
Shaders
Implementing adjustable materialDisplaying a stereoscopic imageShaderGraphMaterialShaderGraphMaterial.FaceCullingShaderGraphMaterial.TriangleFillModeModifying RealityKit rendering using custom materialsCustomMaterialCustomMaterial.SurfaceShaderMaterialFunctionCustomMaterial.ProgramCustomMaterial.Program.DescriptorCustomShaderStage