Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Forums Adobe After Effects Expressions Expression to switch on objects beneath matte

  • Expression to switch on objects beneath matte

  • Matthew

    January 1, 2015 at 8:23 pm

    hi there

    i’m working on a personal project for which i would greatly appreciate some help.

    i’m wondering if there is a way of “switching on” the visibility of objects beneath a matte.

    the areas (they might be individual letters) can’t be cropped/clipped by the matte – they have to be either switched on or off in a way that creates an aliased edge.

    here’s a visual example of what i mean if i’m not being clear. the red line denotes the edge of the matte.

  • Matthew

    January 4, 2015 at 4:52 pm

    really hoping someone has an idea on this 🙂

  • Dan Ebberts

    January 4, 2015 at 6:59 pm

    Assuming the matte is a layer, something like this should work:

    m = thisComp.layer(“matte”);
    p = m.fromComp(toComp(anchorPoint));
    a = m.sampleImage(p,[width,height]/2,true,time)[3];
    a < .5 ? 0 : 100


  • Matthew

    January 4, 2015 at 7:27 pm

    thanks dan – i’m honoured by your presence.

    i applied it to the transparency of the layers below and (as the saying goes) BOOM. perfect.

  • Matthew

    September 2, 2015 at 1:55 pm

    hi dan (or if anyone else is tuned in…)

    is there a way to tailor this script so that the layers scale up from zero rather than their opacity switches on?

    would be great to know!

    many thanks.

  • Dan Ebberts

    September 2, 2015 at 4:44 pm

    Let me ask you this–is there any animation going on, or, if a layer is under the matte, it’s always under the matte? (It makes a big difference to how complicated the expression would be).


  • Matthew

    September 2, 2015 at 5:11 pm

    thanks dan 🙂

    apart from the scaling up – no there wouldn’t be any other animation (they are preComps – so i can put animation in there)

    yes – everything could be under the matte.

    very much appreciated


  • Dan Ebberts

    September 2, 2015 at 5:21 pm

    Something like this then probably:

    m = thisComp.layer("matte");
    scaleTime = .5;
    p = m.fromComp(toComp(anchorPoint));
    a = m.sampleImage(p,[width,height]/2,true,time)[3];
    if (a < .5){


  • Matthew

    September 3, 2015 at 5:07 pm

    beautiful. thank you 🙂

Viewing 1 - 9 of 9 posts

Log in to reply.

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