{"record":{"id":"bca047b950d6aa11","repo":"BabylonJS/Babylon.js","slug":"vertex-shader-log","errorCode":null,"errorMessage":"VERTEX SHADER ${log}","messagePattern":"VERTEX SHADER (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/dev/core/src/Engines/thinEngine.functions.ts","lineNumber":229,"sourceCode":"\r\n/**\r\n * @internal\r\n */\r\nexport function _finalizePipelineContext(pipelineContext: WebGLPipelineContext, gl: WebGLContext, validateShaderPrograms?: boolean) {\r\n    const context = pipelineContext.context!;\r\n    const vertexShader = pipelineContext.vertexShader!;\r\n    const fragmentShader = pipelineContext.fragmentShader!;\r\n    const program = pipelineContext.program!;\r\n\r\n    const linked = context.getProgramParameter(program, context.LINK_STATUS);\r\n    if (!linked) {\r\n        // Get more info\r\n        // Vertex\r\n        if (!gl.getShaderParameter(vertexShader, gl.COMPILE_STATUS)) {\r\n            const log = gl.getShaderInfoLog(vertexShader);\r\n            if (log) {\r\n                pipelineContext.vertexCompilationError = log;\r\n                throw new Error(\"VERTEX SHADER \" + log);\r\n            }\r\n        }\r\n\r\n        // Fragment\r\n        if (!gl.getShaderParameter(fragmentShader, gl.COMPILE_STATUS)) {\r\n            const log = gl.getShaderInfoLog(fragmentShader);\r\n            if (log) {\r\n                pipelineContext.fragmentCompilationError = log;\r\n                throw new Error(\"FRAGMENT SHADER \" + log);\r\n            }\r\n        }\r\n\r\n        const error = context.getProgramInfoLog(program);\r\n        if (error) {\r\n            pipelineContext.programLinkError = error;\r\n            throw new Error(error);\r\n        }\r\n    }\r","sourceCodeStart":211,"sourceCodeEnd":247,"githubUrl":"https://github.com/BabylonJS/Babylon.js/blob/0592b347b8a4ee0236089ea86a749cacfdb266d8/packages/dev/core/src/Engines/thinEngine.functions.ts#L211-L247","documentation":"During pipeline finalization the engine checks gl.getShaderParameter(vertexShader, COMPILE_STATUS). If the vertex shader failed to compile, the engine stores the driver's info log in pipelineContext.vertexCompilationError and throws \"VERTEX SHADER <log>\". This is a shader source/feature error surfaced by the GLSL compiler, not a runtime state problem.","triggerScenarios":"Creating any Effect/material whose vertex shader fails GLSL compilation: syntax errors, unsupported GLSL version/extension (WebGL1 vs GLSL ES 3.0 features), uniforms exceeding limits, invalid precision qualifiers.","commonSituations":"Custom ShaderMaterial with GLSL bugs, shader code written for WebGL2 (in/out, texture()) running on a WebGL1 context, driver-specific strictness, missing #extension directives.","solutions":["Read the driver log appended to the message and fix the reported GLSL line/syntax error.","Verify the shader's GLSL version matches the engine context (use ShaderStore with both .vertex/.fragment for GLSL ES 1.0 and WGSL/ES3 variants as needed).","Add required #extension directives or remove unsupported features for the target WebGL version.","Test with a minimal shader to isolate whether the error comes from custom code or the engine's injected defines."],"exampleFix":"// before (WebGL1 context)\nvertexShader: `in vec3 position; void main(){ gl_Position = vec4(position,1.0); }`\n// after\nvertexShader: `attribute vec3 position; void main(){ gl_Position = vec4(position,1.0); }`","handlingStrategy":"try-catch","validationCode":"function validateShaderSource(src) {\n  if (!/#version|attribute|in\\s/.test(src)) console.warn(\"shader may be missing declarations\");\n  // optionally compile in an offscreen context in CI to catch errors early\n}","typeGuard":"null","tryCatchPattern":"try {\n  effect = new Effect(name, attrs, uniforms, engine);\n} catch (e) {\n  if (/VERTEX SHADER|FRAGMENT SHADER/.test(e.message)) {\n    console.error(e.message); // driver log included\n    effect = fallbackSimpleEffect;\n  }\n}","preventionTips":["Validate custom GLSL in CI using a headless GL context.","Match GLSL ES version to the engine context (ES 1.0 for WebGL1, ES 3.0 for WebGL2).","Include required #extension directives before any use.","Read pipelineContext.vertexCompilationError for the raw driver log."],"tags":["webgl","glsl","shader-compilation","shaders"],"backgroundTag":"shader-compile-error","analyzedSha":"0592b347b8a4ee0236089ea86a749cacfdb266d8","analyzedAt":"2026-08-30T15:11:20.442Z","schemaVersion":2},"datasetVersion":"2026-08-30T18:17:15.746Z"}