<!--
{
  "availability" : [
    "iOS: 27.0.0 -",
    "iPadOS: 27.0.0 -",
    "macCatalyst: 27.0.0 -",
    "macOS: 27.0.0 -",
    "tvOS: 27.0.0 -",
    "visionOS: 27.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "RealityKit",
  "identifier" : "/documentation/RealityKit/PortalMaterial/Program-swift.struct/Descriptor-swift.struct/constantValues",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Property",
  "symbol" : {
    "kind" : "Instance Property",
    "modules" : [
      "RealityKit"
    ],
    "preciseIdentifier" : "s:17RealityFoundation14PortalMaterialV7ProgramV10DescriptorV14constantValuesSo019MTLFunctionConstantH0Cvp"
  },
  "title" : "constantValues"
}
-->

# constantValues

Values for the function-constant inputs that the shader graph
declares.

```
var constantValues: MTLFunctionConstantValues
```

## Discussion

Function constants are baked into the compiled shader at program
creation time and can’t be changed afterward. Use them for
values that don’t vary at runtime — for example, a feature flag
that selects between two code paths — to eliminate runtime
branching and produce a leaner shader. To vary a value across
frames or instances, declare it as a regular graph input and
supply it through [`inputValues`](/documentation/RealityKit/PortalMaterial/Program-swift.struct/Descriptor-swift.struct/inputValues) or
[`setParameter(name:value:)`](/documentation/RealityKit/PortalMaterial/setParameter(name:value:)) instead.

Two descriptors that share the same shader graph but differ in
their function-constant values produce distinct compiled
programs that don’t compare equal.

---

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)