{"record":{"id":"4973fc276d4be4ed","repo":"phaserjs/phaser","slug":"link-shader-failed","errorCode":null,"errorMessage":"Link Shader failed:","messagePattern":"Link Shader failed:","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"src/renderer/webgl/wrappers/WebGLProgramWrapper.js","lineNumber":345,"sourceCode":"        var fs = this._fragmentShader;\n\n        var failed = 'Shader failed:\\n';\n\n        if (!gl.getProgramParameter(program, gl.LINK_STATUS))\n        {\n            if (!gl.getShaderParameter(vs, gl.COMPILE_STATUS))\n            {\n                console.log(this.vertexSource);\n                throw new Error('Vertex ' + failed + gl.getShaderInfoLog(vs));\n            }\n\n            if (!gl.getShaderParameter(fs, gl.COMPILE_STATUS))\n            {\n                console.log(this.fragmentSource);\n                throw new Error('Fragment ' + failed + gl.getShaderInfoLog(fs));\n            }\n            console.log(this.vertexSource, this.fragmentSource);\n            throw new Error('Link Shader failed:' + gl.getProgramInfoLog(program));\n        }\n\n        this._setupAttributesAndUniforms();\n\n        this.compileTimeMs = performance.now() - this._compileStartTime;\n        this.compiling = false;\n    },\n\n    /**\n     * Set up the attributes and uniforms for this program.\n     * This is called after the program is created or re-created.\n     *\n     * @method Phaser.Renderer.WebGL.Wrappers.WebGLProgramWrapper#_setupAttributesAndUniforms\n     * @private\n     * @since 4.0.0\n     */\n    _setupAttributesAndUniforms: function ()\n    {","sourceCodeStart":327,"sourceCodeEnd":363,"githubUrl":"https://github.com/phaserjs/phaser/blob/41be1e462bc600064e498cba370bfa8c5c055a22/src/renderer/webgl/wrappers/WebGLProgramWrapper.js#L327-L363","documentation":"Thrown by WebGLProgramWrapper when both vertex and fragment shaders compiled successfully but gl.LINK_STATUS is still false. This means the shaders are individually valid but incompatible with each other (e.g. varying/in-out mismatch, missing attribute bindings, or unsupported feature combination). Both shader sources are console.logged before the throw.","triggerScenarios":"Vertex shader outputs (varying/out) that the fragment shader does not consume or declares with a different type; fragment shader inputs the vertex shader never writes; missing/inconsistent layout(location=...) bindings; exceeding varying limits; using transform-feedback-only varyings incorrectly.","commonSituations":"Mixing GLSL versions between the two shaders (vertex 1.0, fragment 3.0); editing one shader but not the other during development; renaming a varying in one file only; shaderAdditions that patch one stage but not the matching one.","solutions":["Read gl.getProgramInfoLog output appended to the error; link errors usually name the mismatched varying.","Ensure vertex 'out' declarations and fragment 'in' declarations match in name, type, and (for WebGL2) layout location.","Use a consistent #version in both stages.","Confirm shaderAdditions applied to one stage have a matching patch in the other where varyings cross the boundary.","Compare the two console.logged sources side by side for the interface block."],"exampleFix":"// before: vertex outputs vUv but fragment declares inTuv\n// vertex: out vec2 vUv;\n// fragment: in vec2 inTuv; // name mismatch -> link fails\n\n// after\n// fragment: in vec2 vUv;","handlingStrategy":"try-catch","validationCode":"function interfacesMatch(vsOuts, fsIns) {\n  const v = new Set(vsOuts.map(o => o.name + ':' + o.type));\n  return fsIns.every(i => v.has(i.name + ':' + i.type));\n}","typeGuard":null,"tryCatchPattern":"try { program.create(vs, fs); } catch (e) { if (/Link Shader failed/.test(e.message)) { console.error('Link error:', e.message); /* align varyings between stages */ } else throw e; }","preventionTips":["Keep vertex/fragment varying declarations in a shared GLSL chunk.","Use the same #version in both stages.","When patching one stage with shaderAdditions, patch the matching one too."],"tags":["renderer","webgl","shader","glsl","program-link","phaser4"],"backgroundTag":null,"analyzedSha":"41be1e462bc600064e498cba370bfa8c5c055a22","analyzedAt":"2026-08-13T04:23:39.729Z","schemaVersion":2},"datasetVersion":"2026-08-13T09:17:06.757Z"}