BabylonJS/Babylon.js · error

${this.blockType} did not have a render target texture.

Error message

${this.blockType} did not have a render target texture.

What it means

When a ShaderBlock's output is not the final filter output, the runtime renders into a render target texture taken from this.output.runtimeData.value. If that runtime value is null/undefined (or not a ThinRenderTargetTexture), generateCommandsAndGatherInitPromises throws this error because there is nowhere to render the block's result.

Source

Thrown at packages/dev/smartFilters/src/blockFoundation/shaderBlock.ts:142

    }

    /**
     * Generates the commands needed to execute the block at runtime and gathers promises for initialization work
     * @param initializationData - The initialization data to use
     * @param finalOutput - Defines if the block is the final output of the smart filter
     */
    public override generateCommandsAndGatherInitPromises(initializationData: InitializationData, finalOutput: boolean): void {
        const runtime = initializationData.runtime;
        const shaderBlockRuntime = new ShaderRuntime(runtime.effectRenderer, this.getShaderProgram(), this.getShaderBinding());
        initializationData.initializationPromises.push(shaderBlockRuntime.onReadyAsync);
        runtime.registerResource(shaderBlockRuntime);

        if (finalOutput) {
            RegisterFinalRenderCommand(initializationData.outputBlock, runtime, this, shaderBlockRuntime);
        } else {
            const renderTargetTexture = this.output.runtimeData?.value as Nullable<ThinRenderTargetTexture>;
            if (!renderTargetTexture) {
                throw new Error(`${this.blockType} did not have a render target texture.`);
            }

            runtime.registerCommand(
                CreateCommand(`${this.blockType}.render`, this, () => {
                    shaderBlockRuntime.renderToTargetTexture(renderTargetTexture);
                })
            );
        }

        super.generateCommandsAndGatherInitPromises(initializationData, finalOutput);
    }
}

View on GitHub (pinned to 0592b347b8)

Solutions

  1. Ensure the shader block's output connection is connected and its runtime data has an initialized render target texture.
  2. Do not dispose render target textures used by blocks that are still part of the running filter.
  3. Rebuild/refresh the filter runtime after graph edits so runtimeData is re-initialized.
  4. If the block should be the final output, mark it as finalOutput so the output block path is used.

Example fix

// before
runtimeData.outputTexture?.dispose(); // frees the RTT while block still renders
// after
runtimeData.outputTexture?.dispose();
filter.rebuild(); // re-initialize runtime data / RTTs before next frame
Defensive patterns

Strategy: validation

Validate before calling

const rtt = shaderBlock.output.runtimeData?.value as Nullable<ThinRenderTargetTexture>;
if (!rtt || rtt.isDisposed) {
  throw new Error("Render target not ready for shader block");
}

Type guard

function hasRenderTarget(cp: ConnectionPoint): cp is ConnectionPoint & { runtimeData: { value: ThinRenderTargetTexture } } {
  const v = cp.runtimeData?.value;
  return !!v && !!(v as ThinRenderTargetTexture).renderTargetTexture;
}

Try / catch

try {
  await runtime.generateCommandsAsync();
} catch (e) {
  if (e.message.endsWith("did not have a render target texture.")) {
    runtime.rebuild(); // re-initialize RTTs
  } else throw e;
}

Prevention

When it happens

Trigger: Building a runtime for a shader graph where a non-final ShaderBlock's output connection point was never bound to a render target — e.g. the output texture was disposed, the block's output was never connected, or the runtime data was not initialized before command generation.

Common situations: Disposing a render target texture while the filter is still running; constructing a custom runtime that skips the output-texture initialization step; graph edits that orphan a shader block's output.

Related errors


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