ComfyUI Node

vec3

Three floats in a trenchcoat, for colors and 3D positions

By patriciogonzalezvivo·Created 2 years ago·Updated about a year ago· 246
vec3
    • vec3
    x0.000
    y0.000
    z0.000

    A vec3 is just x, y, z traveling as one value, and in shader land that one value is doing a shocking amount of work: a color (RGB), a 3D position, a direction, a normal, a light intensity. This node is the pack's blunt instrument for all of those - three number fields, one vec3 output, no ceremony.

    It becomes meaningful when it hits a shader. Connect it to a glslViewer and the front-end names the connection u_valN, sets #define U_VALN_TYPE vec3, and your code can do:

    uniform vec3 u_val0;
    // ...
    color.rgb = u_val0;            // tint a whole pass
    vec3 dir = normalize(u_val0);  // point a raymarch at something
    

    If you've ever watched someone's raymarching demo and thought "how do I change where the light is without editing the code?" - this is the answer. The math in the shader stays put; the numbers become wires you can drag.

    Inputs that matter

    • x, y, z - FLOAT each, default 0, step 0.001. Output: vec3.

    That's the entire schema. Note the defaults are all zero - which for a color is black and for a position is the origin, so the node alone renders nothing interesting. It's a feed, not a result.

    The sibling you'll sometimes want instead

    For 3D positioning specifically - a light source, a camera target, a point in space - consider vec3 (pos), which gives you a draggable 3D pad instead of three number boxes. And for colors, vec4 (color) gives you an actual color picker with an alpha channel. The plain vec3 is the right tool when you want explicit control over each component, or when your value isn't spatial or chromatic at all (like a three-part blend weight).

    Install - one pack, all nodes

    cd ComfyUI/custom_nodes
    git clone https://github.com/patriciogonzalezvivo/comfyui_glslnodes
    

    Restart ComfyUI after cloning, or use ComfyUI Manager and search "GLSL Nodes". No model files anywhere - the pack is pure code, with moderngl and numpy (and optional snowy) pulled from its requirements.txt. If you're on a headless box, remember this whole pack renders through an offscreen OpenGL context, so a machine without a working GL stack won't play nice regardless of which value node you pick.

    CategoryGLSL

    Inputs (3)

    NameTypeDefaultDescription
    xFLOAT0.000-18446744073709550000–18446744073709550000
    yFLOAT0.000-18446744073709550000–18446744073709550000
    zFLOAT0.000-18446744073709550000–18446744073709550000

    Outputs (1)

    NameTypeDescription
    vec3VEC3