H3 Painted Region (internal)
Make a hand-painted mask ride along with the head instead of sitting still
- painted
- track
- masks
Here's the naive version of video inpainting: paint a mask on frame 1, and hope the model keeps it in the right place. It doesn't. If your character turns their head, a mask that was "the head" at frame 1 is now "the background" at frame 40. H3 Painted Region (internal) is the node that fixes that for the Mask mode pipeline - it takes a mask you painted on one frame and follows it through the video using the SAM 3 track, so hair, hats and accessories stay attached to the head as it moves.
The mechanism is admirably simple and it works. Every frame, the painted mask is shifted by how much the tracked region's centroid has drifted since frame 0, then OR-ed with that frame's actual track mask. If the track briefly gaps (SAM lost the object for a frame), it falls back to the last computed shift, so the region never jumps or vanishes. That fallback is the part that stops the mask from flickering into nothing mid-shot.
Inputs:
painted(MASK) - the mask you painted, one frame.track(MASK) - the SAM 3 track, one mask per video frame.grow(INT, default 8, range 0–64) - how many pixels to dilate the painted mask. A little grow softens the edges and gives the replacement room to blend.
Output: masks (MASK), one per frame, ready for the inpainting path. Both inputs are required - the node raises a clear error if you leave either unwired, which is the right failure mode for an internal node.
Two things are worth knowing to use it well. First, the grow knob is your sanity valve: if the replaced region looks pinched or the seam shows, bump it toward 16–24 before you blame the sampler. Second, this node is why the pack's Mask mode handles whole-head replacement the way it does - the changelog calls it out explicitly: painting a whole head now replaces the whole region, long hair and hats included, instead of just the face SAM 3 detects. Before this approach, accessories sat at their first-frame spot while the head moved on, which looked broken.
It's internal, so you won't add it by hand - it's generated inside the Mask-mode workflow, which needs the MaskVidExperiments pack and the SAM 3.1 checkpoint (sam3.1_multiplex_fp16.safetensors in checkpoints/). And remember the pack's own testing note: paint a region or describe it with text, but don't mix both approaches for one mask - this node is the painted path, and it works best when you commit to it.
Inputs (3)
| Name | Type | Default | Description |
|---|---|---|---|
| painted | MASK | — | |
| track | MASK | — | |
| grow | INT | 80–64 | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| masks | MASK | — |