Nodes/More Math/Noise math
ComfyUI Node

Noise math

Custom noise, written as math — the deep-end sampling node

By mcDandy·Created about a year ago·Updated 3 days ago· 5
Noise math
  • a
  • b
  • c
  • d
  • NOISE
Noisea*(1-w)+b*w
w0.00
x0.00
y0.00
z0.00

Noise math lets you build the noise the sampler uses, out of expressions. Most workflows never touch this - you plug RandomNoise into the KSampler and move on. But when you want structured, position-dependent, or blended noise instead of pure random, this is the node that writes it. The default expression, a*(1-w)+b*w, blends two noise generators; the interesting part is what you can reference inside the expression.

How it works

The key thing to understand: the output is not a noise tensor - it's a noise generator. The node hands you back an object that generates noise on demand, and it's evaluated later, when the sampler asks for noise at each step. That lazy design is why the expression can reference variables that only exist at generation time:

  • X, Y, W, H, C, B - position, dimensions, channel, batch
  • I / input_latent - the latent the noise is being generated for
  • w, x, y, z - your float knobs
  • plus the per-dimension index tensors

So a*(1-w)+b*w mixes two generators with a weight, and something like a * (1 - Y/H) makes noise that fades with vertical position. Each input generator's generate_noise() is called and fed into the expression.

The inputs that matter

  • a - required noise generator. b, c, d optional (missing ones become zero noise).
  • Noise - the expression, default a*(1-w)+b*w.
  • w, x, y, z - floats.

Output is a NOISE, which plugs into a sampler's noise input just like RandomNoise does.

Installing it

Part of More Math (mcDandy/more_math). ComfyUI Manager - search "More Math" - or:

cd ComfyUI/custom_nodes
git clone https://github.com/mcDandy/more_math
cd more_math
pip install -r requirements.txt

Restart. Dependencies are just antlr4-python3-runtime and torch. Needs a current ComfyUI (newer node API).

Where people get burned

Because evaluation is lazy, errors don't surface when you queue the graph - they blow up mid-sampling, when the generator runs and your expression produces the wrong shape or an undefined value. Debugging that means watching the sampler fail, not the node. If your custom noise has a bug, expect the error deep in the run log.

Second, the expression has to return something the same shape as the input latent. Mismatches fail at generation time, not at node time. Start from the default and modify one term at a time.

Honest verdict: this is the deepest node in the pack. If your goal is just "different random pattern," the core sampler and its seed controls already do that. Reach for Noise math when you specifically want structured, deterministic, position-dependent noise - for example, forcing certain frequencies or keeping noise consistent across a video in a way the standard generator can't. And like most of the pack, the classic form is deprecated in favor of an autogrow variant; both ship, and the newer one gives you more generator inputs.

Categorysd

Inputs (9)

NameTypeDefaultDescription
aNOISE
NoiseSTRINGa*(1-w)+b*wExpression to apply on input noise generators
boptNOISE
coptNOISE
doptNOISE
woptFLOAT0.00
xoptFLOAT0.00
yoptFLOAT0.00
zoptFLOAT0.00

Outputs (1)

NameTypeDescription
NOISENOISE