FORUMS: list search recent posts

Incredibly slow looping sampleimage expression

COW Forums : Adobe After Effects Expressions

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Paul Roper
Incredibly slow looping sampleimage expression
on Feb 8, 2016 at 5:36:45 pm

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.



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



Return to posts index

Paul Roper
Re: Incredibly slow looping sampleimage expression
on Feb 8, 2016 at 5:41:51 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!

Return to posts index

<< PREVIOUS   •   VIEW ALL   •   PRINT   •   NEXT >>
© 2018 All Rights Reserved