BabylonJS/Babylon.js · error

FrameGraphCopyToBackbufferColorTask "${this.name}": sourceTe

Error message

FrameGraphCopyToBackbufferColorTask "${this.name}": sourceTexture is required

What it means

FrameGraphCopyToBackbufferColorTask.record() requires a sourceTexture handle before it can create its render pass that copies a frame graph color texture to the backbuffer. If sourceTexture is undefined there is nothing to copy, so the task throws at record time rather than silently producing an empty output.

Source

Thrown at packages/dev/core/src/FrameGraph/Tasks/Texture/copyToBackbufferColorTask.ts:20

import { backbufferColorTextureHandle } from "../../frameGraphTypes";
import { FrameGraphTask } from "../../frameGraphTask";

/**
 * Task which copies a texture to the backbuffer color texture.
 */
export class FrameGraphCopyToBackbufferColorTask extends FrameGraphTask {
    /**
     * The source texture to copy to the backbuffer color texture.
     */
    public sourceTexture: FrameGraphTextureHandle;

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

    public record() {
        if (this.sourceTexture === undefined) {
            throw new Error(`FrameGraphCopyToBackbufferColorTask "${this.name}": sourceTexture is required`);
        }

        const pass = this._frameGraph.addRenderPass(this.name);

        pass.addDependencies(this.sourceTexture);

        pass.setRenderTarget(backbufferColorTextureHandle);
        pass.setExecuteFunc((context) => {
            if (!context.isBackbuffer(this.sourceTexture)) {
                context.copyTexture(this.sourceTexture);
            }
        });

        const passDisabled = this._frameGraph.addRenderPass(this.name + "_disabled", true);

        passDisabled.setRenderTarget(backbufferColorTextureHandle);
        passDisabled.setExecuteFunc((_context) => {});
    }

View on GitHub (pinned to 0592b347b8)

Solutions

  1. Assign task.sourceTexture to the output texture handle of the producing task before frameGraph.build().
  2. Ensure the source task is added to the frame graph and records before this copy task in the graph order.
  3. If the copy is conditional, guard build()/record() behind a check that sourceTexture is set.

Example fix

// before
const copy = new FrameGraphCopyToBackbufferColorTask('copy');
fg.addTask(copy);
// after
const copy = new FrameGraphCopyToBackbufferColorTask('copy');
copy.sourceTexture = renderTask.outputTexture;
fg.addTask(copy);
Defensive patterns

Strategy: validation

Validate before calling

if (copyTask.sourceTexture === undefined) {
  throw new Error('copyTask.sourceTexture must be wired before frameGraph.build()');
}

Type guard

function hasSourceTexture(t: FrameGraphCopyToBackbufferColorTask): t is FrameGraphCopyToBackbufferColorTask & { sourceTexture: FrameGraphTextureHandle } {
  return t.sourceTexture !== undefined;
}

Prevention

When it happens

Trigger: Instantiating FrameGraphCopyToBackbufferColorTask and calling frameGraph.addTask(...)/build() without ever assigning task.sourceTexture (e.g. forgetting to wire the previous task's output handle).

Common situations: Assembling a frame graph pipeline and forgetting to connect the last rendering task's outputTexture; refactoring that renamed the source task variable leaving the assignment missing; building the graph before the source task creates its output.

Related errors


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