{"record":{"id":"ef698f6db63b7416","repo":"BabylonJS/Babylon.js","slug":"a-block-that-uses-a-blockdisablestrategy-other-th","errorCode":null,"errorMessage":"\"A block that uses a BlockDisableStrategy other than Manual should not declare its own 'disabled' uniform\"","messagePattern":"\"A block that uses a BlockDisableStrategy other than Manual should not declare its own 'disabled' uniform\"","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/dev/smartFilters/src/utils/buildTools/convertGlslIntoBlock.ts","lineNumber":296,"sourceCode":"        shaderBlockExtends = \"DisableableShaderBlock\";\r\n        shaderBindingExtends = \"DisableableShaderBinding\";\r\n        blockDisableStrategy = `, BlockDisableStrategy.${BlockDisableStrategy[fragmentShaderInfo.blockDisableStrategy]}`;\r\n        shaderBindingSuperParams = \"parentBlock\";\r\n\r\n        shaderBindingCtorDocstringParams.unshift(\"     * @param parentBlock - IDisableableBlock\");\r\n        shaderBindingCtorParams.unshift(\"        parentBlock: IDisableableBlock\");\r\n        blockGetShaderParamList.unshift(\"this\");\r\n\r\n        extraImports.push(\"    type IDisableableBlock\");\r\n        extraImports.push(\"    BlockDisableStrategy\");\r\n\r\n        shaderBindingBind.unshift(\"        super.bind(effect);\");\r\n    }\r\n\r\n    // Additional validation\r\n    if (fragmentShaderInfo.blockDisableStrategy !== undefined && fragmentShaderInfo.blockDisableStrategy !== BlockDisableStrategy.Manual) {\r\n        if (fragmentShaderInfo.uniforms.findIndex((uniform) => uniform.name === \"disabled\") !== -1) {\r\n            throw new Error(\"A block that uses a BlockDisableStrategy other than Manual should not declare its own 'disabled' uniform\");\r\n        }\r\n    }\r\n\r\n    // Generate final contents\r\n    const finalContents = FileTemplate.replace(SHADER_PROGRAM, shaderProgramCode)\r\n        .replace(EXTRA_IMPORTS, extraImports.join(\",\\n\"))\r\n        .replace(BABYLON_CORE_PATH, babylonCorePath || \"@babylonjs/core\")\r\n        .replace(SMART_FILTER_CORE_IMPORT, smartFiltersCorePath)\r\n        .replace(new RegExp(BLOCK_NAME, \"g\"), fragmentShaderInfo.blockType)\r\n        .replace(NAMESPACE, fragmentShaderInfo.namespace || \"Other\")\r\n        .replace(new RegExp(SHADER_BINDING_EXTENDS, \"g\"), shaderBindingExtends)\r\n        .replace(SHADER_BINDING_PRIVATE_VARIABLES, shaderBindingPrivateVariables.join(\"\\n\"))\r\n        .replace(SHADER_BINDING_CTOR_DOCSTRING_PARAMS, shaderBindingCtorDocstringParams.join(\"\\n\"))\r\n        .replace(SHADER_BINDING_CTOR_PARAMS, shaderBindingCtorParams.join(\",\\n\"))\r\n        .replace(SHADER_BINDING_CTOR, shaderBindingCtor.join(\"\\n\"))\r\n        .replace(SHADER_BINDING_SUPER_PARAMS, shaderBindingSuperParams)\r\n        .replace(SHADER_BINDING_BIND, shaderBindingBind.join(\"\\n\"))\r\n        .replace(EXTRA_BIND_DOCSTRING, extraBindDocstring)\r","sourceCodeStart":278,"sourceCodeEnd":314,"githubUrl":"https://github.com/BabylonJS/Babylon.js/blob/0592b347b8a4ee0236089ea86a749cacfdb266d8/packages/dev/smartFilters/src/utils/buildTools/convertGlslIntoBlock.ts#L278-L314","documentation":"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.","triggerScenarios":"A glsl block file with a header smartFilterBlockDisableStrategy of Always/Connected (anything but Manual) whose uniform list contains a uniform named 'disabled'.","commonSituations":"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.","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."],"exampleFix":"// before\n// smartFilterBlockDisableStrategy: Connected\nuniform bool disabled;\n// after\n// smartFilterBlockDisableStrategy: Connected\n// (disabled uniform auto-generated by the framework)","handlingStrategy":"validation","validationCode":"const src = fs.readFileSync(glslPath, 'utf8');\nconst strategy = src.match(/smartFilterBlockDisableStrategy:\\s*(\\w+)/)?.[1];\nconst declaresDisabled = /uniform\\s+\\w+\\s+disabled\\s*;/.test(src);\nif (strategy && strategy !== 'Manual' && declaresDisabled) console.error(`${glslPath}: remove 'disabled' uniform or use Manual strategy`);","typeGuard":null,"tryCatchPattern":"try { await ConvertShader(path, ...); } catch (e) { if (e.message.includes(\"'disabled' uniform\")) { removeDisabledUniformOrUseManual(path); } else { throw e; } }","preventionTips":["When setting an automatic disable strategy, delete the manual 'disabled' uniform.","Document the convention in block templates.","Grep blocks for 'disabled' uniforms during review."],"tags":["build-tools","glsl","disable-strategy","conflict"],"backgroundTag":"shader-uniform-conflict","analyzedSha":"0592b347b8a4ee0236089ea86a749cacfdb266d8","analyzedAt":"2026-08-30T15:11:20.442Z","schemaVersion":2},"datasetVersion":"2026-08-30T18:17:15.746Z"}