@woosh/meep-engine 3.79.0 → 3.80.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +62 -3
- package/README.md +1 -1
- package/package.json +1 -1
- package/src/format/image/webp/vp8/VP8BoolDecoder.d.ts +45 -0
- package/src/format/image/webp/vp8/VP8BoolDecoder.d.ts.map +1 -0
- package/src/format/image/webp/vp8/VP8BoolDecoder.js +137 -0
- package/src/format/image/webp/vp8/vp8_decode.d.ts +21 -0
- package/src/format/image/webp/vp8/vp8_decode.d.ts.map +1 -0
- package/src/format/image/webp/vp8/vp8_decode.js +756 -0
- package/src/format/image/webp/vp8/vp8_loop_filter.d.ts +31 -0
- package/src/format/image/webp/vp8/vp8_loop_filter.d.ts.map +1 -0
- package/src/format/image/webp/vp8/vp8_loop_filter.js +189 -0
- package/src/format/image/webp/vp8/vp8_predict.d.ts +48 -0
- package/src/format/image/webp/vp8/vp8_predict.d.ts.map +1 -0
- package/src/format/image/webp/vp8/vp8_predict.js +290 -0
- package/src/format/image/webp/vp8/vp8_tables.d.ts +34 -0
- package/src/format/image/webp/vp8/vp8_tables.d.ts.map +1 -0
- package/src/format/image/webp/vp8/vp8_tables.js +350 -0
- package/src/format/image/webp/vp8/vp8_transform.d.ts +22 -0
- package/src/format/image/webp/vp8/vp8_transform.d.ts.map +1 -0
- package/src/format/image/webp/vp8/vp8_transform.js +114 -0
- package/src/format/image/webp/vp8/vp8_yuv_to_rgba.d.ts +23 -0
- package/src/format/image/webp/vp8/vp8_yuv_to_rgba.d.ts.map +1 -0
- package/src/format/image/webp/vp8/vp8_yuv_to_rgba.js +133 -0
- package/src/format/image/webp/vp8l/VP8LBitReader.d.ts +47 -0
- package/src/format/image/webp/vp8l/VP8LBitReader.d.ts.map +1 -0
- package/src/format/image/webp/vp8l/VP8LBitReader.js +84 -0
- package/src/format/image/webp/vp8l/VP8LPrefixCode.d.ts +27 -0
- package/src/format/image/webp/vp8l/VP8LPrefixCode.d.ts.map +1 -0
- package/src/format/image/webp/vp8l/VP8LPrefixCode.js +184 -0
- package/src/format/image/webp/vp8l/vp8l_decode.d.ts +28 -0
- package/src/format/image/webp/vp8l/vp8l_decode.d.ts.map +1 -0
- package/src/format/image/webp/vp8l/vp8l_decode.js +261 -0
- package/src/format/image/webp/vp8l/vp8l_distance.d.ts +22 -0
- package/src/format/image/webp/vp8l/vp8l_distance.d.ts.map +1 -0
- package/src/format/image/webp/vp8l/vp8l_distance.js +62 -0
- package/src/format/image/webp/vp8l/vp8l_inverse_transforms.d.ts +50 -0
- package/src/format/image/webp/vp8l/vp8l_inverse_transforms.d.ts.map +1 -0
- package/src/format/image/webp/vp8l/vp8l_inverse_transforms.js +267 -0
- package/src/format/image/webp/vp8l/vp8l_read_prefix_code.d.ts +14 -0
- package/src/format/image/webp/vp8l/vp8l_read_prefix_code.d.ts.map +1 -0
- package/src/format/image/webp/vp8l/vp8l_read_prefix_code.js +99 -0
- package/src/format/image/webp/webp_decode.d.ts +23 -0
- package/src/format/image/webp/webp_decode.d.ts.map +1 -0
- package/src/format/image/webp/webp_decode.js +179 -0
- package/src/format/image/webp/webp_decode_alpha.d.ts +18 -0
- package/src/format/image/webp/webp_decode_alpha.d.ts.map +1 -0
- package/src/format/image/webp/webp_decode_alpha.js +84 -0
- package/src/format/texture/{basis → astc}/astc_block.d.ts +41 -0
- package/src/format/texture/astc/astc_block.d.ts.map +1 -0
- package/src/format/texture/{basis → astc}/astc_block.js +284 -164
- package/src/format/texture/astc/astc_decode_block.d.ts +68 -0
- package/src/format/texture/astc/astc_decode_block.d.ts.map +1 -0
- package/src/format/texture/astc/astc_decode_block.js +1119 -0
- package/src/format/texture/astc/astc_encode_block_4x4.d.ts +32 -0
- package/src/format/texture/astc/astc_encode_block_4x4.d.ts.map +1 -0
- package/src/format/texture/astc/astc_encode_block_4x4.js +181 -0
- package/src/format/texture/astc/astc_encode_block_4x4_rgba.d.ts +32 -0
- package/src/format/texture/astc/astc_encode_block_4x4_rgba.d.ts.map +1 -0
- package/src/format/texture/astc/astc_encode_block_4x4_rgba.js +337 -0
- package/src/format/texture/astc/astc_integer_sequence.d.ts.map +1 -0
- package/src/format/texture/{basis → astc}/astc_integer_sequence.js +251 -251
- package/src/format/texture/astc/astc_partition.d.ts.map +1 -0
- package/src/format/texture/{basis → astc}/astc_partition.js +199 -199
- package/src/format/texture/basis/transcode/etc1s_to_astc.js +329 -329
- package/src/format/texture/basis/transcode/etc1s_to_etc2.d.ts.map +1 -1
- package/src/format/texture/basis/transcode/etc1s_to_etc2.js +305 -332
- package/src/format/texture/basis/transcode/fit_endpoints.d.ts.map +1 -1
- package/src/format/texture/basis/transcode/fit_endpoints.js +14 -27
- package/src/format/texture/basis/uastc/uastc_bc7_tables.d.ts +66 -0
- package/src/format/texture/basis/uastc/uastc_bc7_tables.d.ts.map +1 -0
- package/src/format/texture/basis/uastc/uastc_bc7_tables.js +148 -0
- package/src/format/texture/basis/uastc/uastc_decode_block.js +463 -463
- package/src/format/texture/basis/uastc/uastc_to_astc.js +421 -421
- package/src/format/texture/basis/uastc/uastc_to_bc5.d.ts +1 -6
- package/src/format/texture/basis/uastc/uastc_to_bc5.d.ts.map +1 -1
- package/src/format/texture/basis/uastc/uastc_to_bc5.js +48 -115
- package/src/format/texture/basis/uastc/uastc_to_bc7.d.ts.map +1 -1
- package/src/format/texture/basis/uastc/uastc_to_bc7.js +604 -602
- package/src/format/texture/bc/bc1_decode_block.d.ts +19 -0
- package/src/format/texture/bc/bc1_decode_block.d.ts.map +1 -0
- package/src/format/texture/bc/bc1_decode_block.js +22 -0
- package/src/format/texture/bc/bc1_decode_colors.d.ts +27 -0
- package/src/format/texture/bc/bc1_decode_colors.d.ts.map +1 -0
- package/src/format/texture/bc/bc1_decode_colors.js +100 -0
- package/src/format/texture/bc/bc2_decode_block.d.ts +18 -0
- package/src/format/texture/bc/bc2_decode_block.d.ts.map +1 -0
- package/src/format/texture/bc/bc2_decode_block.js +28 -0
- package/src/format/texture/bc/bc3_decode_block.d.ts +18 -0
- package/src/format/texture/bc/bc3_decode_block.d.ts.map +1 -0
- package/src/format/texture/bc/bc3_decode_block.js +23 -0
- package/src/format/texture/bc/bc4_decode_channel.d.ts +56 -0
- package/src/format/texture/bc/bc4_decode_channel.d.ts.map +1 -0
- package/src/format/texture/bc/bc4_decode_channel.js +138 -0
- package/src/format/texture/bc/bc4_encode_block.d.ts +43 -0
- package/src/format/texture/bc/bc4_encode_block.d.ts.map +1 -0
- package/src/format/texture/bc/bc4_encode_block.js +324 -0
- package/src/format/texture/bc/bc4_snorm_decode_block.d.ts +18 -0
- package/src/format/texture/bc/bc4_snorm_decode_block.d.ts.map +1 -0
- package/src/format/texture/bc/bc4_snorm_decode_block.js +27 -0
- package/src/format/texture/bc/bc4_unorm_decode_block.d.ts +17 -0
- package/src/format/texture/bc/bc4_unorm_decode_block.d.ts.map +1 -0
- package/src/format/texture/bc/bc4_unorm_decode_block.js +26 -0
- package/src/format/texture/bc/bc5_encode_block.d.ts +25 -0
- package/src/format/texture/bc/bc5_encode_block.d.ts.map +1 -0
- package/src/format/texture/bc/bc5_encode_block.js +34 -0
- package/src/format/texture/bc/bc5_snorm_decode_block.d.ts +18 -0
- package/src/format/texture/bc/bc5_snorm_decode_block.d.ts.map +1 -0
- package/src/format/texture/bc/bc5_snorm_decode_block.js +27 -0
- package/src/format/texture/bc/bc5_unorm_decode_block.d.ts +17 -0
- package/src/format/texture/bc/bc5_unorm_decode_block.d.ts.map +1 -0
- package/src/format/texture/bc/bc5_unorm_decode_block.js +26 -0
- package/src/format/texture/bc/bc6h_decode_texels.d.ts +30 -0
- package/src/format/texture/bc/bc6h_decode_texels.d.ts.map +1 -0
- package/src/format/texture/bc/bc6h_decode_texels.js +430 -0
- package/src/format/texture/bc/bc6h_sfloat_decode_block.d.ts +20 -0
- package/src/format/texture/bc/bc6h_sfloat_decode_block.d.ts.map +1 -0
- package/src/format/texture/bc/bc6h_sfloat_decode_block.js +23 -0
- package/src/format/texture/bc/bc6h_ufloat_decode_block.d.ts +18 -0
- package/src/format/texture/bc/bc6h_ufloat_decode_block.d.ts.map +1 -0
- package/src/format/texture/bc/bc6h_ufloat_decode_block.js +21 -0
- package/src/format/texture/bc/bc7_decode_block.d.ts +30 -0
- package/src/format/texture/bc/bc7_decode_block.d.ts.map +1 -0
- package/src/format/texture/bc/bc7_decode_block.js +232 -0
- package/src/format/texture/bc/bc7_encode_block.d.ts +39 -0
- package/src/format/texture/bc/bc7_encode_block.d.ts.map +1 -0
- package/src/format/texture/bc/bc7_encode_block.js +423 -0
- package/src/format/texture/bc/bc7_tables.d.ts +126 -0
- package/src/format/texture/bc/bc7_tables.d.ts.map +1 -0
- package/src/format/texture/{basis/uastc → bc}/bc7_tables.js +225 -276
- package/src/format/texture/bc/bc7_write_block.d.ts +65 -0
- package/src/format/texture/bc/bc7_write_block.d.ts.map +1 -0
- package/src/format/texture/{basis/uastc → bc}/bc7_write_block.js +185 -227
- package/src/format/texture/etc/eac_decode_channel.d.ts +50 -0
- package/src/format/texture/etc/eac_decode_channel.d.ts.map +1 -0
- package/src/format/texture/etc/eac_decode_channel.js +142 -0
- package/src/format/texture/etc/eac_modifiers.d.ts +15 -0
- package/src/format/texture/etc/eac_modifiers.d.ts.map +1 -0
- package/src/format/texture/etc/eac_modifiers.js +31 -0
- package/src/format/texture/etc/eac_r11_snorm_decode_block.d.ts +21 -0
- package/src/format/texture/etc/eac_r11_snorm_decode_block.d.ts.map +1 -0
- package/src/format/texture/etc/eac_r11_snorm_decode_block.js +30 -0
- package/src/format/texture/etc/eac_r11_unorm_decode_block.d.ts +20 -0
- package/src/format/texture/etc/eac_r11_unorm_decode_block.d.ts.map +1 -0
- package/src/format/texture/etc/eac_r11_unorm_decode_block.js +29 -0
- package/src/format/texture/etc/eac_rg11_snorm_decode_block.d.ts +19 -0
- package/src/format/texture/etc/eac_rg11_snorm_decode_block.d.ts.map +1 -0
- package/src/format/texture/etc/eac_rg11_snorm_decode_block.js +28 -0
- package/src/format/texture/etc/eac_rg11_unorm_decode_block.d.ts +19 -0
- package/src/format/texture/etc/eac_rg11_unorm_decode_block.d.ts.map +1 -0
- package/src/format/texture/etc/eac_rg11_unorm_decode_block.js +28 -0
- package/src/format/texture/etc/etc2_decode_color.d.ts +25 -0
- package/src/format/texture/etc/etc2_decode_color.d.ts.map +1 -0
- package/src/format/texture/etc/etc2_decode_color.js +370 -0
- package/src/format/texture/etc/etc2_rgb8_decode_block.d.ts +18 -0
- package/src/format/texture/etc/etc2_rgb8_decode_block.d.ts.map +1 -0
- package/src/format/texture/etc/etc2_rgb8_decode_block.js +21 -0
- package/src/format/texture/etc/etc2_rgb8a1_decode_block.d.ts +21 -0
- package/src/format/texture/etc/etc2_rgb8a1_decode_block.d.ts.map +1 -0
- package/src/format/texture/etc/etc2_rgb8a1_decode_block.js +24 -0
- package/src/format/texture/etc/etc2_rgba8_decode_block.d.ts +18 -0
- package/src/format/texture/etc/etc2_rgba8_decode_block.d.ts.map +1 -0
- package/src/format/texture/etc/etc2_rgba8_decode_block.js +24 -0
- package/src/format/texture/fit/fit_line.d.ts +23 -0
- package/src/format/texture/fit/fit_line.d.ts.map +1 -0
- package/src/format/texture/fit/fit_line.js +123 -0
- package/src/format/texture/fit/fit_line_refine.d.ts +21 -0
- package/src/format/texture/fit/fit_line_refine.d.ts.map +1 -0
- package/src/format/texture/fit/fit_line_refine.js +69 -0
- package/src/format/texture/fit/fit_line_solve.d.ts +23 -0
- package/src/format/texture/fit/fit_line_solve.d.ts.map +1 -0
- package/src/format/texture/fit/fit_line_solve.js +71 -0
- package/src/format/texture/texel_decode_image.d.ts +44 -0
- package/src/format/texture/texel_decode_image.d.ts.map +1 -0
- package/src/format/texture/texel_decode_image.js +251 -0
- package/src/format/texture/texel_encode_image.d.ts +77 -0
- package/src/format/texture/texel_encode_image.d.ts.map +1 -0
- package/src/format/texture/texel_encode_image.js +187 -0
- package/src/shade/renderer/ShadeIndirectLightingMode.js +2 -0
- package/src/shade/renderer/acoustics/GPUAcousticLattice.d.ts +1 -1
- package/src/shade/renderer/acoustics/GPUAcoustics.d.ts +1 -1
- package/src/shade/renderer/loader/mtf/mtf_encode_texture.d.ts +1 -0
- package/src/shade/renderer/loader/mtf/mtf_encode_texture.d.ts.map +1 -1
- package/src/shade/renderer/loader/mtf/mtf_encode_texture.js +102 -28
- package/src/shade/renderer/loader/mtf/mtf_replace_textures.d.ts +19 -0
- package/src/shade/renderer/loader/mtf/mtf_replace_textures.d.ts.map +1 -0
- package/src/shade/renderer/loader/mtf/mtf_replace_textures.js +60 -0
- package/src/shade/renderer/loader/mtf/mtf_write.d.ts.map +1 -1
- package/src/shade/renderer/loader/mtf/mtf_write.js +7 -31
- package/src/shade/renderer/loader/mtf/mtf_write_collection.d.ts +23 -0
- package/src/shade/renderer/loader/mtf/mtf_write_collection.d.ts.map +1 -0
- package/src/shade/renderer/loader/mtf/mtf_write_collection.js +36 -0
- package/src/shade/renderer/texture/encode/chunk_astc_encode_block_4x4.d.ts +13 -0
- package/src/shade/renderer/texture/encode/chunk_astc_encode_block_4x4.d.ts.map +1 -0
- package/src/shade/renderer/texture/encode/chunk_astc_encode_block_4x4.js +39 -0
- package/src/shade/renderer/texture/encode/chunk_astc_encode_block_4x4_rgb.d.ts +3 -2
- package/src/shade/renderer/texture/encode/chunk_astc_encode_block_4x4_rgb.d.ts.map +1 -1
- package/src/shade/renderer/texture/encode/chunk_astc_encode_block_4x4_rgb.js +6 -21
- package/src/shade/renderer/texture/encode/chunk_astc_encode_block_4x4_rgba.d.ts +42 -0
- package/src/shade/renderer/texture/encode/chunk_astc_encode_block_4x4_rgba.d.ts.map +1 -0
- package/src/shade/renderer/texture/encode/chunk_astc_encode_block_4x4_rgba.js +612 -0
- package/src/shade/renderer/texture/encode/chunk_bc1_encode_block.d.ts +5 -4
- package/src/shade/renderer/texture/encode/chunk_bc1_encode_block.d.ts.map +1 -1
- package/src/shade/renderer/texture/encode/chunk_bc1_encode_block.js +8 -25
- package/src/shade/renderer/texture/encode/chunk_bc6h_encode_block_mode11.d.ts.map +1 -1
- package/src/shade/renderer/texture/encode/chunk_bc6h_encode_block_mode11.js +3 -19
- package/src/shade/renderer/texture/encode/chunk_bc7_encode_block.d.ts +14 -4
- package/src/shade/renderer/texture/encode/chunk_bc7_encode_block.d.ts.map +1 -1
- package/src/shade/renderer/texture/encode/chunk_bc7_encode_block.js +65 -54
- package/src/shade/renderer/texture/encode/chunk_bc7_encode_block_mode6.d.ts +2 -2
- package/src/shade/renderer/texture/encode/chunk_bc7_encode_block_mode6.d.ts.map +1 -1
- package/src/shade/renderer/texture/encode/chunk_bc7_encode_block_mode6.js +5 -22
- package/src/shade/renderer/texture/encode/chunk_bc7_partition_2.js +1 -1
- package/src/shade/renderer/texture/encode/chunk_scatter_principal_axis.d.ts +27 -0
- package/src/shade/renderer/texture/encode/chunk_scatter_principal_axis.d.ts.map +1 -0
- package/src/shade/renderer/texture/encode/chunk_scatter_principal_axis.js +147 -0
- package/src/shade/renderer/texture/encode/shader_texture_encode_astc_4x4.d.ts +3 -4
- package/src/shade/renderer/texture/encode/shader_texture_encode_astc_4x4.d.ts.map +1 -1
- package/src/shade/renderer/texture/encode/shader_texture_encode_astc_4x4.js +6 -13
- package/src/shade/renderer/texture/encode/shader_texture_encode_bc7_rgb.d.ts +13 -0
- package/src/shade/renderer/texture/encode/shader_texture_encode_bc7_rgb.d.ts.map +1 -0
- package/src/shade/renderer/texture/encode/shader_texture_encode_bc7_rgb.js +66 -0
- package/src/shade/renderer/texture/encode/texture_encode.d.ts +28 -1
- package/src/shade/renderer/texture/encode/texture_encode.d.ts.map +1 -1
- package/src/shade/renderer/texture/encode/texture_encode.js +202 -168
- package/src/shade/renderer/texture/encode/texture_encode_shader.d.ts +13 -1
- package/src/shade/renderer/texture/encode/texture_encode_shader.d.ts.map +1 -1
- package/src/shade/renderer/texture/encode/texture_encode_shader.js +146 -108
- package/src/shade/renderer/texture/format/texture_formats_to_build.d.ts +20 -0
- package/src/shade/renderer/texture/format/texture_formats_to_build.d.ts.map +1 -0
- package/src/shade/renderer/texture/format/texture_formats_to_build.js +98 -0
- package/src/shade/renderer/texture/mipmaps/WebGPUMipmapGenerator.d.ts.map +1 -1
- package/src/shade/renderer/texture/mipmaps/WebGPUMipmapGenerator.js +4 -23
- package/src/shade/renderer/texture/mipmaps/cpu/MipmapBilinearAxis.d.ts +53 -0
- package/src/shade/renderer/texture/mipmaps/cpu/MipmapBilinearAxis.d.ts.map +1 -0
- package/src/shade/renderer/texture/mipmaps/cpu/MipmapBilinearAxis.js +76 -0
- package/src/shade/renderer/texture/mipmaps/cpu/MipmapKernelAxis.d.ts +40 -0
- package/src/shade/renderer/texture/mipmaps/cpu/MipmapKernelAxis.d.ts.map +1 -0
- package/src/shade/renderer/texture/mipmaps/cpu/MipmapKernelAxis.js +43 -0
- package/src/shade/renderer/texture/mipmaps/cpu/mipmap_bilinear_centres.d.ts +17 -0
- package/src/shade/renderer/texture/mipmaps/cpu/mipmap_bilinear_centres.d.ts.map +1 -0
- package/src/shade/renderer/texture/mipmaps/cpu/mipmap_bilinear_centres.js +29 -0
- package/src/shade/renderer/texture/mipmaps/cpu/mipmap_bilinear_sample.d.ts +21 -0
- package/src/shade/renderer/texture/mipmaps/cpu/mipmap_bilinear_sample.d.ts.map +1 -0
- package/src/shade/renderer/texture/mipmaps/cpu/mipmap_bilinear_sample.js +91 -0
- package/src/shade/renderer/texture/mipmaps/cpu/mipmap_chain_cpu.d.ts +32 -0
- package/src/shade/renderer/texture/mipmaps/cpu/mipmap_chain_cpu.d.ts.map +1 -0
- package/src/shade/renderer/texture/mipmaps/cpu/mipmap_chain_cpu.js +216 -0
- package/src/shade/renderer/texture/mipmaps/cpu/mipmap_cubic_filter_cpu.d.ts +30 -0
- package/src/shade/renderer/texture/mipmaps/cpu/mipmap_cubic_filter_cpu.d.ts.map +1 -0
- package/src/shade/renderer/texture/mipmaps/cpu/mipmap_cubic_filter_cpu.js +134 -0
- package/src/shade/renderer/texture/mipmaps/cpu/mipmap_filter_catmull_rom_cpu.d.ts +16 -0
- package/src/shade/renderer/texture/mipmaps/cpu/mipmap_filter_catmull_rom_cpu.d.ts.map +1 -0
- package/src/shade/renderer/texture/mipmaps/cpu/mipmap_filter_catmull_rom_cpu.js +33 -0
- package/src/shade/renderer/texture/mipmaps/cpu/mipmap_filter_linear_cpu.d.ts +18 -0
- package/src/shade/renderer/texture/mipmaps/cpu/mipmap_filter_linear_cpu.d.ts.map +1 -0
- package/src/shade/renderer/texture/mipmaps/cpu/mipmap_filter_linear_cpu.js +71 -0
- package/src/shade/renderer/texture/mipmaps/cpu/mipmap_filter_linear_normal_cpu.d.ts +20 -0
- package/src/shade/renderer/texture/mipmaps/cpu/mipmap_filter_linear_normal_cpu.d.ts.map +1 -0
- package/src/shade/renderer/texture/mipmaps/cpu/mipmap_filter_linear_normal_cpu.js +57 -0
- package/src/shade/renderer/texture/mipmaps/cpu/mipmap_filter_magic_kernel_cpu.d.ts +18 -0
- package/src/shade/renderer/texture/mipmaps/cpu/mipmap_filter_magic_kernel_cpu.d.ts.map +1 -0
- package/src/shade/renderer/texture/mipmaps/cpu/mipmap_filter_magic_kernel_cpu.js +111 -0
- package/src/shade/renderer/texture/mipmaps/cpu/mipmap_filter_mitchell_cpu.d.ts +16 -0
- package/src/shade/renderer/texture/mipmaps/cpu/mipmap_filter_mitchell_cpu.d.ts.map +1 -0
- package/src/shade/renderer/texture/mipmaps/cpu/mipmap_filter_mitchell_cpu.js +33 -0
- package/src/shade/renderer/texture/mipmaps/cpu/mipmap_filter_mks_cpu.d.ts +18 -0
- package/src/shade/renderer/texture/mipmaps/cpu/mipmap_filter_mks_cpu.d.ts.map +1 -0
- package/src/shade/renderer/texture/mipmaps/cpu/mipmap_filter_mks_cpu.js +128 -0
- package/src/shade/renderer/texture/mipmaps/cpu/mipmap_filter_wronski2021_cpu.d.ts +21 -0
- package/src/shade/renderer/texture/mipmaps/cpu/mipmap_filter_wronski2021_cpu.d.ts.map +1 -0
- package/src/shade/renderer/texture/mipmaps/cpu/mipmap_filter_wronski2021_cpu.js +169 -0
- package/src/shade/renderer/texture/mipmaps/cpu/mipmap_kernel_reduce.d.ts +21 -0
- package/src/shade/renderer/texture/mipmaps/cpu/mipmap_kernel_reduce.d.ts.map +1 -0
- package/src/shade/renderer/texture/mipmaps/cpu/mipmap_kernel_reduce.js +119 -0
- package/src/shade/renderer/texture/mipmaps/cpu/mipmap_source_centre.d.ts +16 -0
- package/src/shade/renderer/texture/mipmaps/cpu/mipmap_source_centre.d.ts.map +1 -0
- package/src/shade/renderer/texture/mipmaps/cpu/mipmap_source_centre.js +19 -0
- package/src/shade/renderer/texture/mipmaps/cpu/texels_f32_to_rgba8unorm.d.ts +24 -0
- package/src/shade/renderer/texture/mipmaps/cpu/texels_f32_to_rgba8unorm.d.ts.map +1 -0
- package/src/shade/renderer/texture/mipmaps/cpu/texels_f32_to_rgba8unorm.js +41 -0
- package/src/shade/renderer/texture/mipmaps/cpu/texels_f32_to_rgba8unorm_srgb.d.ts +24 -0
- package/src/shade/renderer/texture/mipmaps/cpu/texels_f32_to_rgba8unorm_srgb.d.ts.map +1 -0
- package/src/shade/renderer/texture/mipmaps/cpu/texels_f32_to_rgba8unorm_srgb.js +140 -0
- package/src/shade/renderer/texture/mipmaps/cpu/texels_rgba8unorm_srgb_to_f32.d.ts +21 -0
- package/src/shade/renderer/texture/mipmaps/cpu/texels_rgba8unorm_srgb_to_f32.d.ts.map +1 -0
- package/src/shade/renderer/texture/mipmaps/cpu/texels_rgba8unorm_srgb_to_f32.js +35 -0
- package/src/shade/renderer/texture/mipmaps/cpu/texels_rgba8unorm_to_f32.d.ts +19 -0
- package/src/shade/renderer/texture/mipmaps/cpu/texels_rgba8unorm_to_f32.d.ts.map +1 -0
- package/src/shade/renderer/texture/mipmaps/cpu/texels_rgba8unorm_to_f32.js +27 -0
- package/src/shade/renderer/texture/mipmaps/filters/mipmap_shader_code_catmull_rom.js +4 -4
- package/src/shade/renderer/texture/mipmaps/filters/mipmap_shader_code_linear.d.ts +13 -0
- package/src/shade/renderer/texture/mipmaps/filters/mipmap_shader_code_linear.d.ts.map +1 -1
- package/src/shade/renderer/texture/mipmaps/filters/mipmap_shader_code_linear.js +54 -4
- package/src/shade/renderer/texture/mipmaps/filters/mipmap_shader_code_mitchell.js +4 -4
- package/src/shade/renderer/texture/mipmaps/filters/mipmap_shader_code_mks.d.ts.map +1 -1
- package/src/shade/renderer/texture/mipmaps/filters/mipmap_shader_code_mks.js +9 -13
- package/src/shade/renderer/texture/texture_block_encodings.d.ts +33 -0
- package/src/shade/renderer/texture/texture_block_encodings.d.ts.map +1 -0
- package/src/shade/renderer/texture/texture_block_encodings.js +89 -0
- package/src/format/texture/basis/astc_block.d.ts.map +0 -1
- package/src/format/texture/basis/astc_integer_sequence.d.ts.map +0 -1
- package/src/format/texture/basis/astc_partition.d.ts.map +0 -1
- package/src/format/texture/basis/uastc/bc7_tables.d.ts +0 -111
- package/src/format/texture/basis/uastc/bc7_tables.d.ts.map +0 -1
- package/src/format/texture/basis/uastc/bc7_write_block.d.ts +0 -124
- package/src/format/texture/basis/uastc/bc7_write_block.d.ts.map +0 -1
- /package/src/format/texture/{basis → astc}/astc_integer_sequence.d.ts +0 -0
- /package/src/format/texture/{basis → astc}/astc_partition.d.ts +0 -0
|
@@ -1,329 +1,329 @@
|
|
|
1
|
-
import {
|
|
2
|
-
ASTC_BLOCK_BYTES,
|
|
3
|
-
ASTC_WEIGHT_UNQUANTIZED,
|
|
4
|
-
astc_interpolate,
|
|
5
|
-
astc_order_endpoints,
|
|
6
|
-
astc_write_block
|
|
7
|
-
} from "
|
|
8
|
-
import { etc1s_block_colors } from "../etc1s/etc1s_block_colors.js";
|
|
9
|
-
import { number_compare_ascending } from "../../../../core/primitives/numbers/number_compare_ascending.js";
|
|
10
|
-
|
|
11
|
-
/**
|
|
12
|
-
* Bits a weight takes in the blocks this writes, and the levels that follow from it.
|
|
13
|
-
*
|
|
14
|
-
* **Two, where {@link uastc_to_astc} takes three.** An ETC1S block holds four colours and no more,
|
|
15
|
-
* so eight weight levels would spend half of them describing points the source never had — the
|
|
16
|
-
* limit here is the source, not the container. Two bits is also what leaves room for the endpoints
|
|
17
|
-
* a four-channel mode would need, should alpha ever be worth carrying this way.
|
|
18
|
-
*
|
|
19
|
-
* @readonly
|
|
20
|
-
* @type {number}
|
|
21
|
-
*/
|
|
22
|
-
const WEIGHT_BITS = 2;
|
|
23
|
-
|
|
24
|
-
/**
|
|
25
|
-
* @readonly
|
|
26
|
-
* @type {number[]}
|
|
27
|
-
*/
|
|
28
|
-
const LEVELS = ASTC_WEIGHT_UNQUANTIZED[WEIGHT_BITS];
|
|
29
|
-
|
|
30
|
-
/**
|
|
31
|
-
* Transcode ETC1S to ASTC 4x4.
|
|
32
|
-
*
|
|
33
|
-
* **The mobile counterpart to {@link etc1s_to_etc2}**, and the one compressed format that appears in
|
|
34
|
-
* every role's preference list — every recent phone samples it, where ETC2 is the older floor. Both
|
|
35
|
-
* are eight bits a texel.
|
|
36
|
-
*
|
|
37
|
-
* **A close fit, because an ETC1S block is already a line.** Its four colours are one base colour
|
|
38
|
-
* plus the same offset in each channel, so they lie on a line parallel to the grey axis, which is
|
|
39
|
-
* exactly what a single-partition ASTC block with two endpoints and an interpolant represents. What
|
|
40
|
-
* is left is choosing where on that line the four weight levels sit, which {@link fit_block} searches.
|
|
41
|
-
*
|
|
42
|
-
* **Opaque only.** ASTC can carry alpha, but not with a shared weight plane: an ETC1S payload's
|
|
43
|
-
* colour and alpha come from two independent slices with their own selectors, and forcing them onto
|
|
44
|
-
* one set of weights would wreck both. The dual-plane block mode that would separate them cannot also
|
|
45
|
-
* hold eight endpoints and thirty-two weight bits in 128 bits. So this declares no alpha and a
|
|
46
|
-
* payload carrying some falls through to a target that has room — the mechanism BC1 has used since
|
|
47
|
-
* step 9, and which `ktx2_read` now applies before a format is committed to rather than after.
|
|
48
|
-
*
|
|
49
|
-
* @param {Etc1sSlice} slice
|
|
50
|
-
* @param {Etc1sSlice|undefined} _alpha_slice refused before this is called; see above
|
|
51
|
-
* @param {Etc1sEndpointCodebook} endpoints
|
|
52
|
-
* @param {Etc1sSelectorCodebook} selectors
|
|
53
|
-
* @returns {Uint8Array} tightly packed ASTC blocks, in raster order
|
|
54
|
-
*
|
|
55
|
-
* @author Alex Goldring
|
|
56
|
-
* @copyright Company Named Limited (c) 2026
|
|
57
|
-
*/
|
|
58
|
-
export function etc1s_to_astc(slice, _alpha_slice, endpoints, selectors) {
|
|
59
|
-
const block_count = slice.blocks_x * slice.blocks_y;
|
|
60
|
-
|
|
61
|
-
const out = new Uint8Array(block_count * ASTC_BLOCK_BYTES);
|
|
62
|
-
|
|
63
|
-
const palette = new Uint8Array(12);
|
|
64
|
-
const fitted = new Int32Array(6);
|
|
65
|
-
const weights = new Uint8Array(16);
|
|
66
|
-
|
|
67
|
-
for (let block = 0; block < block_count; block++) {
|
|
68
|
-
etc1s_block_colors(
|
|
69
|
-
palette, 0, endpoints.color5, endpoints.intensity, slice.endpoint_index[block]
|
|
70
|
-
);
|
|
71
|
-
|
|
72
|
-
const selector_base = slice.selector_index[block] * 16;
|
|
73
|
-
|
|
74
|
-
fit_block(fitted, weights, palette, selectors.selectors, selector_base);
|
|
75
|
-
|
|
76
|
-
astc_order_endpoints(fitted, weights, LEVELS.length - 1);
|
|
77
|
-
|
|
78
|
-
astc_write_block(out, block * ASTC_BLOCK_BYTES, fitted, weights, WEIGHT_BITS);
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
return out;
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
/**
|
|
85
|
-
* Every strictly increasing choice of `count` of the four weight levels.
|
|
86
|
-
*
|
|
87
|
-
* Enumerated rather than reasoned about: fifteen in total across all four sizes, and the arithmetic
|
|
88
|
-
* that would pick the right one directly is longer than the list.
|
|
89
|
-
*
|
|
90
|
-
* @readonly
|
|
91
|
-
* @type {number[][][]}
|
|
92
|
-
*/
|
|
93
|
-
const PLACEMENTS = [0, 1, 2, 3, 4].map(count => {
|
|
94
|
-
const out = [];
|
|
95
|
-
|
|
96
|
-
const walk = (start, chosen) => {
|
|
97
|
-
if (chosen.length === count) {
|
|
98
|
-
out.push(chosen.slice());
|
|
99
|
-
|
|
100
|
-
return;
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
for (let level = start; level < 4; level++) {
|
|
104
|
-
chosen.push(level);
|
|
105
|
-
walk(level + 1, chosen);
|
|
106
|
-
chosen.pop();
|
|
107
|
-
}
|
|
108
|
-
};
|
|
109
|
-
|
|
110
|
-
walk(0, []);
|
|
111
|
-
|
|
112
|
-
return out;
|
|
113
|
-
});
|
|
114
|
-
|
|
115
|
-
/**
|
|
116
|
-
* Fit a block: which weight level each of its selectors takes, and the endpoints that follow.
|
|
117
|
-
*
|
|
118
|
-
* **The selectors are placed on the weight levels rather than used as them.** ETC1S's four colours
|
|
119
|
-
* and ASTC's four weight levels are both ordered darkest to brightest, so the identity mapping is
|
|
120
|
-
* available and is what a block using its whole palette is stuck with — but a block using only two
|
|
121
|
-
* or three entries should spread those over all four levels instead, which costs nothing and is
|
|
122
|
-
* exact for two. Skipping this is worth about nine decibels, and it is what the reference transcoder
|
|
123
|
-
* does.
|
|
124
|
-
*
|
|
125
|
-
* The two orderings are not alike even when all four are used: ETC1S's middle pair sits at roughly
|
|
126
|
-
* 0.37 and 0.63 of the range against ASTC's 21/64 and 43/64, so the identity mapping is a fit rather
|
|
127
|
-
* than an equality. Nothing better is available at two bits a weight.
|
|
128
|
-
*
|
|
129
|
-
* @param {Int32Array} endpoints_out six values, `R0 R1 G0 G1 B0 B1`
|
|
130
|
-
* @param {Uint8Array} weights_out sixteen weight levels, in raster order
|
|
131
|
-
* @param {Uint8Array} palette twelve bytes, four RGB triples
|
|
132
|
-
* @param {Uint8Array} selector_values
|
|
133
|
-
* @param {number} selector_base
|
|
134
|
-
*/
|
|
135
|
-
function fit_block(endpoints_out, weights_out, palette, selector_values, selector_base) {
|
|
136
|
-
const used = [];
|
|
137
|
-
|
|
138
|
-
for (let texel = 0; texel < 16; texel++) {
|
|
139
|
-
const selector = selector_values[selector_base + texel];
|
|
140
|
-
|
|
141
|
-
if (!used.includes(selector)) {
|
|
142
|
-
used.push(selector);
|
|
143
|
-
}
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
used.sort(number_compare_ascending);
|
|
147
|
-
|
|
148
|
-
let best_error = Infinity;
|
|
149
|
-
|
|
150
|
-
const level_of = new Int32Array(4);
|
|
151
|
-
const candidate = new Int32Array(6);
|
|
152
|
-
|
|
153
|
-
for (const placement of PLACEMENTS[used.length]) {
|
|
154
|
-
for (let i = 0; i < used.length; i++) {
|
|
155
|
-
level_of[used[i]] = placement[i];
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
const error = fit_endpoints(candidate, palette, selector_values, selector_base, level_of);
|
|
159
|
-
|
|
160
|
-
if (error < best_error) {
|
|
161
|
-
best_error = error;
|
|
162
|
-
|
|
163
|
-
endpoints_out.set(candidate);
|
|
164
|
-
|
|
165
|
-
for (let texel = 0; texel < 16; texel++) {
|
|
166
|
-
weights_out[texel] = level_of[selector_values[selector_base + texel]];
|
|
167
|
-
}
|
|
168
|
-
}
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
refine(endpoints_out, palette, selector_values, selector_base, weights_out);
|
|
172
|
-
}
|
|
173
|
-
|
|
174
|
-
/**
|
|
175
|
-
* Nudge each channel's endpoints to the best pair within a step or two of the least-squares one.
|
|
176
|
-
*
|
|
177
|
-
* **Least squares minimises the wrong thing by a little.** It fits real-valued endpoints against
|
|
178
|
-
* real-valued targets; what gets written is the rounded pair, and what is read back is
|
|
179
|
-
* {@link interpolate}'s integer arithmetic on it. Those two roundings do not commute, so the rounded
|
|
180
|
-
* least-squares answer is usually but not always the best integer pair — a step in one direction
|
|
181
|
-
* often trades a large error on one texel for small ones on several.
|
|
182
|
-
*
|
|
183
|
-
* Only the winning placement is refined, and only over a small window. The placement search above
|
|
184
|
-
* runs first on the cheaper score, because refining all fifteen would multiply the cost of every
|
|
185
|
-
* block by more than it buys: this closes the last level against the reference encoder, which is
|
|
186
|
-
* worth a bounded pass and not an unbounded one.
|
|
187
|
-
*
|
|
188
|
-
* Channels are independent once the weights are fixed, so each is searched on its own — three
|
|
189
|
-
* searches of twenty-five candidates rather than one of fifteen thousand.
|
|
190
|
-
*
|
|
191
|
-
* @param {Int32Array} endpoints six values, modified in place
|
|
192
|
-
* @param {Uint8Array} palette
|
|
193
|
-
* @param {Uint8Array} selector_values
|
|
194
|
-
* @param {number} selector_base
|
|
195
|
-
* @param {Uint8Array} weights the chosen weight level per texel
|
|
196
|
-
*/
|
|
197
|
-
function refine(endpoints, palette, selector_values, selector_base, weights) {
|
|
198
|
-
for (let channel = 0; channel < 3; channel++) {
|
|
199
|
-
const start0 = endpoints[channel * 2];
|
|
200
|
-
const start1 = endpoints[channel * 2 + 1];
|
|
201
|
-
|
|
202
|
-
let best0 = start0;
|
|
203
|
-
let best1 = start1;
|
|
204
|
-
let best_error = Infinity;
|
|
205
|
-
|
|
206
|
-
for (let d0 = -2; d0 <= 2; d0++) {
|
|
207
|
-
for (let d1 = -2; d1 <= 2; d1++) {
|
|
208
|
-
const q0 = clamp255(start0 + d0);
|
|
209
|
-
const q1 = clamp255(start1 + d1);
|
|
210
|
-
|
|
211
|
-
let error = 0;
|
|
212
|
-
|
|
213
|
-
for (let texel = 0; texel < 16; texel++) {
|
|
214
|
-
const decoded = astc_interpolate(q0, q1, LEVELS[weights[texel]]);
|
|
215
|
-
|
|
216
|
-
const delta = decoded
|
|
217
|
-
- palette[selector_values[selector_base + texel] * 3 + channel];
|
|
218
|
-
|
|
219
|
-
error += delta * delta;
|
|
220
|
-
}
|
|
221
|
-
|
|
222
|
-
if (error < best_error) {
|
|
223
|
-
best_error = error;
|
|
224
|
-
best0 = q0;
|
|
225
|
-
best1 = q1;
|
|
226
|
-
}
|
|
227
|
-
}
|
|
228
|
-
}
|
|
229
|
-
|
|
230
|
-
endpoints[channel * 2] = best0;
|
|
231
|
-
endpoints[channel * 2 + 1] = best1;
|
|
232
|
-
}
|
|
233
|
-
}
|
|
234
|
-
|
|
235
|
-
/**
|
|
236
|
-
* Least-squares endpoints for one placement, and the squared error it leaves.
|
|
237
|
-
*
|
|
238
|
-
* A two-parameter linear fit per channel, sharing one set of `t` statistics because every channel's
|
|
239
|
-
* texels sit at the same positions along the line. The fit is real-valued and the scoring is not:
|
|
240
|
-
* what is compared is what {@link interpolate} will actually produce from the rounded, clamped
|
|
241
|
-
* endpoints, so a placement is judged on the block that will be written.
|
|
242
|
-
*
|
|
243
|
-
* @param {Int32Array} out six values
|
|
244
|
-
* @param {Uint8Array} palette
|
|
245
|
-
* @param {Uint8Array} selector_values
|
|
246
|
-
* @param {number} selector_base
|
|
247
|
-
* @param {Int32Array} level_of weight level for each selector value
|
|
248
|
-
* @returns {number} summed squared error over all sixteen texels and three channels
|
|
249
|
-
*/
|
|
250
|
-
function fit_endpoints(out, palette, selector_values, selector_base, level_of) {
|
|
251
|
-
let sum_t = 0;
|
|
252
|
-
let sum_tt = 0;
|
|
253
|
-
|
|
254
|
-
for (let texel = 0; texel < 16; texel++) {
|
|
255
|
-
const t = LEVELS[level_of[selector_values[selector_base + texel]]] / 64;
|
|
256
|
-
|
|
257
|
-
sum_t += t;
|
|
258
|
-
sum_tt += t * t;
|
|
259
|
-
}
|
|
260
|
-
|
|
261
|
-
const n = 16;
|
|
262
|
-
|
|
263
|
-
/*
|
|
264
|
-
The normal equations for `value = e0 (1 - t) + e1 t`, written in terms of `e0` and `d = e1 - e0`
|
|
265
|
-
so that the shared statistics fall out: `sum(v) = n e0 + d sum(t)` and
|
|
266
|
-
`sum(v t) = e0 sum(t) + d sum(t t)`.
|
|
267
|
-
*/
|
|
268
|
-
const determinant = n * sum_tt - sum_t * sum_t;
|
|
269
|
-
|
|
270
|
-
let error = 0;
|
|
271
|
-
|
|
272
|
-
for (let channel = 0; channel < 3; channel++) {
|
|
273
|
-
let sum_v = 0;
|
|
274
|
-
let sum_vt = 0;
|
|
275
|
-
|
|
276
|
-
for (let texel = 0; texel < 16; texel++) {
|
|
277
|
-
const selector = selector_values[selector_base + texel];
|
|
278
|
-
|
|
279
|
-
const v = palette[selector * 3 + channel];
|
|
280
|
-
const t = LEVELS[level_of[selector]] / 64;
|
|
281
|
-
|
|
282
|
-
sum_v += v;
|
|
283
|
-
sum_vt += v * t;
|
|
284
|
-
}
|
|
285
|
-
|
|
286
|
-
let e0;
|
|
287
|
-
let d;
|
|
288
|
-
|
|
289
|
-
if (determinant === 0) {
|
|
290
|
-
/*
|
|
291
|
-
Every texel at the same weight, so the line is a point and only one endpoint is
|
|
292
|
-
determined. Both are set to it, which reproduces the block exactly whatever the weights
|
|
293
|
-
then say.
|
|
294
|
-
*/
|
|
295
|
-
e0 = sum_v / n;
|
|
296
|
-
d = 0;
|
|
297
|
-
} else {
|
|
298
|
-
e0 = (sum_v * sum_tt - sum_vt * sum_t) / determinant;
|
|
299
|
-
d = (n * sum_vt - sum_v * sum_t) / determinant;
|
|
300
|
-
}
|
|
301
|
-
|
|
302
|
-
const q0 = clamp255(Math.round(e0));
|
|
303
|
-
const q1 = clamp255(Math.round(e0 + d));
|
|
304
|
-
|
|
305
|
-
out[channel * 2] = q0;
|
|
306
|
-
out[channel * 2 + 1] = q1;
|
|
307
|
-
|
|
308
|
-
for (let texel = 0; texel < 16; texel++) {
|
|
309
|
-
const selector = selector_values[selector_base + texel];
|
|
310
|
-
|
|
311
|
-
const decoded = astc_interpolate(q0, q1, LEVELS[level_of[selector]]);
|
|
312
|
-
|
|
313
|
-
const delta = decoded - palette[selector * 3 + channel];
|
|
314
|
-
|
|
315
|
-
error += delta * delta;
|
|
316
|
-
}
|
|
317
|
-
}
|
|
318
|
-
|
|
319
|
-
return error;
|
|
320
|
-
}
|
|
321
|
-
|
|
322
|
-
/**
|
|
323
|
-
* @param {number} value
|
|
324
|
-
* @returns {number} `value` brought into `[0, 255]`
|
|
325
|
-
*/
|
|
326
|
-
function clamp255(value) {
|
|
327
|
-
return value < 0 ? 0 : value > 255 ? 255 : value;
|
|
328
|
-
}
|
|
329
|
-
|
|
1
|
+
import {
|
|
2
|
+
ASTC_BLOCK_BYTES,
|
|
3
|
+
ASTC_WEIGHT_UNQUANTIZED,
|
|
4
|
+
astc_interpolate,
|
|
5
|
+
astc_order_endpoints,
|
|
6
|
+
astc_write_block
|
|
7
|
+
} from "../../astc/astc_block.js";
|
|
8
|
+
import { etc1s_block_colors } from "../etc1s/etc1s_block_colors.js";
|
|
9
|
+
import { number_compare_ascending } from "../../../../core/primitives/numbers/number_compare_ascending.js";
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Bits a weight takes in the blocks this writes, and the levels that follow from it.
|
|
13
|
+
*
|
|
14
|
+
* **Two, where {@link uastc_to_astc} takes three.** An ETC1S block holds four colours and no more,
|
|
15
|
+
* so eight weight levels would spend half of them describing points the source never had — the
|
|
16
|
+
* limit here is the source, not the container. Two bits is also what leaves room for the endpoints
|
|
17
|
+
* a four-channel mode would need, should alpha ever be worth carrying this way.
|
|
18
|
+
*
|
|
19
|
+
* @readonly
|
|
20
|
+
* @type {number}
|
|
21
|
+
*/
|
|
22
|
+
const WEIGHT_BITS = 2;
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* @readonly
|
|
26
|
+
* @type {number[]}
|
|
27
|
+
*/
|
|
28
|
+
const LEVELS = ASTC_WEIGHT_UNQUANTIZED[WEIGHT_BITS];
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Transcode ETC1S to ASTC 4x4.
|
|
32
|
+
*
|
|
33
|
+
* **The mobile counterpart to {@link etc1s_to_etc2}**, and the one compressed format that appears in
|
|
34
|
+
* every role's preference list — every recent phone samples it, where ETC2 is the older floor. Both
|
|
35
|
+
* are eight bits a texel.
|
|
36
|
+
*
|
|
37
|
+
* **A close fit, because an ETC1S block is already a line.** Its four colours are one base colour
|
|
38
|
+
* plus the same offset in each channel, so they lie on a line parallel to the grey axis, which is
|
|
39
|
+
* exactly what a single-partition ASTC block with two endpoints and an interpolant represents. What
|
|
40
|
+
* is left is choosing where on that line the four weight levels sit, which {@link fit_block} searches.
|
|
41
|
+
*
|
|
42
|
+
* **Opaque only.** ASTC can carry alpha, but not with a shared weight plane: an ETC1S payload's
|
|
43
|
+
* colour and alpha come from two independent slices with their own selectors, and forcing them onto
|
|
44
|
+
* one set of weights would wreck both. The dual-plane block mode that would separate them cannot also
|
|
45
|
+
* hold eight endpoints and thirty-two weight bits in 128 bits. So this declares no alpha and a
|
|
46
|
+
* payload carrying some falls through to a target that has room — the mechanism BC1 has used since
|
|
47
|
+
* step 9, and which `ktx2_read` now applies before a format is committed to rather than after.
|
|
48
|
+
*
|
|
49
|
+
* @param {Etc1sSlice} slice
|
|
50
|
+
* @param {Etc1sSlice|undefined} _alpha_slice refused before this is called; see above
|
|
51
|
+
* @param {Etc1sEndpointCodebook} endpoints
|
|
52
|
+
* @param {Etc1sSelectorCodebook} selectors
|
|
53
|
+
* @returns {Uint8Array} tightly packed ASTC blocks, in raster order
|
|
54
|
+
*
|
|
55
|
+
* @author Alex Goldring
|
|
56
|
+
* @copyright Company Named Limited (c) 2026
|
|
57
|
+
*/
|
|
58
|
+
export function etc1s_to_astc(slice, _alpha_slice, endpoints, selectors) {
|
|
59
|
+
const block_count = slice.blocks_x * slice.blocks_y;
|
|
60
|
+
|
|
61
|
+
const out = new Uint8Array(block_count * ASTC_BLOCK_BYTES);
|
|
62
|
+
|
|
63
|
+
const palette = new Uint8Array(12);
|
|
64
|
+
const fitted = new Int32Array(6);
|
|
65
|
+
const weights = new Uint8Array(16);
|
|
66
|
+
|
|
67
|
+
for (let block = 0; block < block_count; block++) {
|
|
68
|
+
etc1s_block_colors(
|
|
69
|
+
palette, 0, endpoints.color5, endpoints.intensity, slice.endpoint_index[block]
|
|
70
|
+
);
|
|
71
|
+
|
|
72
|
+
const selector_base = slice.selector_index[block] * 16;
|
|
73
|
+
|
|
74
|
+
fit_block(fitted, weights, palette, selectors.selectors, selector_base);
|
|
75
|
+
|
|
76
|
+
astc_order_endpoints(fitted, weights, LEVELS.length - 1);
|
|
77
|
+
|
|
78
|
+
astc_write_block(out, block * ASTC_BLOCK_BYTES, fitted, weights, WEIGHT_BITS);
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
return out;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* Every strictly increasing choice of `count` of the four weight levels.
|
|
86
|
+
*
|
|
87
|
+
* Enumerated rather than reasoned about: fifteen in total across all four sizes, and the arithmetic
|
|
88
|
+
* that would pick the right one directly is longer than the list.
|
|
89
|
+
*
|
|
90
|
+
* @readonly
|
|
91
|
+
* @type {number[][][]}
|
|
92
|
+
*/
|
|
93
|
+
const PLACEMENTS = [0, 1, 2, 3, 4].map(count => {
|
|
94
|
+
const out = [];
|
|
95
|
+
|
|
96
|
+
const walk = (start, chosen) => {
|
|
97
|
+
if (chosen.length === count) {
|
|
98
|
+
out.push(chosen.slice());
|
|
99
|
+
|
|
100
|
+
return;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
for (let level = start; level < 4; level++) {
|
|
104
|
+
chosen.push(level);
|
|
105
|
+
walk(level + 1, chosen);
|
|
106
|
+
chosen.pop();
|
|
107
|
+
}
|
|
108
|
+
};
|
|
109
|
+
|
|
110
|
+
walk(0, []);
|
|
111
|
+
|
|
112
|
+
return out;
|
|
113
|
+
});
|
|
114
|
+
|
|
115
|
+
/**
|
|
116
|
+
* Fit a block: which weight level each of its selectors takes, and the endpoints that follow.
|
|
117
|
+
*
|
|
118
|
+
* **The selectors are placed on the weight levels rather than used as them.** ETC1S's four colours
|
|
119
|
+
* and ASTC's four weight levels are both ordered darkest to brightest, so the identity mapping is
|
|
120
|
+
* available and is what a block using its whole palette is stuck with — but a block using only two
|
|
121
|
+
* or three entries should spread those over all four levels instead, which costs nothing and is
|
|
122
|
+
* exact for two. Skipping this is worth about nine decibels, and it is what the reference transcoder
|
|
123
|
+
* does.
|
|
124
|
+
*
|
|
125
|
+
* The two orderings are not alike even when all four are used: ETC1S's middle pair sits at roughly
|
|
126
|
+
* 0.37 and 0.63 of the range against ASTC's 21/64 and 43/64, so the identity mapping is a fit rather
|
|
127
|
+
* than an equality. Nothing better is available at two bits a weight.
|
|
128
|
+
*
|
|
129
|
+
* @param {Int32Array} endpoints_out six values, `R0 R1 G0 G1 B0 B1`
|
|
130
|
+
* @param {Uint8Array} weights_out sixteen weight levels, in raster order
|
|
131
|
+
* @param {Uint8Array} palette twelve bytes, four RGB triples
|
|
132
|
+
* @param {Uint8Array} selector_values
|
|
133
|
+
* @param {number} selector_base
|
|
134
|
+
*/
|
|
135
|
+
function fit_block(endpoints_out, weights_out, palette, selector_values, selector_base) {
|
|
136
|
+
const used = [];
|
|
137
|
+
|
|
138
|
+
for (let texel = 0; texel < 16; texel++) {
|
|
139
|
+
const selector = selector_values[selector_base + texel];
|
|
140
|
+
|
|
141
|
+
if (!used.includes(selector)) {
|
|
142
|
+
used.push(selector);
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
used.sort(number_compare_ascending);
|
|
147
|
+
|
|
148
|
+
let best_error = Infinity;
|
|
149
|
+
|
|
150
|
+
const level_of = new Int32Array(4);
|
|
151
|
+
const candidate = new Int32Array(6);
|
|
152
|
+
|
|
153
|
+
for (const placement of PLACEMENTS[used.length]) {
|
|
154
|
+
for (let i = 0; i < used.length; i++) {
|
|
155
|
+
level_of[used[i]] = placement[i];
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
const error = fit_endpoints(candidate, palette, selector_values, selector_base, level_of);
|
|
159
|
+
|
|
160
|
+
if (error < best_error) {
|
|
161
|
+
best_error = error;
|
|
162
|
+
|
|
163
|
+
endpoints_out.set(candidate);
|
|
164
|
+
|
|
165
|
+
for (let texel = 0; texel < 16; texel++) {
|
|
166
|
+
weights_out[texel] = level_of[selector_values[selector_base + texel]];
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
refine(endpoints_out, palette, selector_values, selector_base, weights_out);
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
/**
|
|
175
|
+
* Nudge each channel's endpoints to the best pair within a step or two of the least-squares one.
|
|
176
|
+
*
|
|
177
|
+
* **Least squares minimises the wrong thing by a little.** It fits real-valued endpoints against
|
|
178
|
+
* real-valued targets; what gets written is the rounded pair, and what is read back is
|
|
179
|
+
* {@link interpolate}'s integer arithmetic on it. Those two roundings do not commute, so the rounded
|
|
180
|
+
* least-squares answer is usually but not always the best integer pair — a step in one direction
|
|
181
|
+
* often trades a large error on one texel for small ones on several.
|
|
182
|
+
*
|
|
183
|
+
* Only the winning placement is refined, and only over a small window. The placement search above
|
|
184
|
+
* runs first on the cheaper score, because refining all fifteen would multiply the cost of every
|
|
185
|
+
* block by more than it buys: this closes the last level against the reference encoder, which is
|
|
186
|
+
* worth a bounded pass and not an unbounded one.
|
|
187
|
+
*
|
|
188
|
+
* Channels are independent once the weights are fixed, so each is searched on its own — three
|
|
189
|
+
* searches of twenty-five candidates rather than one of fifteen thousand.
|
|
190
|
+
*
|
|
191
|
+
* @param {Int32Array} endpoints six values, modified in place
|
|
192
|
+
* @param {Uint8Array} palette
|
|
193
|
+
* @param {Uint8Array} selector_values
|
|
194
|
+
* @param {number} selector_base
|
|
195
|
+
* @param {Uint8Array} weights the chosen weight level per texel
|
|
196
|
+
*/
|
|
197
|
+
function refine(endpoints, palette, selector_values, selector_base, weights) {
|
|
198
|
+
for (let channel = 0; channel < 3; channel++) {
|
|
199
|
+
const start0 = endpoints[channel * 2];
|
|
200
|
+
const start1 = endpoints[channel * 2 + 1];
|
|
201
|
+
|
|
202
|
+
let best0 = start0;
|
|
203
|
+
let best1 = start1;
|
|
204
|
+
let best_error = Infinity;
|
|
205
|
+
|
|
206
|
+
for (let d0 = -2; d0 <= 2; d0++) {
|
|
207
|
+
for (let d1 = -2; d1 <= 2; d1++) {
|
|
208
|
+
const q0 = clamp255(start0 + d0);
|
|
209
|
+
const q1 = clamp255(start1 + d1);
|
|
210
|
+
|
|
211
|
+
let error = 0;
|
|
212
|
+
|
|
213
|
+
for (let texel = 0; texel < 16; texel++) {
|
|
214
|
+
const decoded = astc_interpolate(q0, q1, LEVELS[weights[texel]]);
|
|
215
|
+
|
|
216
|
+
const delta = decoded
|
|
217
|
+
- palette[selector_values[selector_base + texel] * 3 + channel];
|
|
218
|
+
|
|
219
|
+
error += delta * delta;
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
if (error < best_error) {
|
|
223
|
+
best_error = error;
|
|
224
|
+
best0 = q0;
|
|
225
|
+
best1 = q1;
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
endpoints[channel * 2] = best0;
|
|
231
|
+
endpoints[channel * 2 + 1] = best1;
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
/**
|
|
236
|
+
* Least-squares endpoints for one placement, and the squared error it leaves.
|
|
237
|
+
*
|
|
238
|
+
* A two-parameter linear fit per channel, sharing one set of `t` statistics because every channel's
|
|
239
|
+
* texels sit at the same positions along the line. The fit is real-valued and the scoring is not:
|
|
240
|
+
* what is compared is what {@link interpolate} will actually produce from the rounded, clamped
|
|
241
|
+
* endpoints, so a placement is judged on the block that will be written.
|
|
242
|
+
*
|
|
243
|
+
* @param {Int32Array} out six values
|
|
244
|
+
* @param {Uint8Array} palette
|
|
245
|
+
* @param {Uint8Array} selector_values
|
|
246
|
+
* @param {number} selector_base
|
|
247
|
+
* @param {Int32Array} level_of weight level for each selector value
|
|
248
|
+
* @returns {number} summed squared error over all sixteen texels and three channels
|
|
249
|
+
*/
|
|
250
|
+
function fit_endpoints(out, palette, selector_values, selector_base, level_of) {
|
|
251
|
+
let sum_t = 0;
|
|
252
|
+
let sum_tt = 0;
|
|
253
|
+
|
|
254
|
+
for (let texel = 0; texel < 16; texel++) {
|
|
255
|
+
const t = LEVELS[level_of[selector_values[selector_base + texel]]] / 64;
|
|
256
|
+
|
|
257
|
+
sum_t += t;
|
|
258
|
+
sum_tt += t * t;
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
const n = 16;
|
|
262
|
+
|
|
263
|
+
/*
|
|
264
|
+
The normal equations for `value = e0 (1 - t) + e1 t`, written in terms of `e0` and `d = e1 - e0`
|
|
265
|
+
so that the shared statistics fall out: `sum(v) = n e0 + d sum(t)` and
|
|
266
|
+
`sum(v t) = e0 sum(t) + d sum(t t)`.
|
|
267
|
+
*/
|
|
268
|
+
const determinant = n * sum_tt - sum_t * sum_t;
|
|
269
|
+
|
|
270
|
+
let error = 0;
|
|
271
|
+
|
|
272
|
+
for (let channel = 0; channel < 3; channel++) {
|
|
273
|
+
let sum_v = 0;
|
|
274
|
+
let sum_vt = 0;
|
|
275
|
+
|
|
276
|
+
for (let texel = 0; texel < 16; texel++) {
|
|
277
|
+
const selector = selector_values[selector_base + texel];
|
|
278
|
+
|
|
279
|
+
const v = palette[selector * 3 + channel];
|
|
280
|
+
const t = LEVELS[level_of[selector]] / 64;
|
|
281
|
+
|
|
282
|
+
sum_v += v;
|
|
283
|
+
sum_vt += v * t;
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
let e0;
|
|
287
|
+
let d;
|
|
288
|
+
|
|
289
|
+
if (determinant === 0) {
|
|
290
|
+
/*
|
|
291
|
+
Every texel at the same weight, so the line is a point and only one endpoint is
|
|
292
|
+
determined. Both are set to it, which reproduces the block exactly whatever the weights
|
|
293
|
+
then say.
|
|
294
|
+
*/
|
|
295
|
+
e0 = sum_v / n;
|
|
296
|
+
d = 0;
|
|
297
|
+
} else {
|
|
298
|
+
e0 = (sum_v * sum_tt - sum_vt * sum_t) / determinant;
|
|
299
|
+
d = (n * sum_vt - sum_v * sum_t) / determinant;
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
const q0 = clamp255(Math.round(e0));
|
|
303
|
+
const q1 = clamp255(Math.round(e0 + d));
|
|
304
|
+
|
|
305
|
+
out[channel * 2] = q0;
|
|
306
|
+
out[channel * 2 + 1] = q1;
|
|
307
|
+
|
|
308
|
+
for (let texel = 0; texel < 16; texel++) {
|
|
309
|
+
const selector = selector_values[selector_base + texel];
|
|
310
|
+
|
|
311
|
+
const decoded = astc_interpolate(q0, q1, LEVELS[level_of[selector]]);
|
|
312
|
+
|
|
313
|
+
const delta = decoded - palette[selector * 3 + channel];
|
|
314
|
+
|
|
315
|
+
error += delta * delta;
|
|
316
|
+
}
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
return error;
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
/**
|
|
323
|
+
* @param {number} value
|
|
324
|
+
* @returns {number} `value` brought into `[0, 255]`
|
|
325
|
+
*/
|
|
326
|
+
function clamp255(value) {
|
|
327
|
+
return value < 0 ? 0 : value > 255 ? 255 : value;
|
|
328
|
+
}
|
|
329
|
+
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"etc1s_to_etc2.d.ts","sourceRoot":"","sources":["../../../../../../src/format/texture/basis/transcode/etc1s_to_etc2.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"etc1s_to_etc2.d.ts","sourceRoot":"","sources":["../../../../../../src/format/texture/basis/transcode/etc1s_to_etc2.js"],"names":[],"mappings":"AAmCA;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,8DAXW,aAAW,SAAS,8EAGpB,MAAM,WACN,MAAM,eACN,OAAO,GACL,UAAU,CAgDtB"}
|