AE ENHANCERS

Expressions/Scripts/Presets
It is currently Thu Oct 23, 2014 4:01 am

All times are UTC - 8 hours [ DST ]




Post new topic Reply to topic  [ 15 posts ] 
Author Message
 Post subject: Increasing opacity
PostPosted: Fri Nov 09, 2007 1:46 am 
Offline

Joined: Fri Nov 09, 2007 1:01 am
Posts: 10
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


Top
 Profile  
 
 Post subject:
PostPosted: Fri Nov 09, 2007 6:57 am 
Offline
User avatar

Joined: Mon Apr 30, 2007 5:55 am
Posts: 157
Location: United States, Ohio
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.
Code:
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;}


Top
 Profile  
 
 Post subject:
PostPosted: Fri Nov 09, 2007 12:12 pm 
Offline

Joined: Fri Nov 09, 2007 1:01 am
Posts: 10
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


Top
 Profile  
 
 Post subject:
PostPosted: Sat Nov 10, 2007 2:24 am 
Offline

Joined: Sat Jun 05, 2004 7:59 am
Posts: 698
Location: London, UK
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);


Top
 Profile  
 
 Post subject:
PostPosted: Sat Nov 10, 2007 3:30 am 
Offline

Joined: Fri Nov 09, 2007 1:01 am
Posts: 10
sir, that's just awesome! and the copy / paste expression solved a lot too.

big thanks!

-ilmeri


Top
 Profile  
 
 Post subject: Re: Increasing opacity
PostPosted: Wed Jan 30, 2008 6:59 am 
Offline

Joined: Mon Jan 07, 2008 1:57 pm
Posts: 7
how should i change the script, when i don´t want it to fade in?
linear = ?

thanks alot.


Top
 Profile  
 
 Post subject: Re: Increasing opacity
PostPosted: Wed Jan 30, 2008 12:25 pm 
Offline
Enhancement master
User avatar

Joined: Thu Jun 17, 2004 9:27 am
Posts: 460
Location: New York City, NY
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

Code:
fadeDurationInFrames = 1;

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

_________________
http://aescripts.com


Top
 Profile  
 
 Post subject: Re: Increasing opacity
PostPosted: Thu Jan 31, 2008 11:33 am 
Offline
User avatar

Joined: Sat Jun 05, 2004 8:05 am
Posts: 137
Location: Los Angeles, CA
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


Top
 Profile  
 
 Post subject: Re: Increasing opacity
PostPosted: Thu Jan 31, 2008 12:16 pm 
Offline
Enhancement master
User avatar

Joined: Thu Jun 17, 2004 9:27 am
Posts: 460
Location: New York City, NY
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

_________________
http://aescripts.com


Top
 Profile  
 
 Post subject: Re: Increasing opacity
PostPosted: Thu Jan 31, 2008 12:29 pm 
Offline
User avatar

Joined: Sat Jun 05, 2004 8:05 am
Posts: 137
Location: Los Angeles, CA
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%


Top
 Profile  
 
 Post subject: Re: Increasing opacity
PostPosted: Thu Jan 31, 2008 12:58 pm 
Offline
Enhancement master
User avatar

Joined: Thu Jun 17, 2004 9:27 am
Posts: 460
Location: New York City, NY
try changing index with number:

Code:
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

_________________
http://aescripts.com


Top
 Profile  
 
 Post subject: Re: Increasing opacity
PostPosted: Thu Jan 31, 2008 4:46 pm 
Offline

Joined: Sat Jun 05, 2004 7:59 am
Posts: 698
Location: London, UK
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


Top
 Profile  
 
 Post subject: Re: Increasing opacity
PostPosted: Thu Jan 31, 2008 10:17 pm 
Offline
User avatar

Joined: Sat Jun 05, 2004 8:05 am
Posts: 137
Location: Los Angeles, CA
Well. the value that is displayed is 100...

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

Alex


Top
 Profile  
 
 Post subject: Re: Increasing opacity
PostPosted: Fri Feb 01, 2008 1:25 am 
Offline

Joined: Sat Jun 05, 2004 7:59 am
Posts: 698
Location: London, UK
I don't know. It works in my copy of 6.5. Those were four separate expressions I was suggesting you try.

Paul


Top
 Profile  
 
 Post subject: Re: Increasing opacity
PostPosted: Sat Feb 02, 2008 8:54 pm 
Offline
User avatar

Joined: Sat Jun 05, 2004 8:05 am
Posts: 137
Location: Los Angeles, CA
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


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 15 posts ] 

All times are UTC - 8 hours [ DST ]


Who is online

Users browsing this forum: Yahoo [Bot] and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group