# Re: ISSUE-2095 (soft-light blend mode): Algorithm for soft-light blend mode [Module: Filters]

From: Benjamin Otte <otte@gnome.org>
Date: Thu, 09 Oct 2008 07:01:38 +0000
Message-ID: <a4ed255b0810090001l25cf52f5gcaecd3dabcac4b4f@mail.gmail.com>
To: "Alex Danilo" <alex@abbra.com>
Cc: "SVG Working Group WG" <public-svg-wg@w3.org>

Adobe has published the blend modes used in PDF at
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 <alex@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
>
>
Received on Thursday, 9 October 2008 07:05:11 UTC

This archive was generated by hypermail 2.4.0 : Friday, 17 January 2020 22:54:20 UTC