Skip to content

Commit 9fc20f1

Browse files
mvaligurskyMartin Valigursky
andauthored
Add viewport / scissor support to RenderPassShaderQuad (playcanvas#8254)
Co-authored-by: Martin Valigursky <mvaligursky@snapchat.com>
1 parent 6b7699d commit 9fc20f1

1 file changed

Lines changed: 18 additions & 1 deletion

File tree

src/scene/graphics/render-pass-shader-quad.js

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import { RenderPass } from '../../platform/graphics/render-pass.js';
77
/**
88
* @import { Shader } from '../../platform/graphics/shader.js'
99
* @import { StencilParameters } from '../../platform/graphics/stencil-parameters.js'
10+
* @import { Vec4 } from '../../core/math/vec4.js'
1011
*/
1112

1213
/**
@@ -60,6 +61,22 @@ class RenderPassShaderQuad extends RenderPass {
6061
*/
6162
stencilBack = null;
6263

64+
/**
65+
* Optional viewport rectangle (x, y, width, height). If set, the quad renders only to this
66+
* region and the original viewport is restored after rendering.
67+
*
68+
* @type {Vec4|undefined}
69+
*/
70+
viewport;
71+
72+
/**
73+
* Optional scissor rectangle (x, y, width, height). If set, pixels outside this region are
74+
* discarded. Only used when viewport is also set. Defaults to the viewport if not specified.
75+
*
76+
* @type {Vec4|undefined}
77+
*/
78+
scissor;
79+
6380
/**
6481
* Sets the shader used to render the quad.
6582
*
@@ -92,7 +109,7 @@ class RenderPassShaderQuad extends RenderPass {
92109
device.setDepthState(this.depthState);
93110
device.setStencilState(this.stencilFront, this.stencilBack);
94111

95-
this.quadRender.render();
112+
this.quadRender?.render(this.viewport, this.scissor);
96113
}
97114
}
98115

0 commit comments

Comments
 (0)