{"record":{"id":"1eff954c844870b1","repo":"BabylonJS/Babylon.js","slug":"the-glsl-file-must-contain-a-header-comment-with","errorCode":null,"errorMessage":"\"The glsl file must contain a header comment with a smartFilterBlockType value\"","messagePattern":"\"The glsl file must contain a header comment with a smartFilterBlockType value\"","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/dev/smartFilters/src/utils/buildTools/convertGlslIntoBlock.ts","lineNumber":165,"sourceCode":"}\r\n\r\n`;\r\n\r\n/**\r\n * Converts a single shader to a .ts file which exports a Smart Filter block\r\n * @param fragmentShaderPath - The path to the fragment file for the shader\r\n * @param smartFiltersCorePath - The path to import the Smart Filters core from\r\n * @param babylonCorePath - The path to import the Babylon core from (optional)\r\n\r\n */\r\nexport function ConvertGlslIntoBlock(fragmentShaderPath: string, smartFiltersCorePath: string, babylonCorePath?: string): void {\r\n    const extraImports: string[] = [];\r\n\r\n    const { shaderProgramCode, fragmentShaderInfo } = ExtractShaderProgramFromGlsl(fragmentShaderPath, smartFiltersCorePath, false, false);\r\n\r\n    // Validation\r\n    if (!fragmentShaderInfo.blockType) {\r\n        throw new Error(\"The glsl file must contain a header comment with a smartFilterBlockType value\");\r\n    }\r\n\r\n    // Generate shader binding private variables\r\n    const shaderBindingPrivateVariables = fragmentShaderInfo.uniforms\r\n        .map((uniform) => {\r\n            return uniform.properties?.autoBind\r\n                ? null\r\n                : ShaderBindingPrivateVariablesTemplate.replace(CAMEL_CASE_UNIFORM, uniform.name).replace(CONNECTION_POINT_TYPE, GetConnectionPointTypeString(uniform.type));\r\n        })\r\n        .filter((line) => line !== null);\r\n\r\n    // Generate the shader binding constructor docstring params\r\n    const shaderBindingCtorDocstringParams = fragmentShaderInfo.uniforms\r\n        .map((uniform) => {\r\n            return uniform.properties?.autoBind ? null : ShaderBindingCtorDocstringParams.replace(new RegExp(CAMEL_CASE_UNIFORM, \"g\"), uniform.name);\r\n        })\r\n        .filter((param) => param !== null);\r\n\r","sourceCodeStart":147,"sourceCodeEnd":183,"githubUrl":"https://github.com/BabylonJS/Babylon.js/blob/0592b347b8a4ee0236089ea86a749cacfdb266d8/packages/dev/smartFilters/src/utils/buildTools/convertGlslIntoBlock.ts#L147-L183","documentation":"ConvertGlslIntoBlock requires every block .glsl fragment shader to carry a header comment declaring a smartFilterBlockType value, which the build tool uses to name/generate the block class. If ExtractShaderProgramFromGlsl finds no blockType in the header, conversion fails with this error.","triggerScenarios":"Converting a .fragment.glsl / .block.glsl file whose header comment lacks the smartFilterBlockType annotation (e.g. a header comment like '// smartFilterBlockType: myBlock').","commonSituations":"Hand-written glsl files created without the required header; header removed during editing; typo in the annotation name; third-party shader converted without adding the header.","solutions":["Add a header comment with smartFilterBlockType at the top of the glsl file.","Check spelling/case of smartFilterBlockType in the header comment.","Verify the file is the fragment shader and was parsed by ExtractShaderProgramFromGlsl (correct path passed)."],"exampleFix":"// before\n// A simple blur block\nuniform float textureWidth;\n// after\n// smartFilterBlockType: blur\n// A simple blur block\nuniform float textureWidth;","handlingStrategy":"validation","validationCode":"/^\\s*\\/\\/\\s*smartFilterBlockType:\\s*[\\w-]+/m.test(fs.readFileSync(glslPath, 'utf8')) || console.error(`${glslPath} missing smartFilterBlockType header`);","typeGuard":null,"tryCatchPattern":"try { await ConvertShader(path, ...); } catch (e) { if (e.message.includes('smartFilterBlockType')) { fixShaderHeader(path); } else { throw e; } }","preventionTips":["Template every block glsl with the smartFilterBlockType header comment.","Lint glsl files for required header annotations in CI.","Never strip header comments during codegen."],"tags":["build-tools","glsl","shader-header"],"backgroundTag":"missing-shader-header-annotation","analyzedSha":"0592b347b8a4ee0236089ea86a749cacfdb266d8","analyzedAt":"2026-08-30T15:11:20.442Z","schemaVersion":2},"datasetVersion":"2026-08-30T18:17:15.746Z"}