Nodes/GLSL Nodes/glslUniforms
ComfyUI Node

glslUniforms

GlslUniforms — the caching node that keeps your shader workflows fast

By patriciogonzalezvivo·Created 2 years ago·Updated about a year ago· 246
glslUniforms
    • uniforms

    glslUniforms looks like nothing - it has no required inputs and one output - but it's the node that keeps video-shader workflows from being unbearably slow. It collects your textures and values into a single GLSL_CONTEXT that you hand to glslViewer, and it's the pack author's own recommendation for anything working with videos or long image sequences.

    Why it exists

    Every time glslViewer runs, it has to push your textures into GPU memory and set up the GL context. With a single image that's cheap. With a 90-frame video feeding a shader as a texture array, re-uploading every frame of that video every time you tweak one line of code is wasteful in a way you'll feel immediately - each edit triggers a full reload, and you sit there watching the progress bar crawl.

    glslUniforms fixes that by doing the loading once and holding onto the GLSL_CONTEXT. Connect your inputs to this node instead of the viewer, and the context - loaded textures, texture arrays, uniforms - gets cached and reused across runs. Edit your shader, re-run, and only the code recompiles, not the whole texture upload. If you've hit the "why is my GLSL workflow so slow to iterate" wall, this is the fix.

    How to use it

    The node has no fixed input slots; it's dynamically extensible. You connect images and values to it by name using the convention baked into the pack:

    • Inputs starting with u_tex become textures - a single image becomes a sampler2D, a batch of frames becomes a sampler2DArray (a texture array you sample in the shader as texture(u_tex0, vec3(st, u_frame))). The pack even defines U_TEX0_TYPE / U_TEX0_TOTALFRAMES macros so your shader can branch on what it was given.
    • Inputs starting with u_val become scalar or vector uniforms - an INT/FLOAT becomes a float, a VEC2/VEC3/VEC4 becomes the matching vecN.

    The single output is uniforms, typed GLSL_CONTEXT, and it plugs into glslViewer's optional uniforms input. Wire your vec4 (color) and vec2 (pos) nodes, your loaded images, your video frames - all of it - into glslUniforms, then one wire into the viewer.

    Gotchas

    Masks and optical flow get special treatment here. If a texture input comes in as a MASK (a single-channel tensor), the pack expands it to RGB and, when the optional snowy library is installed, generates a signed-distance field from it - encoded across the channels so your shader can use SDFs for soft edges. Flow textures (2-channel) get visualized as color-coded motion. Both are deliberate features, not corruption, so don't be surprised when a mask that was greyscale comes out multicolored.

    If snowy isn't installed, the mask just gets duplicated into three channels and you lose the SDF, so if you're doing mask work, let the pack install its snowy dependency.

    Install is the same as the rest of the pack: ComfyUI Manager → search "GLSL Nodes", or cd ComfyUI/custom_nodes && git clone https://github.com/patriciogonzalezvivo/comfyui_glslnodes, then restart.

    CategoryGLSL

    Inputs (0)

    No inputs

    Outputs (1)

    NameTypeDescription
    uniformsGLSL_CONTEXT