Skip to main content

Texture Formats

The term "texture format" here refers to how pixels are stored in memory, which is an important property of a GPU Texture which must be specified on Texture creation.

In luma.gl, texture formats are identified using string constants, and the TextureFormat type can be used to ensure texture format strings are valid.

The following table lists all the texture formats constants supported by luma.gl (ordered by how many bytes each pixel occupies).

Note that even though a GPU supports creating and sampling textures of a certain format, additional capabilities may need to be checked separatey, more information below the table.

Formats

TextureFormatAvailableFilterableRenderableNotes / WebGL counterpart
1 byte per pixel formats
r8unormN/AN/AN/AGL.R8
r8snormN/AN/AN/AGL.R8_SNORM
r8uintN/AN/AN/AGL.R8UI
r8sintN/AN/AN/AGL.R8I
2 bytes per pixel formats
r16uintN/AN/AN/AGL.R16UI
r16sintN/AN/AN/AGL.R16I
r16unorm-webglN/AN/AN/AGL.R16_EXT EXT_texture_norm16
r16snorm-webglN/AN/AN/AGL.R16_SNORM_EXT EXT_texture_norm16
r16floatN/AN/AN/AGL.R16F
rg8unormN/AN/AN/AGL.RG8
rg8snormN/AN/AN/A
rg8uintN/AN/AN/AGL.RG8UI
rg8sintN/AN/AN/AGL.RG8I
Packed 2 bytes per pixel formats
rgba4norm-webglN/AN/AN/AGL.RGBA4
rgb565norm-webglN/AN/AN/AGL.RGB565
rgb5a1norm-webglN/AN/AN/AGL.RGB5_A1
3 bytes per pixel formats
rbg8norm-webglN/AN/AN/AGL.RGB8
4 bytes per pixel formats
r32uintN/AN/AN/AGL.R32UI
r32sintN/AN/AN/AGL.R32I
r32floatN/AN/AN/AGL.R32F
rg16uintN/AN/AN/AGL.RG16UI
rg16sintN/AN/AN/AGL.RG16I
rg16unorm-webglN/AN/AN/A
rg16snorm-webglN/AN/AN/A
rg16floatN/AN/AN/AGL.RG16F
rgba8unormN/AN/AN/AGL.RGBA8
rgba8unorm-srgbN/AN/AN/AGL.SRGB8_ALPHA8
rgba8snormN/AN/AN/A
rgba8uintN/AN/AN/AGL.RGBA8UI
rgba8sintN/AN/AN/AGL.RGBA8I
bgra8unormN/AN/AN/A
bgra8unorm-srgbN/AN/AN/A
Packed 4 bytes per pixel formats
rgb9e5ufloatN/AN/AN/AGL.RGB9_E5
rg11b10ufloatN/AN/AN/AGL.R11F_G11F_B10F
rgb10a2unormN/AN/AN/AGL.RGB10_A2
rgb10a2uint-webglN/AN/AN/AGL.RGB10_A2UI
6 bytes per pixel formats
rgb16unorm-webglN/AN/AN/A
rgb16snorm-webglN/AN/AN/A
8 bytes per pixel formats
rg32uintN/AN/AN/AGL.RG32UI
rg32sintN/AN/AN/AGL.RG32I
rg32floatN/AN/AN/AGL.RG32F
rgba16uintN/AN/AN/AGL.RGBA16UI
rgba16sintN/AN/AN/AGL.RGBA16I
rgba16unorm-webglN/AN/AN/A
rgba16snorm-webglN/AN/AN/A
rgba16floatN/AN/AN/AGL.RGBA16F
12 bytes per pixel formats
rgb32float-webglN/AN/AN/AGL.RGB32F Deprecated format.
16 bytes per pixel formats
rgba32uintN/AN/AN/A
rgba32sintN/AN/AN/A
rgba32floatN/AN/AN/A
Depth and stencil formats
stencil8N/AN/AN/APlatform dependent: Might use depth24stencil8 with hidden depth.
depth16unormN/AN/AN/A
depth24plusN/AN/AN/APlatform dependent: Maps to "depth24unorm" or depth32float.
depth24plus-stencil81N/AN/AN/APlatform dependent: Maps to "depth24unorm" or depth32float.
depth32floatN/AN/AN/AHigher precision than depth24unorm in representable range (0.0 to 1.0)
depth24unorm-stencil8N/AN/AN/APlatform dependent: Check via depth24unorm-stencil8 feature.
depth32float-stencil8N/AN/AN/APlatform dependent: Check via depth32float-stencil8 feature.
texture-compression-bc(5)S3 Texture Compression, aka BC (Block Compression) using FourCC DXTn file identifiers. 4-6x compression.
bc1-rgb-unorm-webglN/AN/AN/ABC1 / DXT1: 16 input pixels in 64 bits.
bc1-rgb-unorm-srgb-webglN/AN/AN/A
bc1-rgba-unormN/AN/AN/A
bc1-rgba-unorm-srgbN/AN/AN/A
bc2-rgba-unormN/AN/AN/ABC2 / DXT3: 16 input pixels in 128 bits
bc2-rgba-unorm-srgbN/AN/AN/A
bc3-rgba-unormN/AN/AN/ABC3 / DXT5: as BC2 with interpolated alpha.
bc3-rgba-unorm-srgbN/AN/AN/A
bc4-r-unormN/AN/AN/ABC4: 16 input single-channel (e.g. greyscale) pixels into 64 bits of output.
bc4-r-snormN/AN/AN/A
bc5-rg-unormN/AN/AN/A
bc5-rg-snormN/AN/AN/A
texture-compression-bc
bc6h-rgb-ufloatN/AN/AN/ABC6H: 6 input RGB HDR (float16) pixels into 128 bits of output
bc6h-rgb-floatN/AN/AN/A
bc7-rgba-unormN/AN/AN/ABC7: encodes 16 input RGB8/RGBA8 pixels into 128 bits of output
bc7-rgba-unorm-srgbN/AN/AN/A
texture-compression-etc2Performance caveat: Often CPU decompressed.
etc2-rgb8unormN/AN/AN/AGL.COMPRESSED_RGB8_ETC2
etc2-rgb8unorm-srgbN/AN/AN/AGL.COMPRESSED_SRGB8_ETC2
etc2-rgb8a1unormN/AN/AN/AGL.COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2
etc2-rgb8a1unorm-srgbN/AN/AN/AGL.COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2
etc2-rgba8unormN/AN/AN/AGL.COMPRESSED_RGBA8_ETC2_EAC
etc2-rgba8unorm-srgbN/AN/AN/AGL.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC
eac-r11unormN/AN/AN/AGL.COMPRESSED_R11_EAC
eac-r11snormN/AN/AN/AGL.COMPRESSED_SIGNED_R11_EAC
eac-rg11unormN/AN/AN/AGL.COMPRESSED_RG11_EAC
eac-rg11snormN/AN/AN/AGL.COMPRESSED_SIGNED_RG11_EAC
texture-compression-astcX_ASTC compressed formats device.features.has
astc-4x4-unormN/AN/AN/AGL.COMPRESSED_RGBA_ASTC_4x4_KHR
astc-4x4-unorm-srgbN/AN/AN/AGL.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR
astc-5x4-unormN/AN/AN/AGL.COMPRESSED_RGBA_ASTC_5x4_KHR
astc-5x4-unorm-srgbN/AN/AN/AGL.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR
astc-5x5-unormN/AN/AN/AGL.COMPRESSED_RGBA_ASTC_5x5_KHR
astc-5x5-unorm-srgbN/AN/AN/AGL.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR
astc-6x5-unormN/AN/AN/AGL.COMPRESSED_RGBA_ASTC_6x5_KHR
astc-6x5-unorm-srgbN/AN/AN/AGL.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR
astc-6x6-unormN/AN/AN/AGL.COMPRESSED_RGBA_ASTC_6x6_KHR
astc-6x6-unorm-srgbN/AN/AN/AGL.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR
astc-8x5-unormN/AN/AN/AGL.COMPRESSED_RGBA_ASTC_8x5_KHR
astc-8x5-unorm-srgbN/AN/AN/AGL.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR
astc-8x6-unormN/AN/AN/AGL.COMPRESSED_RGBA_ASTC_8x6_KHR
astc-8x6-unorm-srgbN/AN/AN/AGL.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR
astc-8x8-unormN/AN/AN/AGL.COMPRESSED_RGBA_ASTC_8x8_KHR
astc-8x8-unorm-srgbN/AN/AN/AGL.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR
astc-10x5-unormN/AN/AN/AGL.COMPRESSED_RGBA_ASTC_10x10_KHR
astc-10x5-unorm-srgbN/AN/AN/AGL.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR
astc-10x6-unormN/AN/AN/AGL.COMPRESSED_RGBA_ASTC_10x6_KHR
astc-10x6-unorm-srgbN/AN/AN/AGL.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR
astc-10x8-unormN/AN/AN/AGL.COMPRESSED_RGBA_ASTC_10x8_KHR
astc-10x8-unorm-srgbN/AN/AN/AGL.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR
astc-10x10-unormN/AN/AN/AGL.COMPRESSED_RGBA_ASTC_10x10_KHR
astc-10x10-unorm-srgbN/AN/AN/AGL.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR
astc-12x10-unormN/AN/AN/AGL.COMPRESSED_RGBA_ASTC_12x10_KHR
astc-12x10-unorm-srgbN/AN/AN/AGL.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR
astc-12x12-unormN/AN/AN/AGL.COMPRESSED_RGBA_ASTC_12x12_KHR
astc-12x12-unorm-srgbN/AN/AN/AGL.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR
texture-compression-pvrtc-webglWEBGL_compressed_texture_pvrtc
pvrtc-rgb4unorm-webglN/AN/AN/AGL.COMPRESSED_RGB_PVRTC_4BPPV1_IMG
pvrtc-rgba4unorm-webglN/AN/AN/AGL.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG
pvrtc-rbg2unorm-webglN/AN/AN/AGL.COMPRESSED_RGB_PVRTC_2BPPV1_IMG
pvrtc-rgba2unorm-webglN/AN/AN/AGL.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG
texture-compression-etc1-webgl
etc1-rbg-unorm-webglN/AN/AN/AGL.COMPRESSED_RGB_ETC1_WEBGL
texture-compression-pvrtc-webgl
atc-rgb-unorm-webglN/AN/AN/AGL.COMPRESSED_RGB_ATC_WEBGL
atc-rgba-unorm-webglN/AN/AN/AGL.COMPRESSED_RGBA_ATC_EXPLICIT_ALPHA_WEBGL
atc-rgbai-unorm-webglN/AN/AN/AGL.COMPRESSED_RGBA_ATC_INTERPOLATED_ALPHA_WEBGL

Texture Format detection

While a subset of texture formats are supported on all devices of a certain type, many texture formats are only supported if the underlying hardware supports them.

You can use device.isTextureFormatSupported(format) check if it is possible to create and sample textures with a specific texture format on your current device.

Texture Format Capabilities

Even though a device allows a Texture to be created with a certain texture format, there may still be limitations in what operations can be done with that texture. luma provides Device methods to help applications determine the capabilities of a texture format.

Can textures with the format...Check using
be created and sampled (using nearest filters)?device.isTextureFormatSupported(format)
be sampled using linear filtering?device.isTextureFormatFilterable(format)
be rendered into? (render targets / color attachments)device.isTextureFormatRenderable(format)
be used for storage bindings?N/A
be blended?Yes, if sampler type float is supported
support multisampling?N/A

Remarks

  • Mipmaps can only be auto created for formats that are both filterable and renderable.
  • A renderable format is either a color renderable format, or a depth-or-stencil format
  • All depth/stencil formats are renderable.
  • Samplers always read a "vec4" regardless of which texture format is used. For formats with less than 4 components, missing red, green and blue components in the texture format are read as 0.0, alpha as 1.0/
  • Note that some formats are not mandated by the base standard but represent additional capabilities (e.g. a WebGL2 device running on top of an OpenGL ES 3.2 driver). .

Texture Format Groups

Support for some types of texture formats come in groups. As an alternative to checking texture support format-by-format, Device.features can be queried to determine if specific groups or classes of texture formats are supported.

FeatureOptional capabilities
texture-srgb-webgl1sRGB formats are supported
texture-depth-webgldepth texture formats are supported
texture-float32-webglCreate floating point textures (nearest sampling only)
texture-float16-webglCreate half-floating point textures (nearest sampling)
float32-renderable-webglFloating point textures are color-renderable and readable
texture-renderable-float15-webglHalf float textures are color-renderable and readable
texture-filterable-anisotropic-webglanisotropic filtering
float32-filterable-linear-webgllinear sampling of floating point textures
float16-filterable-linear-webgllinear sampling of half-floating point textures

Compressed Textures

For more information on compressed textures, see e.g. Compressed Textures in 2020.

FeatureTypeDevicesDescription
texture-compression-bc5-webglDXT compressed textures (BC1-BC5)Mainly desktops.
texture-compression-bcDXT compressed textures (BC1-BC7)Mainly desktops.Includes texture-compression-bc5-webgl
texture-compression-etcEricsson compression."Always" available (CPU decode).Slow, not recommended
texture-compression-astcIntel GPUs, Nividia Tegra, Mali ARM GPUs.
texture-compression-pvrtc-webglPowerVR chipsets.iPhone, iPad, certain Android
texture-compression-atc-webglAdreno GPUsQualcomm Snapdragon devices.
texture-compression-etc1-webglEricsson CompressionOlder ETC compression.

Supercompressed Textures

To use Basis supercompressed textures in luma.gl, see the loaders.gl BasisLoader which can extract compressed textures from a basis encoded texture.

WebGL notes

Below is WebGL specific technical reference information that has been kept since luma.gl v8, it can be ignored for most applications

On WebGL devices, luma.gl maps WebGPU style texture format strings to WebGL constants under the hood. It is however possible to provide overrides for the WebGL constants. The following tables provide some information about WebGL texture constants

If an application wants to store the texture at a certain resolution or in a certain format, it can request the resolution and format with internalFormat. WebGL will choose an internal representation with least the internal component sizes, and exactly the component types shown for that format, although it may not match exactly.

Internal Formats

Sized Internal FormatComp.SizeDescription
GL.R818 bitsred component
GL.R16F116 bitshalf float red component
GL.R32F132 bitsfloat red component
GL.R8UI18 bitsunsigned int red component, usampler, no filtering
GL.RG8116 bitsred and green components
GL.RG16F232 bitsred and green components, half float
GL.RG32F264 bitsred and green components, float
GL.RGUI216 bitsred and green components, usampler, no filtering
GL.RGB8324 bitsred, green and blue components
GL.SRGB8 (EXT_sRGB)324 bitsColor values are encoded to/decoded from sRGB before being written to/read from framebuffer
GL.RGB565316 bits5 bit red, 6 bit green, 5 bit blue
GL.R11F_G11F_B10F332 bits11 and 10 bit floating point colors
GL.RGB9_E5332 bits14 bit floating point RGB, shared exponent
GL.RGB16F348 bitshalf float RGB
GL.RGB32F396 bitsfloat RBG
GL.RGB8UI324 bitsunsigned integer 8 bit RGB: use usampler, no filtering
GL.RGBA8432 bits8 bit RGBA, typically what GL.RGBA "resolves" to
GL.SRGB_APLHA8 (EXT_sRGB)432 bitsColor values are encoded to/decoded from sRGB before being written to/read from framebuffer
GL.RGB5_A1416 bits5 bit RGB, 1 bit alpha
GL.RGBA4444416 bits4 bit RGBA
GL.RGBA16F464 bitshalf float RGBA
GL.RGBA32F4128 bitsfloat RGA
GL.RGBA8UI432 bitsunsigned integer 8 bit RGBA, usampler, no filtering

Texture Component Type

Describes the layout of each color component in memory.

ValueWebGL 2
GL.UNSIGNED_BYTEYesGLbyte 8 bits per channel for GL.RGBA
GL.UNSIGNED_SHORT_5_6_5Yes5 red bits, 6 green bits, 5 blue bits
GL.UNSIGNED_SHORT_4_4_4_4Yes4 red bits, 4 green bits, 4 blue bits, 4 alpha bits
GL.UNSIGNED_SHORT_5_5_5_1Yes5 red bits, 5 green bits, 5 blue bits, 1 alpha bit
GL.BYTEYes
GL.UNSIGNED_SHORTYes
GL.SHORTYes
GL.UNSIGNED_INTYes
GL.INTYes
GL.HALF_FLOATYes
GL.FLOATYes
GL.UNSIGNED_INT_2_10_10_10_REVYes
GL.UNSIGNED_INT_10F_11F_11F_REVYes
GL.UNSIGNED_INT_5_9_9_9_REVYes
GL.UNSIGNED_INT_24_8Yes
GL.FLOAT_32_UNSIGNED_INT_24_8_REVYes(pixels must be null)

Texture Format Combinations

This a simplified table illustrating what combinations of internal formats work with what data formats and types. Note that luma.gl deduces dataFormat and type from format by taking the first value from the data format and data type entries in this table.

For more details, see tables in:

Internal FormatData FormatData Type
GL.RGBGL.RGBGL.UNSIGNED_BYTE GL.UNSIGNED_SHORT_5_6_5
GL.RGBAGL.RGBAGL.UNSIGNED_BYTE GL.UNSIGNED_SHORT_4_4_4_4 GL.UNSIGNED_SHORT_5_5_5_1
GL.R8GL.REDGL.UNSIGNED_BYTE
GL.R16FGL.REDGL.HALF_FLOAT GL.FLOAT
GL.R32FGL.REDGL.FLOAT
GL.R8UIGL.RED_INTEGERGL.UNSIGNED_BYTE
GL.RG8GL.RGGL.UNSIGNED_BYTE
GL.RG16FGL.RGGL.HALF_FLOAT GL.FLOAT
GL.RG32FGL.RGGL.FLOAT
GL.RG8UIGL.RG_INTEGERGL.UNSIGNED_BYTE
GL.RGB8GL.RGBGL.UNSIGNED_BYTE
GL.SRGB8GL.RGBGL.UNSIGNED_BYTE
GL.RGB565GL.RGBGL.UNSIGNED_BYTE GL.UNSIGNED_SHORT_5_6_5
GL.R11F_G11F_B10FGL.RGBGL.UNSIGNED_INT_10F_11F_11F_REV GL.HALF_FLOAT GL.FLOAT
GL.RGB9_E5GL.RGBGL.HALF_FLOAT GL.FLOAT
GL.RGB16FGGL.RGBGL.HALF_FLOAT GL.FLOAT
GL.RGB32FGL.RGBGL.FLOAT
GL.RGB8UIGL.RGB_INTEGERGL.UNSIGNED_BYTE
GL.RGBA8GL.RGBAGL.UNSIGNED_BYTE
GL.SRGB8_ALPHA8GL.RGBAGL.UNSIGNED_BYTE
GL.RGB5_A1GL.RGBAGL.UNSIGNED_BYTE GL.UNSIGNED_SHORT_5_5_5_1
GL.RGBA4GL.RGBAGL.UNSIGNED_BYTE GL.UNSIGNED_SHORT_4_4_4_4
GL.RGBA16FGL.RGBAGL.HALF_FLOAT GL.FLOAT
GL.RGBA32FGL.RGBAGL.FLOAT
GL.RGBA8UIGL.RGBA_INTEGERGL.UNSIGNED_BYTE