Tutorial 171: Glitch Paths

Joe Clay | Apr 12, 2019

In this week's After Effects tutorial, we're actually back in After Effects. I was talking to Mikey Borup about messing with paths using expressions, and while he was working on something, I had an idea for something else. So we're going to explore glitching paths. The basic idea is to take paths and screw them up with code.

Mikey had done something cool with messing with path resolution, using pointOnPath(). So I built glitchy text by rebuilding paths with different points. Then I started to move those points around, and ultimately I started adding in my own blocky glitches.

Since we're just using paths, we can actually use any shape, so this isn't just limited to text. So experiment with different things. You can even add in path operations like the ones I mentioned from the Mo Better Blobs tutorial—and make sure to read the text for an update.

Now, here's some code for you to examine.

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.

All of these are set to glitch randomly, so sometimes the original paths are shown. In the first one, we build an array of points at a specified resolution, and then we randomly select points from that array and move them before passing them back into createPath().

var origPath = thisProperty;
var freq = effect("Glitch Frequency")("Slider")/100;

if(random() < freq){
    var res = effect("Resolution")("Slider");
    var amp = effect("Amplitude")("Slider");
    var amt = effect("Glitch Amount")("Slider");
    var seed = effect("Seed")("Slider");
    var pts = new Array;
    var skip = 1/res;
    seedRandom(seed);

    for(var i = 0; i < res; i++){
        pts.push(origPath.pointOnPath(i*skip));

    }

    for(var i = 0; i < amt; i++){
        var j = Math.floor(random(res));
        var offset = [random(-amp,amp),random(-amp,amp)];
        pts[j] += offset;
        if(j < res - 1) {
            j++;
            pts[j] += offset;
        }
    }
    createPath(pts);
} else {
    origPath;
}

In this version, we've changed out glitches to happen randomly, and we're also using the timeless argument to seedRandom() so that our random numbers will only change every 2-3 frames. This allows out glitches to hold for a frame or two longer so it's less crazy but more distinctive—like animating on twos. We've also change our random movements to push out in x only, effectively pushing out boxes from our paths. Even though I pressed on, I think I actually prefer this one.

var origPath = thisProperty;
var freq = effect("Glitch Frequency")("Slider")/100;
var seed = effect("Seed")("Slider");
seed = seed + Math.floor(time*15);
seedRandom(seed, true);

if(random() < freq){
    var res = effect("Resolution")("Slider");
    var amp = effect("Amplitude")("Slider");
    var amt = effect("Glitch Amount")("Slider");
    var pts = new Array;
    var skip = 1/res;

    for(var i = 0; i < res; i++){
        pts.push(origPath.pointOnPath(i*skip));=
    }

    for(var i = 0; i < amt; i++){
        var j = Math.floor(random(1,res-2));
        var x = random(-amp,amp);
        pts[j] = [pts[j][0] + x, pts[j-1][1]];
        pts[j+1] = [pts[j+1][0] + x, pts[j+2][1]];
    }
    createPath(pts);
} else {
    origPath;
}

In this one, we've added in a function called buildBlock() so that we can bump out a block whenever we want. So we grab all of our points, and when we're done with that, we add in boxes up to the number specified in the amount slider. Those are concatenated to the end of the original points. So they're drawn in order after the original points, so that they'll intersect the existing geometry.

function buildBlock(a, b) {
    var x = random(-amp, amp);
    var block = new Array;
    block.push(a);
    block.push([a[0] + x, a[1]]);
    block.push([b[0] + x, b[1]]);
    block.push(b);
    return block;
}

var origPath = thisProperty;
var freq = effect("Glitch Frequency")("Slider")/100;
var seed = effect("Seed")("Slider");
seedRandom(seed);

if(random() < freq){
    var res = effect("Resolution")("Slider");
    var amp = effect("Amplitude")("Slider");
    var amt = effect("Glitch Amount")("Slider");
    var pts = origPath.points();
    var inTangents = origPath.inTangents();
    var outTangents = origPath.outTangents();
    var skip = 1/res;

    for(var i = 0; i < amt; i++) {
        var pt = random();
        var a = origPath.pointOnPath(pt - .01);
        var b = origPath.pointOnPath(pt + .01);
        pts = pts.concat(buildBlock(a, b));
        for(var j = 0; j < 4; j++) {
            inTangents.push([0,0]);
            outTangents.push([0,0]);
        }
    }
    createPath(pts, inTangents, outTangents);
} else {
    origPath;
}

This is the final expression. To save time and also make cleaner paths, we test to see if we should add a glitch and then we add it instead of the point we were going to add so that it occurs where it should along the path. This makes it less crazy. Earlier versions didn't have a the Glitch Spread slider and the spread variable. This allows you to force the glitches to occur less frequently, so that instead of showing up all at the top of the paths, they spread out. This is because if they will glitch points 80% of the time, most of the glitches will be used earlier in the process of building the paths leaving none for the rest. So adding in that slider allows you to fine tune it.

function buildBlock(a, b, glitches) {
    var x = random(-amp, amp);
    var block = new Array;
    block.push(a);
    block.push([a[0] + x, a[1]]);
    block.push([b[0] + x, b[1]]);
    block.push(b);
    return block;
}

var origPath = thisProperty;
var freq = effect("Glitch Frequency")("Slider")/100;
var seed = effect("Seed")("Slider");

seed += Math.floor(time*15);
seedRandom(seed, true);

if(random() < freq){
    var res = effect("Resolution")("Slider");
    var amp = effect("Amplitude")("Slider");
    var amt = effect("Glitch Amount")("Slider");
    var size = effect("Glitch Size")("Slider") * .01;
    var pts = new Array;
    var inTangents = new Array;
    var outTangents = new Array;
    var skip = 1/res;
    var glitches = 0;

    for(var i = 0; i < res; i++) {
        if(random() > .5 && glitches < amt) {
            var a = origPath.pointOnPath(i * skip - size);
            var b = origPath.pointOnPath(i * skip + size);
            pts = pts.concat(buildBlock(a, b));
            for(var j = 0; j < 4; j++) {
                inTangents.push([0,0]);
                outTangents.push([0,0]);
            }
            glitches ++;
        } else {
            pts.push(origPath.pointOnPath(i * skip));
            tangent = origPath.tangentOnPath(i * skip)*10;
            inTangents.push(mul(tangent, -1));
            outTangents.push(tangent);
        }
    }
    createPath(pts, inTangents, outTangents);
} else {
    origPath;
}

And that's it. I hope this helps you, or at least gets you thinking of the power that we finally have to control the destiny of our paths.

Grab the Project Files

The best way to get our project files is to become a patron on Patreon. For $5 a month, you get access to all of the tutorial project files we've made available as well as other monthly projects, rigs, R&D, elements, early product previews, and BTS content not available anywhere else! You can also purchase just this project file on our Gumroad Store if you would rather do that.

Get access to all of our project files on Patreon or Get this single project file on Gumroad

Tutorial 170: Fields Reveal

Severo Ojea | Apr 5, 2019

In this week's Cinema 4D tutorial, we explore making a liquid effect from 3D noise. We'll make a mesh using Volume Builder and noise that will animate to fill an object.

Grab the Project Files

The best way to get our project files is to become a patron on Patreon. For $5 a month, you get access to all of the tutorial project files we've made available as well as other monthly projects, rigs, R&D, elements, early product previews, and BTS content not available anywhere else! You can also purchase just this project file on our Gumroad Store if you would rather do that.

Get access to all of our project files on Patreon or Get this single project file on Gumroad

Tutorial 169: FUI with Nodebox

Joe Clay | Mar 29, 2019

In this week's After Effects tutorial, we explore Nodebox again! If you're unfamiliar with Nodebox and you missed Tutorial 167, go check it out. Last time we made an FUI-style element with random data. This week, we bring in CSV data.

I used an app on my iPhone called Sound Spectrum Analysis to make noises and capture the audio data. You can send an email with exported data using the app. It puts some extra info at the top, and adds in some extra spacing for some reason. It also separates with semicolons, which Nodebox can use if you want, but I like to keep them commas. So I simplified the CSV's header and used find and replace in a text editor to remove those lines and convert the semicolons to commas. After that, the CSV worked perfectly in Nodebox.

Anyway, Nodebox is great for generating these types of elements. Play around with it and see what you can come up with!

Grab the Project Files

The best way to get our project files is to become a patron on Patreon. For $5 a month, you get access to all of the tutorial project files we've made available as well as other monthly projects, rigs, R&D, elements, early product previews, and BTS content not available anywhere else! You can also purchase just this project file on our Gumroad Store if you would rather do that.

Get access to all of our project files on Patreon or Get this single project file on Gumroad

Tutorial 168: Fields Reveal

Severo Ojea | Mar 22, 2019

In this week's Cinema 4D tutorial, we're exploring how to use fields and vertex maps to break up a dissolve to reveal geometry. We build the fields in the vertex map and then use that to drive the animation of a fracture object with a plain effector.

Grab the Project Files

The best way to get our project files is to become a patron on Patreon. For $5 a month, you get access to all of the tutorial project files we've made available as well as other monthly projects, rigs, R&D, elements, early product previews, and BTS content not available anywhere else! You can also purchase just this project file on our Gumroad Store if you would rather do that.

Get access to all of our project files on Patreon or Get this single project file on Gumroad

Tutorial 167: Intro to Nodebox

Joe Clay | Mar 15, 2019

In this week's After Effects tutorial, we explore Nodebox instead. Nodebox is a free node-based application that is perfect for 2D graphics—especially for data-vis. Since a lot of motion graphics work overlaps into this field—especially with future user interfaces (FUI)—it's an excellent tool for building elements to bring into After Effects. In the short time I've worked with it, I've made a few interesting elements that would've take a lot longer to build in AE, and it's fun working and thinking in a different manner—especially without keyframes.

Since you're basically manipulating data, it's really easy to build things that are representative of data. I've brought text files in and animated an interesting take on a file system. You can go line by line and add things based on filtering text. It's crazy how far you can take it if you like tinkering. So I encourage you to download Nodebox and give it a try. It's available on all major OSes and other than a few quirks, it's rock solid. And don't forget to check out the docs and tutorials on their site too!

Grab the Project Files

The best way to get our project files is to become a patron on Patreon. For $5 a month, you get access to all of the tutorial project files we've made available as well as other monthly projects, rigs, R&D, elements, early product previews, and BTS content not available anywhere else! You can also purchase just this project file on our Gumroad Store if you would rather do that.

Get access to all of our project files on Patreon or Get this single project file on Gumroad

Tutorial 166: Free 3D Terrain

Joe Clay | Mar 8, 2019

In this week's After Effects tutorial, we explore an old effect—Wave World. The last time I used this effect, I was watching Total Training DVDs from Brian Maffitt in like 2005.

Today, I was trying to do something else, and I accidentally clicked on Wave World. I had forgotten it has a 3D preview of the waves. So, with some quick tweaking, I was able to get rid of the UI elements and get a 3D terrain.

Hopefully you can take it and build on it.

Grab the Project Files

The best way to get our project files is to become a patron on Patreon. For $5 a month, you get access to all of the tutorial project files we've made available as well as other monthly projects, rigs, R&D, elements, early product previews, and BTS content not available anywhere else! You can also purchase just this project file on our Gumroad Store if you would rather do that.

Get access to all of our project files on Patreon or Get this single project file on Gumroad

Tutorial 165: Generative Art

Joe Clay | Mar 1, 2019

We just got back from Keyframes Conference so we're going to explore a little bit of what we talked about there. We'll take a look at how to set up a grid that can generate imagery using master properties in a single precomp. Building the grids using StackIt, it's pretty easy to make some interesting imagery with short expressions.

Expressions

Inside of your block precomps, add a controller layer. Add a slider to it called Brightness. Then you'll have to add your own expressions to achieve whatever you're looking for. Here are some examples.

For poly shape points:

Math.floor(thisComp.layer("Controller").effect("Brightness")("Slider")%.06*100)+3;

For shape strokes:

thisComp.layer("Controller").effect("Brightness")("Slider")*7+1;

For grids (sized from width):

b = Math.floor(thisComp.layer("Controller").effect("Brightness")("Slider")*8);
if(b < 1) { b = .5 }
30/b;

Then in your main comp, also set up a controller layer. On that layer you'll need a Layer Control. Then add this to your precomp with Brightness Master Property.

l = thisComp.layer("Controller").effect("Layer Control")("Layer");
b = l.sampleImage(position,[5,5], true);
b[0];

And then duplicate your layers with either StackIt or do it manually. If you grab the project file, there is a 60x60 and a 30x30 grid already set up.

Grab the Project Files

The best way to get our project files is to become a patron on Patreon. For $5 a month, you get access to all of the tutorial project files we've made available as well as other monthly projects, rigs, R&D, elements, early product previews, and BTS content not available anywhere else! You can also purchase just this project file on our Gumroad Store if you would rather do that.

Get access to all of our project files on Patreon or Get this single project file on Gumroad

Tutorial 164: Maximum Impact

Severo Ojea | Feb 22, 2019

In this week's Cinema 4D tutorial, we're going to take some techniques we've recently explored and use them to make an impactful logo reveal. If you need a refresher, check out how we made smoke and how we fractured objects.

Grab the Project Files

The best way to get our project files is to become a patron on Patreon. For $5 a month, you get access to all of the tutorial project files we've made available as well as other monthly projects, rigs, R&D, elements, early product previews, and BTS content not available anywhere else! You can also purchase just this project file on our Gumroad Store if you would rather do that.

Get access to all of our project files on Patreon or Get this single project file on Gumroad

Tutorial 163: Uncle Fill

Severo Ojea | Feb 15, 2019

In this week's Cinema 4D tutorial, we'll explore how to set up an object so that it can be filled with smoke. We'll use X-particles to create the smoke and then finish it by rendering it in Redshift.

Grab the Project Files

The best way to get our project files is to become a patron on Patreon. For $5 a month, you get access to all of the tutorial project files we've made available as well as other monthly projects, rigs, R&D, elements, early product previews, and BTS content not available anywhere else! You can also purchase just this project file on our Gumroad Store if you would rather do that.

Get access to all of our project files on Patreon or Get this single project file on Gumroad

Tutorial 162: Beat-based Time Shifting

Joe Clay | Feb 8, 2019

I was asked, a while ago, to look into time shifting based on audio. So in this week's After Effects tutorial, we use audio amplitude along with an expression to shift a layer's time. We're using the Timewarp effect for time shifting, since we can change speed pretty easily. We could use time-remapping but that would be more complicated.

To get the audio amplitude, I'm using Trapcode Sound Keys but you can make due using built-in audio effects to pull out specific frequencies. When you use Animation > Keyframe Assistant > Convert Audio to Keyframes, it takes those audio effects into account when determining amplitude. You could also run Convert Audio to Keyframes on a special track you've run through another audio program, like Audition. Of course, Sound Keys is the best way to achieve this effect because it has other options, like falloff, that allow you to fine tune the effect to your taste.

The music used for the beat is: Jesse Warren - Miles Above You.

Expression Code

This is only an example. You'll need to modify what layer you're picking amp from if you're using Sound Keys for example. You'll also need to modify the ease() to match your actual audio amplitude or Sound Keys.

amp = thisComp.layer("Audio Amplitude").effect("Both Channels")("Slider");
ease(amp, 7, 8.5, 100, -400);

Grab the Project Files

The best way to get our project files is to become a patron on Patreon. For $5 a month, you get access to all of the tutorial project files we've made available as well as other monthly projects, rigs, R&D, elements, early product previews, and BTS content not available anywhere else! You can also purchase just this project file on our Gumroad Store if you would rather do that.

Get access to all of our project files on Patreon or Get this single project file on Gumroad
 12345678910111213141516171819202122 

Workbench tools are used by designers at hundreds of amazing companies