Nodes/ComfyUI_Mira/Create Tilling PNG Mask
ComfyUI Node

Create Tilling PNG Mask

Grid masks for regional prompting

By mirabarukaso·Created 2 years ago·Updated 5 days ago· 206
Create Tilling PNG Mask
    • PngImage
    • PngColorMasks
    • PngRectangles
    • Debug
    Width576
    Height1024
    Colum_firstfalse
    Rows1
    Colums1
    Layout1,1,1

    If you've ever prompted two characters into one image and watched the redhead on the left steal the blonde's hair, you already know the problem this node exists to solve. Conditioning in Stable Diffusion is global. A single prompt describing two people smears their attributes together, and no amount of prompt-wrangling reliably fixes it. The standing answer is regional prompting: carve the canvas into areas and give each its own prompt. Create Tilling PNG Mask is where that carving happens in the ComfyUI_Mira workflow.

    It's the flagship node of Mira's Mask group, and the whole pack is really one person's regional-conditioning rig for anime/Illustrious multi-character work - mirabarukaso is better known for their character-select app than for this toolkit, so treat Mira as a personal kit that got shared, not a big community staple. That's fine. This particular node is genuinely useful and directly borrows its idea from the old sd-webui-regional-prompter, so if you came from A1111's Regional Prompter it'll feel familiar.

    How it works

    You describe a grid, the node paints it as a color-coded PNG, and downstream Mira nodes turn each colored block into a mask you attach to a prompt. The clever bit is the Layout string. Digits 0-9 are block weights; a comma is a normal cut; a semicolon is a high-priority cut running perpendicular to the normal direction. So 1,2,1,1;2,4,6 first splits the canvas by the semicolon groups, then splits each part by the comma weights. Equal-weight blocks are just Rows x Colums.

    The one that trips people up: to flip the whole thing between horizontal and vertical, use Colum_first - don't swap your commas and semicolons by hand. The arithmetic isn't the same as WebUI's, and the author calls this out specifically. If you don't want a custom layout at all, put # in Layout and let Rows/Colums drive it.

    Inputs and outputs that matter

    • Layout - the grid recipe (e.g. 1,2,3,2,1). High priority; this is where you spend your time.
    • Colum_first - the direction switch. Leave it off for horizontal cuts, on for vertical.
    • Width / Height - connect these to the same size you generate at.

    Rows and Colums only kick in when the layout is blank/invalid, so think of them as the fallback.

    Outputs: PngImage is a preview so you can eyeball the split before committing. PngColorMasks and PngRectangles are the real payload - lists you feed into the other Mira mask nodes (Create PNG Mask, Color Mask to HEX/INT RGB, PngRectangles to Mask) to get actual MASK tensors for your regional conditioning. Debug is a string; wire it to a ShowText node so you can read what the layout actually parsed to.

    Installing it

    Easiest path is ComfyUI Manager: open the Custom Nodes Manager, search ComfyUI_Mira, hit Install, restart. Manual works too - cd ComfyUI/custom_nodes && git clone https://github.com/mirabarukaso/ComfyUI_Mira.git, then restart ComfyUI. If it errors on load, run pip install -r requirements.txt inside the ComfyUI_Mira folder and restart again. No model downloads are needed for the mask nodes.

    Common issues

    The biggest one isn't a bug, it's the technique: hard masks held through the entire sample produce a collaged look with visible seams between regions. That's inherent to region masking, not to this node. The community best practice is to end masking early - once composition has formed - and blend back to the base conditioning, so plan for the masks to feed a system that supports that rather than expecting seamless output from tiling alone.

    Second: regional prompting is architecture-specific and doesn't port cleanly. This node just produces geometry, so it's fairly model-agnostic, but the conditioning nodes you connect it to may not be - if your model is brand-new, check that your regional-conditioning node supports it before blaming the mask. And always send Debug to a ShowText node; reading the parsed layout is the fastest way to understand why a split came out sideways.

    CategoryMira/Mask

    Inputs (6)

    NameTypeDefaultDescription
    WidthINT576
    HeightINT1024
    Colum_firstBOOLEANfalse
    RowsINT1
    ColumsINT1
    LayoutSTRING1,1,1

    Outputs (4)

    NameTypeDescription
    PngImageIMAGE
    PngColorMasksMIRA_COLOR_LIST
    PngRectanglesMIRA_MASKS_LIST
    DebugSTRING