Randomized Mask Transform
Jitter a mask's rotation and position for free variety
- mask
- MASK
If you're generating batches from the same mask over and over - say, an inpainting region or a compositing shape - the output can start looking suspiciously identical run after run, because the mask never moves. Randomized Mask Transform exists to break that: it takes a mask and nudges its rotation and center position within limits you set, so a batch built off the same base mask gets a little natural variety instead of pixel-identical placement every time.
The three knobs, and they're the whole node. rotation (default 5, range −360 to 360) is a maximum rotation angle in degrees - per the node's own tooltip, set it to 0 to disable rotation entirely. x_axis and y_axis (both default 0, range −100 to 100) shift the mask's center along each axis; per their tooltips, −100 moves the center to the left/top edge and 100 to the right/bottom edge, so these read as percentage offsets across the canvas rather than raw pixels. Leave both at 0 and the mask stays centered where it started, only rotating (if rotation is nonzero). Push them and the mask's center drifts toward an edge, randomly within that range, on every run.
Inputs and output. mask in, MASK out - it's a straight transform node, drop it between wherever your mask comes from (manual paint, a detector, a Florence-2 grounding pass) and wherever it's consumed (inpainting, compositing, FilterAndCombineMasks).
It's worth being deliberate about where in the chain you place it relative to GR85_FilterAndCombineMasks: transform-then-filter and filter-then-transform aren't the same operation. Rotating or shifting a mask before combining it with others can change how much they overlap; combining first and transforming the single merged result gives you one consistent jitter instead of several independently-jittered pieces.
Installing it. Search "comfyui_gr85" in ComfyUI Manager, or manually:
cd ComfyUI/custom_nodes
git clone https://github.com/veighnsche/comfyui_gr85
Restart ComfyUI. No models, no extra dependencies - it's pixel-space math on a mask tensor.
Where to be careful with it. Because the transform is randomized rather than deterministic per input, don't expect the same mask in to give the same mask out across runs unless you're controlling randomness upstream some other way - this node doesn't take a seed input, so re-running the same graph will give you a different jitter each time by design. If you need the mask to end up entirely off the visible content for some subjects (a large x_axis/y_axis push on a mask that's already near an edge), you can end up transforming a chunk of the mask off-canvas and effectively shrinking the usable masked area - worth previewing the mask output before you commit a full batch to it, especially if you're pushing the offsets toward the extremes.
Inputs (4)
| Name | Type | Default | Description |
|---|---|---|---|
| mask | MASK | — | |
| rotation | FLOAT | 5.0-360–360 | Maximum rotation angle in degrees. Set to 0 to disable rotation. |
| x_axis | FLOAT | 0.00-100–100 | Shifts the center along the x-axis. -100 moves it to the left edge, 100 to the right edge. |
| y_axis | FLOAT | 0.00-100–100 | Shifts the center along the y-axis. -100 moves it to the top edge, 100 to the bottom edge. |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| MASK | MASK | — |