Nodes/comfyui-common-util/Enhanced Random Light Source
ComfyUI Node

Enhanced Random Light Source

A seeded studio-lighting overlay generator — but it doesn't composite for you

By longgui0318·Created 2 years ago·Updated about a year ago· 1
Enhanced Random Light Source
  • image
  • IMAGE
seed0

"Enhanced Random Light Source" generates a plausible multi-source lighting pass as an image, driven by a seed so you can reproduce the exact same lighting again and again. If you're batch-generating product shots or doing photorealism tests and want varied-but-reproducible lighting instead of the same flat glow every run, this is the node.

But read the fine print before you wire it up, because the name implies more than it delivers: it does not light your image for you. The input image is only used to gauge how bright the scene is. The output is a standalone lighting overlay - an RGBA image that's white where the light falls and transparent where it doesn't - which you then composite over your original. There's no blending step built in. Think of it as a light matte factory, not a lighting effect.

How it works

The generator is genuinely a bit clever for a utility node. It places between 3 and 7 light sources: with 70% probability a light sits off-canvas at an edge and casts directionally (its intensity is weighted by the cosine of the angle, so it fades as surfaces turn away), otherwise a light sits near the center and radiates evenly. Each source falls off with distance - 1 / (1 + (distance / (diagonal/4))²) - the layers are summed, normalized, and blurred with a Gaussian whose width scales with the image. Then 20% ambient is added and the peak intensity is scaled to roughly double your image's brightest pixels (based on the top 20% of the input's brightness, skipping pure white). The seed input seeds both Python's random and numpy, so the same seed gives you the same light layout every time.

Inputs and output

  • image (IMAGE) - read for base brightness only. It won't be composited onto.
  • seed (INT, default 0) - reproducibility knob. Same seed, same lights.

Output is a single IMAGE - the RGBA light overlay.

How to actually use it

Composite the output over your original. In ComfyUI terms that means a blend or alpha-composite node (or drop into any node that accepts RGBA on top of RGBA). If you want the light to tint as well as brighten, multiply it first; if you want it stronger or weaker, scale the alpha. The node's "enhanced" claim is fair - the multiple-source falloff does read more like real studio lighting than a single radial gradient - but the missing composite step is exactly where beginners get stuck: they run it, see a washed-out white-on-transparent image, and assume it's broken.

For batch work, the workflow to reach for: fixed image in, varying seed in, composite out - you get a cheap, deterministic set of lighting variants. Useful for training-data variation and product-photography iteration where "same product, different light" is the whole brief.

Installing it

It lives in the longgui0318/comfyui-common-util pack:

cd ComfyUI/custom_nodes
git clone https://github.com/longgui0318/comfyui-common-util
cd comfyui-common-util && pip install -r requirements.txt

Restart after, or use ComfyUI Manager and search "comfyui-common-util". The README is minimal and requirements.txt lists only opencv-python, but the pack imports scipy, scikit-image, and PyWavelets at load - if it won't load, pip install scipy scikit-image PyWavelets and restart. (This node's generator also uses scipy.ndimage, so that one is load-bearing here.)

Categoryutils

Inputs (2)

NameTypeDefaultDescription
imageIMAGE
seedINT0

Outputs (1)

NameTypeDescription
IMAGEIMAGE