Re: Brightness filter in CSS Filters spec is wrong?

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?

-----
~Chris
cmarrin@apple.com

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