W3C home > Mailing lists > Public > www-svg@w3.org > July 2012

Re: Compositing math in SVG

From: Rik Cabanier <cabanier@gmail.com>
Date: Sun, 15 Jul 2012 18:30:44 -0700
Message-ID: <CAGN7qDAo98nDq1eXOkiUWhX_Kp_ovRwKZfv1v69btM4UVmmJxA@mail.gmail.com>
To: Calculemus <calculemus1988@gmail.com>
Cc: www-svg@w3.org
On Sat, Jul 14, 2012 at 12:23 AM, Calculemus <calculemus1988@gmail.com>wrote:

> I am optimizing the blend modes and over. I got stuck with color dodge.
>
> This is the general compositing formula from SVG spec, for
> over and some blend mode B:
>
> result = alpha_a * (1-alpha_b) * Cs + alpha_a * alpha_b * B(Cb,Cs) +
> alpha_b * (1-alpha_a) * Cb
>
> and the code for color dodge is:
>
> float colordodge (float Cb, float Cs) {
>     if (b == 1) return 1;
>     return min (1.0f, Cb/(1-Cs));
> }
>
> I am not sure if I can ignore the clamping part and just use Cb/(1-Cs) for
> B(Cb,Cs) in the
> general compositing formula, and then simplify it. And, only then clamp.
>

No, you need to clamp after blending.
In the case of colordodge, what happens if Cs is 1 and you divide by zero?
If you get infinity and the min(1, infinity) returns 1, you're set. (This
is not clamping)


>
> Are there completely reduced versions of the combinations of blend modes
> with over somewhere?
>
> The existing SVG spec should have them but they might not be in an obvious
notation.
Received on Monday, 16 July 2012 01:31:12 GMT

This archive was generated by hypermail 2.3.1 : Friday, 8 March 2013 15:54:51 GMT