Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Incredibly slow looping sampleimage expression

  • Incredibly slow looping sampleimage expression

    Posted by Paul Roper on February 8, 2016 at 5:36 pm

    Hello,
    I’m trying to determine the height of a wave (a shape layer with just a path and a stroke) at various points along the x-axis. I’ve made (adapted) an expression to do a sampleImage starting at y=0, moving down the comp a pixel at a time, until it finds a pixel whose alpha is greater than 0.

    But it’s unbelievably slow to evaluate, sometimes just timing out. Any suggestions why this is happening? The “for” loop should only be looping a few hundred times to find the pixel. the wave does not change shape, so the expression only needs to evaluate once.

    x=900;

    L=thisComp.layer("audioWave");

    for (i = 0; i <= 1080; i++){
    temp = L.sampleImage([x,i],[0.5,0.5],true,1);
    if (temp[3] > 0) break;
    }

    y=i;

    [x,y]

    Paul Roper replied 10 years, 3 months ago 1 Member · 1 Reply
  • 1 Reply
  • Paul Roper

    February 8, 2016 at 5:41 pm

    Hmmmm….I seem to have fixed it, by making it evaluate every second pixel. I changed i++ to i=i+2 and now I can render a preview faster than realtime! Weird. I’d predict that doing this would make it evaluate twice as fast, not hundreds of times faster!

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