Skip to content

Conversation

@Mugen87
Copy link
Collaborator

@Mugen87 Mugen87 commented Aug 21, 2025

Related issue: #31627 (comment)

Description

Makes sure PointsNodeMaterial generates the correct vertex shader for point primitives (which always have a size of 1 pixel in WebGPURenderer).

It also makes sure the scale factor introduced in #31627 and the DPR handling is implemented based on uniforms.

@Mugen87 Mugen87 added this to the r180 milestone Aug 21, 2025
@github-actions
Copy link

github-actions bot commented Aug 21, 2025

📦 Bundle size

Full ESM build, minified and gzipped.

Before After Diff
WebGL 338.91
79.1
338.91
79.1
+0 B
+0 B
WebGPU 576.19
158.93
576.49
159.04
+302 B
+112 B
WebGPU Nodes 574.8
158.69
575.1
158.8
+302 B
+111 B

🌳 Bundle size after tree-shaking

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

Before After Diff
WebGL 470.7
113.91
470.7
113.91
+0 B
+0 B
WebGPU 646.81
174.91
647.1
175.02
+290 B
+107 B
WebGPU Nodes 600.99
164.09
601.11
164.13
+120 B
+42 B

@Mugen87 Mugen87 merged commit e1ea0a0 into mrdoob:dev Aug 21, 2025
9 checks passed

const scale = /*@__PURE__*/ uniform( 1 ).onFrameUpdate( function ( { renderer } ) {

const dpr = renderer.getPixelRatio();
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is dpr applied in screenDPR and in scale intentional?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yes, since the scale computation should happen in pure JS.

You could compute everything in the shader but then you end up with more computations since you do redundant computations per vertex.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Actually, I was asking a different question. :-)

In any event, I found it. You introduced an error in your formula for scale. I'll file a PR.

My 2^n tests are looking better with this fixed.

const dpr = builder.renderer.getPixelRatio();

pointSize = pointSize.mul( dpr );
pointSize = pointSize.mul( screenDPR );
Copy link
Collaborator

Choose a reason for hiding this comment

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

Duplicating this line does not change the rendered output.

This appears to be returning 1, not the actual DPR.

Is there something about the context missing?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Ups, the correct update type is missing. I'll file a PR.

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.

2 participants