<!--
{
  "availability" : [
    "iOS: 27.0.0 -",
    "iPadOS: 27.0.0 -",
    "tvOS: 27.0.0 -",
    "visionOS: 27.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "RealityKit",
  "identifier" : "/documentation/RealityKit/LowLevelMaterialResource/SurfaceShader/Descriptor/init(named:in:constantValues:uniformsSize:)",
  "metadataVersion" : "0.1.0",
  "role" : "Initializer",
  "symbol" : {
    "kind" : "Initializer",
    "modules" : [
      "RealityKit"
    ],
    "preciseIdentifier" : "s:19RealityCoreRenderer24LowLevelMaterialResourceC13SurfaceShaderC10DescriptorV5named2in14constantValues12uniformsSizeAGSS_So10MTLLibrary_pSo019MTLFunctionConstantN0CSitcfc"
  },
  "title" : "init(named:in:constantValues:uniformsSize:)"
}
-->

# init(named:in:constantValues:uniformsSize:)

Creates a descriptor for a surface shader that accepts a custom uniforms argument buffer.

```
init(named name: String, in library: any MTLLibrary, constantValues: MTLFunctionConstantValues = .init(), uniformsSize: Int)
```

## Parameters

`name`

The name of the Metal function in the library.

`library`

The Metal library that contains the function.

`constantValues`

The Metal function constant values to specialize the function with. The function descriptor takes a snapshot of the constant values passed in.

`uniformsSize`

The size of the custom uniforms buffer, in bytes.

## Discussion

Use this initializer when your Metal surface shader function reads per-draw parameters
through a custom uniforms argument buffer, using the same mechanism as
[`CustomMaterial/withMutableUniforms(ofType:stage:_:)`](https://developer.apple.com/documentation/realitykit/custommaterial/withmutableuniforms(oftype:stage:_:)). The function must be
`[[stitchable]]` and declare the uniforms as a second `constant T &customParams`
parameter:

```cpp
[[stitchable]]
void mySurfaceShader(realitykit::surface_parameters params,
                     constant MyUniforms &customParams) { ... }
```

The renderer sizes the uniforms buffer to `uniformsSize` bytes and configures
the argument table automatically.

---

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)