Moving mask on green screen layer mas- should I be using set matte?

faulkner Website User Posts: 18 Just Starting Out

Hi all,

I'm hitting my knowledge limit with this and need to access the hive mind, because I'm sure there is an easier way to do this than animating a mask frame by frame. The background of my shot is reproduced below. It's a very shaky, hand held shot, which I love and don't want to stabilize. High contrast, as you can see, with blow-outs. I'm trying to put someone (A) on the other side of that door, between the "No Exit" sign and the black door frame. My person A is cleanly shot against a green screen, so that part is good. A is technically supposed to be floating, so I don't need their motion to match the shakiness of the shot. What I DO need is a mask of the door frame (horizontal and vertical pieces) and the "No Exit" sign to move with the motion of the background shot in order to appear in front of my person A that is floating outside the door. Make sense?

So I do a double-tracking point to capture the motion of the underlying shot. I apply all four tracked values to a point layer. Then I thought the easiest thing would be to duplicate the background shot (below), mask out everything but the door frame and No Exit sign, move it above my green screen layer (A) and then apply the motion of the background shot to this duplicated layer. But when I do this, the motion of the mask in the top, duplicated layer does NOT match the motion of the door frame in the bottom layer. It's the same shot... why doesn't it match?

Would a "set matte" effect work better here? Where do I apply it, what do I set as source, and how do I set the values? I'm completely flummoxed and am going to start animating a mask on my green screen layer 10 frames at a time then going back and cleaning up inbetween. If anyone has a better way, please reply!



  • EvilDaystar
    EvilDaystar Website User Posts: 300 Enthusiast

    You don't need to modify the mask every frame.

    You might be able to do it every 5th frame or more since the path will tween between the keyframes.

  • Triem23
    Triem23 Moderator Moderator, Website User, Ambassador, Imerge Beta Tester, HitFilm Beta Tester Posts: 18,963 Ambassador

    Ok, so. Video is a bunch of dots drawn on screen that change every frame. The editor doesn't know what the dots represent (the image), in general.

    A mask is a mathematical definition of an area on a layer that is transparent. As you've discovered the mask is independent of the image/dots data.

    Masks cannot be parented to points (there is a Feature Request for that in the Feature Request forum you can Vote Up.)

    A matte uses pixel data from layer B to drive transparency on layer A, and your instinct is dead-on... This is a job for Set Matte! The steps below are really for a more complex job than this one, but you might need the additional information later, so....

    1. Track your footage.
    2. Create a point and attach the track to this point.
    3. Create a new plane layer - you'll want this layer to be larger than the video frame to account for movement with the track. The color doesn't matter, but it needs to be contrasting. You can always use the Fill Color effect on the plane to change color if needed.
    4. Parent the plane to the point and place it above your video.
    5. Lower the opacity of the plane so you can see through it - somewhere around 35% always works for me.
    6. Mask the plane. You'll see that the plane is following the track so you can concentrate on your shapes, while the track is keeping your plane aligned with the actor.
    7. Roto the entire clip. Note, for roto it's better to do multiple small shapes, not one big one. If you're rotoing an actor this means you want a spline for the head, one or two for the torso, one for each upper arm, each lower arm, etc. This sounds like more work, but it's not. Remember that not all the overlapping splines have to be precise everywhere. For example an upper arm spline needs to be tight along the edges of the arm, but the shoulder end, where it meets the torso, can overlap in a sloppy way over the chest spline. In this case you're rotoing simple rectangles, but that's a good tip if you ever need to roto an actor.
    8. Now, the way Set Matte - and any effect in Hitfilm that uses a source layer - works is by seeing the "Raw State" of a layer. This means no effects or masking. If you applied Set Matte to your video using the plane at this point it won't work as you expect. Once your roto is complete you'll need one more step - Turn the opacity of the plane back to 100%, right click on it and select "Make Composite Shot. Take Properties from the Current Timeline and Move all Effects and Masks with the Plane. This "bakes in" the transparency. Another way to look at it is the "Raw State" of a nested/embedded Composite Shot is the final render of the nest. either way, you should now have an embedded comp of your roto mattes.
    9. Turn off/Mute/hide the roto plane comp. You don't need to see it anymore.
    10. Add Set Matte to the Video clip. Set the embedded Comp to the SOurce Layer, the Matte Source to Alpha and the Blend to Subtract then click the Invert checkbox. This will remove everything outside the spline.

    Depending on how much roto you have to do, consider investing in the Mocha Hitfilm add-on. Mocha contains a lot of tools to simplify and speed up roto work. Roto in Mocha usually takes less than a third of the time of roto directly in Hitfilm. If you're only doing this one shot, don't worry about it, but if you have roto-heavy ambitions that will save you time.

    Now... Since you're rotoing rectangles, depending on your camera movement you might be able to simplify this a bit. Above I said that applying Set Matte using a masked plane required baking in a comp shot. For that door sign you might be able to just create a plane, attach it to the track then scale and move it into position over the sign, then move to the Set Matte step without nesting. The Set Matte would remove the entire rectangle of the plane, but, when you're rotoing a rectangle, that might be good enough.

    Otherwise, as EvilDaystar correctly notes, and you already were thinking, yeah, go ahead and do your first pass every 10 frames or so, then go back and refine.

  • EvilDaystar
    EvilDaystar Website User Posts: 300 Enthusiast

    Otherwise, as EvilDaystar correctly notes, and you already were thinking, yeah, go ahead and do your first pass every 10 frames or so, then go back and refine.

    Sorry, I was half asleep still when I read the OP. LOL

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!