-
Notifications
You must be signed in to change notification settings - Fork 22.4k
/
index.md
60 lines (39 loc) · 1.43 KB
/
index.md
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
---
title: "GPURenderPassEncoder: setStencilReference() method"
short-title: setStencilReference()
slug: Web/API/GPURenderPassEncoder/setStencilReference
page-type: web-api-instance-method
status:
- experimental
browser-compat: api.GPURenderPassEncoder.setStencilReference
---
{{APIRef("WebGPU API")}}{{SeeCompatTable}}{{SecureContext_Header}}
The **`setStencilReference()`** method of the
{{domxref("GPURenderPassEncoder")}} interface sets the stencil reference value using during stencil tests with the `"replace"` stencil operation (as set in the descriptor of the {{domxref("GPUDevice.createRenderPipeline()")}} method, in the properties defining the various stencil operations).
## Syntax
```js-nolint
setStencilReference(reference)
```
### Parameters
- `reference`
- : A number representing the new stencil reference value to set for the render pass.
> **Note:** If a `setStencilReference()` call is not made, the stencil reference value defaults to 0 for each render pass.
### Return value
None ({{jsxref("Undefined")}}).
## Examples
```js
// ...
const passEncoder = commandEncoder.beginRenderPass(renderPassDescriptor);
passEncoder.setPipeline(renderPipeline);
passEncoder.setVertexBuffer(0, vertexBuffer);
passEncoder.setStencilReference(1);
passEncoder.draw(3);
passEncoder.end();
// ...
```
## Specifications
{{Specifications}}
## Browser compatibility
{{Compat}}
## See also
- The [WebGPU API](/en-US/docs/Web/API/WebGPU_API)