---
title: "init(named:in:constantValues:uniformsSize:)"
framework: realitykit
role: symbol
role_heading: Initializer
path: "realitykit/lowlevelmaterialresource/surfaceshader/descriptor/init(named:in:constantvalues:uniformssize:)"
---

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

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

## Declaration

```swift
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.
- `uniformsSize`: The size of the custom uniforms buffer, in bytes.

## Discussion

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 withMutableUniforms(ofType:stage:_:). The function must be [[stitchable]] and declare the uniforms as a second constant T &customParams parameter: [[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.

## See Also

### Creating a descriptor

- [init(named:in:constantValues:)](realitykit/lowlevelmaterialresource/surfaceshader/descriptor/init(named:in:constantvalues:).md)
- [init(named:in:constantValues:uniformsType:)](realitykit/lowlevelmaterialresource/surfaceshader/descriptor/init(named:in:constantvalues:uniformstype:).md)
