{"record":{"id":"eb892582dd4989c0","repo":"BabylonJS/Babylon.js","slug":"uniform-line-not-found","errorCode":null,"errorMessage":"\"Uniform line not found\"","messagePattern":"\"Uniform line not found\"","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/dev/smartFilters/src/utils/buildTools/shaderConverter.ts","lineNumber":134,"sourceCode":" * @param fragmentShader - The fragment shader to process\r\n * @returns The processed fragment shader\r\n */\r\nexport function ParseFragmentShader(fragmentShader: string): FragmentShaderInfo {\r\n    const { header, fragmentShaderWithoutHeader } = ReadHeader(fragmentShader);\r\n    fragmentShader = fragmentShaderWithoutHeader;\r\n    const blockType = header?.[SmartFilterBlockTypeKey] || undefined;\r\n    const namespace = header?.namespace || null;\r\n\r\n    // Read the uniforms\r\n    const uniforms: UniformMetadata[] = [];\r\n    const uniformRegExp = new RegExp(/(\\/\\/\\s*\\{.*\\}\\s*(?:\\r\\n|\\r|\\n)+)?(uniform .*)/gm);\r\n    const uniformGroups = fragmentShader.matchAll(uniformRegExp);\r\n    for (const matches of uniformGroups) {\r\n        const annotationJSON = matches[1];\r\n        const uniformLine = matches[2];\r\n\r\n        if (!uniformLine) {\r\n            throw new Error(\"Uniform line not found\");\r\n        }\r\n\r\n        const uniformLineMatches = new RegExp(/^uniform\\s+(\\w+)\\s+(\\w+)\\s*;?/gm).exec(uniformLine);\r\n        if (!uniformLineMatches || uniformLineMatches.length < 3) {\r\n            throw new Error(`Uniforms must have a type and a name: '${uniformLine}'`);\r\n        }\r\n        const uniformTypeString = uniformLineMatches[1];\r\n        const uniformName = uniformLineMatches[2];\r\n\r\n        if (!uniformTypeString) {\r\n            throw new Error(`Uniforms must have a type: '${uniformLine}'`);\r\n        }\r\n        if (!uniformName) {\r\n            throw new Error(`Uniforms must have a name: '${uniformLine}'`);\r\n        }\r\n\r\n        // Convert to ConnectionPointType\r\n        let type: ConnectionPointType;\r","sourceCodeStart":116,"sourceCodeEnd":152,"githubUrl":"https://github.com/BabylonJS/Babylon.js/blob/0592b347b8a4ee0236089ea86a749cacfdb266d8/packages/dev/smartFilters/src/utils/buildTools/shaderConverter.ts#L116-L152","documentation":"ParseFragmentShader matches uniform declarations with an annotation regex; group 1 is the optional JSON annotation and group 2 is the uniform declaration line. If the regex matched but the uniform line itself is empty, the annotation is malformed/unattached, so this error is thrown.","triggerScenarios":"A uniform annotation comment (e.g. /// {\"x\":...}) immediately followed by an empty or missing 'uniform' declaration line, so the regex's second capture group is empty.","commonSituations":"Annotation comment left behind after the uniform line was deleted; comment formatting broke the uniform match; template generation emitted an annotation without the uniform.","solutions":["Ensure every uniform annotation is directly followed by a valid 'uniform <type> <name>;' line.","Remove orphaned annotation comments that no longer precede a uniform.","Check line endings/formatting so the uniform statement is on the line after the annotation."],"exampleFix":"// before\n/// {\"autoBind\": true}\n\n// after\n/// {\"autoBind\": true}\nuniform float textureWidth;","handlingStrategy":"validation","validationCode":"// Each '/// {...}' annotation must be immediately followed by a uniform line\nconst lines = fs.readFileSync(glslPath, 'utf8').split('\\n');\nlines.forEach((l, i) => { if (/^\\s*\\/\\/\\/\\s*\\{/.test(l) && !/^\\s*uniform\\b/.test(lines[i+1] ?? '')) console.error(`Orphan annotation at line ${i+1} of ${glslPath}`); });","typeGuard":null,"tryCatchPattern":"try { await ConvertShader(path, ...); } catch (e) { if (e.message.includes('Uniform line not found')) { fixOrphanAnnotation(path); } else { throw e; } }","preventionTips":["Always pair annotation comments with the uniform on the next line.","Delete annotations when deleting their uniform.","Lint for orphan '///' JSON comments."],"tags":["glsl","uniform-parsing","annotations"],"backgroundTag":"uniform-declaration-missing","analyzedSha":"0592b347b8a4ee0236089ea86a749cacfdb266d8","analyzedAt":"2026-08-30T15:11:20.442Z","schemaVersion":2},"datasetVersion":"2026-08-30T18:17:15.746Z"}