- From: Jasper St. Pierre via GitHub <sysbot+gh@w3.org>
- Date: Tue, 26 Dec 2023 23:22:44 +0000
- To: public-fxtf-archive@w3.org
The logic in here is hard to follow. The original expression that CoreCG has is: `1 - ((1 - S) + (1 - D))`. This effectively works out to `S + D - 1`. It's additive, but there's an extra -1 tossed into one of the sides for good measure. That doesn't give you the generalized formula for blending with alpha, though.
> However, my formula was sort of close; it appears (based on fiddling with my test) that what Safari implements for `plus-darker` is:
>
> co = min(1, αs + αb) - min(1, αs x (1 - Cs) + αb x (1 - Cb));
> αo = min(1, αs + αb);
I don't have an easy system to test CoreCG with, so I'm going to assume this is the actual formula. `min(1, ...)` on the left here is loadbearing, perhaps unintentionally. It's what's stopping this from becoming the same as plus-lighter. Normally, `αs + αb` would add to 2.0 for two opaque images, but since the min caps it to 1 it effectively adds the `- 1` bias on the right-hand side. Note, however, that if you have two images with alphas that don't add to more than 1, it becomes the same as plus-lighter.
There are some other formulas that you could come up with, like `S + D - Sa*Da` that I think would try to take this into account, but I can't think of any correct way to blend darker that doesn't make compromises somewhere.
> Comments in Apple source code say:
>
> ```
> // /* R = MAX(0, 1 - ((1 - D) + (1 - S))). {R, S and D are premultiplied
> // so actually R = MAX(0, (Da+Sa) - ((Da - D) + (Sa - S))) } */
> // = MAX(0, Da + Sa - Da + D - Sa + S
> // = MAX(0, D + S)
> ```
This is clearly incorrect, as should be evidenced by the resulting formula being effectively the same as plus-lighter (additive blending). You can't swap out the 1 for both "Da+Sa" and "Da"/"Sa" without a clamp.
--
GitHub Notification of comment by magcius
Please view or discuss this issue at https://github.com/w3c/fxtf-drafts/issues/447#issuecomment-1869817982 using your GitHub account
--
Sent via github-notify-ml as configured in https://github.com/w3c/github-notify-ml-config
Received on Tuesday, 26 December 2023 23:22:46 UTC