Nodes/ComfyUI-NKD-Basic-Tools/😺NKD Gradient Generate
ComfyUI Node

😺NKD Gradient Generate

Build a gradient from scratch — as a background, a mask, or a light leak

By Nekodificador·Created about a month ago·Updated 3 days ago· 71
😺NKD Gradient Generate
  • image
  • image
  • mask
â—„width1024â–º
â—„height1024â–º
â—„shapeLinearâ–º
â—„handles{"p0": [0.0, 0.5], "p1": [1.0, 0.5], "mid": 0.5}â–º
â—„ramp{"stops": [{"pos": 0.0, "color": "#000000"}, {"pos": 1.0, "color": "#ffffff"}]}â–º
â—„blend_modenoneâ–º
â—„opacity1.00â–º

Gradients are the unsung workhorse of compositing - sky replacements, light leaks, vignette bases, and the background behind a product shot all want one, and until recently you either generated a noise-then-gradient or, worse, typed coordinates into a math node. 😺NKD Gradient Generate makes one from scratch, no input image needed, and lets you place it with a Photoshop-style gizmo on the preview instead of a coordinate box.

Four shapes cover the practical set: Linear, Radial, Angular (conic), and Diamond. You edit the color ramp on the node itself - click the bar to add a stop, click a stop for the native color picker, drag to move, Shift-click to remove - and you can save and load your own ramps as presets, which means your "brand" gradient is one click away forever.

What you actually set

  • width / height - the output size (defaults 1024×1024). Ignored if you connect the optional image.
  • shape - Linear / Radial / Angular / Diamond.
  • handles and ramp - the JSON the editor writes; you drag on the preview rather than typing these. A midpoint diamond on the gizmo biases where the 50% color lands.
  • blend_mode - how the gradient composites over the optional image: multiply, screen, overlay, soft/hard light, add, difference, darken, lighten. This is the sneaky-good feature: a light leak, vignette, or sky grad composited straight over the image with no separate blend node.
  • opacity - how much of the composited gradient shows through (ignored when blend mode is none).

The optional image input is worth understanding: the gradient takes that image's size (width/height ignored), and with blend_mode you composite over it - or leave blend mode on none to use it purely as a size reference and get the bare gradient.

Outputs

image - the generated gradient. And mask, which is the luminance of the gradient - use it directly as a mask. That's the output most people miss and it's half the reason to use this node: a radial gradient's mask output is a soft-edged feathered matte for free, the thing you'd otherwise blur-and-threshold into existence.

Install and gotchas

Install via ComfyUI Manager (search ComfyUI-NKD-Basic-Tools) or:

cd ComfyUI/custom_nodes
git clone https://github.com/Nekodificador/ComfyUI-NKD-Basic-Tools

Restart after. Pack dependencies are onnxruntime and huggingface_hub; neither is needed here, so this loads on a bare install. Two things worth knowing: the mask output is always the gradient's own falloff (so a linear gradient gives you a linear alpha, not a hard matte), and the whole point of blend_mode is to skip a separate composite node - but only when you're compositing over an image, which means feeding an image in. For a standalone gradient, leave image unconnected.

Category😺NKD Nodes/Basic

Inputs (8)

NameTypeDefaultDescription
widthINT10248–8192—
heightINT10248–8192—
shapeCOMBOLinear4 options: Linear, Radial, Angular, Diamond
handlesSTRING{"p0": [0.0, 0.5], "p1": [1.0, 0.5], "mid": 0.5}Gradient handles, dragged on the preview above.
rampSTRING{"stops": [{"pos": 0.0, "color": "#000000"}, {"pos": 1.0, "color": "#ffffff"}]}The color ramp, edited above.
blend_modeCOMBOnoneHow the gradient composites over the optional image. 'none' outputs the bare gradient (the image only sets the size).
opacityFLOAT1.000–1How much of the composited gradient shows through. Ignored when blend_mode is 'none'.
imageoptIMAGEOptional — the gradient takes this image's size (width/height are ignored). Composite over it with blend_mode, or leave blend_mode on 'none' to use it as a size reference only.

Outputs (2)

NameTypeDescription
imageIMAGEThe generated gradient.
maskMASKLuminance of the gradient — use it as a mask.