{"record":{"id":"b605c80eee9d54d4","repo":"mrdoob/three.js","slug":"three-webgltextureutils-unsupported-webgl-type","errorCode":null,"errorMessage":"THREE.WebGLTextureUtils: Unsupported WebGL type: ${glType}","messagePattern":"THREE\\.WebGLTextureUtils: Unsupported WebGL type: (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"src/renderers/webgl-fallback/utils/WebGLTextureUtils.js","lineNumber":1312,"sourceCode":"\t * @param {GLenum} glType - The WebGL data type.\n\t * @return {TypedArray.constructor} The typed array type.\n\t */\n\t_getTypedArrayType( glType ) {\n\n\t\tconst { gl } = this;\n\n\t\tif ( glType === gl.UNSIGNED_BYTE ) return Uint8Array;\n\n\t\tif ( glType === gl.UNSIGNED_SHORT_4_4_4_4 ) return Uint16Array;\n\t\tif ( glType === gl.UNSIGNED_SHORT_5_5_5_1 ) return Uint16Array;\n\t\tif ( glType === gl.UNSIGNED_SHORT_5_6_5 ) return Uint16Array;\n\t\tif ( glType === gl.UNSIGNED_SHORT ) return Uint16Array;\n\t\tif ( glType === gl.UNSIGNED_INT ) return Uint32Array;\n\n\t\tif ( glType === gl.HALF_FLOAT ) return Uint16Array;\n\t\tif ( glType === gl.FLOAT ) return Float32Array;\n\n\t\tthrow new Error( `THREE.WebGLTextureUtils: Unsupported WebGL type: ${glType}` );\n\n\t}\n\n\t/**\n\t * Returns the bytes-per-texel value for the given WebGL data type and texture format.\n\t *\n\t * @private\n\t * @param {GLenum} glType - The WebGL data type.\n\t * @param {GLenum} glFormat - The WebGL texture format.\n\t * @return {number} The bytes-per-texel.\n\t */\n\t_getBytesPerTexel( glType, glFormat ) {\n\n\t\tconst { gl } = this;\n\n\t\tlet bytesPerComponent = 0;\n\n\t\tif ( glType === gl.UNSIGNED_BYTE ) bytesPerComponent = 1;","sourceCodeStart":1294,"sourceCodeEnd":1330,"githubUrl":"https://github.com/mrdoob/three.js/blob/da05705fa31f02710c19772a2aa70c7454807f0c/src/renderers/webgl-fallback/utils/WebGLTextureUtils.js#L1294-L1330","documentation":"Thrown by WebGLTextureUtils._getTypedArrayType() when a WebGL pixel type (glType) does not match any of the supported readback types (UNSIGNED_BYTE, UNSIGNED_SHORT_4_4_4_4, UNSIGNED_SHORT_5_5_5_1, UNSIGNED_SHORT_5_6_5, UNSIGNED_SHORT, UNSIGNED_INT, HALF_FLOAT, FLOAT). The method picks a JS typed array to receive readback pixels; if the texture's GL type isn't in the table, it can't choose a destination array.","triggerScenarios":"Reading back pixels (e.g. via renderer.readback / renderTarget readback) from a texture whose GL type is an integer/signed format or an extension type not in the supported list (e.g. signed normalized formats, certain compressed formats).","commonSituations":"Readback from a render target using an unusual internal format (e.g. RG16I, RGBA32I, depth). Using a compressed texture format and trying to readback raw pixels. Browser/driver exposing a glType constant not anticipated by three's mapping table. Mismatched format between write and readback.","solutions":["Read back from a render target whose color attachment uses a supported type ( UNSIGNED_BYTE / FLOAT / HALF_FLOAT ).","Blit/copy the unusual-format texture into a standard RGBA8/RGBA16F target and read back from that.","Avoid pixel readback for compressed or integer textures; use a buffer readback instead where supported.","Update three.js — newer versions may extend the supported glType table."],"exampleFix":"// before - reading back from an integer-format target\nrenderer.readbackPixels(intFormatRT); // throws via _getTypedArrayType\n\n// after - blit to a standard RGBA8 target first\nrenderer.setRenderTarget(rgba8RT);\nrenderer.render(scene, orthoCam);\nconst pixels = renderer.readbackPixels(rgba8RT);","handlingStrategy":"validation","validationCode":"const SUPPORTED_GL_TYPES = new Set(['UNSIGNED_BYTE','UNSIGNED_SHORT_4_4_4_4','UNSIGNED_SHORT_5_5_5_1','UNSIGNED_SHORT_5_6_5','UNSIGNED_SHORT','UNSIGNED_INT','HALF_FLOAT','FLOAT']);\nfunction canReadbackType(gl, glType) {\n  return [...SUPPORTED_GL_TYPES].some(k => glType === gl[k]);\n}","typeGuard":"function isReadableTextureType(gl, glType) {\n  return [gl.UNSIGNED_BYTE, gl.UNSIGNED_SHORT_4_4_4_4, gl.UNSIGNED_SHORT_5_5_5_1, gl.UNSIGNED_SHORT_5_6_5, gl.UNSIGNED_SHORT, gl.UNSIGNED_INT, gl.HALF_FLOAT, gl.FLOAT].includes(glType);\n}","tryCatchPattern":"try {\n  pixels = renderer.readbackPixels(rt);\n} catch (e) {\n  if (/Unsupported WebGL type/.test(e.message)) { /* blit to RGBA8/RGBA16F target, then readback */ }\n  else throw e;\n}","preventionTips":["Prefer standard RGBA8 / RGBA16F render-target formats when you intend to readback pixels.","Avoid readback of compressed or integer-format textures; read from a buffer or a blit target instead.","Keep three.js up to date; the supported-type table grows over time."],"tags":["webgl","texture","readback","pixel-format","data-format"],"backgroundTag":null,"analyzedSha":"da05705fa31f02710c19772a2aa70c7454807f0c","analyzedAt":"2026-08-12T22:51:37.160Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}