Skip to content

PassNode: Provide viewport and scissor API.#31390

Merged
Mugen87 merged 6 commits into
mrdoob:devfrom
Mugen87:dev1
Jul 11, 2025
Merged

PassNode: Provide viewport and scissor API.#31390
Mugen87 merged 6 commits into
mrdoob:devfrom
Mugen87:dev1

Conversation

@Mugen87

@Mugen87 Mugen87 commented Jul 10, 2025

Copy link
Copy Markdown
Collaborator

Fixed #31387

Description

It is currently not possible to define a custom viewport and scissor box when using pass(). The PR introduces setViewport() and setScissor() for custom value definition.

So in #31387, the OP must use below code in the render loop:

const dim = 128;
const x = renderer.domElement.offsetWidth - dim;
const y = renderer.domElement.offsetHeight - dim;

mapPass.setViewport( x, y, dim, dim );
//  renderer.setViewport(x, y, dim, dim); // previously

@github-actions

github-actions Bot commented Jul 10, 2025

Copy link
Copy Markdown

📦 Bundle size

Full ESM build, minified and gzipped.

Before After Diff
WebGL 338.37
78.95
338.37
78.95
+0 B
+0 B
WebGPU 558.42
154.55
558.42
154.55
+0 B
+0 B
WebGPU Nodes 557.34
154.34
557.34
154.34
+0 B
+0 B

🌳 Bundle size after tree-shaking

Minimal build including a renderer, camera, empty scene, and dependencies.

Before After Diff
WebGL 469.6
113.66
469.6
113.66
+0 B
+0 B
WebGPU 634.09
171.59
634.09
171.59
+0 B
+0 B
WebGPU Nodes 589.22
160.94
589.22
160.94
+0 B
+0 B

@sunag sunag added this to the r179 milestone Jul 10, 2025
Comment thread src/nodes/display/PassNode.js Outdated
Comment thread src/nodes/display/PassNode.js Outdated
Comment thread src/nodes/display/PassNode.js Outdated
@Mugen87 Mugen87 merged commit 906211f into mrdoob:dev Jul 11, 2025
7 of 8 checks passed
this._layers = null;

/**
* Scales the resolution of the internal render taregt.

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: taregt > target

* @type {?Vector4}
* @default null
*/
this._customViewport = null;

@mrdoob mrdoob Jul 16, 2025

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about just this._viewport = null;?
If it's null it just uses the renderer one.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've fixed the typo and renamed the properties but the fallback to the renderer viewport and scissor needs a bit more though.

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

* @type {?Vector4}
* @default null
*/
this._customScissor = null;

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about just this._scissor = null;?
If it's null it just uses the renderer one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Viewport rendering with PostProcessing renderer

4 participants