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
Increasing opacity
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
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.
http://www.aenhancers.com/viewtopic.php?t=719
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: Select all
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;}
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

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
-
- Posts: 704
- Joined: June 5th, 2004, 7:59 am
- 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);
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);
- lloydalvarez
- Enhancement master
- Posts: 460
- Joined: June 17th, 2004, 9:27 am
- Location: New York City, NY
- Contact:
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.to299 wrote:how should i change the script, when i don´t want it to fade in?
-Lloyd
Code: Select all
fadeDurationInFrames = 1;
seedRandom(index, true);
theStart = random(0,2);
numFrames = fadeDurationInFrames*thisComp.frameDuration;
linear(time, theStart, theStart+numFrames, 0, 100);
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
Thanks
Alex
- lloydalvarez
- Enhancement master
- Posts: 460
- Joined: June 17th, 2004, 9:27 am
- Location: New York City, NY
- Contact:
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
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%
- lloydalvarez
- Enhancement master
- Posts: 460
- Joined: June 17th, 2004, 9:27 am
- Location: New York City, NY
- Contact:
try changing index with number:
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
Code: Select all
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
-
- Posts: 704
- Joined: June 5th, 2004, 7:59 am
- Location: London, UK
Actually, it won't. Multiple expressions with the same randomSeed will still generate different random values.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
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 propertyDisciple 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%
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
Well. the value that is displayed is 100...
Could this be due to the fact I'm running this project in 6.5?
Alex
Could this be due to the fact I'm running this project in 6.5?
Alex
-
- Posts: 704
- Joined: June 5th, 2004, 7:59 am
- 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
Paul
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
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