LayerMask: CreateGradientMask
CreateGradientMask
- size_as
- mask
CreateGradientMask generates a smooth black-to-white gradient mask from scratch - no input image needed, just dimensions and a direction. Masks in ComfyUI are grayscale where white means "affect this" and black means "leave it alone," so a gradient mask gives you a fade: an effect that's full-strength on one side and tapers off across the image. It's the building block for anything that should blend rather than switch on and off - graduated color grades, soft vignettes, smooth transitions between two images, feathered composites.
The controls:
- width / height - the mask size (default 512×512). It has to match whatever you're masking, which is why there's also...
- size_as - an optional wildcard input. Connect an image or another mask here and the gradient inherits its dimensions automatically, so you don't have to keep the numbers in sync by hand. Handy in a graph where sizes change.
- gradient_side - where the fade originates:
bottom,top,left,right, orcenter.centergives you a radial-ish fade out from the middle (think vignette); the edge options give linear top/bottom/side fades. - gradient_scale - how long the transition is (default 100). Small values make a hard, quick fade; large values stretch the gradient out gently across the frame.
- gradient_offset - shifts where the gradient sits, pushing the transition earlier or later.
- opacity - the overall strength ceiling of the mask (default 100).
The single mask output wires into anything that takes a MASK: a blend/composite node, a masked color adjustment, an inpaint region, whatever needs a soft edge.
Where it fits: this is a graphics-fundamentals utility. Any time you want an effect to fade rather than cut, you reach for a gradient mask. Grade the sky darker toward the top? Gradient mask from top into a color node. Blend two images with a soft seam? Gradient mask driving the composite. Soft vignette? center gradient into a darken. Because it generates the mask procedurally, you get clean, resolution-independent gradients without painting anything or loading an external file.
There's not much to trip on here - it's a generator with no models and no heavy dependencies. The only things to watch: match the mask size to your target (or just use size_as and forget about it), and remember which end is white. If the fade is going the wrong way, flip the gradient_side or use the offset rather than fighting it downstream. It pairs naturally with the pack's other mask nodes when you want to combine a procedural gradient with a real subject mask.
Install is the pack standard. Easiest is ComfyUI Manager - search ComfyUI Layer Style (or "LayerStyle"), install, restart. Manual: cd ComfyUI/custom_nodes && git clone https://github.com/chflame163/ComfyUI_LayerStyle, then pip install -r requirements.txt from inside the folder using ComfyUI's Python, and restart. On a hosted ComfyUI it's usually preinstalled.
The pack-wide caveat: Layer Style is notorious for import failures - install it, restart, and the whole node set shows up red or missing. It's rarely the specific node; it's a dependency clash. The pack pulls a heavy stack (transformers, onnxruntime, opencv), and one mismatched version - a stray transformers or tensorflow being the usual culprit - takes the entire pack down on import. Fix it by reading the ComfyUI startup log for the traceback (it names the package that failed), reinstalling requirements against ComfyUI's own Python, and using Manager's Try Fix. If CreateGradientMask is missing, so is every other LayerStyle node, and that shared import failure is the real thing to solve.
Inputs (7)
| Name | Type | Default | Description |
|---|---|---|---|
| width | INT | 5124–99999 | — |
| height | INT | 5124–99999 | — |
| gradient_side | COMBO | 5 options: bottom, top, left, right, center | |
| gradient_scale | INT | 1001–9999 | — |
| gradient_offset | INT | 0-9999–9999 | — |
| opacity | INT | 1000–100 | — |
| size_asopt | * | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| mask | MASK | — |