Expressions/Scripts/Presets

Moderators: Disciple, zlovatt

 
ilmeri
Topic Author
Posts: 10
Joined: Fri Nov 09, 2007 1:01 am

Increasing opacity

Fri Nov 09, 2007 1:46 am

Hi, and greetings to all forum members!

Im new to scripting, but understand some of the restrictions there are.
I'm wondering, if there's a way to do this:

I have 300 layers that i want to fade in randomly during few seconds.
Can i somehow achieve this with expressions?

What i was thinking was that i have a random number generator on each layer, and when it receives a value in certain range, it would execute the code that would fade the layer in. But what i know, it can't be done just like this.

Any tips?

And, is there a way to add an expression to multiple layers easily?

Thanks,

ilmeri
 
User avatar
Atomic
Posts: 157
Joined: Mon Apr 30, 2007 5:55 am
Location: United States, Ohio

Fri Nov 09, 2007 6:57 am

I'm not sure if your layers are text or images, but here is a link to a script that will import everything in a folder and make a comp for you.

http://www.aenhancers.com/viewtopic.php?t=719

http://aenhancers.com/viewtopic.php?t=102

The code in this script actually generates expressions for you, so it is possible to have expressions created automatically.

http://www.aenhancers.com/viewtopic.php?t=751

Here is a link to a script that takes a text file and makes 3D text that fades in and then out as it approaches and passes the camera.

http://www.aenhancers.com/viewtopic.php?t=142

Here is some code I use to make an expression only execute within a specific frame range.
thisFrame=timeToFrames(t=time+thisComp.displayStartTime,fps=1.0/thisComp.frameDuration,isDuration=false); 
if (thisFrame>50 & thisFrame<104)
{
f=effect(1)(1);
div = Math.abs(Math.sin(2 * textIndex/textTotal -(time/2.5)*f)*100);
result = 0;
if (div) {result =300/div - 3;}
}
else{result =0;}
 
ilmeri
Topic Author
Posts: 10
Joined: Fri Nov 09, 2007 1:01 am

Fri Nov 09, 2007 12:12 pm

thanks..but i didn't really get it. :)

My comp is a logo cut to 300 layers. I want all the pieces to fade in during, let's say 2-3 seconds time, but each separately. It's painstaking to animate the opacity on all layers separately, by hand, so i was thinking if there's a way to fade the layers in with an expression.

Any more specific instructions?

Thanks anyway,

-ilmeri
 
Paul Tuersley
Posts: 704
Joined: Sat Jun 05, 2004 7:59 am
Location: London, UK

Sat Nov 10, 2007 2:24 am

This expression will fade up each layer over 1 second, starting somewhere between 0-2 seconds. Just add it to one layer's Opacity, copy that property, then select all the other layers and paste.

seedRandom(index, true);
theStart = random(0,2);
linear(time, theStart, theStart+1, 0, 100);


Here's a bit of an explanation about what it's doing:

// seedRandom gives some control over how random values are generated. setting "timeless = true" means the randomly generated value will not change on each frame.
seedRandom(index, true);

// generate a random value between 0 and 2 for the fade up start time
theStart = random(0,2);

// linear used to fade up from 0 to 100%, from theStart time to 1 sec later.
linear(time, theStart, theStart+1, 0, 100);
 
ilmeri
Topic Author
Posts: 10
Joined: Fri Nov 09, 2007 1:01 am

Sat Nov 10, 2007 3:30 am

sir, that's just awesome! and the copy / paste expression solved a lot too.

big thanks!

-ilmeri
 
to299
Posts: 7
Joined: Mon Jan 07, 2008 1:57 pm

Re: Increasing opacity

Wed Jan 30, 2008 6:59 am

how should i change the script, when i don´t want it to fade in?
linear = ?

thanks alot.
 
User avatar
lloydalvarez
Enhancement master
Posts: 460
Joined: Thu Jun 17, 2004 9:27 am
Location: New York City, NY
Contact:

Re: Increasing opacity

Wed Jan 30, 2008 12:25 pm

to299 wrote:
how should i change the script, when i don´t want it to fade in?


This will cut the layers on. It actually does a 1 frame fade, you can change the fadeDurationInFrames variable to change the number of frame you'd like the fade to take.

-Lloyd

fadeDurationInFrames = 1;

seedRandom(index, true);
theStart = random(0,2);
numFrames = fadeDurationInFrames*thisComp.frameDuration;
linear(time, theStart, theStart+numFrames, 0, 100);
 
User avatar
Disciple
Posts: 137
Joined: Sat Jun 05, 2004 8:05 am
Location: Los Angeles, CA
Contact:

Re: Increasing opacity

Thu Jan 31, 2008 11:33 am

How would you modify this expression if you have 10 layers in a comp that need the random opacity fade in, but there are 50 layers in the whole comp. In other words, the index count is not the right method (if I understand the expression correctly...)

Thanks
Alex
 
User avatar
lloydalvarez
Enhancement master
Posts: 460
Joined: Thu Jun 17, 2004 9:27 am
Location: New York City, NY
Contact:

Re: Increasing opacity

Thu Jan 31, 2008 12:16 pm

Index is used to generate a unique random seed for each layer so that there are no repeats. So the expression should work regardless of how many layers you have in your comp
 
User avatar
Disciple
Posts: 137
Joined: Sat Jun 05, 2004 8:05 am
Location: Los Angeles, CA
Contact:

Re: Increasing opacity

Thu Jan 31, 2008 12:29 pm

Stange, if I apply it to the opacity stream of a layer in a large comp the opacity goes straight to and stays at 100%
 
User avatar
lloydalvarez
Enhancement master
Posts: 460
Joined: Thu Jun 17, 2004 9:27 am
Location: New York City, NY
Contact:

Re: Increasing opacity

Thu Jan 31, 2008 12:58 pm

try changing index with number:

fadeDurationInFrames = 1;

seedRandom(1, true);
theStart = random(0,2);
numFrames = fadeDurationInFrames*thisComp.frameDuration;
linear(time, theStart, theStart+numFrames, 0, 100);




does that fix it? the thing is the same random seed will always generate the same number which is why you use index to give each layer a unique index seed, but to help you debug it you can use any number
 
Paul Tuersley
Posts: 704
Joined: Sat Jun 05, 2004 7:59 am
Location: London, UK

Re: Increasing opacity

Thu Jan 31, 2008 4:46 pm

lloydalvarez wrote:
the thing is the same random seed will always generate the same number which is why you use index to give each layer a unique index seed

Actually, it won't. Multiple expressions with the same randomSeed will still generate different random values.


Disciple wrote:
if I apply it to the opacity stream of a layer in a large comp the opacity goes straight to and stays at 100%

You're saying all layers with this expression have 100% Opacity from frame 1? Not sure what that could be. Add the Numbers effect to your layer, then add expressions like these to the Value property

time;

random(0,2);

seedRandom(1, true);
random(0,2);

seedRandom(1, true);
theStart = random(0,2);
linear(time, theStart, theStart+10, 0, 100);


and see what happens.

Paul
 
User avatar
Disciple
Posts: 137
Joined: Sat Jun 05, 2004 8:05 am
Location: Los Angeles, CA
Contact:

Re: Increasing opacity

Thu Jan 31, 2008 10:17 pm

Well. the value that is displayed is 100...

Could this be due to the fact I'm running this project in 6.5?

Alex
 
Paul Tuersley
Posts: 704
Joined: Sat Jun 05, 2004 7:59 am
Location: London, UK

Re: Increasing opacity

Fri Feb 01, 2008 1:25 am

I don't know. It works in my copy of 6.5. Those were four separate expressions I was suggesting you try.

Paul
 
User avatar
Disciple
Posts: 137
Joined: Sat Jun 05, 2004 8:05 am
Location: Los Angeles, CA
Contact:

Re: Increasing opacity

Sat Feb 02, 2008 8:54 pm

Paul

I'm sorry, I tried this in the peak of crunch time while I was rendering the project. I guess I was hasty.
I'll try to give it a shot again asap.

Thanks
Alex

Who is online

Users browsing this forum: No registered users and 3 guests