BabylonJS/Babylon.js · error · Error
FrameGraphDepthOfFieldTask: sourceTexture, depthTexture and
Error message
FrameGraphDepthOfFieldTask: sourceTexture, depthTexture and camera are required
What it means
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.
Source
Thrown at packages/dev/core/src/FrameGraph/Tasks/PostProcesses/depthOfFieldTask.ts:152
this._blurY.push(new FrameGraphDepthOfFieldBlurTask(`${name} Blur Y${i}`, this._frameGraph, this.depthOfField._depthOfFieldBlurY[i][0]));
}
this._merge = new FrameGraphDepthOfFieldMergeTask(`${name} Merge`, this._frameGraph, this.depthOfField._dofMerge);
this.outputTexture = this._frameGraph.textureManager.createDanglingHandle();
}
public override isReady() {
return this.depthOfField.isReady();
}
public override getClassName(): string {
return "FrameGraphDepthOfFieldTask";
}
public record(): void {
if (this.sourceTexture === undefined || this.depthTexture === undefined || this.camera === undefined) {
throw new Error("FrameGraphDepthOfFieldTask: sourceTexture, depthTexture and camera are required");
}
const sourceTextureDescription = this._frameGraph.textureManager.getTextureDescription(this.sourceTexture);
const textureSize = {
width: sourceTextureDescription.size.width,
height: sourceTextureDescription.size.height,
};
const circleOfConfusionTextureFormat = this._engine.isWebGPU || this._engine.version > 1 ? Constants.TEXTUREFORMAT_RED : Constants.TEXTUREFORMAT_RGBA;
const textureCreationOptions: FrameGraphTextureCreationOptions = {
size: textureSize,
options: {
createMipMaps: false,
types: [this._defaultPipelineTextureType],
formats: [circleOfConfusionTextureFormat],
samples: 1,
useSRGBBuffers: [false],
labels: [""],
View on GitHub (pinned to 0592b347b8)
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.
Example fix
// before dofTask.sourceTexture = colorTask.outputTexture; frameGraph.addTask(dofTask); // after dofTask.sourceTexture = colorTask.outputTexture; dofTask.depthTexture = depthTask.outputTexture; dofTask.camera = scene.activeCamera; frameGraph.addTask(dofTask);
Defensive patterns
Strategy: validation
Validate before calling
if (dofTask.sourceTexture === undefined || dofTask.depthTexture === undefined || dofTask.camera === undefined) {
throw new Error("DoF task missing sourceTexture/depthTexture/camera before build");
} Type guard
function hasDoFInputs(t: { sourceTexture?: unknown; depthTexture?: unknown; camera?: unknown }): boolean {
return t.sourceTexture !== undefined && t.depthTexture !== undefined && t.camera !== undefined;
} Try / catch
try {
frameGraph.build();
} catch (e) {
if (String(e?.message).includes("FrameGraphDepthOfFieldTask: sourceTexture, depthTexture and camera are required")) {
console.error("DoF aggregate task not fully wired:", e.message);
} else { throw e; }
} Prevention
- 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().
When it happens
Trigger: Adding a FrameGraphDepthOfFieldTask and calling record()/build without setting task.sourceTexture, task.depthTexture, or task.camera.
Common situations: 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.
Related errors
- FrameGraphDepthOfFieldBlurTask "${this.name}": sourceTexture
- FrameGraphBloomMergeTask "${this.name}": sourceTexture, circ
- FrameGraphMotionBlurTask "${this.name}": sourceTexture is re
- FrameGraphPostProcessTask "${this.name}": sourceTexture or t
- FrameGraphScreenSpaceCurvatureTask "${this.name}": sourceTex
AI-assisted analysis of BabylonJS/Babylon.js@0592b347b8 (2026-08-30).
Data as JSON: /api/errors/ecb377ddfd8abfe4.
Report an issue: GitHub.