| From | Sent On | Attachments |
|---|---|---|
| SVG Working Group Issue Tracker | Oct 8, 2008 2:31 pm | |
| Alex Danilo | Oct 8, 2008 9:29 pm | |
| Alex Danilo | Oct 9, 2008 3:22 am | |
| Alex Danilo | Oct 9, 2008 2:31 pm | |
| Anthony Grasso | Feb 12, 2009 4:31 pm |
| Subject: | Re: ISSUE-2095 (soft-light blend mode): Algorithm for soft-light blend mode [Module: Filters] | |
|---|---|---|
| From: | Alex Danilo (al...@abbra.com) | |
| Date: | Oct 9, 2008 3:22:35 am | |
| List: | org.w3.public-svg-wg | |
Hi Benjamin,
In that case you should use that as the definitive formula. As I said, we had to try to work it out by help of others reverse engineering work. A pixel by pixel comparison of all input values against the PDF viewer should be used to verify that it's correct.
_But_, as I said before we had to extend the formulas to take into account alpha. There's no alpha in the formulas you quoted, so you will need to derive the correct formulas based on source and destination alpha to give the correct result for the general case. Opaque blends are just a subset of what is needed.
Alex
--Original Message--:
Adobe has published the blend modes used in PDF at http://www.adobe.com/devnet/pdf/pdfs/blend_modes.pdf It defines soft-light as
if (Sc <= 0.5) Dc' = Dc - (1 - 2.Sc).Dc.(1-Dc) otherwise Dc' = Dc + (2.Sc - 1) . (F(Dc) - Dc)
with if (x <= 0.25) F(x) = ((16.x - 12).x + 4).x otherwise F(x) = x
which is slightly different from the formula you presented. It is also easier to implement as it doesn't involve square roots.
Cheers, Benjamin
On Thu, Oct 9, 2008 at 6:30 AM, Alex Danilo <al...@abbra.com> wrote:
Hi All,
--Original Message--:
ISSUE-2095 (soft-light blend mode): Algorithm for soft-light blend mode [Module:
Filters]
http://www.w3.org/Graphics/SVG/WG/track/issues/2095
Raised by: Doug Schepers On product: Module: Filters
Benjamin Otte <http://lists.w3.org/Archives/Public/www-svg/2008Oct/0029.html>: [[ I'm in the process of implementing bend modes in the Cairo imaging library[1]. As Cairo is used as the renderer for a wide variety of formats, I wanted to have an as comprehensive list of blend modes as possible. And it turns out that the blend mode algorithms used are almost always equal. However, there is one exception: soft-light. The latest SVG draft specifies a different algorithm than PDF.
So I was wondering if it was possible to change the algorithm in SVG to match the one of PDF, as that would solve a lot of problems. ]]
If there is a discrepancy it is a mistake.
While I was working on this, we had to deduce the functions from various sources, since the equations were not published. The starting point was some Japanese site that had reverse engineered the equations from looking at Photoshop. We extended the base equations to include alpha correctly.
These were always supposed to be compatible with PDF.
Implementing this showed up bugs in compatibility which were fixed but probably never made it out to the spec. I believe the correct equations are:
if 2.Sca < Sa
Dca' = Dca.(Sa + (1 - Dca/Da).(2.Sca - Sa)) + Sca.(1 - Da) + Dca.(1 - Sa)
otherwise if 8.Dca <= Da
Dca' = Dca.(Sa + (1 - Dca/Da).(2.Sca - Sa).(3 - 8.Dca/Da)) + Sca.(1 - Da) +
Dca.(1 - Sa)
otherwise
Dca' = (Dca.Sa + ((Dca/Da)^(0.5).Da - Dca).(2.Sca - Sa)) + Sca.(1 - Da) +
Dca.(1 - Sa)
Da' = Sa + Da - Sa.Da
which is different to what is in the latest published spec. Adobe had an action
to
check the equations many years ago which was never acted on. Hopefully the
above equation is what you expected, if not please point us to the references
that
are causing issues for you.
Thanks, Alex





