Skip to content

Conversation

Mugen87
Copy link
Collaborator

@Mugen87 Mugen87 commented Jul 10, 2025

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

Copy link

github-actions bot commented Jul 10, 2025

📦 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
@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
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;
Copy link
Owner

@mrdoob mrdoob Jul 16, 2025

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
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
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
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