mrdoob/three.js · error
THREE.PassNode: Depth texture is not available for this pass
Error message
THREE.PassNode: Depth texture is not available for this pass.
What it means
Thrown by PassNode.getTexture('depth') when no depth texture was registered for the pass. PassNode only creates a depth texture when its scope is DEPTH or `options.depthBuffer !== false`; otherwise `_textures['depth']` is never populated. Requesting the depth output then fails.
Source
Thrown at src/nodes/display/PassNode.js:610
return this._mrt;
}
/**
* Returns the texture for the given output name.
*
* @param {string} name - The output name to get the texture for.
* @return {Texture} The texture.
*/
getTexture( name ) {
let texture = this._textures[ name ];
if ( texture === undefined ) {
if ( name === 'depth' ) {
throw new Error( 'THREE.PassNode: Depth texture is not available for this pass.' );
}
const refTexture = this.renderTarget.texture;
texture = refTexture.clone();
texture.name = name;
this._textures[ name ] = texture;
this.renderTarget.textures.push( texture );
}
return texture;
}
View on GitHub (pinned to da05705fa3)
Solutions
- Construct the PassNode with depth enabled: do not set `depthBuffer: false`, or pass an explicit `depthTexture` in options.
- Ensure the pass scope is DEPTH if the pass exists solely to capture depth.
- Before calling getTexture('depth'), check `pass.renderTarget.depthTexture !== null`.
Example fix
// before
const pass = passNode( renderer, PassNode.COLOR, { depthBuffer: false } );
const depth = pass.getTexture( 'depth' );
// after
const pass = passNode( renderer, PassNode.COLOR );
const depth = pass.getTexture( 'depth' ); Defensive patterns
Strategy: validation
Validate before calling
function assertDepthAvailable( pass ) {
if ( pass.renderTarget.depthTexture === null ) {
throw new Error( 'PassNode has no depth texture; create it with depth enabled.' );
}
}
// before:
assertDepthAvailable( pass );
const depth = pass.getTexture( 'depth' ); Type guard
const passHasDepth = ( pass ) => pass.renderTarget.depthTexture !== null;
Prevention
- Create passes that read depth with depth enabled (no depthBuffer:false) or an explicit depthTexture.
- Check renderTarget.depthTexture before calling getTexture('depth').
- Keep depth requirements documented per pass in your post-processing graph.
When it happens
Trigger: Creating a PassNode/post-processing pass with `depthBuffer: false` (or omitting it in a context where it defaults off) and later calling `pass.getTexture('depth')`, or using a depth-output node against a pass that was not given a depthTexture.
Common situations: Post-processing graphs that read depth (e.g. depth-of-field, fog, screen-space effects) wired to a pass created without depth; reusing a pass instance after toggling its depth buffer off for performance; passing a custom depthTexture that is null.
Related errors
- THREE.ReflectorNode: Depth node can only be requested when t
- no diagram ${name}
- THREE.WebGPURenderer: Shadow map type not supported yet.
- THREE.BatchedMesh: Maximum item count reached.
- THREE.WebGLRenderer: Attached DepthTexture is initialized to
AI-assisted analysis of mrdoob/three.js@da05705fa3 (2026-08-12).
Data as JSON: /api/errors/40baa9a6279637cb.
Report an issue: GitHub.