glslUniforms
GlslUniforms — the caching node that keeps your shader workflows fast
- 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_texbecome textures - a single image becomes asampler2D, a batch of frames becomes asampler2DArray(a texture array you sample in the shader astexture(u_tex0, vec3(st, u_frame))). The pack even definesU_TEX0_TYPE/U_TEX0_TOTALFRAMESmacros so your shader can branch on what it was given. - Inputs starting with
u_valbecome scalar or vector uniforms - anINT/FLOATbecomes afloat, aVEC2/VEC3/VEC4becomes the matchingvecN.
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.
Inputs (0)
No inputs
Outputs (1)
| Name | Type | Description |
|---|---|---|
| uniforms | GLSL_CONTEXT | — |