Skip to content

Renderers: 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

Merged
merged 2 commits into from
Jun 10, 2025
Merged

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

WestLangley commented Jun 9, 2025

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
@sunag sunag merged commit 4ee7352 into mrdoob:dev Jun 10, 2025
12 checks passed
@WestLangley WestLangley deleted the dev-blend_modes branch June 10, 2025 17:15
@Mugen87
Copy link
Collaborator

Mugen87 commented Jun 10, 2025

I've added a note about this change in the migration guide: https://github.com/mrdoob/three.js/wiki/Migration-Guide#177--178

@WestLangley WestLangley changed the title Src: Correct the blending formulas Renderers: Correct the blending formulas Jun 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.

3 participants