ADOBE AFTER EFFECTS: Forum Expressions Tutorials Creative Cloud

Expression to control Brightness (HSB) over Luminance (HSL)

COW Forums : Adobe After Effects Expressions

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Chris Voelz
Expression to control Brightness (HSB) over Luminance (HSL)
on Jul 9, 2020 at 6:48:39 pm

I know how to use luminance to drive an expression, but I'm having issues with those values. It's my understanding that Luminance is an average of all color values (RGB). Where Brightness is a control of how much white vs black is added when using HSB values. Since you can create color using HSB in AE I need to reference the "B" value of a layers color.

I have this on Opacity of the layer I am trying to control.
c = thisComp.layer("Color").content("Group 1").content("Fill 1").color;
L = rgbToHsl(c)[2];
(L < .6) ? [50] : [0]

This works partially, but saturated colors cause the opacity to be set to 50%. I would like the expression to trigger if brightness is above 60%. I have tried adding in Saturation as value too, but that doesn't work either. Ideally I would like the expression triggered based off the Brightness of the color and not the Luminance. Is there anyway at all to do this? Thank you.


Return to posts index

Filip Vandueren
Re: Expression to control Brightness (HSB) over Luminance (HSL)
on Jul 9, 2020 at 8:09:57 pm

Hi Chris,

the formula for Brightness from RGB, is just the highest value of the three:


c = thisComp.layer("Color").content("Group 1").content("Fill 1").color;
B = Math.max(c[0],c[1],c[2]);

(B < .6) ? [50] : [0]




Return to posts index

Chris Voelz
Re: Expression to control Brightness (HSB) over Luminance (HSL)
on Jul 9, 2020 at 8:49:08 pm

Thank you! I have been trying hard to find documentation on how to understand that. The banging of my forehead on the desk can now end.


Return to posts index


Filip Vandueren
Re: Expression to control Brightness (HSB) over Luminance (HSL)
on Jul 9, 2020 at 9:10:41 pm

I thought it was the maximum, and quickly double checked here:

http://colorizer.org/



Return to posts index

<< PREVIOUS   •   VIEW ALL   •   PRINT   •   NEXT >>
© 2020 CreativeCOW.net All Rights Reserved
[TOP]