Skip to content

Update additive blend mode to multiply alpha#82

Merged
cklosters merged 3 commits into0.8from
blend_additive
Feb 19, 2025
Merged

Update additive blend mode to multiply alpha#82
cklosters merged 3 commits into0.8from
blend_additive

Conversation

@lshoek
Copy link
Contributor

@lshoek lshoek commented Feb 10, 2025

I think it would make more sense if the Additive blend function takes source alpha into account. This will resolve the same final color independent of ordering. Below an example where I'm rendering point sprites with alpha as a distance function in the fragment shader.

Original additive blending:

srcAlphaBlendFactor = VK_BLEND_FACTOR_ONE;
dstAlphaBlendFactor = VK_BLEND_FACTOR_ONE;
srcColorBlendFactor = VK_BLEND_FACTOR_ONE;
dstColorBlendFactor = VK_BLEND_FACTOR_ONE;

Screenshot from 2025-02-10 09-47-47

Updated additive blending:

srcAlphaBlendFactor = VK_BLEND_FACTOR_ONE;
dstAlphaBlendFactor = VK_BLEND_FACTOR_ZERO;
srcColorBlendFactor = VK_BLEND_FACTOR_SRC_ALPHA;
dstColorBlendFactor = VK_BLEND_FACTOR_ONE;

Screenshot from 2025-02-10 09-45-56

This update could change the look of existing projects. Alternatively we could add this under the name AdditiveBlend or something like that.

@lshoek lshoek added enhancement New feature or request rendering Render related Questions & Issues labels Feb 10, 2025
Copy link
Member

@cklosters cklosters left a comment

Choose a reason for hiding this comment

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

I'm ok with this change as it makes more sense when using the additive blend mode, but we should merge it into 0.8 because it's potentially a breaking change

@cklosters cklosters changed the base branch from main to 0.8 February 18, 2025 12:29
@cklosters cklosters merged commit 97e2f55 into 0.8 Feb 19, 2025
3 checks passed
@cklosters cklosters deleted the blend_additive branch February 19, 2025 09:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request rendering Render related Questions & Issues

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants