ComfyUI Node

vec2

Shader offsets, directions, and UV nudges in one node

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

    A vec2 is two floats that travel together, and if you've ever written a shader you know how often you need exactly that: a UV offset, a direction, a scale, a single point in 2D space. vec2 in this pack is the no-frills way to hand one of those to your shader - two number fields (x, y), one vec2 output, nothing else on the node.

    When you connect it to a glslViewer, the front-end registers the connection as a u_valN uniform and sets #define U_VALN_TYPE vec2. In your shader that means:

    uniform vec2 u_val0;
    // ...
    vec2 shifted = st + u_val0;
    

    That's the whole trick of the pack: the value nodes exist so your shader code can stay generic and the numbers can live as tweakable wires in the graph.

    Inputs that matter

    • x - FLOAT, default 0
    • y - FLOAT, default 0

    Both step at 0.001, and the range is effectively unbounded (you can go far into negative or positive territory). Output: vec2.

    Two ways to use it, depending on what you're doing. If you're nudging UVs or scrolling textures by fractions of a unit, the plain x/y fields are perfect. If you're pointing at a place - "the center of this mask," "where the light comes from" - you'll probably prefer the vec2 (pos) sibling, which swaps these two number boxes for a draggable 2D pad you can click on directly. Same output type, same wire, friendlier input for spatial thinking.

    Install (shared with the whole pack)

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

    Restart, or just search "GLSL Nodes" in ComfyUI Manager. No models to fetch - the only "download" is the pack's own code plus moderngl/numpy from requirements.txt. If Manager isn't your thing, pip install -r requirements.txt in the cloned folder does the same job.

    One practical note: vec2 outputs a tuple, not a torch tensor or anything ComfyUI-native, so don't try to wire it into image-processing nodes that expect IMAGE data. It's strictly shader fuel - it wants to land on a glslViewer (or a glslUniforms context) input. If a connection won't attach, that's why.

    CategoryGLSL

    Inputs (2)

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

    Outputs (1)

    NameTypeDescription
    vec2VEC2