Skip to content

Src: Correct the blending formulas #31246

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: dev
Choose a base branch
from

Conversation

WestLangley
Copy link
Collaborator

Correct the blending formulas for WebGLRenderer, and for both backends of WebGPURenderer.

The NormalBlending formulas are correct, so no changes are needed.

AdditiveBlending had a minor error, which is fixed.

SubtractiveBlending and MultiplyBlending have never been correct. The changes here align with the behavior familiar to Photoshop users.

... more comments later ...

@WestLangley WestLangley added this to the r178 milestone Jun 8, 2025
Copy link

github-actions bot commented Jun 8, 2025

📦 Bundle size

Full ESM build, minified and gzipped.

Before After Diff
WebGL 337.4
78.67
337.53
78.73
+129 B
+52 B
WebGPU 554.99
153.61
555.29
153.68
+302 B
+75 B
WebGPU Nodes 554.34
153.46
554.64
153.53
+302 B
+74 B

🌳 Bundle size after tree-shaking

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

Before After Diff
WebGL 468.59
113.33
468.72
113.38
+129 B
+50 B
WebGPU 630.02
170.38
630.32
170.46
+302 B
+76 B
WebGPU Nodes 584.87
159.73
585.17
159.81
+302 B
+75 B

@WestLangley
Copy link
Collaborator Author

Ephemeral test link, not included in the PR.

https://raw.githack.com/westlangley/three.js/dev-blend-examples/examples/webgl_blend_test_2.html.

For MultiplyBlending and SubtractiveBlending the opacity of the blend layer controls the intensity of the effect -- not the opacity of the result.

@WestLangley WestLangley marked this pull request as ready for review June 9, 2025 05:03
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.

1 participant