ComfyUI Node

int

Whole numbers for shader logic, not shader math

By patriciogonzalezvivo·Created 2 years ago·Updated about a year ago· 246
int
    • int
    value0

    Some numbers need to stay whole. If you're picking a frame, choosing which of several textures to sample, or counting passes, a float feels wrong - you don't want 2.999 sloshing around in logic you expect to be discrete. That's the gap int fills in the GLSL Nodes pack: a single integer passthrough, default 0, output int.

    Like its float sibling, the node itself is a nothingburger - one input, one output, zero state. The value is how it becomes useful. When you connect it to a glslViewer, the front-end turns the connection into a u_valN uniform, and your shader reads it like any other value.

    The one honest gotcha

    Here's the thing people discover after wiring it up: in this pack, an int doesn't arrive at the shader as a GLSL int. The uniform system types incoming values as float (the U_VALN_TYPE define becomes float), so in your code you'll typically declare uniform float u_val0; even though you fed it an int. It still behaves like a whole number for practical purposes - you just don't get integer division semantics or ivec casts for free. If you genuinely need a real int uniform in the shader, you can read it from u_frame (the built-in frame counter), which is genuinely typed int.

    The practical upshot: think of int as "a knob that snaps to whole numbers," not "a GLSL int type." For index-style logic - if (u_val0 == 2) { … } - it works exactly as you'd hope.

    Inputs, install, and the shared pack

    • value - INT, default 0. Output: int.

    That's the whole schema. Install the pack once for all its 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". There are no model downloads; moderngl and numpy (and optional snowy) come from the pack's requirements.txt, which Manager installs for you.

    Honestly, most people reach for float first and only grab int when they hit the "I wanted 3, not 3.7" wall. That's a legitimate use - just remember the value's a float once it's inside the shader, and you won't be surprised.

    CategoryGLSL

    Inputs (1)

    NameTypeDefaultDescription
    valueINT0

    Outputs (1)

    NameTypeDescription
    intINT