Nodes/Jovimetrix/SWIZZLE (JOV) 😡
ComfyUI Node

SWIZZLE (JOV) 😡

Recombine vector components without the headache

By AmoranoΒ·Created 3 years agoΒ·Updated 12 months agoΒ· 397
SWIZZLE (JOV) 😡
  • πŸ…°οΈ
  • πŸ…±οΈ
  • VECTOR
  • πŸ¦„
◄❓VEC3β–Ί
β—„SWAP XA_Xβ–Ί
β—„SWAP YA_Yβ–Ί
β—„SWAP ZA_Zβ–Ί
β—„SWAP WA_Wβ–Ί

Swizzling is one of those graphics-programming tricks that sounds exotic until you see how often it's the exact thing you need. You have two vectors - a position and an offset, a color and a mask, anything - and you want to rearrange their components into a new one. Maybe you want (B.x, A.y, A.z, A.w) because one axis should come from the other vector. Doing that with separate VALUE nodes and manual math is a chore. SWIZZLE is that chore, packaged.

It takes πŸ…°οΈ and πŸ…±οΈ - any of the numeric types: boolean, int, float, vec2/3/4, or 2D/3D coordinates. Then four swizzle controls, one per output component: SWAP X, SWAP Y, SWAP Z, and SWAP W. Each is a dropdown that picks where that output component comes from: a component of A (A_X, A_Y, A_Z, A_W), a component of B (B_X, B_Y, B_Z, B_W), or a CONSTANT. When you choose CONSTANT, the value comes from the VECTOR input (a VEC4, default all zeros). The ❓ dropdown sets what comes out the other end - VEC2, VEC2INT, VEC3, VEC3INT, VEC4, VEC4INT, or COORD2D - so you build exactly the shape you need. The single output πŸ¦„ matches that requested type.

In practice: swap the first component of A for the first component of B and you've "crossed" two values. Rearrange (B_X, A_Y, A_Z, A_W) to pull one axis from a second vector - the bread and butter of aligning two objects or clamping one dimension. Mix in CONSTANT and you can pin an output axis to a fixed number without a separate node. If your vectors are RGBA colors, swizzle is also channel remapping: (B_R, B_G, A_B, A_A) mixes two colors' channels into one, which is the same idea as PIXEL SWAP but on pure values instead of images.

Two things to know before you click around. First, the tooltips on SWAP X/Y/Z are a bit sloppy - they all say "Replace input Red channel..." even for the W axis; that's a copy-paste from the color version, ignore the wording and trust the dropdown semantics. Second, the defaults are identity (A_X, A_Y, A_Z, A_W), so a fresh SWIZZLE passes A through unchanged - a good sanity anchor when you're debugging a rearrangement.

SWIZZLE is a current node, and it got a real quality pass in the pack's 2.1.0 cleanup, where the output-type enums were aligned with the cozy_comfyui system. If you're feeding it from a VALUE (JOV) node or a ComfyMath vector, they interoperate fine - the pack explicitly added ComfyMath compatibility in 2.1.5.

Install is pack-wide: ComfyUI Manager β†’ search "Jovimetrix", or

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

then restart. Shared dependencies only (numpy, opencv-contrib-python, Pillow, matplotlib, cozy-comfyui helpers), no model downloads. Keep ComfyUI at 0.1.3+ with a current frontend and you're good.

CategoryJOVIMETRIX πŸ”ΊπŸŸ©πŸ”΅/CALC

Inputs (8)

NameTypeDefaultDescription
πŸ…°οΈoptBOOLEAN,FLOAT,INT,VEC2,VEC3,VEC4,VEC2INT,VEC3INT,VEC4INT,COORD2D,COORD3DInput A
πŸ…±οΈoptBOOLEAN,FLOAT,INT,VEC2,VEC3,VEC4,VEC2INT,VEC3INT,VEC4INT,COORD2D,COORD3DInput B
❓optCOMBOVEC3Output type desired from resultant operation
SWAP XoptCOMBOA_XReplace input Red channel with target channel or constant
SWAP YoptCOMBOA_YReplace input Red channel with target channel or constant
SWAP ZoptCOMBOA_ZReplace input Red channel with target channel or constant
SWAP WoptCOMBOA_WReplace input W channel with target channel or constant
VECTORoptVEC40,0,0,0Compound value of type float, vec2, vec3 or vec4

Outputs (1)

NameTypeDescription
πŸ¦„*β€”