{"record":{"id":"398f609154ec1160","repo":"phaserjs/phaser","slug":"vertex-shader-failed","errorCode":null,"errorMessage":"Vertex Shader failed:\n","messagePattern":"Vertex Shader failed:\n","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"src/renderer/webgl/wrappers/WebGLProgramWrapper.js","lineNumber":336,"sourceCode":"     * @private\n     * @since 4.0.0\n     */\n    _completeProgram: function ()\n    {\n        var program = this.webGLProgram;\n        var renderer = this.renderer;\n        var gl = renderer.gl;\n        var vs = this._vertexShader;\n        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    /**","sourceCodeStart":318,"sourceCodeEnd":354,"githubUrl":"https://github.com/phaserjs/phaser/blob/41be1e462bc600064e498cba370bfa8c5c055a22/src/renderer/webgl/wrappers/WebGLProgramWrapper.js#L318-L354","documentation":"Thrown by WebGLProgramWrapper when a shader program fails to link AND the vertex shader failed to compile. The error message is 'Vertex ' + 'Shader failed:\\n' + the GL info log, and the vertex source is console.logged just before throwing so the developer can inspect the offending GLSL.","triggerScenarios":"Supplying a vertex shader with a syntax error, undeclared uniform/attribute, unsupported GLSL version/extension, type mismatch, or undefined function. Triggered when the program is created and link is attempted.","commonSituations":"Typing errors in custom GLSL; using WebGL2-only syntax (e.g. 'in'/'out' qualifiers, #version 300 es) on a WebGL1 context or vice versa; referencing an attribute the layout doesn't declare; shader injection via shaderAdditions producing invalid GLSL; vendor-specific reserved keywords.","solutions":["Read the info log appended to the error; it names the line and the GLSL error.","Inspect the console.log of the vertex source to see exactly what the compiler received (after additions are applied).","Match the GLSL version to the context version (WebGL1 = glsl 1.0 with attribute/varying; WebGL2 = 3.0 es with in/out and #version 300 es).","Validate the shader in a tool like ShaderToy or the GLSL validator before loading.","Disable suspect shaderAdditions one at a time to isolate which injection broke the source."],"exampleFix":"// before (WebGL2 context, wrong qualifiers)\nattribute vec2 aPos;\n\n// after\n#version 300 es\nin vec2 aPos;","handlingStrategy":"try-catch","validationCode":"function validateVertexShaderGLSL(src, isWebGL2) {\n  if (isWebGL2 && !/^#version\\s+300\\s+es/m.test(src) && /\\battribute\\b|\\bvarying\\b/.test(src)) {\n    console.warn('Vertex shader uses WebGL1 qualifiers under WebGL2');\n  }\n}","typeGuard":null,"tryCatchPattern":"try { program.create(vertexSource, fragmentSource); } catch (e) { if (/Vertex Shader failed/.test(e.message)) { console.error('Vertex compile error:', e.message, vertexSource); /* fix GLSL */ } else throw e; }","preventionTips":["Match GLSL version to the context.","Validate shaders offline before loading.","Inspect the console.logged source to confirm shaderAdditions didn't corrupt it."],"tags":["renderer","webgl","shader","glsl","phaser4"],"backgroundTag":null,"analyzedSha":"41be1e462bc600064e498cba370bfa8c5c055a22","analyzedAt":"2026-08-13T04:23:39.729Z","schemaVersion":2},"datasetVersion":"2026-08-13T09:17:06.757Z"}