ADOBE AFTER EFFECTS: Forum Expressions Tutorials Creative Cloud

randomize expression within composition that repeats many times

COW Forums : Adobe After Effects Expressions

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
derek bass
randomize expression within composition that repeats many times
on Sep 19, 2013 at 10:03:23 pm

Hi -

I have a composition that contains a simple opacity wiggle expression in one of its shape layers. This comp is duplicated 30 times simultaneously in another comp. I need each copy of this comp to have a different wiggle output, so that all 30 comps have a different opacity level when viewed in the parent comp.

The expression below applies to a shape layer that is overlaid on another shape layer for a specific amount of time, so I don't think I can apply any kind of time randomize function to each of the 30 comps in the parent comp.

It seems like there would be a simple way to "wiggle my wiggle" so the repeated comps all have different output. Any ideas?

op = value;
if(op > 0 && op &lt; 100){
reverseAmt=100-transform.opacity;
wiggledAmt=wiggle(flickerFrequency,reverseAmt);
roundedAmt=Math.round((wiggledAmt/100));
roundedAmt*100;


Return to posts index

Michał Orzełek
Re: randomize expression within composition that repeats many times
on Sep 20, 2013 at 12:00:30 pm

I think you should use seedRandom() function with layer index as a parameter. That will make "wiggle my wiggle" effect you described.

Code should be sth like that (I'm not sure). Just copy and position layers.

wiggleFreq = 2 // your frequency
wiggleMax = 100 // max opacity
wiggleMin = 0 // min opacity
seedRandom(index,true); // random number per layer index
wiggleAmout = random(wiggleMin,wiggleMax) // generates random opacity level
wiggle(wiggleFreq,wiggleAmout) // wiggles your opacity


Return to posts index

derek bass
Re: randomize expression within composition that repeats many times
on Sep 20, 2013 at 6:30:03 pm

Thanks for the reply Michael. With your expression, I still see 30 copies of the comp on the screen all doing the same thing at the same time.

There are other ways to do this besides using an expression, but I was hoping to go for a simple comp that I can duplicate. To keep my story simple, I didn't mention every detail in the first post. To better explain, the comp has 3 layers:

1. Red shape with flicker expression
2. Light blue shape with flicker expression
3. Dark blue shape as the base - no flicker expression

The dark blue needs to show the most frequently, light blue, next, and red least frequently. The length of time that each shape shows is variable and random.

This comp is repeated 30 times to form an array in the parent comp. The colors only flicker for a specific duration. The rest of the time they are dark blue.

I feel like I'm making this a lot more complicated than it needs to be. Here's an image of the output I'm looking for.



Return to posts index


Dan Ebberts
Re: randomize expression within composition that repeats many times
on Sep 20, 2013 at 11:19:37 pm

What you're trying to do won't work if you've duplicated your precomp layer 30 times. You would have to duplicate the comp in the project window so that each layer links to a different comp. Then inside each comp you could make the wiggle different by using a random seed derived from, for example, a number at the end of the comp's name (Comp 1, Comp 2, etc.):

n = thisComp.name.split(" ");
seedRandom(parseInt(n[n.length-1],10));
wiggle(1,300);

The wiggle for that layer should be different in each comp.


Dan



Return to posts index

derek bass
Re: randomize expression within composition that repeats many times
on Sep 20, 2013 at 11:32:52 pm

Thanks Dan. It sounds like I'd have to make 30 different compositions, which doesn't work for my goal of keeping it simple. I was hoping there was a way to do this because there are other situations I would be able to apply similar effects to.

To accomplish this task, I think I will end up using one or more mosaics of changing colors and overlay the negative space with a shape layer to create the right shapes.


Return to posts index

Dan Ebberts
Re: randomize expression within composition that repeats many times
on Sep 20, 2013 at 11:37:54 pm

It wouldn't be too bad--you'd just have to make one comp, duplicate it 29 times, and pull them all in as layers in your main comp.


Dan



Return to posts index


derek bass
Re: randomize expression within composition that repeats many times
on Sep 20, 2013 at 11:48:47 pm

I see what you mean now. I'm having trouble applying this to my original expression. The original expression has the variable "flickerFrequency." How do apply this random seed based on the comp name to this?

flickerFrequency =4;

op = value;
if(op > 0 && op < 100){
reverseAmt=100-transform.opacity;
wiggledAmt=wiggle(flickerFrequency,reverseAmt);
roundedAmt=Math.round((wiggledAmt/100));
roundedAmt*100;
}


Return to posts index

Dan Ebberts
Re: randomize expression within composition that repeats many times
on Sep 20, 2013 at 11:55:55 pm

Like this, I would think:


flickerFrequency =4;

op = value;
if(op > 0 && op < 100){
n = thisComp.name.split(" ");
seedRandom(parseInt(n[n.length-1],10));
reverseAmt=100-transform.opacity;
wiggledAmt=wiggle(flickerFrequency,reverseAmt);
roundedAmt=Math.round((wiggledAmt/100));
roundedAmt*100;
}



Dan



Return to posts index

derek bass
Re: randomize expression within composition that repeats many times
on Sep 21, 2013 at 12:00:36 am

It works! Thanks so much!


Return to posts index


Michał Orzełek
Re: randomize expression within composition that repeats many times
on Sep 21, 2013 at 11:18:01 am

[derek bass] "There are other ways to do this besides using an expression, but I was hoping to go for a simple comp that I can duplicate"

Yeah. The same I was trying to do with my "randomness" problem, but unfortunately I didn't solve it out. Maybe your code can be adjusted to my situation somehow.


Return to posts index

Matthias Stoll
Re: randomize expression within composition that repeats many times
on Jan 24, 2020 at 9:15:11 am

hi Dan,

I need to read out the Name of the contents of a shape layer "Shape 1", "Shape 2" etc. to create a delay. I want to duplicate those Shapes to get an increasing number and increasing delays.

Something like "thisContent.name" would help - which doesn't exist.

Do you know about any other way to create fixed increasing numbers? I mean besides Comp names or layer indexes. I want to create a toolbox with many different shape layer animations, each reduced to one single shape layer.

Thanks a lot!

on transform: Shape 1

var mult=parseInt(content(1).name.split(" ")[1]);
var delay= effect("delay")(1)*mult;
anim=linear(time,0+delay,2+delay,0,1);
P.pointOnPath(anim,time)


Return to posts index

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