Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions sampleImage with multiple channels

  • sampleImage with multiple channels

    Posted by David Bode on November 7, 2011 at 9:42 pm

    Hello AE friends!

    I am trying to make an animation that is driven the color information from another layer. I have a set of 3D triangles that I am trying to get to spin on the Y axis. I made a 3D null and linked the Y rotation of the triangle to the Y rotation of the null and applied this expression.

    target = thisComp.layer(“GRAD”);
    red = target.sampleImage([120, 200],[3.5, 3.5])[0];
    linear (red, 0, 1, transform.yRotation, 120);

    This works just fine. The “GRAD” layer is a black solid and a red solid with a feathered mask that animates from right to left.

    But what I would like is to be able to drive the Y rotation with this red channel so that when the layer is filled with red, it rotates to 120 degrees. Then when I animate a green solid in the “GRAD” layer it will go from what ever the current Y value is to 240 degrees.

    I tried this….

    target = thisComp.layer(“GRAD”);
    red = target.sampleImage([80, 200],[3.5, 3.5])[0];
    green = target.sampleImage([80, 200],[3.5, 3.5])[1]
    linear (red, 0, 1, transform.yRotation, 120);
    linear (green, 0, 1, transform.yRotation, 240);

    Using [0] to index the red channel in line 2 and [1] to index the green channel in line 3. This expression seems to ignore the red channel but it does function for the green channel.

    Any help? This is the first time I have worked with the sampleImage expression.

    I am trying to re-create the NBC which can be seen here. https://youtu.be/raWfiU8Y3v4

    target = thisComp.layer("GRAD");
    red = target.sampleImage([80, 200],[3.5, 3.5])[0];
    green = target.sampleImage([80, 200],[3.5, 3.5])[1]
    linear (red, 0, 1, transform.yRotation, 120);
    linear (green, 0, 1, transform.yRotation, 240);

    David Bode replied 14 years, 9 months ago 2 Members · 2 Replies
  • 2 Replies
  • Dan Ebberts

    November 7, 2011 at 10:35 pm

    Yeah, that’s not going to work. The problem is that expressions don’t remember anything that’s happened in the past. When your expression accesses transform.yRotation, it’s always going to get the pre-expression value (as if the expression didn’t exist). So the green part won’t know where the red part left the rotation. You’ll need to rethink how you trigger the second part of the animation.

    Dan

  • David Bode

    November 8, 2011 at 10:25 pm

    Dan,

    Thanks for the reply. I have read a bunch on your motionscript.com site, and I figured this was the case here. I remember reading what you responded with on your site, but I couldn’t find a way to make the expression calculate what it had already done. I am sure there is some way to do it, but I couldn’t figure it out.

    Anyway, I managed to work a different way around it by using a null with a different expression and then adding the result to my control null. It seems to work just fine. I am sure this is not the most elegant way to do this, but it works and I feel like I have seceded in nailing this effect pretty darn well.

    Check it out and let me know what you think!

    https://vimeo.com/davebode/nbceffect

    Thanks again!
    Dave Bode

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