BabylonJS/Babylon.js · error · Error
"A block that uses a BlockDisableStrategy other than Manual
Error message
"A block that uses a BlockDisableStrategy other than Manual should not declare its own 'disabled' uniform"
What it means
When a block declares a smartFilterBlockDisableStrategy other than Manual, the framework itself controls the 'disabled' uniform. If the glsl also declares its own 'disabled' uniform it would collide with the auto-generated one, so the build tool throws this validation error.
Source
Thrown at packages/dev/smartFilters/src/utils/buildTools/convertGlslIntoBlock.ts:296
shaderBlockExtends = "DisableableShaderBlock";
shaderBindingExtends = "DisableableShaderBinding";
blockDisableStrategy = `, BlockDisableStrategy.${BlockDisableStrategy[fragmentShaderInfo.blockDisableStrategy]}`;
shaderBindingSuperParams = "parentBlock";
shaderBindingCtorDocstringParams.unshift(" * @param parentBlock - IDisableableBlock");
shaderBindingCtorParams.unshift(" parentBlock: IDisableableBlock");
blockGetShaderParamList.unshift("this");
extraImports.push(" type IDisableableBlock");
extraImports.push(" BlockDisableStrategy");
shaderBindingBind.unshift(" super.bind(effect);");
}
// Additional validation
if (fragmentShaderInfo.blockDisableStrategy !== undefined && fragmentShaderInfo.blockDisableStrategy !== BlockDisableStrategy.Manual) {
if (fragmentShaderInfo.uniforms.findIndex((uniform) => uniform.name === "disabled") !== -1) {
throw new Error("A block that uses a BlockDisableStrategy other than Manual should not declare its own 'disabled' uniform");
}
}
// Generate final contents
const finalContents = FileTemplate.replace(SHADER_PROGRAM, shaderProgramCode)
.replace(EXTRA_IMPORTS, extraImports.join(",\n"))
.replace(BABYLON_CORE_PATH, babylonCorePath || "@babylonjs/core")
.replace(SMART_FILTER_CORE_IMPORT, smartFiltersCorePath)
.replace(new RegExp(BLOCK_NAME, "g"), fragmentShaderInfo.blockType)
.replace(NAMESPACE, fragmentShaderInfo.namespace || "Other")
.replace(new RegExp(SHADER_BINDING_EXTENDS, "g"), shaderBindingExtends)
.replace(SHADER_BINDING_PRIVATE_VARIABLES, shaderBindingPrivateVariables.join("\n"))
.replace(SHADER_BINDING_CTOR_DOCSTRING_PARAMS, shaderBindingCtorDocstringParams.join("\n"))
.replace(SHADER_BINDING_CTOR_PARAMS, shaderBindingCtorParams.join(",\n"))
.replace(SHADER_BINDING_CTOR, shaderBindingCtor.join("\n"))
.replace(SHADER_BINDING_SUPER_PARAMS, shaderBindingSuperParams)
.replace(SHADER_BINDING_BIND, shaderBindingBind.join("\n"))
.replace(EXTRA_BIND_DOCSTRING, extraBindDocstring)
View on GitHub (pinned to 0592b347b8)
Solutions
- Remove the 'disabled' uniform declaration from the glsl when using an automatic disable strategy.
- Or set smartFilterBlockDisableStrategy: Manual in the header if you intend to manage the uniform yourself.
- Regenerate/rebuild the block after fixing the shader.
Example fix
// before // smartFilterBlockDisableStrategy: Connected uniform bool disabled; // after // smartFilterBlockDisableStrategy: Connected // (disabled uniform auto-generated by the framework)
Defensive patterns
Strategy: validation
Validate before calling
const src = fs.readFileSync(glslPath, 'utf8');
const strategy = src.match(/smartFilterBlockDisableStrategy:\s*(\w+)/)?.[1];
const declaresDisabled = /uniform\s+\w+\s+disabled\s*;/.test(src);
if (strategy && strategy !== 'Manual' && declaresDisabled) console.error(`${glslPath}: remove 'disabled' uniform or use Manual strategy`); Try / catch
try { await ConvertShader(path, ...); } catch (e) { if (e.message.includes("'disabled' uniform")) { removeDisabledUniformOrUseManual(path); } else { throw e; } } Prevention
- When setting an automatic disable strategy, delete the manual 'disabled' uniform.
- Document the convention in block templates.
- Grep blocks for 'disabled' uniforms during review.
When it happens
Trigger: A glsl block file with a header smartFilterBlockDisableStrategy of Always/Connected (anything but Manual) whose uniform list contains a uniform named 'disabled'.
Common situations: Copied shader code where 'disabled' was a manual uniform, then an automatic disable strategy was added in the header; scaffolding templates that include the uniform but set a non-manual strategy.
Related errors
- "The glsl file must contain a header comment with a smartFil
- "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/ef698f6db63b7416.
Report an issue: GitHub.