Tutorial 96: Mask Vertex Expressions plus Grading

Joe Clay | Nov 10, 2017

This video was sponsored by VideoBlocks. And because of that we have some nice footage to work with. And we're using that footage to take a quick look at a feature I've been dying to have in AE since at least 2005—mask vertex expression access! It's finally here in CC 2018!

I've needed this so many times, from locking other layers to masks to generating connecting lines on the fly without having to resort to scripts or a bunch of Beam effects. Here, we're using it to draw triangles on our footage. But combined with After Effects facial tracker and some setup, you can make polygonal faces that move with real footage, or whatever you can think up. I have some other ideas in the works, but I'm going to need some time to experiment. Until then, take this technique and run wild! Also, if you watched the grading section, I'm sorry I said "little bit" about a bajillion times. I'll keep it down next time. I just didn't realize I was doing it.

Here's some code for you to use. You're going to need to mix and match this code to get what you're after.

Get Points from Mask and Make a Triangle

Don't forget to add a Layer control and a Slider control called 'Offset.'

l = effect("Layer Control")("Layer");
offset = Math.floor(effect("Offset")("Slider"));
numPts = this.parent.mask("Mask 1").maskPath.points().length;

p = new Array();
p.push(toComp(l.mask("Mask 1").maskPath.points()[(offset+1) % numPts]));
p.push(toComp(l.mask("Mask 1").maskPath.points()[(offset+2) % numPts]));
p.push(toComp(l.mask("Mask 1").maskPath.points()[(offset+3) % numPts]));


Get Points from Face Tracking and Make a Triangle

Don't forget to add a Layer control, Checkbox control called 'Random' and a Slider control called 'Offset.'

l = effect("Layer Control")("Layer");
r = effect("Random")("Checkbox").value;
offset = Math.floor(effect("Offset")("Slider"));

pts = new Array();
pts.push(l.effect("Face Track Points")("Left Eyebrow Inner").value);
pts.push(l.effect("Face Track Points")("Left Eyebrow Middle").value);
pts.push(l.effect("Face Track Points")("Left Eyebrow Outer").value);
pts.push(l.effect("Face Track Points")("Left Eye Inner").value);
pts.push(l.effect("Face Track Points")("Left Pupil").value);
pts.push(l.effect("Face Track Points")("Left Eye Outer").value);
pts.push(l.effect("Face Track Points")("Right Eyebrow Inner").value);
pts.push(l.effect("Face Track Points")("Right Eyebrow Middle").value);
pts.push(l.effect("Face Track Points")("Right Eyebrow Outer").value);
pts.push(l.effect("Face Track Points")("Right Eye Inner").value);
pts.push(l.effect("Face Track Points")("Right Pupil").value);
pts.push(l.effect("Face Track Points")("Right Eye Outer").value);
pts.push(l.effect("Face Track Points")("Nose Bridge").value);
pts.push(l.effect("Face Track Points")("Nose Tip").value);
pts.push(l.effect("Face Track Points")("Left Nostril").value);
pts.push(l.effect("Face Track Points")("Right Nostril").value);
pts.push(l.effect("Face Track Points")("Mouth Left").value);
pts.push(l.effect("Face Track Points")("Mouth Top").value);
pts.push(l.effect("Face Track Points")("Mouth Right").value);
pts.push(l.effect("Face Track Points")("Mouth Bottom").value);
pts.push(l.effect("Face Track Points")("Left Cheek Top").value);
pts.push(l.effect("Face Track Points")("Left Cheek Middle").value);
pts.push(l.effect("Face Track Points")("Right Cheek Top").value);
pts.push(l.effect("Face Track Points")("Right Cheek Middle").value);
pts.push(l.effect("Face Track Points")("Chin").value);

numPts = pts.length;

p = new Array();
if(r > 0) {
} else {
    p.push(toComp(pts[(offset) % numPts]));
    p.push(toComp(pts[(offset+1) % numPts]));
    p.push(toComp(pts[(offset+2) % numPts]));

Become a Patron

If you'd like to help support Workbench, check out our Patreon page. 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!

Check out our Patreon Today