---
title: "setStencilReferenceValue(_:)"
framework: metal
role: symbol
role_heading: Instance Method
path: "metal/mtlrendercommandencoder/setstencilreferencevalue(_:)"
---

# setStencilReferenceValue(_:)

Configures the same comparison value for front- and back-facing primitives.

## Declaration

```swift
func setStencilReferenceValue(_ referenceValue: UInt32)
```

## Parameters

- `referenceValue`: A stencil test comparison value the render pipeline applies to both front- and back-facing primitives.

## Discussion

Discussion The command sets the same reference value for front- and back-facing primitives (see stencilCompareFunction, frontFaceStencil, and backFaceStencil). This reference value applies to the stencil state you set with the setDepthStencilState(_:) method. The render pass’s default reference value for the front and back stencil compare function is 0.

## See Also

### Configuring depth and stencil behavior

- [setDepthStencilState(_:)](metal/mtlrendercommandencoder/setdepthstencilstate(_:).md)
- [setDepthBias(_:slopeScale:clamp:)](metal/mtlrendercommandencoder/setdepthbias(_:slopescale:clamp:).md)
- [setDepthClipMode(_:)](metal/mtlrendercommandencoder/setdepthclipmode(_:).md)
- [setDepthTestBounds(_:)](metal/mtlrendercommandencoder/setdepthtestbounds(_:).md)
- [setStencilReferenceValues(front:back:)](metal/mtlrendercommandencoder/setstencilreferencevalues(front:back:).md)
