ADOBE AFTER EFFECTS: Forum Expressions Tutorials Creative Cloud

Fade In Mosaic via Expression

COW Forums : Adobe After Effects Expressions

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Steve Tarlton
Fade In Mosaic via Expression
on Mar 27, 2017 at 8:19:35 pm

Hi,

I'm trying to fade in a mosaic using a gradient matte as a wipe, but I'd like each shape of the mosaic to

(1) individually fade in uniformly, not from left to right, as the gradient wipes over it. (in other words, the gradient triggers the fade in, but does not wipe the opacity of an individual shape) and

(2) the fade in of the shapes to be slightly, randomly offset from the gradient wipe, so the shapes do not fade in in a straight line, but have a little bit of an offset.

I was trying to sample the gradient as it passes the individual shapes, but I can't "Create Shapes from the Vector Layer" without losing the colors of the design. It all turns gray. I was going to sample from the anchor point of the shape created from the vector layer.

I could move the anchor point to the center of each shape manually, but with over 150 shapes, I'm not to excited to do that.

This may be unsolvable with how this project is configured, but maybe someone has an idea.

Here's the mosaic I'm trying to apply this to.


thanks,

Steve


Return to posts index

Steve Tarlton
Re: Fade In Mosaic via Expression
on Mar 28, 2017 at 12:32:44 pm

I figured out a solution using a frankensteined version of Dan Ebberts script to drive opacity using the sampleImage expression.

I ended up creating shapes from the vector layers (which put me up to over 250 layers) then used the awesome reposition anchor points script from AE Scripts to move all the anchor points to the center of those new shape layers. Because, the newly created vector layers were right above their sources, I sampled their position with

samplePos = thisComp.layer(index-1).transform.anchorPoint;

Which basically just targeted the anchor point of the previous layer. I hid all the shape layers so you could see the vector graphics with it's original colors.

To offset the sample time to get a little randomness, I used the current time and added a random number that was in a range determined by a expression control slider on a control layer.

sampleTime = time+random(-thisComp.layer("Opacity Control").effect("Slider Control")("Slider"), thisComp.layer("Opacity Control").effect("Slider Control")("Slider"))};

I learned that if you use seedRandom and set the second parameter to true, the random numbers will remain constant after they are generated. When I did this without seedRandom set to true my layers flickered because it was continuously generating random numbers to add to the current time.

I had to use an if/then statement to make sure that when the current time was 0 the sampleTime wouldn't be affected by adding the random number so that the animation could start with all the shapes at 0% opacity.

So now as the gradient matte wipes across the screen, the shapes will fade in from left to right with a little bit of randomness.

I'm glad there's so much knowledge on this site and across the internet to be able to piece things like this together. It really stretches my brain to try to understand what's going on in these expressions.

Here's how it ended up.




thanks,

Steve

sampleSize = [5,5];
target = thisComp.layer("Gradient Wipe");
samplePos = thisComp.layer(index-1).transform.anchorPoint;
seedRandom(1,true);

if (time&lt;=0){
sampleTime = 0
}else{
sampleTime = time+random(-thisComp.layer("Opacity Control").effect("Slider Control")("Slider"), thisComp.layer("Opacity Control").effect("Slider Control")("Slider"))};

rgb = target.sampleImage(samplePos, sampleSize, true, sampleTime);
hsl = rgbToHsl(rgb);
hsl[2]*100


Return to posts index

<< PREVIOUS   •   VIEW ALL   •   PRINT   •   NEXT >>
© 2017 CreativeCOW.net All Rights Reserved
[TOP]