Nodes/ComfyUI_BattlemapGrid/Map Generator(Outdoors)
ComfyUI Node

Map Generator(Outdoors)

Procgen rivers, roads, and trees — then let img2img do the actual drawing

By fmatray·Created 2 years ago·Updated 2 years ago· 0
Map Generator(Outdoors)
    • image
    • image width
    • image height
    • grid width
    • grid height
    • grid side
    • positive prompt
    • negative prompt
    seed0
    grid_width24
    grid_height32
    grid_side32
    bg_color#00FF00
    rivertrue
    roadtrue
    rockstrue
    treestrue
    positive
    negative

    Most "AI battlemap" workflows fail at the same step: you prompt a diffusion model for a forest clearing and you get either a generic fantasy painting or a muddy grid of noise, rarely something that matches the 24×32 grid you planned the encounter around. Map Generator(Outdoors) is the pragmatic fix: it procedurally drafts the terrain - rivers, roads, rock clusters, trees, random flowers - and hands you both the draft and a ready-made prompt to refine it. The diffusion model does the pretty painting; this node does the layout, so your river actually runs the direction you want.

    How it works

    It's a subclass of Map Generator, so it starts with the same exact-size canvas and green background, then layers on hand-rolled procedural geometry. Rivers and roads are generated as branching paths: they start at a random edge, wander toward the center with random angle drift, and occasionally fork into a thinner tributary (recursively, up to five levels deep). Each is drawn with tapered, multi-stroke widths so they read as organic lines rather than 1px scribbles - black under-stroke plus a colored top in fading shades. Rocks are random polygons (3- to 9-sided), trees are radial "star" bursts of darkgreen-to-lightgreen line clusters, and flowers are scattered colored dots. Everything gets a local noise pass so it doesn't look flat.

    The smart part is the prompt plumbing. Depending on which toggles are on, it appends tokens to positive ("blue river, water.", "saddlebrown road.") and, when a feature is off, adds the inverse to negative ("trees.", "rocks.") so the img2img pass doesn't hallucinate terrain you explicitly didn't ask for. Feed those two output strings straight into a KSampler's positive/negative and the refinement stays on-rails.

    The inputs that matter

    The seed, grid_width, grid_height, grid_side, and bg_color inputs are identical to Map Generator (24×32 grid at 32px = 768×1024, green base). On top of that you get four booleans - river, road, rocks, trees - all defaulting to ON, and positive / negative text fields where you can add your own prompt words to the ones it builds. Kill a toggle and it both skips drawing that feature and adds it to the negative prompt.

    The outputs

    image, plus the same five INTs (image width/height, grid width/height, grid side) so you can wire grid width/grid height into Battlemap Grid's orig_grid_width/orig_grid_height for an aligned overlay. And then the two strings this node exists for: positive prompt and negative prompt, ready for your KSampler.

    One quirk to know about: the auto-built prompt in the current code has the tree and rock descriptors swapped - you'll see "green trees." appended when rocks are on and "gray rocks." when trees are on. Harmless, but don't blindly trust the text; it's a starting point, not scripture.

    How to install it

    The whole pack installs in one go. ComfyUI Manager: search ComfyUI_BattlemapGrid. Or:

    cd ComfyUI/custom_nodes
    git clone https://github.com/fmatray/ComfyUI_BattlemapGrid
    

    Then install the pack's hidden dependency - no requirements.txt, but aggdraw is imported by the grid node, and its absence kills the entire pack's import:

    path/to/ComfyUI/venv/bin/pip install aggdraw
    

    Restart, and it's under Battlemaps. No models to download, runs on CPU.

    Common issues

    • Refined map ignores your layout - your base draft is guidance, not a hard constraint. If the img2img pass washes it out, drop the denoise a bit and lean on the provided positive prompt.
    • Model draws a river you turned off - make sure the negative prompt output is actually wired in; that's precisely what it's for.
    • Everything on but the map still looks abstract - the procedural sketch is low-detail by design. Refine it; that's the whole two-stage idea.

    It's the most opinionated node in the pack, and the one that actually feels like a battlemap generator rather than scaffolding. Worth the extra few minutes of wiring.

    CategoryBattlemaps

    Inputs (11)

    NameTypeDefaultDescription
    seedINT00–18446744073709550000
    grid_widthINT2410–128
    grid_heightINT3210–128
    grid_sideINT3210–2048
    bg_colorSTRING#00FF00
    riverBOOLEANtrue
    roadBOOLEANtrue
    rocksBOOLEANtrue
    treesBOOLEANtrue
    positiveSTRING
    negativeSTRING

    Outputs (8)

    NameTypeDescription
    imageIMAGE
    image widthINT
    image heightINT
    grid widthINT
    grid heightINT
    grid sideINT
    positive promptSTRING
    negative promptSTRING