{"record":{"id":"ae94d073ec261378","repo":"BabylonJS/Babylon.js","slug":"framegraphcleartexturetask-this-name-targettex","errorCode":null,"errorMessage":"FrameGraphClearTextureTask ${this.name}: targetTexture and depthTexture can't both be undefined.","messagePattern":"FrameGraphClearTextureTask (.+?): targetTexture and depthTexture can't both be undefined\\.","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/dev/core/src/FrameGraph/Tasks/Texture/clearTextureTask.ts","lineNumber":78,"sourceCode":"    /**\r\n     * Constructs a new clear task.\r\n     * @param name The name of the task.\r\n     * @param frameGraph The frame graph the task belongs to.\r\n     */\r\n    constructor(name: string, frameGraph: FrameGraph) {\r\n        super(name, frameGraph);\r\n\r\n        this.outputTexture = this._frameGraph.textureManager.createDanglingHandle();\r\n        this.outputDepthTexture = this._frameGraph.textureManager.createDanglingHandle();\r\n    }\r\n\r\n    public override getClassName(): string {\r\n        return \"FrameGraphClearTextureTask\";\r\n    }\r\n\r\n    public record(skipCreationOfDisabledPasses = false): FrameGraphRenderPass {\r\n        if (this.targetTexture === undefined && this.depthTexture === undefined) {\r\n            throw new Error(`FrameGraphClearTextureTask ${this.name}: targetTexture and depthTexture can't both be undefined.`);\r\n        }\r\n\r\n        const textureManager = this._frameGraph.textureManager;\r\n        const targetTextures = this.targetTexture !== undefined ? (Array.isArray(this.targetTexture) ? this.targetTexture : [this.targetTexture]) : undefined;\r\n\r\n        if (this.targetTexture !== undefined) {\r\n            textureManager.resolveDanglingHandle(this.outputTexture, targetTextures![0]);\r\n        }\r\n        if (this.depthTexture !== undefined) {\r\n            textureManager.resolveDanglingHandle(this.outputDepthTexture, this.depthTexture);\r\n        }\r\n        if (this.targetTexture !== undefined && this.depthTexture !== undefined) {\r\n            const targetDescription = textureManager.getTextureDescription(targetTextures![0]);\r\n            const depthDescription = textureManager.getTextureDescription(this.depthTexture);\r\n\r\n            if (targetDescription.size.width !== depthDescription.size.width || targetDescription.size.height !== depthDescription.size.height) {\r\n                throw new Error(\r\n                    `FrameGraphClearTextureTask ${this.name}: the depth texture (size: ${depthDescription.size.width}x${depthDescription.size.height}) and the target texture (size: ${targetDescription.size.width}x${targetDescription.size.height}) must have the same dimensions.`\r","sourceCodeStart":60,"sourceCodeEnd":96,"githubUrl":"https://github.com/BabylonJS/Babylon.js/blob/0592b347b8a4ee0236089ea86a749cacfdb266d8/packages/dev/core/src/FrameGraph/Tasks/Texture/clearTextureTask.ts#L60-L96","documentation":"FrameGraphClearTextureTask exists to clear either color target texture(s), a depth texture, or both. record() throws if both targetTexture and depthTexture are undefined, because there would be nothing to clear and no valid pass to record.","triggerScenarios":"Adding a clear task and building the frame graph without assigning targetTexture or depthTexture; clearing a variable that was set to undefined after a refactor; conditional assignment logic that skipped both branches.","commonSituations":"Template/copy-pasted clear task never wired; a graph refactor removed the upstream texture the clear task targeted; mistakenly assuming the task clears the back buffer by default (it does not — you must pass the handle).","solutions":["Assign task.targetTexture (single handle or array of handles) and/or task.depthTexture before build.","If the intent was to clear the back buffer, set targetTexture to frameGraph.backBufferColorTexture.","Remove the clear task entirely if no texture needs clearing.","Validate at least one of the two fields is defined before frameGraph.build()."],"exampleFix":"// before\nclearTask = new FrameGraphClearTextureTask('clear', frameGraph);\nframeGraph.addTask(clearTask);\nframeGraph.build(); // throws\n\n// after\nclearTask.targetTexture = frameGraph.backBufferColorTexture;\nframeGraph.addTask(clearTask);\nframeGraph.build();","handlingStrategy":"validation","validationCode":"if (clearTask.targetTexture === undefined && clearTask.depthTexture === undefined) {\n    throw new Error('ClearTextureTask needs a targetTexture or depthTexture');\n}","typeGuard":null,"tryCatchPattern":"try {\n    frameGraph.build();\n} catch (e) {\n    if (String(e).includes(\"targetTexture and depthTexture can't both be undefined\")) {\n        console.error('Clear task has nothing to clear; assign a texture or remove the task');\n    } else throw e;\n}","preventionTips":["Create clear tasks only together with the assignment of what they clear.","Remember the task does not clear the back buffer implicitly; pass the handle.","Remove orphaned clear tasks during graph refactors."],"tags":["babylonjs","frame-graph","clear-pass","missing-input"],"backgroundTag":"missing-required-input","analyzedSha":"0592b347b8a4ee0236089ea86a749cacfdb266d8","analyzedAt":"2026-08-30T15:11:20.442Z","schemaVersion":2},"datasetVersion":"2026-08-30T18:17:15.746Z"}