Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions linking luminace value to scale

  • linking luminace value to scale

    Posted by Criis Daw on March 16, 2010 at 5:12 pm

    Hi can anyone help me please.

    I am trying to create an expression where the luminace value of a layer dictates the z scale value of a precomp above it. I want it to work like a displacement map so the precomps scale at different values depending on the luminosity of the displacement image.

    I need to know how to write an expression that will determine what point of the displacment map to take the value from.

    Make sense ?

    Hope some one can help

    Cheers

    Dan Ebberts replied 15 years, 6 months ago 3 Members · 13 Replies
  • 13 Replies
  • Dan Ebberts

    March 16, 2010 at 5:24 pm

    Something like this should work:

    minScale = 0;
    maxScale = 100;
    L = thisComp.layer(“displacement image”);
    sampleSize = 1;
    point = L.fromWorld(toWorld(anchorPoint));
    sample = L.sampleImage(point,[sampleSize,sampleSize]/2,true,time);
    lightness = rgbToHsl(sample)[2];
    s = linear(lightness,0,1,minScale,maxScale);
    [s,s]

    Dan

  • Criis Daw

    March 16, 2010 at 5:29 pm

    Thanks Dan,

    I think i can get my head round it. Did you just write that ?
    I am very impressed…

  • Dan Ebberts

    March 16, 2010 at 5:34 pm

    I did. But I’ve had a lot of practice…. 🙂

    Dan

  • Criis Daw

    March 16, 2010 at 5:41 pm

    well its working….

    but the x and y are scaling and the z remaining the same. Its the reverse I am after.
    I am tying to work it out but ……

  • Dan Ebberts

    March 16, 2010 at 5:45 pm

    Sorry – that’s what I get for reading too fast. Try this:

    minScale = 0;
    maxScale = 100;
    L = thisComp.layer(“displacement image”);
    sampleSize = 1;
    point = L.fromWorld(toWorld(anchorPoint));
    sample = L.sampleImage(point,[sampleSize,sampleSize]/2,true,time);
    lightness = rgbToHsl(sample)[2];
    s = linear(lightness,0,1,minScale,maxScale);
    [value[0],value[1],s]

    Dan

  • Criis Daw

    March 16, 2010 at 5:53 pm

    Thanks i worked it out !
    well almost .

    i changed the last line to

    [50,50,s]

    and typed in suitable x,y values (50) and it works like i want.

    what does the command (value) meam / make it do ?

    thanks for your help.

  • Dan Ebberts

    March 16, 2010 at 5:59 pm

    value just retrieves the pre-expression, keyframed (or static) value. So if you set the scale of the layer to 50%, both versions should give you the same result.

    Dan

  • Criis Daw

    March 16, 2010 at 6:04 pm

    thanks for your help

    little by little I am getting better at them.

    I can even more or less understand the body of the one you sent me. Its a bit like learning a foreign language. Reading often comes more easily than speaking (well correctly at least) .

    again many thanks

    Chris

  • Anton Arkh

    August 19, 2010 at 1:19 pm

    Hello! I am a complete novice when it comes to expressions, so I have no idea how to create anything more complex than a wiggle expression.

    How easy is it to adapt this code that Dan wrote to a lens flare brightness? I have a black/white image that I want to use as a mask, so when the Flare Center is over the white area, the Flare Brightness goes up, when its over black, it’s at 0%

    Thank you very much in advance!

  • Dan Ebberts

    August 19, 2010 at 5:43 pm

    This should work:


    minBrightness = 0;
    maxBrightness = 100;
    L = thisComp.layer("your mask image");
    sampleSize = 1;
    point = L.fromWorld(toWorld(effect("Lens Flare")("Flare Center")));
    sample = L.sampleImage(point,[sampleSize,sampleSize]/2,true,time);
    lightness = rgbToHsl(sample)[2];
    linear(lightness,0,1,minBrightness,maxBrightness);

    Dan

Page 1 of 2

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