<!--
{
  "availability" : [
    "iOS: 27.0.0 -",
    "iPadOS: 27.0.0 -",
    "macOS: 27.0.0 -",
    "tvOS: 27.0.0 -",
    "visionOS: 27.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "RealityKit",
  "identifier" : "/documentation/RealityKit/ComputeGraphSharedUniforms",
  "metadataVersion" : "0.1.0",
  "role" : "Class",
  "symbol" : {
    "kind" : "Class",
    "modules" : [
      "RealityKit",
      "ComputeGraph"
    ],
    "preciseIdentifier" : "s:24_RealityKit_ComputeGraph0cD14SharedUniformsC"
  },
  "title" : "ComputeGraphSharedUniforms"
}
-->

# ComputeGraphSharedUniforms

A transient component that stores typed uniform values shared across all ComputeGraph simulations.

```
class ComputeGraphSharedUniforms
```

## Overview

You add scene-wide uniforms via a `ComputeGraphSharedUniforms` — such as
gravity, wind, attractor locations, or a global time offset.

> Note: Only one instance of this component should exist in a scene at a time.

## Topics

### Initializers

[`init()`](/documentation/RealityKit/ComputeGraphSharedUniforms/init())

Creates an empty `ComputeGraphSharedUniforms` component.

### Instance Methods

[`func setUniform<V>(borrowing V)`](/documentation/RealityKit/ComputeGraphSharedUniforms/setUniform(_:))

Stores a uniform value, replacing any previously stored value of the same type.

[`func setUniformTransform<V>((V, Entity) -> V)`](/documentation/RealityKit/ComputeGraphSharedUniforms/setUniformTransform(_:))

Registers a closure that transforms a uniform value of type `V` on a per-entity basis.

[`func setUniformTransform<V>(type: V.Type, transform: (inout MutableRawSpan, Entity) -> Void)`](/documentation/RealityKit/ComputeGraphSharedUniforms/setUniformTransform(type:transform:))

Registers a raw-data transformer closure for a uniform of type `V`.

[`func uniform<V>(V.Type) -> V?`](/documentation/RealityKit/ComputeGraphSharedUniforms/uniform(_:))

Returns the stored uniform value for the given type, or `nil` if none has been set.

## Relationships

### Conforms To

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

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

---

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)