W3C home > Mailing lists > Public > public-fx@w3.org > January to March 2012

Re: Brightness filter in CSS Filters spec is wrong?

From: Chris Marrin <cmarrin@apple.com>
Date: Tue, 24 Jan 2012 16:12:16 -0800
Cc: public-fx@w3.org
Message-id: <84839006-B880-4517-AB6C-FD0417EB0508@apple.com>
To: Rik Cabanier <cabanier@gmail.com>

On Jan 24, 2012, at 11:05 AM, Rik Cabanier wrote:

> Not sure I follow.
> so instead of brightness:
> -1 < brightness < 0 -> color.rgb * (1-brightness)
> 0 < brightness < 1 -> color.rgb * (1-brightness) + vec3(brightness)
> it would be:
> -1 < darken < 1 -> color.rgb * (1-darken) 
> -1 < lighten < 1 -> color.rgb + vec3(lighten) 

Yes, that would give us a nice single filter for both brightening and darkening. But it's still a multiplicative (non-linear) operation which affects pixels differently based on their original value. A pixel value of 2 changes a lot less than a pixel value of 200. That's often useful, because it can make the light parts darker without affecting the dark parts as much. That's why brighten and darken exist. But it's not an additive (linear) approach, which brightens all pixels equally. 

I don't know which is better. But I have done the additive approach in WebKit and it is much more intuitive than the original, purely multiplicative approach.

Your approach is much better since it allows brightening all the way to white, which the original approach didn't. But I'm not sure whether its better to be linear or non-linear in this case. One thing is that we already have a multiplicative filter, in contrast(). So maybe a multiplicative contrast filter and additive brightness filter is the best combination?

Received on Wednesday, 25 January 2012 00:12:48 UTC

This archive was generated by hypermail 2.3.1 : Monday, 22 June 2015 03:33:46 UTC