GR Mask Create Random Multi
Scatter several random-shaped masks across a canvas
- image
- MASK
- IMAGE
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.01–1) 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 includingrandomfor per-shape variety.use_image_dimensionsplus optionalimage- size the mask against a real image instead of manualheight/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 yourring_color/ring_type/ring_thicknesssettings, 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.
Inputs (16)
| Name | Type | Default | Description |
|---|---|---|---|
| seed | INT | 155484241012781100000000000000–999999999999999 | — |
| mask_size | FLOAT | 0.01–1 | — |
| mask_number | INT | — | |
| exclude_borders | BOOLEAN | false | — |
| border_margin_height | INT | 15 | — |
| border_margin_width | INT | 15 | — |
| min_distance | INT | 10 | — |
| ring_color | COMBO | black | 30 options: amethyst, black, blue, cyan, diamond, emerald, +24 |
| ring_type | COMBO | solid | 3 options: solid, dashed, dotted |
| distance_from_boundary | INT | 10 | — |
| ring_thickness | INT | 5 | — |
| mask_shape | COMBO | rectangular | 9 options: rectangular, circular, elliptical, triangular, polygonal, star, +3 |
| use_image_dimensions | BOOLEAN | false | — |
| height | INT | 256 | — |
| width | INT | 256 | — |
| imageopt | IMAGE | — |
Outputs (2)
| Name | Type | Description |
|---|---|---|
| MASK | MASK | — |
| IMAGE | IMAGE | — |