{"record":{"id":"78548331182d6198","repo":"BabylonJS/Babylon.js","slug":"shader-bindings-not-set","errorCode":null,"errorMessage":"Shader bindings not set!","messagePattern":"Shader bindings not set!","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/dev/smartFilters/src/optimization/optimizedShaderBlock.ts","lineNumber":114,"sourceCode":"    public setShaderProgram(shaderProgram: ShaderProgram): void {\r\n        this._shaderProgram = shaderProgram;\r\n    }\r\n\r\n    /**\r\n     * Sets the list of shader bindings to use to render the block.\r\n     * @param shaderBindings - The list of shader bindings to use to render the block\r\n     */\r\n    public setShaderBindings(shaderBindings: ShaderBinding[]): void {\r\n        this._shaderBindings = shaderBindings;\r\n    }\r\n\r\n    /**\r\n     * Get the class instance that binds all the required data to the shader (effect) when rendering.\r\n     * @returns The class instance that binds the data to the effect\r\n     */\r\n    public getShaderBinding(): ShaderBinding {\r\n        if (this._shaderBindings === null) {\r\n            throw new Error(\"Shader bindings not set!\");\r\n        }\r\n\r\n        for (const input of this.inputs) {\r\n            const name = input.name;\r\n\r\n            if (input.type === ConnectionPointType.Texture) {\r\n                /**\r\n                 * These are the inputs created by the OptimizedShaderBlock\r\n                 * We pass them to OptimizedShaderBinding so that their value can be set appropriately at runtime (in the bind method)\r\n                 */\r\n                this._inputTextures[name] = input.runtimeData as RuntimeData<ConnectionPointType.Texture>;\r\n            }\r\n        }\r\n\r\n        return new OptimizedShaderBinding(this._shaderBindings, this._inputTextures);\r\n    }\r\n}\r\n","sourceCodeStart":96,"sourceCodeEnd":132,"githubUrl":"https://github.com/BabylonJS/Babylon.js/blob/0592b347b8a4ee0236089ea86a749cacfdb266d8/packages/dev/smartFilters/src/optimization/optimizedShaderBlock.ts#L96-L132","documentation":"OptimizedShaderBlock defers creation of its ShaderBinding until bindings are set during optimization (this._shaderBindings). getShaderBinding() throws this error if called before the optimizer has populated them, because there is no object available to bind uniforms/textures to the effect.","triggerScenarios":"Calling getShaderBinding() on an OptimizedShaderBlock that was constructed manually or whose optimization pipeline never completed (e.g. SmartFilterOptimizer was not run, or threw before binding setup).","commonSituations":"Using optimized blocks outside the normal SmartFilter runtime flow; the optimizer run aborted midway due to another error, leaving blocks unbound; custom runtimes reading bindings before the first optimize pass.","solutions":["Run SmartFilterOptimizer (or the standard filter build) to populate shader bindings before rendering.","Ensure the previous optimization step did not throw and leave the block partially optimized.","Only render/execute optimized filters through the SmartFilter runtime rather than calling getShaderBinding manually."],"exampleFix":"// before\nconst binding = optimizedBlock.getShaderBinding(); // too early\n// after\nconst runtimeData = await SmartFilterOptimizer.OptimizeAsync(engine, smartFilter, texture);\n// runtime data is now bound; use runtimeData to render","handlingStrategy":"validation","validationCode":"if (!optimizedBlock[\"_shaderBindings\"]) {\n  throw new Error(\"Run SmartFilterOptimizer before accessing shader bindings\");\n}","typeGuard":"null","tryCatchPattern":"try {\n  const binding = optimizedBlock.getShaderBinding();\n} catch (e) {\n  if (e.message === \"Shader bindings not set!\") {\n    throw new Error(\"Filter must be optimized via SmartFilterOptimizer before rendering\");\n  } else throw e;\n}","preventionTips":["Always create optimized blocks through SmartFilterOptimizer, never by hand.","Handle errors from the optimization pass so partial failures don't leave blocks unbound.","Render optimized filters only via the SmartFilter runtime."],"tags":["optimization","shader-binding","initialization-order"],"backgroundTag":"shader-bindings-not-set","analyzedSha":"0592b347b8a4ee0236089ea86a749cacfdb266d8","analyzedAt":"2026-08-30T15:11:20.442Z","schemaVersion":2},"datasetVersion":"2026-08-30T18:17:15.746Z"}