{"record":{"id":"3c4c705632fc7839","repo":"mrdoob/three.js","slug":"three-webgltextures-unknown-depthtexture-format","errorCode":null,"errorMessage":"THREE.WebGLTextures: Unknown depthTexture format.","messagePattern":"THREE\\.WebGLTextures: Unknown depthTexture format\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"src/renderers/webgl/WebGLTextures.js","lineNumber":1861,"sourceCode":"\t\t\t\t_gl.framebufferTexture2D( _gl.FRAMEBUFFER, glAttachmentType, glTextureType, webglDepthTexture, 0 );\n\n\t\t\t}\n\n\t\t} else if ( renderTarget.depthTexture.format === DepthStencilFormat ) {\n\n\t\t\tif ( useMultisampledRTT( renderTarget ) ) {\n\n\t\t\t\tmultisampledRTTExt.framebufferTexture2DMultisampleEXT( _gl.FRAMEBUFFER, glAttachmentType, glTextureType, webglDepthTexture, 0, samples );\n\n\t\t\t} else {\n\n\t\t\t\t_gl.framebufferTexture2D( _gl.FRAMEBUFFER, glAttachmentType, glTextureType, webglDepthTexture, 0 );\n\n\t\t\t}\n\n\t\t} else {\n\n\t\t\tthrow new Error( 'THREE.WebGLTextures: Unknown depthTexture format.' );\n\n\t\t}\n\n\t}\n\n\t// Setup GL resources for a non-texture depth buffer\n\tfunction setupDepthRenderbuffer( renderTarget ) {\n\n\t\tconst renderTargetProperties = properties.get( renderTarget );\n\t\tconst isCube = ( renderTarget.isWebGLCubeRenderTarget === true );\n\n\t\t// if the bound depth texture has changed\n\t\tif ( renderTargetProperties.__boundDepthTexture !== renderTarget.depthTexture ) {\n\n\t\t\t// fire the dispose event to get rid of stored state associated with the previously bound depth buffer\n\t\t\tconst depthTexture = renderTarget.depthTexture;\n\t\t\tif ( renderTargetProperties.__depthDisposeCallback ) {\n","sourceCodeStart":1843,"sourceCodeEnd":1879,"githubUrl":"https://github.com/mrdoob/three.js/blob/da05705fa31f02710c19772a2aa70c7454807f0c/src/renderers/webgl/WebGLTextures.js#L1843-L1879","documentation":"Thrown by WebGLTextures (setupDepthRenderbuffer / depth attachment path) when a depth texture's format does not match any of the recognized depth/stencil formats. The renderer switches attachment type (DEPTH_ATTACHMENT, DEPTH_STENCIL_ATTACHMENT, etc.) based on format; an unhandled format means it cannot choose the correct GL attachment point.","triggerScenarios":"Setting a DepthTexture with a format that isn't DepthFormat, DepthStencilFormat, or the other handled depth formats (e.g. accidentally assigning RGBAFormat or a stencil-only format) and using it as a render target's depthTexture.","commonSituations":"Constructing DepthTexture with a default or wrong format. Combining a texture format constant from a non-three source. Version mismatches where a previously valid depth format constant was renamed. Mixing up the format and type arguments to DepthTexture.","solutions":["Set the DepthTexture format to THREE.DepthFormat or THREE.DepthStencilFormat as appropriate.","For packed depth+stencil use DepthStencilFormat with UnsignedInt248Type.","Print `depthTexture.format` before rendering and ensure it is one of the recognized constants.","If you need stencil-only, check whether your three.js version supports that path; otherwise use DepthStencilFormat."],"exampleFix":"// before\nrt.depthTexture = new THREE.DepthTexture(w, h, THREE.UnsignedIntType);\nrt.depthTexture.format = THREE.RGBAFormat; // unknown depth format -> throws\n\n// after\nrt.depthTexture = new THREE.DepthTexture(w, h, THREE.UnsignedIntType);\nrt.depthTexture.format = THREE.DepthFormat;","handlingStrategy":"validation","validationCode":"const KNOWN = new Set([THREE.DepthFormat, THREE.DepthStencilFormat]);\nfunction validateDepthFormat(depthTexture) {\n  if (depthTexture && !KNOWN.has(depthTexture.format)) {\n    throw new Error('Unsupported depthTexture format: ' + depthTexture.format);\n  }\n}","typeGuard":"function isKnownDepthFormat(format) {\n  return format === THREE.DepthFormat || format === THREE.DepthStencilFormat;\n}","tryCatchPattern":null,"preventionTips":["Set DepthTexture.format explicitly to DepthFormat or DepthStencilFormat.","Use DepthStencilFormat with UnsignedInt248Type for packed depth+stencil.","Log depthTexture.format during setup to catch accidental reassignment."],"tags":["webgl","render-target","depth-texture","fbo","pixel-format"],"backgroundTag":null,"analyzedSha":"da05705fa31f02710c19772a2aa70c7454807f0c","analyzedAt":"2026-08-12T22:51:37.160Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}