mrdoob/three.js · error · Error
THREE.WebGLTextureUtils: Unsupported WebGL type: ${glType}
Error message
THREE.WebGLTextureUtils: Unsupported WebGL type: ${glType} What it means
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.
Source
Thrown at src/renderers/webgl-fallback/utils/WebGLTextureUtils.js:1312
* @param {GLenum} glType - The WebGL data type.
* @return {TypedArray.constructor} The typed array type.
*/
_getTypedArrayType( glType ) {
const { gl } = this;
if ( glType === gl.UNSIGNED_BYTE ) return Uint8Array;
if ( glType === gl.UNSIGNED_SHORT_4_4_4_4 ) return Uint16Array;
if ( glType === gl.UNSIGNED_SHORT_5_5_5_1 ) return Uint16Array;
if ( glType === gl.UNSIGNED_SHORT_5_6_5 ) return Uint16Array;
if ( glType === gl.UNSIGNED_SHORT ) return Uint16Array;
if ( glType === gl.UNSIGNED_INT ) return Uint32Array;
if ( glType === gl.HALF_FLOAT ) return Uint16Array;
if ( glType === gl.FLOAT ) return Float32Array;
throw new Error( `THREE.WebGLTextureUtils: Unsupported WebGL type: ${glType}` );
}
/**
* Returns the bytes-per-texel value for the given WebGL data type and texture format.
*
* @private
* @param {GLenum} glType - The WebGL data type.
* @param {GLenum} glFormat - The WebGL texture format.
* @return {number} The bytes-per-texel.
*/
_getBytesPerTexel( glType, glFormat ) {
const { gl } = this;
let bytesPerComponent = 0;
if ( glType === gl.UNSIGNED_BYTE ) bytesPerComponent = 1;View on GitHub (pinned to da05705fa3)
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.
Example fix
// before - reading back from an integer-format target renderer.readbackPixels(intFormatRT); // throws via _getTypedArrayType // after - blit to a standard RGBA8 target first renderer.setRenderTarget(rgba8RT); renderer.render(scene, orthoCam); const pixels = renderer.readbackPixels(rgba8RT);
Defensive patterns
Strategy: validation
Validate before calling
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']);
function canReadbackType(gl, glType) {
return [...SUPPORTED_GL_TYPES].some(k => glType === gl[k]);
} Type guard
function isReadableTextureType(gl, glType) {
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);
} Try / catch
try {
pixels = renderer.readbackPixels(rt);
} catch (e) {
if (/Unsupported WebGL type/.test(e.message)) { /* blit to RGBA8/RGBA16F target, then readback */ }
else throw e;
} Prevention
- 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.
When it happens
Trigger: 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).
Common situations: 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.
Related errors
- THREE.WebGLBackend: Unsupported buffer data format:
- THREE.WebGPURenderer: ReadbackBuffer must be released before
- THREE.WebGLAttributes: Unsupported buffer data format:
- THREE.WebGLTextures: Unknown depthTexture format.
- THREE.DepthTexture: format must be either THREE.DepthFormat
AI-assisted analysis of mrdoob/three.js@da05705fa3 (2026-08-12).
Data as JSON: /api/errors/b605c80eee9d54d4.
Report an issue: GitHub.