BabylonJS/Babylon.js · error · Error
"The glsl file must contain a header comment with a smartFil
Error message
"The glsl file must contain a header comment with a smartFilterBlockType value"
What it means
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.
Source
Thrown at packages/dev/smartFilters/src/utils/buildTools/convertGlslIntoBlock.ts:165
}
`;
/**
* Converts a single shader to a .ts file which exports a Smart Filter block
* @param fragmentShaderPath - The path to the fragment file for the shader
* @param smartFiltersCorePath - The path to import the Smart Filters core from
* @param babylonCorePath - The path to import the Babylon core from (optional)
*/
export function ConvertGlslIntoBlock(fragmentShaderPath: string, smartFiltersCorePath: string, babylonCorePath?: string): void {
const extraImports: string[] = [];
const { shaderProgramCode, fragmentShaderInfo } = ExtractShaderProgramFromGlsl(fragmentShaderPath, smartFiltersCorePath, false, false);
// Validation
if (!fragmentShaderInfo.blockType) {
throw new Error("The glsl file must contain a header comment with a smartFilterBlockType value");
}
// Generate shader binding private variables
const shaderBindingPrivateVariables = fragmentShaderInfo.uniforms
.map((uniform) => {
return uniform.properties?.autoBind
? null
: ShaderBindingPrivateVariablesTemplate.replace(CAMEL_CASE_UNIFORM, uniform.name).replace(CONNECTION_POINT_TYPE, GetConnectionPointTypeString(uniform.type));
})
.filter((line) => line !== null);
// Generate the shader binding constructor docstring params
const shaderBindingCtorDocstringParams = fragmentShaderInfo.uniforms
.map((uniform) => {
return uniform.properties?.autoBind ? null : ShaderBindingCtorDocstringParams.replace(new RegExp(CAMEL_CASE_UNIFORM, "g"), uniform.name);
})
.filter((param) => param !== null);
View on GitHub (pinned to 0592b347b8)
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).
Example fix
// before // A simple blur block uniform float textureWidth; // after // smartFilterBlockType: blur // A simple blur block uniform float textureWidth;
Defensive patterns
Strategy: validation
Validate before calling
/^\s*\/\/\s*smartFilterBlockType:\s*[\w-]+/m.test(fs.readFileSync(glslPath, 'utf8')) || console.error(`${glslPath} missing smartFilterBlockType header`); Try / catch
try { await ConvertShader(path, ...); } catch (e) { if (e.message.includes('smartFilterBlockType')) { fixShaderHeader(path); } else { throw e; } } Prevention
- Template every block glsl with the smartFilterBlockType header comment.
- Lint glsl files for required header annotations in CI.
- Never strip header comments during codegen.
When it happens
Trigger: Converting a .fragment.glsl / .block.glsl file whose header comment lacks the smartFilterBlockType annotation (e.g. a header comment like '// smartFilterBlockType: myBlock').
Common situations: 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.
Related errors
- "A block that uses a BlockDisableStrategy other than Manual
- "The shader file must end with .fragment.glsl or .block.glsl
- "Const line not found"
- VERTEX SHADER ${log}
- FRAGMENT SHADER ${log}
AI-assisted analysis of BabylonJS/Babylon.js@0592b347b8 (2026-08-30).
Data as JSON: /api/errors/1eff954c844870b1.
Report an issue: GitHub.