{"record":{"id":"5f9bf6c9481d50dd","repo":"Comfy-Org/ComfyUI","slug":"shader-compilation-failed-n-error","errorCode":null,"errorMessage":"Shader compilation failed:\\n{error}","messagePattern":"Shader compilation failed:\\\\n(.+?)","errorType":"exception","errorClass":"RuntimeError","httpStatus":null,"severity":"error","filePath":"comfy_extras/nodes_glsl.py","lineNumber":354,"sourceCode":"        try:\n            EGL.eglTerminate(self._display)\n        except Exception:\n            pass\n        self._display = None\n\n\ndef _compile_shader(source: str, shader_type: int) -> int:\n    \"\"\"Compile a shader and return its ID.\"\"\"\n    shader = gl.glCreateShader(shader_type)\n    gl.glShaderSource(shader, source)\n    gl.glCompileShader(shader)\n\n    if not gl.glGetShaderiv(shader, gl.GL_COMPILE_STATUS):\n        error = gl.glGetShaderInfoLog(shader)\n        if isinstance(error, bytes):\n            error = error.decode(errors=\"replace\")\n        gl.glDeleteShader(shader)\n        raise RuntimeError(f\"Shader compilation failed:\\n{error}\")\n\n    return shader\n\n\ndef _create_program(vertex_source: str, fragment_source: str) -> int:\n    \"\"\"Create and link a shader program.\"\"\"\n    vertex_shader = _compile_shader(vertex_source, gl.GL_VERTEX_SHADER)\n    try:\n        fragment_shader = _compile_shader(fragment_source, gl.GL_FRAGMENT_SHADER)\n    except RuntimeError:\n        gl.glDeleteShader(vertex_shader)\n        raise\n\n    program = gl.glCreateProgram()\n    gl.glAttachShader(program, vertex_shader)\n    gl.glAttachShader(program, fragment_shader)\n    gl.glLinkProgram(program)\n","sourceCodeStart":336,"sourceCodeEnd":372,"githubUrl":"https://github.com/Comfy-Org/ComfyUI/blob/1c6d8d45b3693bfbb32385b410d813a7fd6be216/comfy_extras/nodes_glsl.py#L336-L372","documentation":"Raised by _compile_shader() when glGetShaderiv(GL_COMPILE_STATUS) is false; the raised message embeds the driver's info log. This is a user-code error: the GLSL source string supplied to the GLSL node (vertex or, almost always, fragment code) does not compile under the context's GLSL ES 3.00 profile.","triggerScenarios":"Writing desktop GLSL (e.g. #version 330 core, texture2D, gl_FragColor, varying) instead of GLSL ES 300 syntax (in/out, texture(), precision qualifiers); missing precision qualifier for float in fragment shader; undefined variables/functions; integer/float literal mix-ups (1 instead of 1.0).","commonSituations":"Porting Shadertoy or desktop GLSL shaders into the node without converting to ES 3.00; typos in uniform names; using functions from extensions the driver does not expose.","solutions":["Read the info log embedded in the error text — it names the line and the syntax problem.","Start the shader with '#version 300 es' and use in/out instead of attribute/varying, and an explicit 'precision highp float;' in the fragment shader.","Replace legacy calls: texture2D(s, uv) -> texture(s, uv), gl_FragColor -> a declared out vec4.","Verify the shader on a site like shadertoy-ish ES validators or with glslangValidator before pasting it in."],"exampleFix":"// before\nvarying vec2 v_uv;\nvoid main() { gl_FragColor = texture2D(img, v_uv); }\n\n// after\nprecision highp float;\nin vec2 v_uv;\nuniform sampler2D img;\nout vec4 fragColor;\nvoid main() { fragColor = texture(img, v_uv); }","handlingStrategy":"validation","validationCode":"import re\ndef glsl_es300_ok(src: str) -> bool:\n    src = re.sub(r\"/\\*.*?\\*/\", \"\", src, flags=re.S).split(\"#version\")[-1]\n    bad = re.findall(r\"\\b(?:varying|attribute|texture2D|texture3D|gl_FragColor)\\b\", src)\n    return not bad and (\"300 es\" in src or \"#version\" not in src)\nassert glsl_es300_ok(fragment_code), \"shader uses desktop-GLSL syntax rejected by GLES3\"","typeGuard":null,"tryCatchPattern":"try:\n    out = run_glsl(fragment_code, ...)\nexcept RuntimeError as e:\n    if \"Shader compilation failed\" in str(e):\n        show_shader_editor_error(str(e))  # surface driver info log with line numbers to the user\n    raise","preventionTips":["Start every fragment shader with '#version 300 es' and 'precision highp float;'.","Convert Shadertoy ports: texture2D -> texture, gl_FragColor -> out vec4.","Validate with glslangValidator before pasting into the node.","Read the embedded info log — it names the exact line."],"tags":["glsl","shader","syntax","opengl"],"backgroundTag":null,"analyzedSha":"1c6d8d45b3693bfbb32385b410d813a7fd6be216","analyzedAt":"2026-08-14T19:37:18.893Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}