BabylonJS/Babylon.js · error
${className} ${this.name}: the back buffer depth/stencil tex
Error message
${className} ${this.name}: the back buffer depth/stencil texture is the only depth texture allowed when the target is the back buffer color What it means
When an ObjectRendererTask renders directly to the frame graph's back buffer color texture, the only depth attachment permitted is the back buffer's own depth/stencil texture. Supplying any custom depthTexture would conflict with the back buffer's depth, so _checkTextureCompatibility throws.
Source
Thrown at packages/dev/core/src/FrameGraph/Tasks/Rendering/objectRendererTask.ts:548
this._frameGraph.textureManager.resolveDanglingHandle(this.outputDepthTexture, this.depthTexture);
}
}
protected _checkParameters() {
if (this.targetTexture === undefined || this.objectList === undefined || this.camera === undefined) {
throw new Error(`FrameGraphObjectRendererTask ${this.name}: targetTexture, objectList, and camera are required`);
}
}
protected _checkTextureCompatibility(targetTextures: FrameGraphTextureHandle[]): boolean {
const className = this.getClassName();
let outputTextureDescription = targetTextures.length > 0 ? this._frameGraph.textureManager.getTextureDescription(targetTextures[0]) : null;
let depthEnabled = false;
if (this.depthTexture !== undefined) {
if (outputTextureDescription && this.depthTexture !== backbufferDepthStencilTextureHandle && targetTextures[0] === backbufferColorTextureHandle) {
throw new Error(`${className} ${this.name}: the back buffer depth/stencil texture is the only depth texture allowed when the target is the back buffer color`);
}
const depthTextureDescription = this._frameGraph.textureManager.getTextureDescription(this.depthTexture);
if (!outputTextureDescription) {
outputTextureDescription = depthTextureDescription;
}
if (depthTextureDescription.options.samples !== outputTextureDescription.options.samples) {
throw new Error(
`${className} ${this.name}: the depth texture "${depthTextureDescription.options.labels?.[0] ?? "noname"}" (${depthTextureDescription.options.samples} samples) and the output texture "${outputTextureDescription.options.labels?.[0] ?? "noname"}" (${outputTextureDescription.options.samples} samples) must have the same number of samples`
);
}
if (depthTextureDescription.size.width !== outputTextureDescription.size.width || depthTextureDescription.size.height !== outputTextureDescription.size.height) {
throw new Error(
`${className} ${this.name}: the depth texture (size: ${depthTextureDescription.size.width}x${depthTextureDescription.size.height}) and the target texture (size: ${outputTextureDescription.size.width}x${outputTextureDescription.size.height}) must have the same dimensions.`
);
}
View on GitHub (pinned to 0592b347b8)
Solutions
- Either remove the custom depthTexture so the back buffer's own depth/stencil is used, or
- Render to a non-back-buffer target texture when a custom depth texture is needed.
- If back-buffer depth is available as a handle, set depthTexture to the back buffer depth/stencil handle instead of a custom one.
Example fix
// before task.targetTexture = frameGraph.backBufferColorTexture; task.depthTexture = myCustomDepthTexture; // not allowed // after task.targetTexture = frameGraph.backBufferColorTexture; task.depthTexture = undefined; // use back buffer depth/stencil
Defensive patterns
Strategy: validation
Validate before calling
if (task.targetTexture === frameGraph.backBufferColorTexture.handle && task.depthTexture !== undefined && task.depthTexture !== frameGraph.backBufferDepthStencilTexture.handle) {
throw new Error('Custom depth not allowed when targeting back buffer color');
} Try / catch
try {
frameGraph.build();
} catch (e) {
if (String(e).includes('back buffer depth/stencil texture is the only depth texture allowed')) {
task.depthTexture = undefined; // fall back to back buffer depth
frameGraph.build();
} else throw e;
} Prevention
- Decide up front whether a task targets the back buffer or an offscreen texture; configure depth accordingly.
- Do not share one task configuration between back-buffer and offscreen targets.
- When targeting the back buffer, omit depthTexture entirely unless you specifically need the back buffer depth handle.
When it happens
Trigger: Setting task.depthTexture to a custom depth texture (any handle other than the back buffer depth/stencil handle) while task.targetTexture equals the back buffer color texture handle.
Common situations: Reusing depth texture configuration from an offscreen-target task and switching targetTexture to the back buffer; assuming custom depth works with back-buffer rendering; sharing one task definition between window and texture targets.
Related errors
- FrameGraphMotionBlurTask "${this.name}": depthTexture is req
- ${className} ${this.name}: the depth texture "${depthTexture
- ${className} ${this.name}: the depth texture (size: ${depthT
- FrameGraphClearTextureTask ${this.name}: the depth texture (
- FrameGraphHighlightLayerTask "${this.name}": objectRendererT
AI-assisted analysis of BabylonJS/Babylon.js@0592b347b8 (2026-08-30).
Data as JSON: /api/errors/0ea32c24024b65f7.
Report an issue: GitHub.