Nodes/GLSL Nodes/glslEditor
ComfyUI Node

glslEditor

GlslEditor — the node where your shader code actually lives

By patriciogonzalezvivo·Created 2 years ago·Updated about a year ago· 246
glslEditor
    • GLSL_CODE
    version140
    code // <NAME>_TYPE: have the uniform type //uniform U_TEX0_TYPE u_tex0; //uniform U_TEX0_TYPE u_val0; uniform vec4 u_date; uniform vec2 u_resolution; uniform float u_delta; uniform float u_time; uniform float u_fps; uniform int u_frame; void main() { vec4 color = vec4(0.0, 0.0, 0.0, 1.0); vec2 pixel = 1.0 / u_resolution; vec2 st = gl_FragCoord.xy * pixel; color.rgb = vec3(st, 0.5 + 0.5 * cos(u_time)); // texture arrays have this <NAME>_TOTALFRAMES //#ifdef U_TEX0_TOTALFRAMES //color = texture(u_tex0, vec3(st, float(u_frame))); //#else //color = texture(u_tex0, st); //#endif gl_FragColor = color; }
    typefragment

    If glslViewer is the engine, this is the steering wheel. glslEditor is the plain text-input node that holds a fragment shader and hands it to the renderer as a GLSL_CODE. You write GLSL, it compiles, the viewer draws. That's the whole job, and the node's real value is in how much shader infrastructure it quietly handles for you.

    It's from Patricio Gonzalez Vivo, the guy behind The Book of Shaders, the standalone glslViewer, and the LYGIA shader library. This pack is basically his GLSL tooling retrofitted into ComfyUI, so the editor follows the conventions his ecosystem already uses.

    What you actually set

    Three inputs, and only two matter on a typical run:

    • version - GLSL version, default 140. This is the one that bites people. Not all drivers support all versions: the author's own note flags 130, 420, 430, and 440 as unsupported on macOS. If your shader fails to compile on a weird version, drop back to 140 or 330.
    • code - the shader source, as a big multiline text box. The default template is worth reading before you replace it: it declares the standard uniforms (u_time, u_resolution, u_frame, u_delta, u_fps, u_date) and shows the commented pattern for texture and value uniforms.
    • type - fragment or fragment (shadertoy). Shadertoy mode wraps your code in a header that aliases the standard uniforms to Shadertoy's names (iTimeu_time, iResolutionu_resolution, iFrame, iDate, iChannel0-3). It also forces version 400 and expects you to write a mainImage(out vec4, in vec2) like you would on the site - so pasting Shadertoy code in here genuinely works, which is the fastest way to get something impressive on screen in two minutes.

    The single output is GLSL_CODE, and it wires into glslViewer's fragment_code input.

    The hidden machinery

    The interesting part happens at output time. The node resolves every #include directive before emitting the code - local files if they exist, otherwise it fetches from LYGIA's server (lygia.xyz). That means you can write #include "lygia/math/decimate.glsl" and get a real function library for free, not a copy-paste job. One caveat: that fetch is a network call at runtime, so if your machine is offline, includes silently fail and your shader won't compile.

    Install

    ComfyUI Manager → search "GLSL Nodes", or cd ComfyUI/custom_nodes && git clone https://github.com/patriciogonzalezvivo/comfyui_glslnodes, then restart. Dependencies (moderngl, numpy, snowy) install automatically on first boot.

    Troubleshooting

    Shader errors don't fail the graph gracefully - they show up as compiler output in the ComfyUI console, with line numbers mapped back to your code via a #line 1 directive, so check the terminal, not the node. If a shader that worked in the plain editor fails in Shadertoy mode, it's almost always the forced version bump to 400 colliding with driver limitations.

    Honest take: for one-off tinkering this is fine, but if you're writing anything longer than a paragraph of GLSL, grab glslEditorPro instead - same node, but with an actual ACE code editor, syntax highlighting, and LYGIA autocomplete built into the node's UI.

    CategoryGLSL

    Inputs (3)

    NameTypeDefaultDescription
    versionCOMBO14012 options: 100, 120, 130, 140, 150, 330, +6
    codeSTRING // <NAME>_TYPE: have the uniform type //uniform U_TEX0_TYPE u_tex0; //uniform U_TEX0_TYPE u_val0; uniform vec4 u_date; uniform vec2 u_resolution; uniform float u_delta; uniform float u_time; uniform float u_fps; uniform int u_frame; void main() { vec4 color = vec4(0.0, 0.0, 0.0, 1.0); vec2 pixel = 1.0 / u_resolution; vec2 st = gl_FragCoord.xy * pixel; color.rgb = vec3(st, 0.5 + 0.5 * cos(u_time)); // texture arrays have this <NAME>_TOTALFRAMES //#ifdef U_TEX0_TOTALFRAMES //color = texture(u_tex0, vec3(st, float(u_frame))); //#else //color = texture(u_tex0, st); //#endif gl_FragColor = color; }
    typeCOMBOfragment2 options: fragment, fragment (shadertoy)

    Outputs (1)

    NameTypeDescription
    GLSL_CODEGLSL_CODE