Menu

Tutorial 175: Looping Noise()

Joe Clay | May 10, 2019

In this week's After Effects tutorial, we take a look at looping elements. This was inspired by Daniel Shiffman's Coding Challenge #136.1 on his excellent YouTube channel Coding Train. Coding Train is an excellent resource for coding visual art. A lot of the topics he covers can be repurposed in After Effects. Since he tackles algorithms frequently, it's also a good way to learn more deeply about the tools we use every day. For example, he has a few videos on Perlin noise, which underpins a lot of the plugins you probably use every day, like Fractal Noise.

For more information on sorting, check out JavaScript Array sort() Method.

Expression Code

Note that all of these require slider controls. You can see which ones you need to make assigned to variables in the following expressions.

This goes in a path property so you can draw a polygon.

seed = effect("Seed")("Slider");
s = effect("Noise Scale")("Slider");
v = effect("Variance")("Slider")/100;
a = degreesToRadians(effect("Evolution")("Angle"));
x = Math.cos(a) * s + seed;
y = Math.sin(a) * s + seed;
angles = new Array();
pts = new Array();
for(i = 0; i < 4; i++)
{
    n = noise([x + (i*v),y + (i*v)]);
    a = linear(n, -1.25,1.25,-1,1) * 360;
    if (a < 0) {
        a = 360 + a;
    }
    angles.push(a);
}

angles.sort(function(a, b){ return a - b });

for(i = 0; i < angles.length; i++)
{
    a = degreesToRadians(angles[i]);
    ptX = Math.cos(a) * 300;
    ptY = Math.sin(a) * 300;
    pts.push([ptX, ptY]);
}
createPath(pts);

All of the text layers have something like this to repeat characters. If you put a few characters in and add a carriage return, it'll duplicate lines and the carriage returns.

text.sourceText.repeat(23);

This is the expression used on text where we don't care if the first and last characters loop together. Apply this to an expression selector in a text animator.

v = effect("Variance")("Slider")/100;
a = degreesToRadians(effect("Evolution")("Angle") + (textIndex * v));
s = effect("Noise Scale")("Slider");
x = Math.cos(a) * s;
y = Math.sin(a) * s;
noise([x, y]) * 100;

This is the expression used on characters that need to loop first and last characters—around a circular path for example. Apply this to an expression selector in a text animator.

seed = effect("Seed")("Slider");
a = degreesToRadians(textIndex/textTotal * 360 + effect("Evolution")("Angle"));
s = effect("Noise Scale")("Slider");
x = Math.cos(a) * s + seed;
y = Math.sin(a) * s + seed;
noise([x, y]) * 100;

Grab the Project Files

Get the project file through our Gumroad Store. This project file contains all of the setups shown in the tutorial, the Workbench Dots font, as well as some other graphic elements used in the final designs. It also includes all of the expressions code shown. This hasn't been fully tested in the Legacy ExtendScript engine, but from switching back and forth a couple of times, it didn't seem to throw any errors. Most of it is pretty standard with maybe the exception of the repeat function in the sourceText. To get around that you'd just need to enter text to fill out the text layers. Because of that this includes a version built in CC 2019 and a version that should open back to CC v14.

If you're buying project files, consider becoming a Patron. At the $5/mo. tier, you get access to project files as they come out and some tutorials also come with additional BTS content showing more of the builds.

Get the project on Gumroad

Become a Patron

If you'd like to help support Workbench, check out our Patreon page. Thank you for even considering clicking this link to support what we're doing. We appreciate it. Patrons get all sorts of benefits, from additional files to early product releases depending upon the tier.

Check out our Patreon Today