<!--
{
  "availability" : [
    "Reality Composer Pro: 3.0.0 -",
    "iOS: 27.0.0 -",
    "iPadOS: 27.0.0 -",
    "macOS: 27.0.0 -",
    "tvOS: 27.0.0 -",
    "visionOS: 27.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "ComputeGraph",
  "identifier" : "/documentation/ComputeGraph",
  "metadataVersion" : "0.1.0",
  "role" : "Framework",
  "symbol" : {
    "kind" : "Framework",
    "modules" : [
      "Compute Graph"
    ],
    "preciseIdentifier" : "ComputeGraph"
  },
  "title" : "Compute Graph"
}
-->

# Compute Graph

Build and run custom particle effects and compute simulations for RealityKit using a programmable node graph.

## Overview

Compute Graph is a node-based framework for constructing particle simulations and general-purpose GPU compute graphs in <doc://com.apple.documentation/documentation/RealityKit>.
Whereas <doc://com.apple.documentation/documentation/ShaderGraph> lets developers build material appearance through a node-based visual editor, Compute Graph provides the same graph-driven, connection-based authoring for simulation behavior.
The technology targets tool and editor developers who need fine-grained, per-stage control over how particles and compute work proceeds.

The Swift API centers on a three-step compilation pipeline.
Describe a simulation as a `GraphDefinition`, a directed graph of typed nodes and edges.
Then assemble the graph into a `ComputeGraphAssembly`, which resolves the buffer, uniform, and texture layout the simulation requires.
Compile that assembly into `ComputeGraphPipelines` to produce GPU shader code; a single set of pipelines can back multiple [`ComputeGraphSimulation`](/documentation/ComputeGraph/ComputeGraphSimulation) instances running concurrently.
`Library` and `SyntheticNodeLibrary` let you supply custom Metal Shading Language functions as node definitions alongside the framework’s built-in set in `ComputeGraphBuiltIns`.

At runtime, [`ComputeGraphSimulation`](/documentation/ComputeGraph/ComputeGraphSimulation) drives GPU execution.
Call [`advance(_:)`](/documentation/ComputeGraph/ComputeGraphSimulation/advance(_:)) each frame, passing an [`ComputeGraphSimulation.AdvanceParams`](/documentation/ComputeGraph/ComputeGraphSimulation/AdvanceParams) that carries the time delta, a Metal command buffer, a compute encoder, and optional world-space transforms.
Bind `GraphBuffer`, `GraphTexture`, and `GraphUniform` resources before the first advance.
To inject elements programmatically, call [`spawn(elements:in:using:)`](/documentation/ComputeGraph/ComputeGraphSimulation/spawn(elements:in:using:)) with [`ElementSpawnParameters`](/documentation/ComputeGraph/ElementSpawnParameters) values that set each element’s initial position, velocity, size, color, and lifetime.

## Topics

### Simulation objects

[`ComputeGraphSimulation`](/documentation/ComputeGraph/ComputeGraphSimulation)

A simulation of particles, which use a single pipeline.

### Built-in nodes

[`element`](/documentation/ComputeGraph/element)

A set of nodes for reading and writing the current element within a particle simulation.

[`emitter`](/documentation/ComputeGraph/emitter)

A set of nodes usable in the emission stage of a simulation, which control how often and how many elements to spawn.

[`force`](/documentation/ComputeGraph/force)

Apply physics forces including gravity, drag, noise, and twist.

[`initialize`](/documentation/ComputeGraph/initialize)

Nodes usable within the initialization stage of an element.

[`output`](/documentation/ComputeGraph/output)

Nodes usable within the output stage of an element. You can use these nodes to change the appearance of an element without making modifications to the element itself.

[`module`](/documentation/ComputeGraph/module)

Mutate per-particle state with operations such as setPosition, addPosition, setVelocity, setColor, setSize, and setLifetime.

[`graph`](/documentation/ComputeGraph/graph)

A set of nodes usable in any stage within a ComputeGraph.

[`group`](/documentation/ComputeGraph/group)

Nodes for querying the group for a current particle. Requires a system whose simulation stage is configured as either `strips` or `grouped`.

[`texture`](/documentation/ComputeGraph/texture)

Nodes usable within the texture stage, for generating textures.

[`random`](/documentation/ComputeGraph/random)

Nodes for generating pseudo-random numbers.

[`matrix4x4f`](/documentation/ComputeGraph/matrix4x4f)

Transform positions and directions using matrix4x4f.

[`matrix4x4h`](/documentation/ComputeGraph/matrix4x4h)

Transform positions and directions using matrix4x4h.

### Graph definition and assembly

### Node parameters and connections

[`PortReference`](/documentation/ComputeGraph/PortReference)

A reference to another group’s values.

[`BinaryOperation`](/documentation/ComputeGraph/BinaryOperation)

An enumeration of binary operations.

[`UnaryOperation`](/documentation/ComputeGraph/UnaryOperation)

An enumeration of single-operand operations.

[`StandardLibraryFunction`](/documentation/ComputeGraph/StandardLibraryFunction)

### Elements and particles

[`ElementGrouping`](/documentation/ComputeGraph/ElementGrouping)

An enumeration of how elements are grouped.

[`ElementSpawnParameters`](/documentation/ComputeGraph/ElementSpawnParameters)

Parameters used to configure the initial state of a particle when it’s spawned in the simulation.

[`Sorting`](/documentation/ComputeGraph/Sorting)

An enumeration of sorting modes.

### Graph resources

[`AddressSpace`](/documentation/ComputeGraph/AddressSpace)

A GPU memory address space.

### Geometry and simulation inputs

[`CoordinateSpace`](/documentation/ComputeGraph/CoordinateSpace)

Simulation coordinate space, controlling how positions and orientations are stored.

[`StripOrientation`](/documentation/ComputeGraph/StripOrientation)

An enumeration that specifies how a strip should be oriented.

[`Viewpoint`](/documentation/ComputeGraph/Viewpoint-swift.struct)

Camera viewpoint parameters in 3D space.

[`MouseParams`](/documentation/ComputeGraph/MouseParams)

Parameters describing mouse interaction in 3D space.

### C macros

[`PS_API`](/documentation/ComputeGraph/PS_API)

[`PS_AVAILABILE`](/documentation/ComputeGraph/PS_AVAILABILE)

[`PS_DEPRECATED`](/documentation/ComputeGraph/PS_DEPRECATED)

[`PS_ALWAYS_INLINE`](/documentation/ComputeGraph/PS_ALWAYS_INLINE)

[`PS_CONSTANT`](/documentation/ComputeGraph/PS_CONSTANT)

[`PS_DEVICE`](/documentation/ComputeGraph/PS_DEVICE)

[`PS_THREAD`](/documentation/ComputeGraph/PS_THREAD)

[`PS_THREADGROUP`](/documentation/ComputeGraph/PS_THREADGROUP)

[`PS_ENUM`](/documentation/ComputeGraph/PS_ENUM)

[`PS_INTERNAL`](/documentation/ComputeGraph/PS_INTERNAL)

[`ps_binding_type`](/documentation/ComputeGraph/ps_binding_type)

### Deprecated



---

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)