-
Notifications
You must be signed in to change notification settings - Fork 51
[css-compositing-2] Add lighter composite operator to mix-blend-mode #445
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
Comments
I threw a few more demos together for this over at https://jakearchibald.com/2021/dom-cross-fade/ |
(Shouldn't this issue be over here? ) I agree that the plus-lighter and plus-darker blend modes from Compositing-2 are useful. A sentence or two of explanation in the spec, in addition to the equations, would be helpful. |
As in, explaining how they're useful for cross-fading? |
Like the others have, for example
But yes, saying briefly why they are useful for cross fading would be good. |
@svgeesus do you know why |
I do not |
This issue is kinda a dupe of #181, except |
Yes! Transferred. |
PR and tests #444 |
Thanks for moving this to the right place @LeaVerou. Could you let me know what the approval/resolution process is from here? |
Updating the proposal based on the discussion here. I propose introducing "lighter" value for the CSS property mix-blend-mode. This would map to using normal blending and lighter compositing operation when an element with this property is composited with its backdrop. The proposal above follows the pattern of globalCompositeOperation in 2D Canvas which allows developers to configure both blend mode and compositing operators. The pattern is as follows :
The current proposal is limited to exposing the "lighter" compositing operator since the use-case here requires only this mode. But we can allow specifying any compositing operator going forward which would make mix-blend-mode consistent with the capabilities globalCompositeOperation provides for 2D canvas. |
WebKit already supports |
The CSS Working Group just discussed
The full IRC log of that discussion<TabAtkins> Topic: Add lighter composite operation<TabAtkins> github: https://github.com//issues/445 <smfr> q+ <TabAtkins> vmpstr: We'd like to add a plus-lighter to mix-blend-mode, and smfr says WebKit already supports plus-lighter and plus-darker <TabAtkins> vmpstr: They're comp operations, not blend, so they'd work in the same way that canvas works, where if you set a blend mode the comp op is src-over; if you set a comp op the blend mode is normal <Rossen_> ack smfr <chris> q+ <TabAtkins> smfr: Issue says lighter, bu tyou're asking for plus-lighter? <TabAtkins> vmpstr: I think the diff is just whether the color is clamped to 1 <TabAtkins> vmpstr: Okay for our use-case either way <TabAtkins> smfr: Preferable to me, because our graphics framework doesn't support lighter. plus-lighter is fine <TabAtkins> vmpstr: That's fine for us, yes. <Rossen_> ack chris <TabAtkins> chris: Good to see the alignment between CSS and Canvas as well. <TabAtkins> chris: This'll be in Compositing 2? Have we had FPWD? <TabAtkins> Rossen_: Don't think so <TabAtkins> chris: Okay to request that? <TabAtkins> Rossen_: Resolve on this issue first. <TabAtkins> Rossen_: Objectiosn to adding plus-lighter and plus-darker? <TabAtkins> RESOLVED: Add plus-lighter and plus-darker to mix-blend-mode in Compositing 2. <TabAtkins> fantasai: Might want to give a chance to review, so fpwd next year. <TabAtkins> Rossen_: Yeah, let's call for it next y ear. |
@smfr Can you give me a practical example of |
Safari doesn't support |
Ok, I'm a bit stuck trying to write tests for
That just doesn't make sense. |
Spec and tests have landed. This can be closed. |
This issue proposes adding "plus-lighter" to the list of blend modes specified in the Compositing and Blending spec. This blend mode is useful when cross-fading 2 elements for which all or a subset of pixels have identical color values. An example showing the problem is here : https://static-misc-3.glitch.me/composite-test/2.html.
Consider 2 elements each having a pixel with value C. These 2 elements are multiplied with opacity α and (1-α) respectively and placed in an isolated group. When blending using the 'normal' blend mode, the resulting pixel value is produced by source over compositing of the 2 elements :
Co = αs x Cs + αb x Cb x (1 – αs).
In this example, Cs = Cb = C; αs = α; αb = (1-α), which results in the follow color :
C0 = C x ( 1 - α + α^2);
For α = 0.5, this would be C x 0.75 while the desired result is C x 1.
The proposed "plus-lighter" blend-mode will add the source and backdrop color value : B(Cb, Cs) = min(Cb x αb + Cs x αs, 1). The backdrop is replaced by the result of this blending operation. For the example above this would result in :
Co = min(C x α + C x (1 - α)) = C
This issue is related to the proposal in w3c/csswg-drafts#6464 with the problem referenced in the explainer under cross-fading
The text was updated successfully, but these errors were encountered: