ComfyUI Node

Gradient RGB image

The gradient generator gradient scaling wants

By Extraltodeus·Created 2 years ago·Updated about a year ago· 66
Gradient RGB image
  • mask
  • IMAGE
  • MASK
width1024
height1024
r10
g10
b10
r2255
g2255
b2255
axis
power_to1
reverse_powerfalse

Pre CFG gradient scaling lets you steer a generation by feeding it an image - and its README is basically a gallery of what you can do with gradients specifically: light coming from one corner, a vignette that darkens the edges, a color field that shifts the whole palette. Gradient RGB image is the generator purpose-built for those. It's the sibling of Empty RGB image in this pack, but instead of a flat color it produces a smooth ramp between two colors, with a matching mask output that makes vignettes trivial.

The mechanism is straightforward tensor math: it builds a 0-to-1 gradient across the image, then interpolates from your first color to your second color along it. What makes it more than a toy is axis - vertical, horizontal, or circular. The circular mode multiplies two perpendicular sine gradients together to produce a radial falloff, which is exactly the shape you want for a vignette. power_to (1–16) is the curve control: crank it past 1 and the gradient concentrates toward one end instead of ramping evenly, which is how you turn a gentle light gradient into a hard spotlight effect. reverse_power flips which end gets the concentration.

Inputs to care about:

  • r1/g1/b1 and r2/g2/b2 - the start and end colors of the ramp (default black to white).
  • axis - vertical, horizontal, or circular.
  • power_to / reverse_power - the falloff curve.
  • Optional mask - multiply the gradient by an existing mask to confine it to part of the image.

The outputs are the useful part: IMAGE is the colored gradient to feed into gradient scaling as a guide, and MASK is the same gradient as a mask - wire that into gradient scaling's input_mask and you've built a per-pixel strength control for free. The README's vignetting example is literally "circular gradient + its own mask."

Where this node shines is the pattern-matching side of gradient scaling: a black-and-white spiral, a blue-on-black ramp, a text-like block - because gradient scaling works on values, not semantics, a clean procedural gradient gives it a clear target to push the generation toward without any image editing software.

Install with the rest of the pack:

cd ComfyUI/custom_nodes
git clone https://github.com/Extraltodeus/pre_cfg_comfy_nodes_for_ComfyUI

or via ComfyUI Manager searching pre_cfg_comfy_nodes_for_ComfyUI, then restart. No dependencies beyond torch.

If gradient scaling is the experiment bench, this node is the paint you mix on it. Start with a vertical ramp and power_to of 2 - that's the classic "light from the left" test.

Categoryimage

Inputs (12)

NameTypeDefaultDescription
widthINT10240–16384
heightINT10240–16384
r1INT00–255
g1INT00–255
b1INT00–255
r2INT2550–255
g2INT2550–255
b2INT2550–255
axisCOMBO3 options: vertical, horizontal, circular
power_toINT11–16
reverse_powerBOOLEANfalse
maskoptMASK

Outputs (2)

NameTypeDescription
IMAGEIMAGE
MASKMASK