WEBGL_compressed_texture_s3tc extension

Limited availability

This feature is not Baseline because it does not work in some of the most widely-used browsers.

The WEBGL_compressed_texture_s3tc extension is part of the WebGL API and exposes four S3TC compressed texture formats.

Compressed textures reduce the amount of memory needed to store a texture on the GPU, allowing for higher resolution textures or more of the same resolution textures.

WebGL extensions are available using the WebGLRenderingContext.getExtension() method. For more information, see also Using Extensions in the WebGL tutorial.

Note: This extension is available to both, WebGL1 and WebGL2 contexts.

Constants

The compressed texture formats are exposed by four constants and can be used in two functions: compressedTexImage2D() and compressedTexSubImage2D().

ext.COMPRESSED_RGB_S3TC_DXT1_EXT

A DXT1-compressed image in an RGB image format.

ext.COMPRESSED_RGBA_S3TC_DXT1_EXT

A DXT1-compressed image in an RGB image format with an on/off alpha value.

ext.COMPRESSED_RGBA_S3TC_DXT3_EXT

A DXT3-compressed image in an RGBA image format. Compared to a 32-bit RGBA texture, it offers 4:1 compression.

ext.COMPRESSED_RGBA_S3TC_DXT5_EXT

A DXT5-compressed image in an RGBA image format. It also provides a 4:1 compression, but differs to the DXT3 compression in how the alpha compression is done.

Examples

js
const ext =
  gl.getExtension("WEBGL_compressed_texture_s3tc") ||
  gl.getExtension("MOZ_WEBGL_compressed_texture_s3tc") ||
  gl.getExtension("WEBKIT_WEBGL_compressed_texture_s3tc");

const texture = gl.createTexture();
gl.bindTexture(gl.TEXTURE_2D, texture);

gl.compressedTexImage2D(
  gl.TEXTURE_2D,
  0,
  ext.COMPRESSED_RGBA_S3TC_DXT5_EXT,
  512,
  512,
  0,
  textureData,
);

gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.LINEAR);
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR);

Specifications

Specification
WebGL WEBGL_compressed_texture_s3tc Khronos Ratified Extension Specification

Browser compatibility

desktop mobile
Chrome
Edge
Firefox
Opera
Safari
Chrome Android
Firefox for Android
Opera Android
Safari on iOS
Samsung Internet
WebView Android
WebView on iOS
WEBGL_compressed_texture_s3tc
Chrome – No support
Chrome 26 – 55 (Release date: 2013-03-26)
prefix
footnote Removed in 56 and later
prefix Implemented with the vendor prefix: WEBKIT_
Chrome – Full support
Chrome 26 (Release date: 2013-03-26)
footnote Full support
Edge – Full support
Edge 12 (Release date: 2015-07-29)
footnote Full support
Firefox – No support
Firefox 15 – 57 (Release date: 2012-08-28)
prefix
footnote Removed in 58 and later
prefix Implemented with the vendor prefix: MOZ_
Firefox – Full support
Firefox 22 (Release date: 2013-06-25)
footnote Full support
Opera – No support
Opera 15 – 42 (Release date: 2013-07-02)
prefix
footnote Removed in 43 and later
prefix Implemented with the vendor prefix: WEBKIT_
Opera – Full support
Opera 15 (Release date: 2013-07-02)
footnote Full support
Safari – Full support
Safari 8 (Release date: 2014-10-16)
footnote Full support
Chrome Android – No support
Chrome Android
footnote No support
Firefox for Android – No support
Firefox for Android
footnote No support
Opera Android – No support
Opera Android
footnote No support
Safari on iOS – No support
Safari on iOS
footnote No support
Samsung Internet – No support
Samsung Internet
footnote No support
WebView Android – No support
WebView Android
footnote No support
WebView on iOS – No support
WebView on iOS
footnote No support

Legend

Tip: you can click/tap on a cell for more information.

Full support
Full support
No support
No support
Requires a vendor prefix or different name for use.
Has more compatibility info.

See also