So I have about 150 PNG files loaded up in a comp containing varied sized dots, lines, scratches. The goal is to make a 5 minute long overlay effect, where all these dots, lines and scratches appear in random positions across the screen at random times lasting 1 frame each, and not all together but a maximum of 3 at a time (per frame). Its basically meant to replicate an old film look with random dust and scratches.
I tried doing it manually but it took over an hour for me to make about 10 seconds (can show example if needed), so I'm asking to see if this could be solvable with any expressions? seems a bit complex, at least for my skill level. If anyone could chime in on it would be awesome. Thanks!
randomizing properties like position and opacity is pretty easy with expressions.
In your case however, the problem is that every layer would have to know if there are already 3/4 layers visible, but expressions on different layers and properties don't "communicate" with each other, there are no shared or global variables.
Expressions can however look up the value of other properties and use those in their calculations.
For example a (Null-) Layer could have 4 sliders with random values every frame and each layer could look at those values to share the same randomness.
A favourite alternative technique of mine is to calculate "global things" with an expression inside of 1 text-layer, and then have other expressions read that textLayer's sourceText value.
In this scenario if the textLayer would spit out an array of 3-4 random integers every frame,
each "noise"-layer can check if their layer-index is in that list and if it is, set opacity to 100.
Caveat, the random numbers are not guaranteed to be 4 different numbers, in those (rather rare) case, you would get less layers light up that frame.
Opacity expression for every dust-speck layer:
Position is more straightforward:
or even set it manually, possibly with some negative margins so elements have more chance of being partially out of frame: