Vec4ScalarOperation
Scale a 4D vector by a plain number
- a
- VEC4
If you're carrying an RGBA color or a homogeneous coordinate as a single VEC4 and you need to scale the whole thing by one plain number - dim a color including its alpha, extend a coordinate - this is the node for that, in one step instead of splitting into four components and doing the math four times.
It's part of ComfyMath, evanspearman's math/logic pack, and it's the vector-times-number counterpart to CM_Vec4BinaryOperation (vector-plus-vector).
How it works
Feed it a (a VEC4, default [0, 0, 0, 0]) and b (a plain FLOAT - the scalar), pick an op: Mul or Div, and it applies that operation to all four components of a using b. One thing to actually watch for if you're treating a VEC4 as RGBA: this scales all four components uniformly, alpha included - multiplying by 0.5 to dim a color also halves its transparency, which usually isn't what you meant. If you only want to touch RGB, you'll need to break the vector apart first.
Worth flagging directly from the node's own definition: b doesn't ship with a default the way a does - a defaults to [0, 0, 0, 0], but b has no listed default. Make sure you've actually set b to something deliberate before running the graph, especially with Div selected - dividing by an unset or zero scalar produces infinity or NaN silently rather than an obvious error.
Inputs and outputs
op- Mul or Div.a(VEC4, default[0, 0, 0, 0]) - the vector being scaled.b(FLOAT) - the scalar to multiply or divide by. No default shown - set it explicitly.- Output:
VEC4- the scaled vector.
How to install it
Through ComfyUI Manager: search ComfyMath, install, restart. Manually:
cd ComfyUI/custom_nodes
git clone https://github.com/evanspearman/ComfyMath.git
then restart ComfyUI. No dependencies, no models to fetch - plain Python.
Common issues & troubleshooting
A color's alpha changed when you only meant to scale RGB. This node scales all four components uniformly - there's no way to exclude the fourth. Break the VEC4 into components first, scale the ones you actually want, and recompose if you need alpha left alone.
Output is infinity or NaN. Almost certainly a Div with b at or near zero. Since b doesn't have a guaranteed default, double-check what's actually wired into it before trusting the result downstream.
Missing node error on workflow load. Install ComfyMath through Manager as above, then reload.
Not sure you need this node at all. Most workflows never touch Vec4 nodes - this shows up specifically when you're building your own color, quaternion, or coordinate math rather than a standard generation graph.
The pack looks unmaintained. A 2024 community thread noted the author had stepped back from active development. It's plain math with no external dependencies, so there's little here that a ComfyUI update is likely to break.
Inputs (3)
| Name | Type | Default | Description |
|---|---|---|---|
| op | COMBO | 2 options: Mul, Div | |
| a | VEC4 | 0,0,0,0 | — |
| b | FLOAT | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| VEC4 | VEC4 | — |