Mask Displacement Script (beta)

Mask Displacement Script

for Adobe After Effects

This page will tell you how to install the necessary files and how to use the script. The basic usage for the script is to use a Rotobezier mask and the script's expressions to allow a user to define weights on each anchor point and use sliders and points to control how that mask moves as if it was pushed or pulled using spring physics. It's great for soft objects to add movement or add additional movement to already moving objects.

Current version: 0.2.0 (in beta!)
You will likely find bugs, leave a comment or email [gmail:(snapplepapplemorphs)] with the error and I'll try and troubleshoot it so I can narrow down the error.

Bug list:

  • Gravity in directions not divisible by 90 degrees have an incorrect starting value and end value. Fixed in 0.1.1
  • Additional Centers for expression ties did not represent actual centers. Fixed in 0.1.2
  • No way to mirror displacement map effect except editing an expression. Fixed in 0.1.3
  • No mask specific way to weight entire movement. Fixed in 0.1.3
  • Presets do not work in other versions of AE (kind of a big deal). Maybe Fixed in 0.2.0
  • If the layer has an unexpected position the created masks move the opposite direction.

Requirements


The Mask Displacement Script has only 1 requirement:

Installation


Installing the Mask Displacement Script is simply moving one file into the proper location for After Effects to find. You are not installing anything in the traditional sense.

Download File via google drive

The 'Mask Displacement.jsx' file needs to be placed into the After Effects script folder:

Windows: C:\Program Files\Adobe\Adobe After Effects CC version\Support Files\Scripts\
Mac: Applications/Adobe After Effects version/Scripts/

Make sure you restart After Effects if you had it open so it can pick up the script. From then on the script will be available in the Scripts menu within After Effects (File->Scripts->Mask Displacement).

If you are updating to a new version, you can just overwrite the files.

How To


Quick Start:


The script will attempt to help you pop-ups and provide directions, but I still highly recommend reading this How To guide so you know what the script is expecting.

  1. The script is requiring a Rotobezier mask on the selected layer. A Rotobezier mask is different than a bezier curve mask, which is what After Effects defaults to. You can convert between the two types, but the path traced by them will be different.
    • To create a Rotobezier mask, select the Pen tool, then in the upper menu check the box that says "Rotobezier". Rotobeziers are different, you don't create any tangents (the handles on the anchor points). Rather, it determines the curve based on the other points you've made. While not as precise as bezier curves, the auto sizing of curves is what the script relies on. I find it easiest to click around and then go back and add more where needed.
    • To convert between the two types, right click on an anchor point of the mask and select the option to convert.
  2. Run the script: File->Scripts->Mask Displacement. It will open a little pallet window you can drag around. There's really only 1 option at the moment: How many Centers do you want?
    • 1 Center: This will create a circular center mask in the displacement map, use this if you cut out something that is more spherical.
    • No Center: The displacement map still works without a center, so if you've got something that is irregular or doesn't have explicitly 1 center, use this option.
  3. Have the layer with the Rotobezier mask present and then click the script's button: Apply Mask Displacement.
    • The script takes about 2 to 3 seconds to run. It will create a couple more layers, compositions, and many options.
    • Important! The script will remind you to change an option on the "Set Matte" effect. Scripts in After Effects do not have access to the option it's requesting you to change, sorry.
      1. In your original layer, locate the effects.
      2. Find the Set Matte effect.
      3. Next to the first option "Take Matte From Layer" there is a second drop down: change it from "Source" to "Masks".
      If you forget to do this step, your whole image/video will warp instead of just the cutout of the original mask.
  4. Set the weights of the mask's points. Locate the Weights layer (if you see a bunch of layers that say Null, you need to switch to Layer view instead of Source: click the header "source" right above all the layers.) The script created a control for every anchor point on your mask.
    • The first value is the horizontal control and the second is the vertical control for every point.
    • By default every is [100,100] so that means it will move 100% in both directions. A value of [0,0] would basically stop the point from moving at all. If you only want a point to move up and down: [0,100].
    • You can even go negative or over 100.
  5. Add a force to create movement: Locate the Control Layer and find the Force effect. In the timeline, you'll want to create a momentary force, which means you'll start at 0, go to a value like 10, then back down to 0. Think of it like poking a spring: if you just slowly push it and apply a force, it won't really wiggle around. To get something to be springy you apply a force and then don't, like a poke or flick.
  6. Fine tune with the other options. See the next Options section for more details.

Tutorials


Reshaping:

  1. The script will lock the original masks on the original layer. It will create Duplicate masks on the Mask Guide Layer. This is where you want to edit the masks now.
  2. It's easier to see your changes if you set the Reshape effect (located on the Control Layer [purple]) to 100. You can keyframe it later.
  3. On the Mask Guide Layer, you can lock the original mask if it keeps getting in the way. Change the colors of the mask to help tell the difference.
  4. If the reshape effect twists, you can add Correspondence points to the actual reshape effect located on the original layer. You need to click on the Correspondence Points property before you can alt+click to create the points. After Effects also does a bad job with these points if you add them after you have multiple keyframes, so add them all at the beginning to prevent weird spinning.
Important: Do not add or subtract anchor points on the masks after the script has run! The weights will get assigned incorrectly if you do.

10 comments:

  1. im using AE 2018 and get an error stating the preset file was saved in a newer AE version. Is there a work around for this?

    ReplyDelete
    Replies
    1. Oh... I did not know that was going to be a thing.
      I tried to upload a 2018 version to google drive, it was not having any of that for some reason.
      Try this one: https://mega.nz/file/ahtT3aLT#B_6t41obgy0n1xoWFhTWYRZ5NJEmws6KMYnjr6hMtIM
      I recreated the preset using a 2018 version of after effects, but I don't know my 2018 version will work with yours. Just replace this preset with the one you've got now and hopefully it will run.

      Delete
    2. The preset file works but now another error: Unable to execute script at line 1085. preset_location undefined. Im unable to shake this error even though I click on the script, locate the preset file, and still get the error. Your help is most appreciated!

      Delete
    3. I'm sorry for all the trouble, turns out that animation preset wasn't going to work since it was dependent on the version and I can't make new ones for every version out there.
      So I changed the script to not use an animation preset file, which I'm not super happy with but at least it runs now (hopefully). Please try the new version: https://drive.google.com/file/d/1hOzw2yQRMjDPapzvsqmhhL29A_VWhJ6P/view?usp=sharing It's only the script file now, so please just overwrite the one you've got and restart AE if it was open. If something doesn't work, let me know.

      Delete
  2. I get the same error upon locating the preset file, and I'm in AE CC 2020

    ReplyDelete
    Replies
    1. hmm... I'm guessing then that the animation presets are AE version specific... which is not going to work since I don't have every version and I certainly don't want to have to make a new one every update.
      Thanks for letting me know, I'll have to come up with something to get around this. The preset creates the controls and their min/max values, by default they'll be 0 to 100, which is difficult when I want default values like 700.

      Delete
    2. I changed the script so the animation preset file is no longer needed, when you get a chance please test out the new version: https://drive.google.com/file/d/1hOzw2yQRMjDPapzvsqmhhL29A_VWhJ6P/view?usp=sharing
      Hopefully I didn't miss anything and it works for you now. If it doesn't, please let me know what's going wrong and I'll try to help out

      Delete
  3. Ooops, you replied that day and I haven't been on my NSFW account since :((
    Good news is it appears to work! I'm messing with it for a few minutes now and I'm able to reshape and key things. I don't have time to give it a full blown test, but at least that fix is working! Thanks for being so quick to fix it, sorry my response was so delayed.

    ReplyDelete
  4. Tried this out again just now it won't show any preview of any kind for this one project. Just a black screen that the program lags when trying to move the time cursor and stops responding whenever either loading a different project or making a new one. Before that happened it simply wouldn't show the reshape at all no matter what I did.

    ReplyDelete
  5. Did you remove the videos?

    ReplyDelete