---
title: "setStencilReferenceValues(front:back:)"
framework: metal
role: symbol
role_heading: Instance Method
path: "metal/mtlrendercommandencoder/setstencilreferencevalues(front:back:)"
---

# setStencilReferenceValues(front:back:)

Configures different comparison values for front- and back-facing primitives.

## Declaration

```swift
func setStencilReferenceValues(front frontReferenceValue: UInt32, back backReferenceValue: UInt32)
```

## Parameters

- `frontReferenceValue`: A stencil test comparison value the render pipeline applies to only front-facing primitives.
- `backReferenceValue`: A stencil test comparison value the render pipeline applies to only back-facing primitives.

## Discussion

Discussion The command sets separate reference values for front- and back-facing primitives (see stencilCompareFunction, frontFaceStencil, and backFaceStencil). These reference values apply 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)
- [setStencilReferenceValue(_:)](metal/mtlrendercommandencoder/setstencilreferencevalue(_:).md)
