Tiện ích WEBGL_compressed_texture_astc
Baseline
Widely available
This feature is well established and works across many devices and browser versions. It’s been available across browsers since January 2020.
Tiện ích WEBGL_compressed_texture_astc là một phần của WebGL API và cung cấp các định dạng texture nén Adaptive Scalable Texture Compression (ASTC) cho WebGL.
Để biết thêm thông tin, xem bài viết Using ASTC Texture Compression for Game Assets của NVIDIA.
Các tiện ích WebGL có thể dùng bằng phương thức WebGLRenderingContext.getExtension(). Để biết thêm thông tin, xem Using Extensions trong hướng dẫn WebGL.
Phương thức phiên bản
Tiện ích này cung cấp một phương thức mới.
ext.getSupportedProfiles()-
Trả về một mảng chuỗi chứa tên của các profile ASTC được hỗ trợ bởi triển khai.
Hằng số
Các định dạng texture nén được cung cấp bởi 28 hằng số và có thể được dùng trong hai hàm: compressedTexImage2D() và compressedTexSubImage2D().
| Hằng số | Khối | Bit mỗi pixel | ArrayBuffer byteLength |
Byte khi chiều cao và rộng là 512 |
|---|---|---|---|---|
ext.COMPRESSED_RGBA_ASTC_4x4_KHR
|
4x4 | 8.00 |
floor((width + 3) / 4) * floor((height + 3) / 4) * 16
|
262144 |
ext.COMPRESSED_RGBA_ASTC_5x4_KHR
|
5x4 | 6.40 |
floor((width + 4) / 5) * floor((height + 3) / 4) * 16
|
210944 |
ext.COMPRESSED_RGBA_ASTC_5x5_KHR
|
5x5 | 5.12 |
floor((width + 4) / 5) * floor((height + 4) / 5) * 16
|
169744 |
ext.COMPRESSED_RGBA_ASTC_6x5_KHR
|
6x5 | 4.27 |
floor((width + 5) / 6) * floor((height + 4) / 5) * 16
|
141728 |
ext.COMPRESSED_RGBA_ASTC_6x6_KHR
|
6x6 | 3.56 |
floor((width + 5) / 6) * floor((height + 5) / 6) * 16
|
118336 |
ext.COMPRESSED_RGBA_ASTC_8x5_KHR
|
8x5 | 3.20 |
floor((width + 7) / 8) * floor((height + 4) / 5) * 16
|
105472 |
ext.COMPRESSED_RGBA_ASTC_8x6_KHR
|
8x6 | 2.67 |
floor((width + 7) / 8) * floor((height + 5) / 6) * 16
|
88064 |
ext.COMPRESSED_RGBA_ASTC_8x8_KHR
|
8x8 | 2.00 |
floor((width + 7) / 8) * floor((height + 7) / 8) * 16
|
65536 |
ext.COMPRESSED_RGBA_ASTC_10x5_KHR
|
10x5 | 2.56 |
floor((width + 9) / 10) * floor((height + 4) / 5) * 16
|
85696 |
ext.COMPRESSED_RGBA_ASTC_10x6_KHR
|
10x6 | 2.13 |
floor((width + 9) / 10) * floor((height + 5) / 6) * 16
|
71552 |
ext.COMPRESSED_RGBA_ASTC_10x8_KHR
|
10x8 | 1.60 |
floor((width + 9) / 10) * floor((height + 7) / 8) * 16
|
53248 |
ext.COMPRESSED_RGBA_ASTC_10x10_KHR
|
10x10 | 1.28 |
floor((width + 9) / 10) * floor((height + 9) / 10) * 16
|
43264 |
ext.COMPRESSED_RGBA_ASTC_12x10_KHR
|
12x10 | 1.07 |
floor((width + 11) / 12) * floor((height + 9) / 10) * 16
|
35776 |
ext.COMPRESSED_RGBA_ASTC_12x12_KHR
|
12x12 | 0.89 |
floor((width + 11) / 12) * floor((height + 11) / 12) * 16
|
29584 |
Ví dụ
const ext = gl.getExtension("WEBGL_compressed_texture_astc");
const 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,
);
Thông số kỹ thuật
| Thông số kỹ thuật |
|---|
| WebGL WEBGL_compressed_texture_astc Extension Specification> |