{"record":{"id":"ecb377ddfd8abfe4","repo":"BabylonJS/Babylon.js","slug":"framegraphdepthoffieldtask-sourcetexture-depthte","errorCode":null,"errorMessage":"FrameGraphDepthOfFieldTask: sourceTexture, depthTexture and camera are required","messagePattern":"FrameGraphDepthOfFieldTask: sourceTexture, depthTexture and camera are required","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/dev/core/src/FrameGraph/Tasks/PostProcesses/depthOfFieldTask.ts","lineNumber":152,"sourceCode":"            this._blurY.push(new FrameGraphDepthOfFieldBlurTask(`${name} Blur Y${i}`, this._frameGraph, this.depthOfField._depthOfFieldBlurY[i][0]));\r\n        }\r\n\r\n        this._merge = new FrameGraphDepthOfFieldMergeTask(`${name} Merge`, this._frameGraph, this.depthOfField._dofMerge);\r\n\r\n        this.outputTexture = this._frameGraph.textureManager.createDanglingHandle();\r\n    }\r\n\r\n    public override isReady() {\r\n        return this.depthOfField.isReady();\r\n    }\r\n\r\n    public override getClassName(): string {\r\n        return \"FrameGraphDepthOfFieldTask\";\r\n    }\r\n\r\n    public record(): void {\r\n        if (this.sourceTexture === undefined || this.depthTexture === undefined || this.camera === undefined) {\r\n            throw new Error(\"FrameGraphDepthOfFieldTask: sourceTexture, depthTexture and camera are required\");\r\n        }\r\n\r\n        const sourceTextureDescription = this._frameGraph.textureManager.getTextureDescription(this.sourceTexture);\r\n\r\n        const textureSize = {\r\n            width: sourceTextureDescription.size.width,\r\n            height: sourceTextureDescription.size.height,\r\n        };\r\n        const circleOfConfusionTextureFormat = this._engine.isWebGPU || this._engine.version > 1 ? Constants.TEXTUREFORMAT_RED : Constants.TEXTUREFORMAT_RGBA;\r\n        const textureCreationOptions: FrameGraphTextureCreationOptions = {\r\n            size: textureSize,\r\n            options: {\r\n                createMipMaps: false,\r\n                types: [this._defaultPipelineTextureType],\r\n                formats: [circleOfConfusionTextureFormat],\r\n                samples: 1,\r\n                useSRGBBuffers: [false],\r\n                labels: [\"\"],\r","sourceCodeStart":134,"sourceCodeEnd":170,"githubUrl":"https://github.com/BabylonJS/Babylon.js/blob/0592b347b8a4ee0236089ea86a749cacfdb266d8/packages/dev/core/src/FrameGraph/Tasks/PostProcesses/depthOfFieldTask.ts#L134-L170","documentation":"The top-level FrameGraphDepthOfFieldTask.record() orchestrates the whole DoF pipeline and needs sourceTexture, depthTexture, and camera before it can create its internal CoC/blur/merge sub-tasks. Any of the three being undefined causes this throw. Unlike leaf tasks, it also requires a camera because CoC computation depends on camera focus/aperture parameters.","triggerScenarios":"Adding a FrameGraphDepthOfFieldTask and calling record()/build without setting task.sourceTexture, task.depthTexture, or task.camera.","commonSituations":"Forgetting the camera assignment (unique to aggregate DoF tasks); using a depth texture from a different camera; wiring the graph before the geometry/depth prepass task exists; migrating from the legacy DepthOfFieldPostProcess pipeline and omitting new required handles.","solutions":["Set task.camera to the scene's active (or intended) camera.","Set task.sourceTexture to the color texture handle to blur.","Set task.depthTexture to the corresponding depth texture handle for that camera.","Ensure all assignments happen before frameGraph.build() or the task's record() call."],"exampleFix":"// before\ndofTask.sourceTexture = colorTask.outputTexture;\nframeGraph.addTask(dofTask);\n\n// after\ndofTask.sourceTexture = colorTask.outputTexture;\ndofTask.depthTexture = depthTask.outputTexture;\ndofTask.camera = scene.activeCamera;\nframeGraph.addTask(dofTask);","handlingStrategy":"validation","validationCode":"if (dofTask.sourceTexture === undefined || dofTask.depthTexture === undefined || dofTask.camera === undefined) {\n  throw new Error(\"DoF task missing sourceTexture/depthTexture/camera before build\");\n}","typeGuard":"function hasDoFInputs(t: { sourceTexture?: unknown; depthTexture?: unknown; camera?: unknown }): boolean {\n  return t.sourceTexture !== undefined && t.depthTexture !== undefined && t.camera !== undefined;\n}","tryCatchPattern":"try {\n  frameGraph.build();\n} catch (e) {\n  if (String(e?.message).includes(\"FrameGraphDepthOfFieldTask: sourceTexture, depthTexture and camera are required\")) {\n    console.error(\"DoF aggregate task not fully wired:\", e.message);\n  } else { throw e; }\n}","preventionTips":["Set the camera first — it is easy to forget since leaf texture tasks don't need it.","Ensure the depth texture comes from the same camera you assign.","Validate the whole task config in one guard function before build()."],"tags":["babylonjs","frame-graph","depth-of-field","missing-texture","configuration"],"backgroundTag":"framegraph-task-missing-texture","analyzedSha":"0592b347b8a4ee0236089ea86a749cacfdb266d8","analyzedAt":"2026-08-30T15:11:20.442Z","schemaVersion":2},"datasetVersion":"2026-08-30T18:17:15.746Z"}