Skip to content

Conversation

@Mugen87
Copy link
Collaborator

@Mugen87 Mugen87 commented Nov 10, 2025

Fixed #32229.

Description

As suggested in #32229 (comment), the PR makes sure the wide line implementation for WebGPURenderer uses CSS pixel units to ensure consistent line widths across devices. For this, the DPR must be factored out of the viewport.

With this PR, the wide line demos now render with equal width for WebGPURenderer and WebGLRenderer.

@Mugen87 Mugen87 requested a review from WestLangley November 10, 2025 09:13
@github-actions
Copy link

📦 Bundle size

Full ESM build, minified and gzipped.

Before After Diff
WebGL 356.24
86.48
356.24
86.48
+0 B
+0 B
WebGPU 610.49
171.27
610.5
171.28
+8 B
+7 B
WebGPU Nodes 609.1
171.01
609.1
171.02
+8 B
+8 B

🌳 Bundle size after tree-shaking

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

Before After Diff
WebGL 488.02
121.25
488.02
121.25
+0 B
+0 B
WebGPU 679.43
186.52
679.43
186.52
+0 B
+0 B
WebGPU Nodes 621.15
169.7
621.15
169.7
+0 B
+0 B


// adjust for clip-space to screen-space conversion // maybe resolution should be based on viewport ...
offset.assign( offset.div( viewport.w ) );
offset.assign( offset.div( viewport.w.div( screenDPR ) ) );
Copy link
Collaborator

Choose a reason for hiding this comment

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

In the library, viewport is sometimes defined in physical pixels, and other times in logical pixels. It would be a lot better if there was consistency in this regard -- or improved nomenclature. Perhaps @sunag and @Mugen87 could come to an agreement on this.

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 agree with what @sunag has defined in #29347.

Copy link
Collaborator

Choose a reason for hiding this comment

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

This bug occurred because the definitions are not consistent.

renderer.setViewport() is in logical pixel units. Can you improve the nomenclature?

Copy link
Collaborator Author

@Mugen87 Mugen87 Nov 10, 2025

Choose a reason for hiding this comment

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

I think there is a difference with what is defined via the renderer API and what TSL objects represent in the shader. That has been mentioned here #29347 (comment). I don't think you can come up with a solution that satisfies every use case. Keeping the TSL objects in physical pixel units seems correct to me. And I would leave the renderer API as it is, especially to avoid any kind of breakage.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Keeping the TSL objects in physical pixel units seems correct to me.

Yes.

And I would leave the renderer API as it is,

Yes.

So the only possible changes are in the margins: revist the docs and inline docs and ensure the units are clearly stated.

Also the internal nomenclature could be reviewed.

_viewport // logical (css) pixel units

_currentViewport // physical pixel units

state.viewport // physical pixel units

@Mugen87 Mugen87 merged commit 8173be8 into mrdoob:dev Nov 10, 2025
10 checks passed
@Mugen87 Mugen87 added this to the r182 milestone Nov 10, 2025
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.

LineMaterial VS Line2NodeMaterial

2 participants