Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Forums Adobe After Effects Expressions Adjust hue, brightness AND saturation through rgbtohsl?

  • Adjust hue, brightness AND saturation through rgbtohsl?

  • Lenny Mason

    December 1, 2019 at 1:24 pm


    I’m working on a preset to add grain to shape layers. I’m trying to set it up with slider controls and color controls to easily adjust the hue, brightness and saturation of the grain. So far I’ve been able to adjust the brightness of the grain color through expressions, linking it to the fill color of the shape layers. I’m now trying to write an expression so that I can also adjust the hue and the saturation of the grain color, but I can’t get it to work.

    This is my setup. It’d be great if I could link the Shadow Color of the layer style to the three seperate sliders. Does anyone know how?

    lightnessOffset = effect("Brightness")("Slider")
    hsl = rgbToHsl(content("Rectangle 1").content("Fill 1").color.value);
    hsl[2] = Math.max(0.0, Math.min(hsl[2]+lightnessOffset/100, 1));

  • Lenny Mason

    December 1, 2019 at 11:08 pm

    Alright, so far I’ve managed to write the following expression:

    if (effect("Lenny's Grain")("Shadow - Custom?") == 0 ? 100 : 0) {
    c = effect("Lenny's Grain")("Fill");
    hsl = rgbToHsl(c);
    factor = effect("Lenny's Grain")("Shadow - Lightness") / 55;
    newL = Math.min(hsl[2]*factor,1);
    } else {
    effect("Lenny's Grain")("Shadow - Color")

    So, if I turn the checkbox on to add a custom shadow color, you can pick your own color. If I turn the checkbox off, the shadow uses a color that updates automatically to the fill color of a Color Overlay layer style. This works fine, but I’d rather not use a Color Overlay, I’d rather make the shadow color adjust to the content fill. This works fine if I just change the code to:

    c = content(“Rectangle 1”).content(“Fill 1”).color

    But that would mean that the shape has to be a rectangle. Is there another way to target the content fill?

Viewing 1 - 2 of 2 posts

Log in to reply.

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