ComfyUI Node Runs on cloud

Offset Mask

Shift, rotate, and batch-animate a mask

By kijai·Created 3 years ago·Updated about 7 hours ago· 2,930
Offset Mask
  • mask
  • mask
x0
y0
angle0
duplication_factor1
rollfalse
incrementalfalse
padding_modeempty

This is the plain utility underneath a couple of the fancier audio-reactive nodes in this pack - it takes a mask and moves it: horizontal offset, vertical offset, rotation, with control over what happens at the edges when it moves. On its own it's the node you reach for any time you need to nudge a mask's position without regenerating it - sliding a crop region, offsetting a detection box before you use it, or building an animated mask that walks across a video batch frame by frame.

How the knobs work together

x and y are a straightforward pixel offset. angle rotates. What happens at the edges once you've shifted the mask off its original bounds is where the interesting choices live: roll, when enabled, wraps content around - anything that shifts off one edge reappears on the opposite edge, like a texture that tiles. Turn it off and you get padding_mode instead, with three options: empty fills the newly exposed area with nothing, border extends the edge pixels outward, and reflection mirrors the mask back on itself. Which one looks right depends entirely on what's next to the mask's edges in your image - reflection tends to look most natural for organic shapes, empty is the honest choice when you genuinely want nothing there.

The other half of this node is about batches. duplication_factor repeats the mask that many times to form a batch, and incremental decides whether every copy gets the same offset or whether the offset accumulates across the batch - turned on, each successive copy in the batch shifts a little further than the last, which is how you'd animate a mask "walking" across a sequence of frames rather than just duplicating a single static offset.

The inputs and outputs that matter

  • mask in, mask out - same MASK type both ends.
  • x, y - pixel offset (range −4096 to 16384).
  • angle - degrees, −360 to 360.
  • roll - wraparound toggle.
  • duplication_factor - how many copies to produce, up to 1000.
  • incremental - whether the offset accumulates across those copies.
  • padding_mode - empty, border, or reflection, only relevant when roll is off.

How to install it

Standard KJNodes install: via ComfyUI Manager (search "KJNodes for ComfyUI"), or manually - cd ComfyUI/custom_nodes && git clone https://github.com/kijai/ComfyUI-KJNodes, pip install -r ComfyUI-KJNodes/requirements.txt, then restart. No extra dependencies for this specific node; it's pure mask math.

Common issues & troubleshooting

Wraparound artifacts you didn't expect. If roll is on and your offset is large relative to the mask's content, you'll get content bleeding in from the opposite edge, which is usually not what people picture when they say "offset." If that's not the look you want, turn roll off and pick a padding_mode instead.

"Nothing happened" with duplication_factor set high. Check incremental - if it's off, you're getting duplication_factor identical copies of the same single-offset mask, not an animated sequence. Turn it on if you wanted the offset to build up across the batch.

Rotation plus offset can crop unexpectedly. Large angle values combined with a non-square mask can push corners outside the canvas in ways that aren't obvious until you preview it - always check the actual output rather than assuming the numbers did what you expected.

CategoryKJNodes/masking

Inputs (8)

NameTypeDefaultDescription
maskMASK
xINT0-4096–16384
yINT0-4096–16384
angleINT0-360–360
duplication_factorINT11–1000
rollBOOLEANfalse
incrementalBOOLEANfalse
padding_modeCOMBOempty3 options: empty, border, reflection

Outputs (1)

NameTypeDescription
maskMASK