BabylonJS/Babylon.js · error · Error

FrameGraphVolumetricLightingBlendVolumeTask "${this.name}":

Error message

FrameGraphVolumetricLightingBlendVolumeTask "${this.name}": sourceTexture, depthTexture and camera are required

What it means

FrameGraphVolumetricLightingBlendVolumeTask.record() requires sourceTexture, depthTexture and camera to be assigned before recording the blend pass that composites volumetric lighting into the scene using the depth buffer. If any of the three is undefined the pass cannot bind its samplers, so the library throws this descriptive error at record time as part of the frame graph task's fail-fast validation.

Source

Thrown at packages/dev/core/src/FrameGraph/Tasks/PostProcesses/volumetricLightingBlendVolumeTask.ts:89

 */
export class FrameGraphVolumetricLightingBlendVolumeTask extends FrameGraphPostProcessTask {
    public override readonly postProcess: VolumetricLightingBlendVolumeThinPostProcess;

    public depthTexture: FrameGraphTextureHandle;

    public camera: Camera;

    constructor(name: string, frameGraph: FrameGraph, enableExtinction = false) {
        super(name, frameGraph, new VolumetricLightingBlendVolumeThinPostProcess(name, frameGraph.engine, enableExtinction));
    }

    public override getClassName(): string {
        return "FrameGraphVolumetricLightingBlendVolumeTask";
    }

    public override record(skipCreationOfDisabledPasses = false): FrameGraphRenderPass {
        if (this.sourceTexture === undefined || this.depthTexture === undefined || this.camera === undefined) {
            throw new Error(`FrameGraphVolumetricLightingBlendVolumeTask "${this.name}": sourceTexture, depthTexture and camera are required`);
        }

        const pass = super.record(skipCreationOfDisabledPasses, undefined, (context) => {
            this.postProcess.camera = this.camera;
            context.bindTextureHandle(this._postProcessDrawWrapper.effect!, "depthSampler", this.depthTexture);
        });

        pass.addDependencies(this.depthTexture);

        this.postProcess.outputTextureWidth = this._outputWidth;
        this.postProcess.outputTextureHeight = this._outputHeight;

        return pass;
    }
}

View on GitHub (pinned to 0592b347b8)

Solutions

  1. Assign task.sourceTexture from the volumetric lighting task's output texture and task.depthTexture from the depth texture handle before build()
  2. Set task.camera to the rendering camera
  3. Ensure the volumetric lighting task and depth-producing task are added to the frame graph before the blend task
  4. Check the three properties for undefined right before FrameGraph.build() to identify the missing one

Example fix

// before
const blendTask = new FrameGraphVolumetricLightingBlendVolumeTask("blend", frameGraph);
frameGraph.addTask(blendTask);
frameGraph.build(); // throws: sourceTexture, depthTexture and camera required

// after
blendTask.sourceTexture = volumetricLightingTask.outputTexture;
blendTask.depthTexture = depthTextureTask.outputTexture;
blendTask.camera = frameGraph.scene.activeCamera;
frameGraph.build();
Defensive patterns

Strategy: validation

Validate before calling

const required = { sourceTexture: blendTask.sourceTexture, depthTexture: blendTask.depthTexture, camera: blendTask.camera };
const missing = Object.entries(required).filter(([, v]) => v === undefined).map(([k]) => k);
if (missing.length) throw new Error(`Volumetric blend task missing inputs: ${missing.join(", ")}`);

Type guard

function hasBlendVolumeInputs(t) { return t.sourceTexture !== undefined && t.depthTexture !== undefined && t.camera !== undefined; }

Try / catch

try { frameGraph.build(); } catch (e) { if (String(e.message).includes("sourceTexture, depthTexture and camera are required")) { console.error("Volumetric lighting blend task inputs not wired"); } else { throw e; } }

Prevention

When it happens

Trigger: Calling record() (directly or through FrameGraph.build()) on a FrameGraphVolumetricLightingBlendVolumeTask when sourceTexture, depthTexture or camera is undefined — i.e. the volumetric lighting task's output, the scene depth texture handle, or the camera was never assigned to the task's input properties.

Common situations: Setting up volumetric lighting in a frame graph but forgetting to pass the depth texture; using a volumetric light setup where the volumetric lighting task output was never linked as sourceTexture; camera not assigned after constructing the task; building the graph before the volumetric lighting task has been added/recorded.

Related errors


AI-assisted analysis of BabylonJS/Babylon.js@0592b347b8 (2026-08-30). Data as JSON: /api/errors/ff8acafccaf14fa4. Report an issue: GitHub.