BD Mask Color Fill
Paint flat colors into mask regions — the fast path to flipbook UV textures
- background
- bg_mask
- mask_1
- mask_2
- mask_3
- mask_4
- image
- rgba
- mask
- status
BD Mask Color Fill takes up to four masks and fills each with a solid color, then composites the whole thing over a background. That's the entire job, and the entire reason it exists is to build flat-color zone textures - most visibly the 2D flipbook UV textures in this pack's face pipeline, where you take BD Face Socket Infill mask outputs and turn them into clean, color-coded regions a game shader can read.
The mental model: each of the four slots is a colored rubber stamp. Wire a MASK into mask_1, pick its RGB with r_1/g_1/b_1, and the node stamps that color wherever the mask is white. Slots layer bottom-to-top - slot 1 is painted first, slot 4 last - so where two regions overlap, the higher-numbered slot wins. Leave a slot unwired and it's simply skipped, which means "up to four" is "however many you need."
The inputs that matter
expand_1…expand_4- dilate each mask before coloring. Grow the painted region outward by N pixels. This is how you close the little gaps between zones that the source masks left behind.feather_1…feather_4- soften the stamp's edge. Positive feathers outward from the fill edge (interior stays opaque, boundary bleeds out); negative feathers inward (the fill fades toward its own edge); 0 is a hard binary edge. Per-slot, so a hard eye region can sit next to a soft hair region in the same pass.background- if you connect an image here, it's used as the base instead of thebg_r/bg_g/bg_bsolid color. This is where the composite gets real: paint your zones over the actual character render.
Then there are two clipping controls that turn "paint rectangles" into "paint the head":
bg_mask- a clip mask applied after all slot painting, ComfyUI convention (white = keep/opaque, black = transparent). Wire your head silhouette here and anything a slot painted outside the head gets cut away. This is the recommended way to clip by head shape - the README is explicit about it.bg_alpha_from_image- when ON with a background image connected, the background's luminance drives the alpha channel: white background pixels become opaque, black become transparent. Pair withbg_alpha_invertif your image uses the opposite convention (white = background to cut out). This is your "background is already a cutout shape" mode.
Outputs
You get three views of the same result: image (RGB composite), rgba (filled regions opaque, background transparent unless you raised bg_alpha), and mask (the union of all active slots - handy if you want the total painted footprint as a mask for something downstream).
A usage note
The classic setup in this pack: BD Face Socket Infill outputs per-zone masks → four of them into BD Mask Color Fill with different colors → rgba out to a texture-save node. It's also a perfectly good general "colorize these regions" node for any mask set, and the per-slot expand/feather is what keeps hand-built masks from looking like hand-built masks.
Installing
Standard BrainDead pack install - ComfyUI Manager search "BrainDead", or clone + pip install -r requirements.txt + restart. All V3 API, so keep ComfyUI updated.
One habit worth picking up: when zones bleed where they shouldn't, the fix order is bg_mask first (clip by shape), then per-slot expand to close gaps, then feather to blend seams. Skip ahead to feathering before clipping and you'll just be softening the spill you meant to remove.
Inputs (32)
| Name | Type | Default | Description |
|---|---|---|---|
| backgroundopt | IMAGE | Base image. If not connected, bg_r/g/b solid color is used as background. | |
| bg_ropt | INT | 00–255 | Background red (used when no background image). |
| bg_gopt | INT | 00–255 | Background green. |
| bg_bopt | INT | 00–255 | Background blue. |
| bg_alphaopt | FLOAT | 0.000–1 | Alpha of the background in the RGBA output. 0 = transparent background (default). 1 = fully opaque. |
| bg_maskopt | MASK | Clip mask applied AFTER all slot painting. Uses ComfyUI mask convention: 1.0 (white) = keep/opaque, 0.0 (black) = transparent. Wire your head silhouette mask here — areas outside the head (mask=0) become transparent even if a slot bleeds there. This is the recommended way to clip by head shape. bg_alpha controls the non-slot base: 0=only slot zones show, 1=whole masked region is opaque showing background pixels. | |
| bg_alpha_from_imageopt | BOOLEAN | false | When ON and a background image is connected, the background image's luminance is also used as a clip (in addition to bg_mask if wired). White=opaque, black=transparent. Enable bg_alpha_invert if your background image has the opposite convention (white=background, dark=head). |
| bg_alpha_invertopt | BOOLEAN | false | Invert the bg_alpha_from_image clip. Use when your background image has white=background (to be clipped out) and dark=head (to be kept). Has no effect when bg_alpha_from_image is OFF. |
| mask_1opt | MASK | Mask slot 1. Leave unconnected to skip. | |
| r_1opt | INT | 2550–255 | Red channel for slot 1. |
| g_1opt | INT | 00–255 | Green channel for slot 1. |
| b_1opt | INT | 00–255 | Blue channel for slot 1. |
| expand_1opt | INT | 00–60 | Dilate mask slot 1 by this many pixels before coloring. Grows the painted region outward. |
| feather_1opt | INT | 0-200–200 | Edge feather for mask slot 1. Applied after expand. Positive: soft ramp extends OUTWARD from the fill edge — interior stays fully opaque, only the boundary bleeds out. Negative: soft ramp goes INWARD — fill fades toward its own edge. 0 = hard binary edge. |
| mask_2opt | MASK | Mask slot 2. Leave unconnected to skip. | |
| r_2opt | INT | 00–255 | Red channel for slot 2. |
| g_2opt | INT | 2550–255 | Green channel for slot 2. |
| b_2opt | INT | 00–255 | Blue channel for slot 2. |
| expand_2opt | INT | 00–60 | Dilate mask slot 2 by this many pixels before coloring. Grows the painted region outward. |
| feather_2opt | INT | 0-200–200 | Edge feather for mask slot 2. Applied after expand. Positive: soft ramp extends OUTWARD from the fill edge — interior stays fully opaque, only the boundary bleeds out. Negative: soft ramp goes INWARD — fill fades toward its own edge. 0 = hard binary edge. |
| mask_3opt | MASK | Mask slot 3. Leave unconnected to skip. | |
| r_3opt | INT | 00–255 | Red channel for slot 3. |
| g_3opt | INT | 00–255 | Green channel for slot 3. |
| b_3opt | INT | 2550–255 | Blue channel for slot 3. |
| expand_3opt | INT | 00–60 | Dilate mask slot 3 by this many pixels before coloring. Grows the painted region outward. |
| feather_3opt | INT | 0-200–200 | Edge feather for mask slot 3. Applied after expand. Positive: soft ramp extends OUTWARD from the fill edge — interior stays fully opaque, only the boundary bleeds out. Negative: soft ramp goes INWARD — fill fades toward its own edge. 0 = hard binary edge. |
| mask_4opt | MASK | Mask slot 4. Leave unconnected to skip. | |
| r_4opt | INT | 2550–255 | Red channel for slot 4. |
| g_4opt | INT | 2550–255 | Green channel for slot 4. |
| b_4opt | INT | 00–255 | Blue channel for slot 4. |
| expand_4opt | INT | 00–60 | Dilate mask slot 4 by this many pixels before coloring. Grows the painted region outward. |
| feather_4opt | INT | 0-200–200 | Edge feather for mask slot 4. Applied after expand. Positive: soft ramp extends OUTWARD from the fill edge — interior stays fully opaque, only the boundary bleeds out. Negative: soft ramp goes INWARD — fill fades toward its own edge. 0 = hard binary edge. |
Outputs (4)
| Name | Type | Description |
|---|---|---|
| image | IMAGE | RGB composite. |
| rgba | IMAGE | RGBA — filled regions opaque, background transparent (unless bg_alpha > 0). |
| mask | MASK | Union of all active mask slots. |
| status | STRING | — |