Mask

Mask or crop images and shapes using stencil regions.

What it does

Mask cuts down content two ways. With the Mask input disconnected it is a rectangle crop, with insets from each edge. Wire an image, a shape, a mesh or a Volume into Mask and it becomes a stencil: only the parts of the content falling inside the mask survive.

Each kind of content is masked in its own terms. Images get a GPU stencil or crop. A shape masked by a shape stays a shape, a clean boolean intersection with no rasterising and no loss of crispness at any zoom; only mixed content, a shape masked by an image or the reverse, is rasterised. Meshes masked by meshes get a real 3D boolean. Volumes get a per-voxel density multiply, and points are culled in or out by where they land inside a Volume mask.

When to use it

ParameterTypeDefault
content_inOneOf([FieldOf(Color), Collection, FieldOf(Volume)])
maskOneOf([FieldOf(Color), FieldOf(Scalar), FieldOf(Vector), Collection])
leftAny0
topAny0
rightAny0
bottomAny0
unitsString"Pixels"
centerBooleanfalse
channelString"Alpha"
mask_channelString""
invertBooleanfalse
softnessNumber0
mixNumber1
strengthNumber1

Gotchas

Cropping a shape with no mask wired trims relative to the shape's own bounding box, not the canvas, so a small inset trims a small shape correctly wherever it sits.

An image wired as the mask becomes the frame: the output takes the mask's size and placement, and the content is repositioned to sit inside it. With nothing wired, the content keeps its own frame and the crop rectangle is measured against it instead.

Worked example

  1. Add a Mask node and wire an image into Content.

  2. Leave Mask disconnected and set Left/Top/Right/Bottom to crop a rectangle out of the image.

  3. Wire a second image (or a shape) into Mask. The crop controls give way to a stencil cut using that mask's Alpha or Luminance channel.

  4. Raise Softness to feather the cut edge, and use Invert to flip which side is kept.

  5. Pull Mix down from 1 toward 0 to blend back toward the unmasked original.

See also

Fill · Trim Path · Transform · Rasters (images)