Nodes/GLSL Nodes/vec4 (color)
ComfyUI Node

vec4 (color)

Vec4 (color) — set a shader color with a real color picker

By patriciogonzalezvivo·Created 2 years ago·Updated about a year ago· 246
vec4 (color)
  • color
  • vec4

If your shader has a color parameter, this is the node you want on the graph. vec4 (color) gives you a color picker widget right on the node and outputs the chosen color as a VEC4 - RGBA - ready to become a uniform vec4 in your GLSL. It's the colored, friendlier cousin of the plain vec4 node, and it's one of the genuinely nice little touches in the GLSL Nodes pack.

Here's the thing that makes it worth using over typing four numbers: colors have a natural visual form, and a picker exploits that. You drag in the color field, you see the color, the shader updates. There's no mental translation between "what number is magenta" and "what color did I mean." For a background tint, a fog color, an ambient light, a clear color - the picker is the correct tool, and it's right there on the node.

Input and output

One input: color, a VEC4COLOR widget. The default is [1, 0, 0, 1] - solid red with full alpha, the classic graphics-programmer default.

One output: vec4, typed VEC4. Wire it into a glslUniforms node as a u_val* input and it becomes a uniform vec4 u_val0 (or whatever you name it) in your shader. The values come through as RGBA floats in 0-to-1 range, which is what GLSL uniforms expect - no 0-to-255 conversion to worry about, and the widget's internal a component maps to the shader's alpha.

The small print

Two notes worth keeping in your head. First, the RGBA ordering: it's red, green, blue, alpha, not the other way around. Get it backwards and your shader will be reading alpha as red, which makes for genuinely confusing output. Second, the widget is a frontend widget, same as the position widgets in this pack - if the picker doesn't render or doesn't respond, refresh the ComfyUI browser page before suspecting your shader code.

Install

ComfyUI Manager → search "GLSL Nodes", or cd ComfyUI/custom_nodes && git clone https://github.com/patriciogonzalezvivo/comfyui_glslnodes, then restart. Dependencies (moderngl, numpy, snowy) install on first boot. And remember: if you're sending this to a shader as a color, keep the alpha at 1.0 unless you specifically want the mask output of glslViewer to be affected - the alpha channel is what becomes the MASK output, so a transparent "color" will also zero out your masks.

CategoryGLSL

Inputs (1)

NameTypeDefaultDescription
colorVEC4COLOR1,0,0,1

Outputs (1)

NameTypeDescription
vec4VEC4