three.js icon indicating copy to clipboard operation
three.js copied to clipboard

InstancedPointsNodeMaterial: Add sizeAttenuation

Open RenaudRohlinger opened this issue 1 year ago • 4 comments

Related issue: #29394 #29374

Description

Second attempt following #29374 to add support for sizeAttenuation in InstancedPointsNodeMaterial as a fallback for THREE.Points.

This contribution is funded by Segments.AI & Utsubo

RenaudRohlinger avatar Sep 25 '24 14:09 RenaudRohlinger

📦 Bundle size

Full ESM build, minified and gzipped.

Before After Diff
WebGL 687.46
170.22
687.46
170.22
+0 B
+0 B
WebGPU 838.62
224.9
839.02
225.03
+404 B
+131 B
WebGPU Nodes 838.13
224.78
838.53
224.91
+404 B
+126 B

🌳 Bundle size after tree-shaking

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

Before After Diff
WebGL 463.24
111.86
463.24
111.86
+0 B
+0 B
WebGPU 533.78
143.98
533.78
143.98
+0 B
+0 B
WebGPU Nodes 490.12
133.72
490.12
133.72
+0 B
+0 B

github-actions[bot] avatar Sep 25 '24 14:09 github-actions[bot]

Sprites have a map, are sized in world units, can be size-attenuated, and can be rotated.

Points are sized in pixels, and are just a "fat" point-list primitive.

It doesn't make sense to size-attenuate something sized in pixels.

WestLangley avatar Sep 25 '24 15:09 WestLangley

Following numerous requests from developers, I'm attempting to offer a fallback solution to THREE.Points, as size attenuation on points larger than 1px is widely used especially since Points.sizeAttenuation is enabled by default.

While I understand that in certain cases, like InstancedPointsNodeMaterial, it may not seem logical to size-attenuate something rendered in pixels, the practical use of size attenuation remains prevalent across many projects.

If you strongly believe that size attenuation is unnecessary for InstancedPointsNodeMaterial, I'm open to creating a new class (e.g., PointsWebGPU) specifically to provide a fallback for THREE.Points in WebGPU. In that scenario, I also plan to rename pointWidth to size to facilitate a smoother transition from Points. Would this approach work for you?

RenaudRohlinger avatar Sep 25 '24 23:09 RenaudRohlinger

Thank you for your reply.

I would be happy if:

  1. (Instanced) sprites could be sized in world units, and points sized in pixels.
  2. Size attenuation set to true by default for sprites, but it can be disabled.
  3. Points cannot be size-attenuated.

If that is not acceptable for some reason, then an alternative could be to allow points to be sized in either pixels or world units -- but I prefer the solution above.

JMHO, of course. If you disagree, I will not object. :-)

WestLangley avatar Sep 25 '24 23:09 WestLangley