Because it’s so useful for adding pleasing randomness to anything, Wiggle
has become a kind of gateway drug to expressions. But it has a much less famous sibling, noise
. I’ve never really played with noise
before, so I thought I’d investigate it further.
This is a test of noise
vs wiggle
. The blue circle has a straight-out-of-the-box wiggle(1, 500)
applied to it (the parameters mean a frequency of 1 and amplitude of 500.
The yellow circle has noise applied to the X and Y according to this expression:
value + [noise(time), noise(time+12345)] * 500
According to the Adobe docs, noise
can take a number or an array as its one parameter, but it always returns a number between -1 and 1. This is why I had to call it twice, once for each component of the position vector. noise
always returns the same result for the same input, so to get it to change over time, I used time
as the input.
The reason why I added 12345
to the time for the y component was that if I’d used noise(time)
for both terms, they would have always been the same, meaning the layer would just move along a diagonal line. To create interesting movement I slipped the x and y components out of phase (more on that later).
The * 500
scales the movement up so that it fills the comp, and to move it to the center I added the layer’s original position to the expression adding the term value
.
If you look at the difference between the noise
layer and the wiggle
layer you’ll see that wiggle wanders more, where noise keeps returning to the center. Here’s the path that each layer takes; first wiggle:
Then noise:
The reason for this daisy-shaped path can be seen from the graph of the position of the noise
layer, and highlights an interesting and useful property of noise()
. If you look at the graph of the expression something is immediately apparent: even though both components are varying smoothly and somewhat randomly, at the points where the time is an integer, i.e. every whole second, noise()
returns zero, which means at that point both x and y come back to the origin.
This could be very useful for random behaviour that you want to loop. Since you know that the value will return zero at when the seed is an integer, you can make sure the seed you give it is an integer at the beginning and end of the loop.
In the above expression the y component is out of phase 12345 seconds, a whole number. What happens if I put it out of phase by half a second, as in the graph below?
The answer is this:
Now instead of a daisy-like pattern with a return to the center every second we get loops. The path looks like this:
So what happens if we animate the phase difference? That is, we move the offset of the time component from zero to an arbitrary number.
noise(time + (time * n))
In the video below, instead of applying the result to the movement of a layer, I applied it to the points in a path, because that’s a thing now. To create the path, I generated 6400 points and used noise to assign their x and y coordinates. I didn’t worry about the in-out handles because the number of points was high enough that it looks smooth just with straight lines.
let pt = [];
for (i = 0; i< 6400; i++){
pt[i] = [thisComp.width,thisComp.height]/2 + [noise(i/100), noise(i/100 + time)]*500;
}
createPath(points = pt, inTangents = [], outTangents = [], isClosed = false)
It looks a bit Lorenz attractor-ish. Interestingly the figure appears to rotate in 3D, even though it’s completely 2D. You’ll also notice the way it comes back to the daisy-like figure at every second, because the two components are out of phase by a whole number. I wonder how long it would take to get back to the original figure?
A different flavour of wiggle
So that’s noise
; a useful addition to the toolbox if you want a random fluctuation but you want it to be periodic. Good for buzzing flies, or looping asteroids, or stochastic daisies.
Next time I’m going to be looking at some of the undocumented text features built-in to expressions, and how they can be used for advanced project management.
Appendix: how I made the trails
Drawing lines and shapes programmatically in After Effects is harder than it should be. This is really basic stuff in something like Processing, but you have to jump through hoops in AE.
Here’s how I did the trails for the circles. It’s a bit of a brute-force approach, nothing too clever, but it does only use built-in effects (that’s generally how I roll).
- First I made a smaller copy of the circle layers, only a couple of pixels wide. I parented them to the originals, and put them on the bottom of the layer stack.
- Then I added an adjustment layer with the echo effect on it.
- I cranked up the number of echoes to an insane amount, 3200 in this case, and set the echo time to about 1/40 th of a frame, or -0.001. A bit of trial and error to get the sweet spot where the trails look smooth, but not too slow.
- to get the nice fade out I adjusted the decay. This setting sets how each echo fades out, so with so many echoes it needs to be close to 1 or the trail fades out too early. the value I ended up with was 0.9994 (In the UI it just show up as 1 until you click on the edit box).
For prettiness I also added another adjustment layer with a blur effect and some curves. This adds a little bit of a halo, and by affecting just the bright parts, makes the highlights pop. The transfer mode of this layer is Add, and its opacity is 60%
To create static shapes I could have used something like the expression in the third video, where I drive a shape layer with noise. But for the sake of a single image I did this:
- convert the position of the circles to keyframes (Animation Assistant>convert Expression to Keyframes)
- Select the keyframes by clicking on the position property.
- create a shape layer with an empty open path by clicking with the pen tool, and selecting the Contents>Shape 1>Path 1>Path property (you have to twirl down all the way
- With the Path property selected, paste the keyframes. They will get converted from movement to a shape (you can do this in reverse too, to make movement out of any shape, it’s quite useful).
- Adjust the properties of the stroke to suit.
About the image
Digitally manipulated image of Pierre Shaeffer, a French music and sound hacker, who was instrumental in the Musique concrète movement. He made all sorts of noise.
Elliot Eustis
Excellent exploration. Very inspiring!
stib
Thanks!
andrew
How did you create the paths? As in how did you make the moving shapes trace a path?
stib
A bit of a brute force method, I’m afraid. I made a small circle shape layer below the original, parented it to the moving circle, and then added an echo effect on an adjustment layer, with a lot of echos. Slow to render and terrible to work with in the timeline, but gave the nice fade-out that I couldn’t get with say, stroke. For the static shapes I just converted the expression to keyframes, then copied the keyframes and pasted them on to the path property of an open path shape.
Eric Honan
Thank you for this explanation! I’m about to try it out but I’d love to know how you created those trails (in both the animated and static examples). In the animated examples it seems that the trail brightness is determined by velocity but it also fades over time. How did you achieve that? The trail stroke also seems to be extremely fine. Is that the result of a high res output or is the stroke set to 0.5 or less? Thanks again!
stib
Thanks! I just added the details of how I did the trails as an appendix.
David Merrick
I’m a software engineer but am new to AE expressions. Just stumbled on your blog. Thanks for all your explanations!