files/en-us/web/api/gpurenderpassencoder/setscissorrect/index.md
{{APIRef("WebGPU API")}}{{SecureContext_Header}}{{AvailableInWorkers}}
The setScissorRect() method of the
{{domxref("GPURenderPassEncoder")}} interface sets the scissor rectangle used during the rasterization stage. After transformation into viewport coordinates any fragments that fall outside the scissor rectangle will be discarded.
setScissorRect(x, y, width, height)
x
y
width
height
[!NOTE] If a
setScissorRect()call is not made, the default values are(0, 0, attachment width, attachment height)for each render pass.
None ({{jsxref("Undefined")}}).
The following criteria must be met when calling setViewport(), otherwise a {{domxref("GPUValidationError")}} is generated and the {{domxref("GPURenderPassEncoder")}} becomes invalid:
x + width is less than or equal to the width of the render pass's render attachments (see note below).y + height is less than or equal to the height of the render pass's render attachments (see note below).[!NOTE] See the color and depth/stencil attachments specified in the descriptor of {{domxref("GPUCommandEncoder.beginRenderPass()")}}; the width and height are based on that of the {{domxref("GPUTexture")}} that their
views originate from.
In a typical canvas render, the following could be used to discard any rendering outside of the top-left quarter of the canvas:
passEncoder.setScissorRect(0, 0, canvas.width / 2, canvas.height / 2);
{{Specifications}}
{{Compat}}