Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Forums Adobe After Effects Expressions Expression to control Brightness (HSB) over Luminance (HSL)

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

  • Chris Voelz

    July 9, 2020 at 6:48 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.

  • Filip Vandueren

    July 9, 2020 at 8:09 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]

  • Chris Voelz

    July 9, 2020 at 8:49 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.

  • Filip Vandueren

    July 9, 2020 at 9:10 pm

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

    http://colorizer.org/

Viewing 1 - 4 of 4 posts

Log in to reply.

We use anonymous cookies to give you the best experience we can.
Our Privacy policy | GDPR Policy