WEBGL_compressed_texture_astc

WEBGL_compressed_texture_astc extension is part of the WebGL API and exposes Adaptive Scalable Texture Compression (ASTC) compressed texture formats to WebGL.

For more information, see the article Using ASTC Texture Compression for Game Assets by nvidia.

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

Availability: ASTC compression is typically available on Mali ARM GPUs, Intel GPUs, and Nividia Tegra chips.

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

方法

This extension exposes one new methods.

ext.getSupportedProfiles()

Returns an array of strings containing the names of the ASTC profiles supported by the implementation.

常量

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

常量 Blocks Bits per pixel ArrayBuffer byteLength bytes if height and width are 512
ext.COMPRESSED_RGBA_ASTC_4x4_KHR
ext.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR
4x4 8.00 floor((width + 3) / 4) * floor((height + 3) / 4) * 16 262144
ext.COMPRESSED_RGBA_ASTC_5x4_KHR
ext.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR
5x4 6.40 floor((width + 4) / 5) * floor((height + 3) / 4) * 16 210944
ext.COMPRESSED_RGBA_ASTC_5x5_KHR
ext.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR
5x5 5.12 floor((width + 4) / 5) * floor((height + 4) / 5) * 16 169744
ext.COMPRESSED_RGBA_ASTC_6x5_KHR
ext.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR
6x5 4.27 floor((width + 5) / 6) * floor((height + 4) / 5) * 16 141728
ext.COMPRESSED_RGBA_ASTC_6x6_KHR
ext.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR
6x6 3.56 floor((width + 5) / 6) * floor((height + 5) / 6) * 16 118336
ext.COMPRESSED_RGBA_ASTC_8x5_KHR
ext.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR
8x5 3.20 floor((width + 7) / 8) * floor((height + 4) / 5) * 16 105472
ext.COMPRESSED_RGBA_ASTC_8x6_KHR
ext.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR
8x6 2.67 floor((width + 7) / 8) * floor((height + 5) / 6) * 16 88064
ext.COMPRESSED_RGBA_ASTC_8x8_KHR
ext.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR
8x8 2.00 floor((width + 7) / 8) * floor((height + 7) / 8) * 16 65536
ext.COMPRESSED_RGBA_ASTC_10x5_KHR
ext.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR
10x5 2.56 floor((width + 9) / 10) * floor((height + 4) / 5) * 16 85696
ext.COMPRESSED_RGBA_ASTC_10x6_KHR
ext.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR
10x6 2.13 floor((width + 9) / 10) * floor((height + 5) / 6) * 16 71552
ext.COMPRESSED_RGBA_ASTC_10x8_KHR
ext.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR
10x8 1.60 floor((width + 9) / 10) * floor((height + 7) / 8) * 16 53248
ext.COMPRESSED_RGBA_ASTC_10x10_KHR
ext.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR
10x10 1.28 floor((width + 9) / 10) * floor((height + 9) / 10) * 16 43264
ext.COMPRESSED_RGBA_ASTC_12x10_KHR
ext.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR
12x10 1.07 floor((width + 11) / 12) * floor((height + 9) / 10) * 16 35776
ext.COMPRESSED_RGBA_ASTC_12x12_KHR
ext.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR
12x12 0.89 floor((width + 11) / 12) * floor((height + 11) / 12) * 16 29584

范例

var ext = gl.getExtension('WEBGL_compressed_texture_astc');
var texture = gl.createTexture();
gl.bindTexture(gl.TEXTURE_2D, texture);
gl.compressedTexImage2D(gl.TEXTURE_2D, 0, ext.COMPRESSED_RGBA_ASTC_12x12_KHR, 512, 512, 0, textureData);
			

规范

规范 状态 Comment
WEBGL_compressed_texture_astc
The definition of 'WEBGL_compressed_texture_astc' in that specification.
Recommendation 初始定义。

浏览器兼容性

更新 GitHub 上的兼容性数据
Desktop Mobile
Chrome Edge Firefox Internet Explorer Opera Safari Android webview Chrome for Android Firefox for Android Opera for Android Safari on iOS Samsung Internet
WEBGL_compressed_texture_astc Chrome 47 Edge 79 Firefox 53 IE ? Opera ? Safari ? WebView Android 47 Chrome Android 47 Firefox Android 53 Opera Android ? Safari iOS ? Samsung Internet Android 5.0
getSupportedProfiles Chrome 47 Edge 79 Firefox 53 IE ? Opera ? Safari ? WebView Android 47 Chrome Android 47 Firefox Android 53 Opera Android ? Safari iOS ? Samsung Internet Android 5.0

图例

完整支持
兼容性未知
兼容性未知

另请参阅

Metadata

  1. WebGL API
  2. WEBGL_compressed_texture_astc
  3. 方法
    1. getSupportedProfiles()
  4. Related pages for WebGL
    1. ANGLE_instanced_arrays
    2. EXT_blend_minmax
    3. EXT_color_buffer_half_float
    4. EXT_disjoint_timer_query
    5. EXT_frag_depth
    6. EXT_sRGB
    7. EXT_shader_texture_lod
    8. EXT_texture_filter_anisotropic
    9. OES_element_index_uint
    10. OES_standard_derivatives
    11. OES_texture_float
    12. OES_texture_float_linear
    13. OES_texture_half_float
    14. OES_texture_half_float_linear
    15. OES_vertex_array_object
    16. WEBGL_color_buffer_float
    17. WEBGL_compressed_texture_atc
    18. WEBGL_compressed_texture_etc1
    19. WEBGL_compressed_texture_pvrtc
    20. WEBGL_compressed_texture_s3tc
    21. WEBGL_compressed_texture_s3tc_srgb
    22. WEBGL_debug_renderer_info
    23. WEBGL_debug_shaders
    24. WEBGL_depth_texture
    25. WEBGL_draw_buffers
    26. WEBGL_lose_context
    27. WebGL2RenderingContext
    28. WebGLActiveInfo
    29. WebGLBuffer
    30. WebGLContextEvent
    31. WebGLFramebuffer
    32. WebGLObject
    33. WebGLProgram
    34. WebGLQuery
    35. WebGLRenderbuffer
    36. WebGLRenderingContext
    37. WebGLSampler
    38. WebGLShader
    39. WebGLShaderPrecisionFormat
    40. WebGLSync
    41. WebGLTexture
    42. WebGLTransformFeedback
    43. WebGLUniformLocation
    44. WebGLVertexArrayObject