Skip to content

Conversation

@mrdoob
Copy link
Owner

@mrdoob mrdoob commented Dec 4, 2025

Related issue: #32449 (comment)

After thinking through it for a few days I think I would probably take the approach of converting to the target color space, applying alpha, and converting back to the working color space. This should be not so expensive in the grand scheme of things and only need to be run when premultiplied alpha is true and blending is enabled.

Screenshot 2025-12-04 at 04 47 50
Before After
Screenshot 2025-12-04 at 04 37 21 Screenshot 2025-12-04 at 04 37 54
Screenshot 2025-12-04 at 04 40 26 Screenshot 2025-12-04 at 04 40 41
Screenshot 2025-12-04 at 04 45 16 Screenshot 2025-12-04 at 04 45 30

It sure looks like an improvement!

@github-actions
Copy link

github-actions bot commented Dec 4, 2025

📦 Bundle size

Full ESM build, minified and gzipped.

Before After Diff
WebGL 350.26
83.01
350.03
83.02
-233 B
+16 B
WebGPU 616.03
171
616.03
171
+0 B
+0 B
WebGPU Nodes 614.64
170.74
614.64
170.74
+0 B
+0 B

🌳 Bundle size after tree-shaking

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

Before After Diff
WebGL 482.3
117.81
482.07
117.82
-233 B
+15 B
WebGPU 687.42
186.76
687.42
186.76
+0 B
+0 B
WebGPU Nodes 637.26
173.94
637.26
173.94
+0 B
+0 B

@gkjohnson
Copy link
Collaborator

To me this seems like a good, well targeted change. The last thing I would suggest is not deleting the "premultiplied_alpha_fragment" shader chunk because it will be a breaking change for anyone using it. And not all shaders use the "opaque_fragment" chunk, as you'll see in the LDrawConditionalLineMaterial.js‎ file. I often add it to the end of my shaders after setting the final gl_FragColor value in order to respect the premultiply alpha flag.

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.

3 participants