Nodes/Jovi_GLSL/INVERT (JOV_GL)
ComfyUI Node

INVERT (JOV_GL)

Invert per channel, not all-or-nothing — and it's the pack's smallest node

By Amorano·Created 2 years ago·Updated about a year ago· 20
INVERT (JOV_GL)
  • image
  • invert
  • RGBA
  • RGB
  • MASK
FRAGMENT// name: INVERT // desc: Invert the channels of an image along a scalar [0..1] range. // category: COLOR uniform sampler2D image; // | 4-channel data uniform vec4 invert; // 0,0,0,0;0;1 | amount to invert each channel void mainImage( out vec4 fragColor, in vec2 fragCoord ) { vec2 uv = fragCoord.xy / iResolution.xy; vec4 col = texture(image, uv); fragColor = mix(col, 1.0 - col, invert); }

Invert is the node you'd assume every pack has, and most do - but most give you a single "invert or don't" switch. This one inverts each of the four channels by its own amount, on a 0–1 scale, which means it's less "negative filter" and more "per-channel negation tool." Invert the green channel alone and a portrait goes magenta-cyan in one step. Invert just the alpha and your mask flips, which is shockingly useful in compositing and is the reason you'd actually seek this node out over the built-in alternatives.

How it works

The shader is four lines: mix(color, 1.0 - color, invert). The invert VEC4 holds one weight per channel - R, G, B, A - where 0 means "leave this channel alone" and 1 means "fully invert it." Anything between is a partial mix. The defaults are (0, 0, 0, 0), i.e., a pass-through, so unlike a lot of filter nodes this one ships in the "doing nothing" state and you push it into effect.

The inputs

  • image - described in the schema as "4-channel data," so this node wants RGBA. It'll take plain RGB too, but the fourth channel is where the per-channel inversion earns its keep.
  • invert - the four per-channel weights, default (0, 0, 0, 0).

Outputs are the pack standard: RGBA, RGB, and MASK. The MASK output on an alpha-inverted pass is where you get "negative of my selection" for free - hand this to a compositing step and you've saved yourself a mask math node.

Install

Same one-time install as the rest of the pack. Via ComfyUI Manager, search Jovi_GLSL; or:

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

Restart ComfyUI. Dependencies: PyOpenGL, glfw, opencv-contrib-python, cozy_comfyui from git; needs an OpenGL context. No models, no keys. It lives in **JOVI_GLSL 🌈 → COLOR`.

Gotchas

The most common "why is nothing happening" is the all-zero default - remember you have to actually dial a channel toward 1 before anything changes. And because inversion on a per-channel basis produces wild, possibly hue-inverted colors, don't expect "invert as a color negative" unless you set all four to 1. For a true photographic negative, all four at 1 is what you want; partial weights are for targeted tricks like the alpha flip above.

CategoryJOV_GL 🌈/COLOR

Inputs (3)

NameTypeDefaultDescription
imageoptIMAGE4-channel data
invertoptVEC40,0,0,0amount to invert each channel
FRAGMENToptSTRING// name: INVERT // desc: Invert the channels of an image along a scalar [0..1] range. // category: COLOR uniform sampler2D image; // | 4-channel data uniform vec4 invert; // 0,0,0,0;0;1 | amount to invert each channel void mainImage( out vec4 fragColor, in vec2 fragCoord ) { vec2 uv = fragCoord.xy / iResolution.xy; vec4 col = texture(image, uv); fragColor = mix(col, 1.0 - col, invert); }

Outputs (3)

NameTypeDescription
RGBAIMAGEFull channel [RGBA] image. If there is an alpha, the image will be masked out with it when using this output.
RGBIMAGEThree channel [RGB] image. There will be no alpha.
MASKMASKSingle channel mask output.