BabylonJS/Babylon.js · error · Error

FrameGraphPostProcessTask "${this.name}": sourceTexture or t

Error message

FrameGraphPostProcessTask "${this.name}": sourceTexture or targetTexture is required

What it means

The base FrameGraphPostProcessTask.record() requires at least one of sourceTexture (input to the post-process) or targetTexture (destination) to be defined; when both are undefined it cannot create the pass and throws. This guard is inherited by all concrete post-process tasks that call super.record().

Source

Thrown at packages/dev/core/src/FrameGraph/Tasks/PostProcesses/postProcessTask.ts:158

        this.outputTexture = this._frameGraph.textureManager.createDanglingHandle();
        this.outputDepthAttachmentTexture = this._frameGraph.textureManager.createDanglingHandle();
    }

    public override isReady() {
        return this.postProcess.isReady();
    }

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

    public record(
        skipCreationOfDisabledPasses = false,
        additionalExecute?: (context: FrameGraphRenderContext) => void,
        additionalBindings?: (context: FrameGraphRenderContext) => void
    ): FrameGraphRenderPass {
        if (this.sourceTexture === undefined && this.targetTexture === undefined) {
            throw new Error(`FrameGraphPostProcessTask "${this.name}": sourceTexture or targetTexture is required`);
        }

        const sourceTextureCreationOptions = this.sourceTexture !== undefined ? this._frameGraph.textureManager.getTextureCreationOptions(this.sourceTexture) : undefined;
        if (sourceTextureCreationOptions) {
            sourceTextureCreationOptions.options.samples = 1;
        }

        this._frameGraph.textureManager.resolveDanglingHandle(this.outputTexture, this.targetTexture, this.name, sourceTextureCreationOptions);
        if (this.depthAttachmentTexture !== undefined) {
            this._frameGraph.textureManager.resolveDanglingHandle(this.outputDepthAttachmentTexture, this.depthAttachmentTexture);
        }

        if (sourceTextureCreationOptions) {
            const sourceSize = this._frameGraph.textureManager.getTextureAbsoluteDimensions(sourceTextureCreationOptions);

            this._sourceWidth = sourceSize.width;
            this._sourceHeight = sourceSize.height;
        }

View on GitHub (pinned to 0592b347b8)

Solutions

  1. Assign task.sourceTexture to the input texture handle (most common fix).
  2. Or assign task.targetTexture if the post-process should render into a specific target without a sampled source.
  3. Verify the task's constructor parameters/order didn't shift in a Babylon upgrade, leaving properties unset.

Example fix

// before
const pp = new FrameGraphPostProcessTask(frameGraph, "tint", postProcess);
frameGraph.addTask(pp);

// after
const pp = new FrameGraphPostProcessTask(frameGraph, "tint", postProcess);
pp.sourceTexture = sceneColorTask.outputTexture;
frameGraph.addTask(pp);
Defensive patterns

Strategy: validation

Validate before calling

if (ppTask.sourceTexture === undefined && ppTask.targetTexture === undefined) {
  throw new Error("Post-process task needs sourceTexture or targetTexture before build");
}

Type guard

function hasPostProcessTarget(t: { sourceTexture?: unknown; targetTexture?: unknown }): boolean {
  return t.sourceTexture !== undefined || t.targetTexture !== undefined;
}

Try / catch

try {
  frameGraph.build();
} catch (e) {
  if (String(e?.message).includes("sourceTexture or targetTexture is required")) {
    console.error("Post-process task has no input/output wired:", e.message);
  } else { throw e; }
}

Prevention

When it happens

Trigger: Adding any FrameGraphPostProcessTask-derived task and building the graph with neither task.sourceTexture nor task.targetTexture assigned.

Common situations: Creating a generic post-process task (e.g. for a custom shader) and forgetting all texture wiring; refactoring that removed the source assignment; conditional pipelines where every texture assignment was skipped.

Related errors


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