Nodes/ComfyUI_Mira/Random Tilling Layouts
ComfyUI Node

Random Tilling Layouts

Roll a random grid for regional masks

By mirabarukaso·Created 2 years ago·Updated 9 days ago· 206
Random Tilling Layouts
  • rnd_seed
  • layout
min_rows1
max_rows1
min_colums1
max_colums1
max_weights_gcuts2.0
max_weights_ncuts2.0

This node generates a random Layout string to feed into Create Tilling PNG Mask. If you've been hand-typing layout strings like 1,2,3,2,1;2,4,6 to slice your canvas into regions, this rolls one for you within bounds you set - great for batch-exploring compositions instead of committing to one grid.

It only makes sense once you know the layout syntax it's feeding. Mira's tiling masks split the canvas with two kinds of cut: N cuts (the comma-separated weights along the normal direction) and G cuts (the semicolon-separated ones, perpendicular and higher priority). The numbers are relative weights, so 1,2,1 makes a middle region twice as wide as its neighbors. Building these by hand gets old fast, and that's the whole reason this generator exists.

Zoom out and this is regional prompting territory - the standard fix for two subjects in one image bleeding attributes into each other. The tiling mask defines the regions; this node just randomizes the division.

How it works

You give it ranges for rows and columns and a maximum weight per cut type, plus a seed, and it composes a valid layout string within those limits. The rows range controls how many N cuts you might get; the columns range controls the G cuts. There's a handy shortcut baked in: set either rows or columns to 0 and it cuts in only the other direction. Set all four to 0 and it safely returns 1,1.

The inputs that matter

  • min_rows / max_rows - the range of N cuts. Set both to 0 to disable that direction.
  • min_colums / max_colums - the range of G cuts. (Yes, "colums" - that's the real input name.) Both 0 disables it.
  • max_weights_ncuts / max_weights_gcuts - the ceiling on the random weight assigned to each cut, from 1 up to this value. Higher means more lopsided regions.
  • rnd_seed - the randomness driver. The README is emphatic about this one: connect it to a Seed Generator node and control it with Global Seed (Inspire) from the Inspire Pack, because ComfyUI's own randomize toggle has a lag - switching from fixed back to randomize needs two Queue Prompts to take effect.

The output

A single STRING named layout. Wire it straight into the Layout input of Create Tilling PNG Mask. Strong recommendation from the author, and it's good advice: also route it (or the mask node's Debug output) into a ShowText node so you can actually see what got rolled.

Installing it

ComfyUI Manager: Manager -> Custom Nodes Manager, search ComfyUI_Mira, Install, restart. Or clone:

cd ComfyUI/custom_nodes
git clone https://github.com/mirabarukaso/ComfyUI_Mira.git

Restart; on a load error run pip install -r requirements.txt inside the folder and restart. No models. For the Seed Generator / Global Seed workflow you'll also want the Inspire Pack installed.

Common issues

The seed behavior burns people. Two things to internalize: first, rnd_seed is not a reproducibility handle - the README is blunt that you can't get the same layout back from the same seed, so if you roll one you love, save the actual output string in a Notes or ShowText node. Don't expect to reconstruct it. Second, the fixed-to-randomize lag is a real ComfyUI quirk, not a bug in this node; the Global Seed (Inspire) route is the clean way around it.

If your layout comes out with only horizontal or only vertical cuts and you didn't want that, check whether you left a rows or columns range at 0 - that's the one-direction shortcut firing.

And the usual note: ComfyUI_Mira is a small solo pack (the author's more visible project is their WAI Character Select app), so the README is your best documentation. Its examples section spells out exactly how the layout syntax maps to the resulting regions.

CategoryMira/Util

Inputs (7)

NameTypeDefaultDescription
min_rowsINT10–16
max_rowsINT10–16
min_columsINT10–16
max_columsINT10–16
max_weights_gcutsFLOAT2.01–10
max_weights_ncutsFLOAT2.01–10
rnd_seed*00–18446744073709550000

Outputs (1)

NameTypeDescription
layoutSTRING