---
title: "StencilState: interface in Runtime, TypeShade API reference"
description: "StencilState, an interface in Runtime. The stencil test of a pipeline."
url: https://typeshade.dev/api/stencilstate/
language: en
---

# `StencilState`

Interface in Runtime

The stencil test of a pipeline.

`import type { StencilState } from 'typeshade/runtime'`

The signature, the description and the examples come from the compiler's own source at commit af54ddad5.

## Syntax

```ts
interface StencilState extends StencilFaceState {
  readonly front?: StencilFaceState;
  readonly back?: StencilFaceState;
  readonly readMask?: number;
  readonly writeMask?: number;
  readonly reference?: number;
}
```

## Description

The four face fields apply to both faces.

## Instance properties

**`front` optional read only `StencilFaceState`**

stencilFront. Overrides for the front face. Each field replaces the shared field for that face.

**`back` optional read only `StencilFaceState`**

stencilBack. Overrides for the back face. Each field replaces the shared field for that face.

**`readMask` optional read only `number`**

stencilReadMask: 0 to 0xFFFFFFFF, default 0xFFFFFFFF. Both tiers keep the low 8 bits.

**`writeMask` optional read only `number`**

stencilWriteMask: 0 to 0xFFFFFFFF, default 0xFFFFFFFF. Both tiers keep the low 8 bits.

**`reference` optional read only `number`**

setStencilReference: the reference of each draw of this pipeline, which has `depth.stencil`. A whole number from 0 to 255. A fraction is refused. Unset, the draw sets the pass value. A declared reference overrides `pass.setStencilReference` for its draws.

## Source

[`src/runtime/program.ts`, line 135](https://github.com/typeshade/typeshade/blob/af54ddad5/src/runtime/program.ts#L135), at commit af54ddad5
