{"record":{"id":"134e851f15942af7","repo":"BabylonJS/Babylon.js","slug":"error","errorCode":null,"errorMessage":"${error}","messagePattern":"\\$\\{error\\}","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/dev/core/src/Engines/thinEngine.functions.ts","lineNumber":245,"sourceCode":"            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\n\r\n    if (/*this.*/ validateShaderPrograms) {\r\n        context.validateProgram(program);\r\n        const validated = context.getProgramParameter(program, context.VALIDATE_STATUS);\r\n\r\n        if (!validated) {\r\n            const error = context.getProgramInfoLog(program);\r\n            if (error) {\r\n                pipelineContext.programValidationError = error;\r\n                throw new Error(error);\r\n            }\r\n        }\r\n    }\r\n\r\n    context.deleteShader(vertexShader);\r\n    context.deleteShader(fragmentShader);\r","sourceCodeStart":227,"sourceCodeEnd":263,"githubUrl":"https://github.com/BabylonJS/Babylon.js/blob/0592b347b8a4ee0236089ea86a749cacfdb266d8/packages/dev/core/src/Engines/thinEngine.functions.ts#L227-L263","documentation":"Thrown when the WebGL program fails to LINK after both shaders compiled individually. _finalizePipelineContext calls context.getProgramInfoLog(program) and throws the raw link log, storing it in pipelineContext.programLinkError. Compilation of each shader succeeded, but glLinkProgram found incompatibilities between them.","triggerScenarios":"Vertex and fragment shaders that compile alone but don't link: varying/in variables with mismatched names, types, or precision between stages; an out variable in vertex shader never declared as in/out in fragment; too many attributes or varyings exceeding GPU limits.","commonSituations":"Hand-written ShaderMaterial where vertex and fragment strings were edited independently; renaming a varying in one stage only; using 'varying' in WebGL2 without #version 300 es handling; exceeding maxVaryings on low-end/mobile GPUs.","solutions":["Read the thrown log — it typically says which varying/attribute is mismatched or which limit was exceeded","Make varying/in-out declarations match exactly (name, type, precision) between vertex and fragment shaders","Reduce the number of varyings/attributes if the log mentions limits","Inspect pipelineContext.programLinkError for the stored log when handling the error"],"exampleFix":"// before\nvertex: `varying vec2 vUv; ...` fragment: `varying vec2 UV; ...` // name mismatch\n// after\nvertex: `varying vec2 vUv; ...` fragment: `varying vec2 vUv; ...`","handlingStrategy":"validation","validationCode":"function checkVaryingsMatch(vertexSrc: string, fragmentSrc: string): string[] {\n  const decl = /(?:varying|out)\\s+\\w+\\s+(\\w+)\\s*;/g;\n  const outs = new Set<string>(); let m;\n  while ((m = decl.exec(vertexSrc))) outs.add(m[1]);\n  const ins = /(?:varying|in)\\s+\\w+\\s+(\\w+)\\s*;/g;\n  const missing: string[] = [];\n  while ((m = ins.exec(fragmentSrc))) outs.delete(m[1]);\n  return [...outs]; // varyings declared in vertex but missing in fragment\n}","typeGuard":"function isLinkError(e: unknown): e is Error & { pipelineProgramLinkError?: string } {\n  return e instanceof Error && !e.message.startsWith('FRAGMENT SHADER');\n}","tryCatchPattern":"try {\n  engine.createEffect(...);\n} catch (e) {\n  const msg = (e as Error).message;\n  if (!msg.startsWith('FRAGMENT SHADER') && !msg.startsWith('VERTEX')) {\n    console.error('Program link failed:', msg); // raw link log\n  }\n}","preventionTips":["Keep varying/in-out declarations in a shared GLSL snippet to guarantee they match","Rename varyings via find-all across both stages","Count varyings against engine._gl.getParameter(gl.MAX_VARYINGS) for big shaders","Test on mobile GPUs early; they enforce tighter limits"],"tags":["webgl","glsl","program-link"],"backgroundTag":"shader-compile-error","analyzedSha":"0592b347b8a4ee0236089ea86a749cacfdb266d8","analyzedAt":"2026-08-30T15:11:20.442Z","schemaVersion":2},"datasetVersion":"2026-08-30T18:17:15.746Z"}