Nodes/GraftingRayman/GR Mask Create Random Multi
ComfyUI Node

GR Mask Create Random Multi

Scatter several random-shaped masks across a canvas

By GraftingRayman·Created 2 years ago·Updated about a month ago· 76
GR Mask Create Random Multi
  • image
  • MASK
  • IMAGE
seed155484241012781
mask_size
mask_number
exclude_bordersfalse
border_margin_height15
border_margin_width15
min_distance10
ring_colorblack
ring_typesolid
distance_from_boundary10
ring_thickness5
mask_shaperectangular
use_image_dimensionsfalse
height256
width256

This is GR Mask's more chaotic sibling - instead of one shape at a controlled position, it scatters several randomly-placed shapes across a canvas, with a choice of nine shape types and a visual preview so you can actually see what got generated before you commit to using it. Good for generating varied inpaint test regions, building randomized damage/wear masks, or anywhere you want "several roughly-random spots" rather than one deliberate one.

How it works

Set a seed (this pack seeds it with a large default value rather than 0, but any INT works) and it randomly places mask_number shapes sized around mask_size (a fraction of the canvas, 0.011) across your canvas. Shape choice is genuinely varied - rectangular, circular, elliptical, triangular, polygonal, star, hexagon, pentagon, or random to let the node pick per-shape. exclude_borders, border_margin_height/_width, and min_distance keep the scattered shapes off the edges and away from each other, the same spacing logic you'd want from any "randomly place N things" generator.

Where this node goes further than a plain mask generator is the preview: ring_color (a 30-color palette), ring_type (solid/dashed/dotted), distance_from_boundary, and ring_thickness control an outlined preview drawn around each generated shape, returned as a second output so you can visually confirm placement, size, and shape distribution before wiring the mask itself into something expensive downstream.

use_image_dimensions is the toggle worth knowing about if you're masking an actual image rather than working in the abstract: turn it on and wire an image in, and the node reads that image's size instead of you having to match height/width by hand.

The inputs and outputs that matter

  • seed, mask_number, mask_size - the core randomization controls: how many shapes, how big, and the reproducibility seed.
  • mask_shape - nine options including random for per-shape variety.
  • use_image_dimensions plus optional image - size the mask against a real image instead of manual height/width.
  • exclude_borders, border_margin_height/_width, min_distance - keep shapes spaced and off the edges.
  • MASK (output) - the actual generated mask, for your inpaint or composite pipeline.
  • IMAGE (output) - a preview render showing the shapes outlined per your ring_color/ring_type/ring_thickness settings, so you can sanity-check the mask visually before using it.

How to install it

Via ComfyUI Manager: search "GraftingRayman", install, restart. Manually:

cd ComfyUI/custom_nodes
git clone https://github.com/GraftingRayman/ComfyUI_GraftingRayman

then restart. Every node here, including this one, needs OpenAI's CLIP package installed separately from ComfyUI's own CLIP:

# portable build
.\python_embeded\python.exe -m pip install git+https://github.com/openai/CLIP.git

# system python
pip install git+https://github.com/openai/CLIP.git

Common issues & troubleshooting

Node missing from search. That's the CLIP dependency above, a pack-wide requirement rather than something specific to this node.

Same shapes every run. Change seed between queues if you want fresh randomization - a fixed seed reproduces the exact same scatter deliberately, which is useful when you've found a layout you like and want to keep it.

Shapes overlapping or clipping the edge. Raise min_distance for overlap, and border_margin_height/_width (or exclude_borders) for edge clipping - both get tighter than you'd expect once mask_number climbs on a small canvas.

Mask doesn't match your actual image size. Turn on use_image_dimensions and wire the real image in, instead of manually keeping height/width in sync with whatever you're masking - it's one less thing to get out of sync when you swap source images.

CategoryGraftingRayman/Tiles

Inputs (16)

NameTypeDefaultDescription
seedINT155484241012781100000000000000–999999999999999
mask_sizeFLOAT0.01–1
mask_numberINT
exclude_bordersBOOLEANfalse
border_margin_heightINT15
border_margin_widthINT15
min_distanceINT10
ring_colorCOMBOblack30 options: amethyst, black, blue, cyan, diamond, emerald, +24
ring_typeCOMBOsolid3 options: solid, dashed, dotted
distance_from_boundaryINT10
ring_thicknessINT5
mask_shapeCOMBOrectangular9 options: rectangular, circular, elliptical, triangular, polygonal, star, +3
use_image_dimensionsBOOLEANfalse
heightINT256
widthINT256
imageoptIMAGE

Outputs (2)

NameTypeDescription
MASKMASK
IMAGEIMAGE