BabylonJS/Babylon.js · error · Error

FrameGraphBloomTask: sourceTexture is required

Error message

FrameGraphBloomTask: sourceTexture is required

What it means

FrameGraphBloomTask kicks off the bloom pipeline (downsample/blur/upsample) from a source texture; record() throws when task.sourceTexture was never assigned, since the pipeline has nothing to process. Notably the message does not include a task name.

Source

Thrown at packages/dev/core/src/FrameGraph/Tasks/PostProcesses/bloomTask.ts:136

        this._downscale = new FrameGraphExtractHighlightsTask(`${name} Downscale`, this._frameGraph, this.bloom._downscale);
        this._blurX = new FrameGraphBlurTask(`${name} Blur X`, this._frameGraph, this.bloom._blurX);
        this._blurY = new FrameGraphBlurTask(`${name} Blur Y`, this._frameGraph, this.bloom._blurY);
        this._merge = new FrameGraphBloomMergeTask(`${name} Merge`, this._frameGraph, this.bloom._merge);

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

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

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

    public record(): void {
        if (this.sourceTexture === undefined) {
            throw new Error("FrameGraphBloomTask: sourceTexture is required");
        }

        const sourceTextureDescription = this._frameGraph.textureManager.getTextureDescription(this.sourceTexture);

        const textureCreationOptions: FrameGraphTextureCreationOptions = {
            size: {
                width: Math.floor(sourceTextureDescription.size.width * this.bloom.scale) || 1,
                height: Math.floor(sourceTextureDescription.size.height * this.bloom.scale) || 1,
            },
            options: {
                createMipMaps: false,
                types: [this._defaultPipelineTextureType],
                formats: [Constants.TEXTUREFORMAT_RGBA],
                samples: 1,
                useSRGBBuffers: [false],
                labels: [""],
            },
            sizeIsPercentage: false,

View on GitHub (pinned to 0592b347b8)

Solutions

  1. Set bloomTask.sourceTexture = mainTargetTask.output (or the desired HDR texture handle) before record().
  2. Ensure the task producing the source texture is recorded prior to the bloom task.
  3. Add a build-time assertion that all post-process task inputs are defined.

Example fix

// before
const bloomTask = new FrameGraphBloomTask("bloom", context, { ... });
context.build();
// after
const bloomTask = new FrameGraphBloomTask("bloom", context, { ... });
bloomTask.sourceTexture = hdrTask.output;
context.build();
Defensive patterns

Strategy: validation

Validate before calling

if (bloomTask.sourceTexture === undefined) {
  throw new Error("BloomTask.sourceTexture must be set before build");
}

Type guard

function isBloomReady(task: FrameGraphBloomTask): boolean {
  return task.sourceTexture !== undefined;
}

Try / catch

try {
  bloomTask.record();
} catch (e) {
  if (String(e).includes("sourceTexture is required")) {
    bloomTask.sourceTexture = hdrTask.output;
    bloomTask.record();
  } else throw e;
}

Prevention

When it happens

Trigger: bloomTask.record() with task.sourceTexture === undefined.

Common situations: Adding a bloom task to a frame graph but forgetting to bind it to the main render target's output; source task renamed/refactored so the assignment was dropped; building the graph before wiring inputs.

Related errors


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