@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
|
@@ -0,0 +1,612 @@
|
|
|
1
|
+
import { CodeChunk } from "../../shader/compiler/CodeChunk.js";
|
|
2
|
+
import { chunk_astc_encode_block_4x4_rgb } from "./chunk_astc_encode_block_4x4_rgb.js";
|
|
3
|
+
import { chunk_scatter_principal_axis } from "./chunk_scatter_principal_axis.js";
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Encode sixteen RGBA texels as one ASTC 4x4 block that holds their alpha: one partition, colour
|
|
7
|
+
* endpoint mode 12 (LDR RGBA, direct), in whichever of two layouts decodes nearer the texels.
|
|
8
|
+
*
|
|
9
|
+
* **The two layouts, and why these.** After the seventeen bits of block mode, partition count and
|
|
10
|
+
* endpoint mode, 111 bits remain for eight endpoint values and the weights, and a weight range fixes
|
|
11
|
+
* the endpoint range: the decoder takes the finest range whose integer sequence fits what the
|
|
12
|
+
* weights leave.
|
|
13
|
+
*
|
|
14
|
+
* 1. **One plane**: a single line through all four channels, sixteen weights of eight levels
|
|
15
|
+
* (48 bits), so the endpoints get 192 levels (six bits and a trit each, 61 bits). The weights are
|
|
16
|
+
* mode 8's own, and the ends nearly as fine as its eight bits. It holds an alpha that is constant,
|
|
17
|
+
* or that moves with the colour.
|
|
18
|
+
* 2. **Two planes**, the colour on one line and alpha on a second plane of weights of its own
|
|
19
|
+
* (colour component selector 3): thirty-two weights of five levels (75 bits as quints) and two
|
|
20
|
+
* bits of selector leave the endpoints 16 levels (four bits each). It holds an alpha that moves
|
|
21
|
+
* independently of the colour — a cut-out's edge, where the alpha crosses its whole range inside
|
|
22
|
+
* a block. There a weight's error, the range over the steps between levels, outweighs an end's:
|
|
23
|
+
* with eight weight levels the ends would get three, with four they would get 48 levels and the
|
|
24
|
+
* alpha only four levels across its range.
|
|
25
|
+
*
|
|
26
|
+
* Both are fitted and the one whose decoded squared error over all four channels is smaller is
|
|
27
|
+
* written; an equal error keeps the single plane. That is how ARM's astcenc chooses between the
|
|
28
|
+
* layouts it tries, restricted to two.
|
|
29
|
+
*
|
|
30
|
+
* **The fit** is the RGB encoder's, generalised over which channels a line carries: the principal
|
|
31
|
+
* axis of the scatter (`chunk_scatter_principal_axis`), the extreme projections, two rounds of least
|
|
32
|
+
* squares with each texel at its nearest weight, then the ends on the endpoint range and one round of
|
|
33
|
+
* coordinate descent over the eight stored values, one level either way, scored against the colours
|
|
34
|
+
* the format decodes. The two-plane layout fits the colour and the alpha as separate lines. Both
|
|
35
|
+
* write the pair the way round colour endpoint mode 12 reads without swapping — the second end's
|
|
36
|
+
* colour sum not below the first's — by swapping the ends and inverting every weight, which decodes
|
|
37
|
+
* identically.
|
|
38
|
+
*
|
|
39
|
+
* Every texel is clamped to [0, 1]. The opaque block is not this chunk's: `astc_encode_block_4x4`
|
|
40
|
+
* gives it the RGB block, whose ends are finer.
|
|
41
|
+
*
|
|
42
|
+
* @type {CodeChunk}
|
|
43
|
+
*/
|
|
44
|
+
export const chunk_astc_encode_block_4x4_rgba = CodeChunk.from(
|
|
45
|
+
//language=WGSL
|
|
46
|
+
`
|
|
47
|
+
struct AstcRgbaCandidate {
|
|
48
|
+
error: f32,
|
|
49
|
+
block: vec4<u32>,
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
// what a weight unquantizes to, out of 64, on a plane of eight levels (top 7) or five (top 4)
|
|
53
|
+
fn astc_rgba_weight(index: u32, top: u32) -> f32 {
|
|
54
|
+
if (top == 7u) {
|
|
55
|
+
return astc_weight3(index);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
return f32(index) * 16.0;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
// the weight of a plane with top + 1 levels whose decoded colour is nearest a texel, and the squared
|
|
62
|
+
// distance; a channel the line does not carry is zero in the texel and in both ends
|
|
63
|
+
fn astc_rgba_nearest(e0: vec4<f32>, e1: vec4<f32>, texel: vec4<f32>, top: u32) -> vec2<f32> {
|
|
64
|
+
let direction = e1 - e0;
|
|
65
|
+
let span = dot(direction, direction);
|
|
66
|
+
let last = f32(top);
|
|
67
|
+
|
|
68
|
+
var estimate = 0.0;
|
|
69
|
+
|
|
70
|
+
if (span > 0.0) {
|
|
71
|
+
estimate = clamp(round(dot(texel - e0, direction) / span * last), 0.0, last);
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
var best = estimate;
|
|
75
|
+
var best_distance = 1e30;
|
|
76
|
+
|
|
77
|
+
for (var offset = -1; offset <= 1; offset++) {
|
|
78
|
+
let candidate = clamp(estimate + f32(offset), 0.0, last);
|
|
79
|
+
let w = astc_rgba_weight(u32(candidate), top);
|
|
80
|
+
|
|
81
|
+
let delta = vec4<f32>(
|
|
82
|
+
astc_interpolate(e0.x, e1.x, w),
|
|
83
|
+
astc_interpolate(e0.y, e1.y, w),
|
|
84
|
+
astc_interpolate(e0.z, e1.z, w),
|
|
85
|
+
astc_interpolate(e0.w, e1.w, w)
|
|
86
|
+
) - texel;
|
|
87
|
+
|
|
88
|
+
let distance = dot(delta, delta);
|
|
89
|
+
|
|
90
|
+
if (distance < best_distance) {
|
|
91
|
+
best_distance = distance;
|
|
92
|
+
best = candidate;
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
return vec2<f32>(best, best_distance);
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
// one round of least squares over the channels in mask: each texel at the weight nearest its
|
|
100
|
+
// projection onto the line through the two ends, as a straight blend, then the two ends that fit
|
|
101
|
+
// those weights best
|
|
102
|
+
fn astc_rgba_refine(texels: array<vec4<f32>, 16>, mask: vec4<f32>, e0: vec4<f32>, e1: vec4<f32>, top: u32) -> array<vec4<f32>, 2> {
|
|
103
|
+
let direction = e1 - e0;
|
|
104
|
+
let span = dot(direction, direction);
|
|
105
|
+
let last = f32(top);
|
|
106
|
+
|
|
107
|
+
var aa = 0.0;
|
|
108
|
+
var ab = 0.0;
|
|
109
|
+
var bb = 0.0;
|
|
110
|
+
var ap = vec4<f32>(0.0);
|
|
111
|
+
var bp = vec4<f32>(0.0);
|
|
112
|
+
|
|
113
|
+
for (var i = 0u; i < 16u; i++) {
|
|
114
|
+
let texel = texels[i] * mask;
|
|
115
|
+
|
|
116
|
+
var estimate = 0.0;
|
|
117
|
+
|
|
118
|
+
if (span > 0.0) {
|
|
119
|
+
estimate = clamp(round(dot(texel - e0, direction) / span * last), 0.0, last);
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
var best_weight = 0.0;
|
|
123
|
+
var best_distance = 1e30;
|
|
124
|
+
|
|
125
|
+
for (var offset = -1; offset <= 1; offset++) {
|
|
126
|
+
let candidate = clamp(estimate + f32(offset), 0.0, last);
|
|
127
|
+
let weight = astc_rgba_weight(u32(candidate), top) / 64.0;
|
|
128
|
+
|
|
129
|
+
let delta = mix(e0, e1, weight) - texel;
|
|
130
|
+
let distance = dot(delta, delta);
|
|
131
|
+
|
|
132
|
+
if (distance < best_distance) {
|
|
133
|
+
best_distance = distance;
|
|
134
|
+
best_weight = weight;
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
let b = best_weight;
|
|
139
|
+
let a = 1.0 - b;
|
|
140
|
+
|
|
141
|
+
aa += a * a;
|
|
142
|
+
ab += a * b;
|
|
143
|
+
bb += b * b;
|
|
144
|
+
ap += a * texel;
|
|
145
|
+
bp += b * texel;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
let determinant = aa * bb - ab * ab;
|
|
149
|
+
|
|
150
|
+
var out: array<vec4<f32>, 2>;
|
|
151
|
+
|
|
152
|
+
if (abs(determinant) < 1e-6) {
|
|
153
|
+
out[0] = e0;
|
|
154
|
+
out[1] = e1;
|
|
155
|
+
|
|
156
|
+
return out;
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
out[0] = (bb * ap - ab * bp) / determinant;
|
|
160
|
+
out[1] = (aa * bp - ab * ap) / determinant;
|
|
161
|
+
|
|
162
|
+
return out;
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
// the two ends of a line through the channels in mask, in [0, 255]
|
|
166
|
+
fn astc_rgba_fit(texels: array<vec4<f32>, 16>, mask: vec4<f32>, top: u32) -> array<vec4<f32>, 2> {
|
|
167
|
+
var low = vec4<f32>(255.0);
|
|
168
|
+
var high = vec4<f32>(0.0);
|
|
169
|
+
var mean = vec4<f32>(0.0);
|
|
170
|
+
|
|
171
|
+
for (var i = 0u; i < 16u; i++) {
|
|
172
|
+
let v = texels[i] * mask;
|
|
173
|
+
|
|
174
|
+
low = min(low, v);
|
|
175
|
+
high = max(high, v);
|
|
176
|
+
mean += v;
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
mean = mean / 16.0;
|
|
180
|
+
|
|
181
|
+
let extent = high - low;
|
|
182
|
+
|
|
183
|
+
var ends: array<vec4<f32>, 2>;
|
|
184
|
+
|
|
185
|
+
ends[0] = mean;
|
|
186
|
+
ends[1] = mean;
|
|
187
|
+
|
|
188
|
+
if (max(max(extent.x, extent.y), max(extent.z, extent.w)) < 0.5) {
|
|
189
|
+
return ends;
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
// the scatter about the mean: xx xy xz xw yy yz yw zz zw ww
|
|
193
|
+
var c = array<f32, 10>(0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0);
|
|
194
|
+
|
|
195
|
+
for (var i = 0u; i < 16u; i++) {
|
|
196
|
+
let d = texels[i] * mask - mean;
|
|
197
|
+
|
|
198
|
+
c[0] += d.x * d.x;
|
|
199
|
+
c[1] += d.x * d.y;
|
|
200
|
+
c[2] += d.x * d.z;
|
|
201
|
+
c[3] += d.x * d.w;
|
|
202
|
+
c[4] += d.y * d.y;
|
|
203
|
+
c[5] += d.y * d.z;
|
|
204
|
+
c[6] += d.y * d.w;
|
|
205
|
+
c[7] += d.z * d.z;
|
|
206
|
+
c[8] += d.z * d.w;
|
|
207
|
+
c[9] += d.w * d.w;
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
let axis = scatter4_principal_axis(c);
|
|
211
|
+
|
|
212
|
+
var t_min = 1e30;
|
|
213
|
+
var t_max = -1e30;
|
|
214
|
+
|
|
215
|
+
for (var i = 0u; i < 16u; i++) {
|
|
216
|
+
let t = dot(texels[i] * mask - mean, axis);
|
|
217
|
+
|
|
218
|
+
t_min = min(t_min, t);
|
|
219
|
+
t_max = max(t_max, t);
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
ends[0] = mean + axis * t_min;
|
|
223
|
+
ends[1] = mean + axis * t_max;
|
|
224
|
+
|
|
225
|
+
for (var refinement = 0u; refinement < 2u; refinement++) {
|
|
226
|
+
let refined = astc_rgba_refine(texels, mask, ends[0], ends[1], top);
|
|
227
|
+
|
|
228
|
+
ends[0] = clamp(refined[0], vec4<f32>(0.0), vec4<f32>(255.0));
|
|
229
|
+
ends[1] = clamp(refined[1], vec4<f32>(0.0), vec4<f32>(255.0));
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
return ends;
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
// the 192-level endpoint range by level, ascending: levels 0..95 are 4g + t for a trit t, and
|
|
236
|
+
// levels 96..191 mirror them down from 255
|
|
237
|
+
fn astc_rgba_value192(level: u32) -> f32 {
|
|
238
|
+
let low = level < 96u;
|
|
239
|
+
let j = select(191u - level, level, low);
|
|
240
|
+
let v = (j / 3u) * 4u + j % 3u;
|
|
241
|
+
|
|
242
|
+
return f32(select(255u - v, v, low));
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
// the level of the 192-level range nearest a value in [0, 255]; of two equally near, the lower
|
|
246
|
+
fn astc_rgba_quantize192(x: f32) -> u32 {
|
|
247
|
+
var estimate = 191.0 - round((255.0 - x) * 0.75);
|
|
248
|
+
|
|
249
|
+
if (x < 127.5) {
|
|
250
|
+
estimate = round(x * 0.75);
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
var best = 0u;
|
|
254
|
+
var best_distance = 1e30;
|
|
255
|
+
|
|
256
|
+
for (var offset = -1; offset <= 1; offset++) {
|
|
257
|
+
let level = u32(clamp(estimate + f32(offset), 0.0, 191.0));
|
|
258
|
+
let distance = abs(astc_rgba_value192(level) - x);
|
|
259
|
+
|
|
260
|
+
if (distance < best_distance) {
|
|
261
|
+
best_distance = distance;
|
|
262
|
+
best = level;
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
return best;
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
// an endpoint level's value: the 192-level range of one plane, or the four bits of two
|
|
270
|
+
fn astc_rgba_value(level: f32, dual: bool) -> f32 {
|
|
271
|
+
if (dual) {
|
|
272
|
+
return level * 17.0;
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
return astc_rgba_value192(u32(level));
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
fn astc_rgba_values(levels: vec4<f32>, dual: bool) -> vec4<f32> {
|
|
279
|
+
return vec4<f32>(
|
|
280
|
+
astc_rgba_value(levels.x, dual),
|
|
281
|
+
astc_rgba_value(levels.y, dual),
|
|
282
|
+
astc_rgba_value(levels.z, dual),
|
|
283
|
+
astc_rgba_value(levels.w, dual)
|
|
284
|
+
);
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
fn astc_rgba_quantize(x: f32, dual: bool) -> f32 {
|
|
288
|
+
if (dual) {
|
|
289
|
+
return clamp(round(x / 17.0), 0.0, 15.0);
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
return f32(astc_rgba_quantize192(x));
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
// the squared error of the block under two ends: one line of eight-level weights, or the colour and
|
|
296
|
+
// the alpha each on a plane of five-level weights
|
|
297
|
+
fn astc_rgba_score(texels: array<vec4<f32>, 16>, e0: vec4<f32>, e1: vec4<f32>, dual: bool) -> f32 {
|
|
298
|
+
var error = 0.0;
|
|
299
|
+
|
|
300
|
+
if (dual) {
|
|
301
|
+
let c0 = vec4<f32>(e0.xyz, 0.0);
|
|
302
|
+
let c1 = vec4<f32>(e1.xyz, 0.0);
|
|
303
|
+
let a0 = vec4<f32>(0.0, 0.0, 0.0, e0.w);
|
|
304
|
+
let a1 = vec4<f32>(0.0, 0.0, 0.0, e1.w);
|
|
305
|
+
|
|
306
|
+
for (var i = 0u; i < 16u; i++) {
|
|
307
|
+
error += astc_rgba_nearest(c0, c1, vec4<f32>(texels[i].xyz, 0.0), 4u).y;
|
|
308
|
+
error += astc_rgba_nearest(a0, a1, vec4<f32>(0.0, 0.0, 0.0, texels[i].w), 4u).y;
|
|
309
|
+
}
|
|
310
|
+
} else {
|
|
311
|
+
for (var i = 0u; i < 16u; i++) {
|
|
312
|
+
error += astc_rgba_nearest(e0, e1, texels[i], 7u).y;
|
|
313
|
+
}
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
return error;
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
fn astc_rgba_with_component(v: vec4<f32>, channel: u32, value: f32) -> vec4<f32> {
|
|
320
|
+
return vec4<f32>(
|
|
321
|
+
select(v.x, value, channel == 0u),
|
|
322
|
+
select(v.y, value, channel == 1u),
|
|
323
|
+
select(v.z, value, channel == 2u),
|
|
324
|
+
select(v.w, value, channel == 3u)
|
|
325
|
+
);
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
// OR a value into the block at a bit position, across a word boundary if it straddles one
|
|
329
|
+
fn astc_rgba_put(words: ptr<function, array<u32, 4>>, at: u32, value: u32) {
|
|
330
|
+
let word = at >> 5u;
|
|
331
|
+
let shift = at & 31u;
|
|
332
|
+
|
|
333
|
+
(*words)[word] |= value << shift;
|
|
334
|
+
|
|
335
|
+
if (shift != 0u && word < 3u) {
|
|
336
|
+
(*words)[word + 1u] |= value >> (32u - shift);
|
|
337
|
+
}
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
// five trits as the eight bits an integer sequence carries them in: the inverse of the
|
|
341
|
+
// specification's decode, case by case
|
|
342
|
+
fn astc_rgba_pack_trits(t0: u32, t1: u32, t2: u32, t3: u32, t4: u32) -> u32 {
|
|
343
|
+
var c = (t2 << 4u) | (t1 << 2u) | t0;
|
|
344
|
+
|
|
345
|
+
if (t2 == 2u && t1 == 2u) {
|
|
346
|
+
c = (3u << 2u) | t0;
|
|
347
|
+
} else if (t2 == 2u) {
|
|
348
|
+
c = (t1 << 4u) | (t0 << 2u) | 3u;
|
|
349
|
+
}
|
|
350
|
+
|
|
351
|
+
if (t3 == 2u && t4 == 2u) {
|
|
352
|
+
return (((c >> 2u) & 7u) << 5u) | (7u << 2u) | (c & 3u);
|
|
353
|
+
}
|
|
354
|
+
|
|
355
|
+
if (t4 == 2u) {
|
|
356
|
+
return (t3 << 7u) | (3u << 5u) | c;
|
|
357
|
+
}
|
|
358
|
+
|
|
359
|
+
return (t4 << 7u) | (t3 << 5u) | c;
|
|
360
|
+
}
|
|
361
|
+
|
|
362
|
+
// three quints as the seven bits an integer sequence carries them in
|
|
363
|
+
fn astc_rgba_pack_quints(q0: u32, q1: u32, q2: u32) -> u32 {
|
|
364
|
+
if (q0 == 4u && q1 == 4u) {
|
|
365
|
+
if (q2 == 4u) {
|
|
366
|
+
return 7u;
|
|
367
|
+
}
|
|
368
|
+
|
|
369
|
+
return 6u | (((q2 >> 1u) & 1u) << 4u) | ((q2 & 1u) << 3u);
|
|
370
|
+
}
|
|
371
|
+
|
|
372
|
+
var c = (q1 << 3u) | q0;
|
|
373
|
+
|
|
374
|
+
if (q1 == 4u) {
|
|
375
|
+
c = (q0 << 3u) | 5u;
|
|
376
|
+
}
|
|
377
|
+
|
|
378
|
+
if (q2 == 4u) {
|
|
379
|
+
return (((c >> 3u) & 3u) << 3u) | ((~(c >> 1u) & 3u) << 5u) | 6u | (c & 1u);
|
|
380
|
+
}
|
|
381
|
+
|
|
382
|
+
return (q2 << 5u) | c;
|
|
383
|
+
}
|
|
384
|
+
|
|
385
|
+
// the integer a 192-level endpoint is stored as: a trit over six bits, the lowest of which says
|
|
386
|
+
// which half of the range the value is in
|
|
387
|
+
fn astc_rgba_integer192(level: u32) -> u32 {
|
|
388
|
+
let low = level < 96u;
|
|
389
|
+
let j = select(191u - level, level, low);
|
|
390
|
+
|
|
391
|
+
return (j % 3u) * 64u + ((j / 3u) << 1u) + select(1u, 0u, low);
|
|
392
|
+
}
|
|
393
|
+
|
|
394
|
+
// a single-plane block: block mode 0x53, CEM 12, eight endpoints of the 192-level range in the order
|
|
395
|
+
// R0 R1 G0 G1 B0 B1 A0 A1 from bit 17, sixteen three-bit weights from the top
|
|
396
|
+
fn astc_rgba_pack_single(lo: vec4<f32>, hi: vec4<f32>, weights: array<u32, 32>) -> vec4<u32> {
|
|
397
|
+
var words = array<u32, 4>(0x53u | (12u << 13u), 0u, 0u, 0u);
|
|
398
|
+
|
|
399
|
+
var q: array<u32, 8>;
|
|
400
|
+
|
|
401
|
+
for (var channel = 0u; channel < 4u; channel++) {
|
|
402
|
+
q[channel * 2u] = astc_rgba_integer192(u32(lo[channel]));
|
|
403
|
+
q[channel * 2u + 1u] = astc_rgba_integer192(u32(hi[channel]));
|
|
404
|
+
}
|
|
405
|
+
|
|
406
|
+
// the integer sequence: each value's six bits, with its group's packed trits cut into pieces of
|
|
407
|
+
// 2, 2, 1, 2 and 1 bits threaded between them; the second group holds three values
|
|
408
|
+
let first = astc_rgba_pack_trits(q[0] >> 6u, q[1] >> 6u, q[2] >> 6u, q[3] >> 6u, q[4] >> 6u);
|
|
409
|
+
let second = astc_rgba_pack_trits(q[5] >> 6u, q[6] >> 6u, q[7] >> 6u, 0u, 0u);
|
|
410
|
+
|
|
411
|
+
var cursor = 17u;
|
|
412
|
+
|
|
413
|
+
for (var i = 0u; i < 8u; i++) {
|
|
414
|
+
let group = select(second, first, i < 5u);
|
|
415
|
+
let member = select(i - 5u, i, i < 5u);
|
|
416
|
+
|
|
417
|
+
astc_rgba_put(&words, cursor, q[i] & 63u);
|
|
418
|
+
cursor += 6u;
|
|
419
|
+
|
|
420
|
+
// the pieces of the packed trits, by member: bits 0..1, 2..3, 4, 5..6, 7
|
|
421
|
+
let piece_shift = member * 2u - select(0u, 1u, member >= 3u);
|
|
422
|
+
let piece_bits = select(2u, 1u, member == 2u || member == 4u);
|
|
423
|
+
|
|
424
|
+
astc_rgba_put(&words, cursor, (group >> piece_shift) & ((1u << piece_bits) - 1u));
|
|
425
|
+
cursor += piece_bits;
|
|
426
|
+
}
|
|
427
|
+
|
|
428
|
+
for (var texel = 0u; texel < 16u; texel++) {
|
|
429
|
+
for (var k = 0u; k < 3u; k++) {
|
|
430
|
+
if (((weights[texel] >> k) & 1u) != 0u) {
|
|
431
|
+
let at = 127u - (texel * 3u + k);
|
|
432
|
+
|
|
433
|
+
words[at >> 5u] |= 1u << (at & 31u);
|
|
434
|
+
}
|
|
435
|
+
}
|
|
436
|
+
}
|
|
437
|
+
|
|
438
|
+
return vec4<u32>(words[0], words[1], words[2], words[3]);
|
|
439
|
+
}
|
|
440
|
+
|
|
441
|
+
// a two-plane block: block mode 0x452, CEM 12, eight four-bit endpoints in the order
|
|
442
|
+
// R0 R1 G0 G1 B0 B1 A0 A1 from bit 17, colour component selector 3 (alpha) below the weights, and
|
|
443
|
+
// thirty-two five-level weights, colour and alpha alternating texel by texel, as quints from the top
|
|
444
|
+
fn astc_rgba_pack_dual(lo: vec4<f32>, hi: vec4<f32>, weights: array<u32, 32>) -> vec4<u32> {
|
|
445
|
+
var words = array<u32, 4>(0x452u | (12u << 13u), 0u, 0u, 0u);
|
|
446
|
+
|
|
447
|
+
for (var channel = 0u; channel < 4u; channel++) {
|
|
448
|
+
astc_rgba_put(&words, 17u + channel * 8u, u32(lo[channel]));
|
|
449
|
+
astc_rgba_put(&words, 21u + channel * 8u, u32(hi[channel]));
|
|
450
|
+
}
|
|
451
|
+
|
|
452
|
+
// the selector sits immediately below the 75 bits of weights
|
|
453
|
+
astc_rgba_put(&words, 51u, 3u);
|
|
454
|
+
|
|
455
|
+
// eleven groups of three quints, seven bits each, the last holding two values and zero above
|
|
456
|
+
// its five bits; the field fills the top of the block with its bit order reversed
|
|
457
|
+
for (var group = 0u; group < 11u; group++) {
|
|
458
|
+
let first = group * 3u;
|
|
459
|
+
|
|
460
|
+
let packed = astc_rgba_pack_quints(
|
|
461
|
+
weights[first],
|
|
462
|
+
weights[first + 1u],
|
|
463
|
+
select(0u, weights[min(first + 2u, 31u)], first + 2u < 32u)
|
|
464
|
+
);
|
|
465
|
+
|
|
466
|
+
for (var k = 0u; k < 7u; k++) {
|
|
467
|
+
if (((packed >> k) & 1u) != 0u) {
|
|
468
|
+
let at = 127u - (group * 7u + k);
|
|
469
|
+
|
|
470
|
+
words[at >> 5u] |= 1u << (at & 31u);
|
|
471
|
+
}
|
|
472
|
+
}
|
|
473
|
+
}
|
|
474
|
+
|
|
475
|
+
return vec4<u32>(words[0], words[1], words[2], words[3]);
|
|
476
|
+
}
|
|
477
|
+
|
|
478
|
+
// one layout fitted, written, and its decoded squared error
|
|
479
|
+
fn astc_rgba_candidate(texels: array<vec4<f32>, 16>, dual: bool) -> AstcRgbaCandidate {
|
|
480
|
+
var e0: vec4<f32>;
|
|
481
|
+
var e1: vec4<f32>;
|
|
482
|
+
|
|
483
|
+
if (dual) {
|
|
484
|
+
let colour = astc_rgba_fit(texels, vec4<f32>(1.0, 1.0, 1.0, 0.0), 4u);
|
|
485
|
+
let alpha = astc_rgba_fit(texels, vec4<f32>(0.0, 0.0, 0.0, 1.0), 4u);
|
|
486
|
+
|
|
487
|
+
e0 = vec4<f32>(colour[0].xyz, alpha[0].w);
|
|
488
|
+
e1 = vec4<f32>(colour[1].xyz, alpha[1].w);
|
|
489
|
+
} else {
|
|
490
|
+
let line = astc_rgba_fit(texels, vec4<f32>(1.0), 7u);
|
|
491
|
+
|
|
492
|
+
e0 = line[0];
|
|
493
|
+
e1 = line[1];
|
|
494
|
+
}
|
|
495
|
+
|
|
496
|
+
let top_level = select(191.0, 15.0, dual);
|
|
497
|
+
|
|
498
|
+
var lo = vec4<f32>(
|
|
499
|
+
astc_rgba_quantize(e0.x, dual),
|
|
500
|
+
astc_rgba_quantize(e0.y, dual),
|
|
501
|
+
astc_rgba_quantize(e0.z, dual),
|
|
502
|
+
astc_rgba_quantize(e0.w, dual)
|
|
503
|
+
);
|
|
504
|
+
var hi = vec4<f32>(
|
|
505
|
+
astc_rgba_quantize(e1.x, dual),
|
|
506
|
+
astc_rgba_quantize(e1.y, dual),
|
|
507
|
+
astc_rgba_quantize(e1.z, dual),
|
|
508
|
+
astc_rgba_quantize(e1.w, dual)
|
|
509
|
+
);
|
|
510
|
+
|
|
511
|
+
var best = astc_rgba_score(texels, astc_rgba_values(lo, dual), astc_rgba_values(hi, dual), dual);
|
|
512
|
+
|
|
513
|
+
// coordinate descent over the eight stored values, one level either way, one round
|
|
514
|
+
for (var component = 0u; component < 8u; component++) {
|
|
515
|
+
let channel = component % 4u;
|
|
516
|
+
|
|
517
|
+
for (var direction = -1; direction <= 1; direction += 2) {
|
|
518
|
+
var c0 = lo;
|
|
519
|
+
var c1 = hi;
|
|
520
|
+
|
|
521
|
+
if (component < 4u) {
|
|
522
|
+
let stepped = clamp(lo[channel] + f32(direction), 0.0, top_level);
|
|
523
|
+
|
|
524
|
+
if (stepped == lo[channel]) {
|
|
525
|
+
continue;
|
|
526
|
+
}
|
|
527
|
+
|
|
528
|
+
c0 = astc_rgba_with_component(lo, channel, stepped);
|
|
529
|
+
} else {
|
|
530
|
+
let stepped = clamp(hi[channel] + f32(direction), 0.0, top_level);
|
|
531
|
+
|
|
532
|
+
if (stepped == hi[channel]) {
|
|
533
|
+
continue;
|
|
534
|
+
}
|
|
535
|
+
|
|
536
|
+
c1 = astc_rgba_with_component(hi, channel, stepped);
|
|
537
|
+
}
|
|
538
|
+
|
|
539
|
+
let error = astc_rgba_score(texels, astc_rgba_values(c0, dual), astc_rgba_values(c1, dual), dual);
|
|
540
|
+
|
|
541
|
+
if (error < best) {
|
|
542
|
+
best = error;
|
|
543
|
+
lo = c0;
|
|
544
|
+
hi = c1;
|
|
545
|
+
}
|
|
546
|
+
}
|
|
547
|
+
}
|
|
548
|
+
|
|
549
|
+
let v0 = astc_rgba_values(lo, dual);
|
|
550
|
+
let v1 = astc_rgba_values(hi, dual);
|
|
551
|
+
|
|
552
|
+
// single: sixteen weights; dual: colour then alpha for each texel
|
|
553
|
+
var weights: array<u32, 32>;
|
|
554
|
+
|
|
555
|
+
for (var i = 0u; i < 16u; i++) {
|
|
556
|
+
if (dual) {
|
|
557
|
+
weights[i * 2u] = u32(astc_rgba_nearest(vec4<f32>(v0.xyz, 0.0), vec4<f32>(v1.xyz, 0.0), vec4<f32>(texels[i].xyz, 0.0), 4u).x);
|
|
558
|
+
weights[i * 2u + 1u] = u32(astc_rgba_nearest(vec4<f32>(0.0, 0.0, 0.0, v0.w), vec4<f32>(0.0, 0.0, 0.0, v1.w), vec4<f32>(0.0, 0.0, 0.0, texels[i].w), 4u).x);
|
|
559
|
+
} else {
|
|
560
|
+
weights[i] = u32(astc_rgba_nearest(v0, v1, texels[i], 7u).x);
|
|
561
|
+
}
|
|
562
|
+
}
|
|
563
|
+
|
|
564
|
+
// mode 12's rule: with the second end's colour sum below the first's, a decoder swaps the ends
|
|
565
|
+
// and blue-contracts them, so such a pair is written the other way up with every weight inverted
|
|
566
|
+
if (v1.x + v1.y + v1.z < v0.x + v0.y + v0.z) {
|
|
567
|
+
let swap = lo;
|
|
568
|
+
|
|
569
|
+
lo = hi;
|
|
570
|
+
hi = swap;
|
|
571
|
+
|
|
572
|
+
let top = select(7u, 4u, dual);
|
|
573
|
+
let count = select(16u, 32u, dual);
|
|
574
|
+
|
|
575
|
+
for (var i = 0u; i < count; i++) {
|
|
576
|
+
weights[i] = top - weights[i];
|
|
577
|
+
}
|
|
578
|
+
}
|
|
579
|
+
|
|
580
|
+
var out: AstcRgbaCandidate;
|
|
581
|
+
|
|
582
|
+
out.error = best;
|
|
583
|
+
|
|
584
|
+
if (dual) {
|
|
585
|
+
out.block = astc_rgba_pack_dual(lo, hi, weights);
|
|
586
|
+
} else {
|
|
587
|
+
out.block = astc_rgba_pack_single(lo, hi, weights);
|
|
588
|
+
}
|
|
589
|
+
|
|
590
|
+
return out;
|
|
591
|
+
}
|
|
592
|
+
|
|
593
|
+
fn astc_encode_block_4x4_rgba(texels: array<vec4<f32>, 16>) -> vec4<u32> {
|
|
594
|
+
var scaled: array<vec4<f32>, 16>;
|
|
595
|
+
|
|
596
|
+
for (var i = 0u; i < 16u; i++) {
|
|
597
|
+
scaled[i] = clamp(texels[i], vec4<f32>(0.0), vec4<f32>(1.0)) * 255.0;
|
|
598
|
+
}
|
|
599
|
+
|
|
600
|
+
let single = astc_rgba_candidate(scaled, false);
|
|
601
|
+
let dual = astc_rgba_candidate(scaled, true);
|
|
602
|
+
|
|
603
|
+
if (dual.error < single.error) {
|
|
604
|
+
return dual.block;
|
|
605
|
+
}
|
|
606
|
+
|
|
607
|
+
return single.block;
|
|
608
|
+
}
|
|
609
|
+
`, [
|
|
610
|
+
chunk_astc_encode_block_4x4_rgb,
|
|
611
|
+
chunk_scatter_principal_axis,
|
|
612
|
+
]);
|
|
@@ -7,10 +7,11 @@
|
|
|
7
7
|
* four points on the segment between them, so the fit is: find the line, place its ends, then find
|
|
8
8
|
* the pair of *representable* ends that the decoder's own palette makes best.
|
|
9
9
|
*
|
|
10
|
-
* 1. **The principal axis
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
10
|
+
* 1. **The principal axis** of the block's covariance, by power iteration from every channel at
|
|
11
|
+
* once ({@link chunk_scatter_principal_axis}). Castaño notes the iteration "is very sensitive to
|
|
12
|
+
* the initial approximation", and every single seed in use has blocks it is orthogonal to: the
|
|
13
|
+
* bounding box's diagonal of `stb_dxt` and betsy leaves two channels moving against each other
|
|
14
|
+
* by equal amounts — pure red against pure blue — at their mean.
|
|
14
15
|
* 2. **The ends, then least squares.** The extreme projections on the axis start the line; two
|
|
15
16
|
* rounds of assigning each texel its nearest of the four real palette points and re-solving
|
|
16
17
|
* both ends by the normal equations — the same solve as `fit_endpoints.js`, with the weights
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"chunk_bc1_encode_block.d.ts","sourceRoot":"","sources":["../../../../../../src/shade/renderer/texture/encode/chunk_bc1_encode_block.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"chunk_bc1_encode_block.d.ts","sourceRoot":"","sources":["../../../../../../src/shade/renderer/texture/encode/chunk_bc1_encode_block.js"],"names":[],"mappings":"AAIA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuCG;AACH,qCAFU,SAAS,CAmUZ;0BA7WmB,oCAAoC"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { CodeChunk } from "../../shader/compiler/CodeChunk.js";
|
|
2
2
|
import { chunk_bc1_pack_block } from "./chunk_bc1_pack_block.js";
|
|
3
|
+
import { chunk_scatter_principal_axis } from "./chunk_scatter_principal_axis.js";
|
|
3
4
|
|
|
4
5
|
/**
|
|
5
6
|
* Encode sixteen RGB texels as one BC1 block, four-colour mode.
|
|
@@ -10,10 +11,11 @@ import { chunk_bc1_pack_block } from "./chunk_bc1_pack_block.js";
|
|
|
10
11
|
* four points on the segment between them, so the fit is: find the line, place its ends, then find
|
|
11
12
|
* the pair of *representable* ends that the decoder's own palette makes best.
|
|
12
13
|
*
|
|
13
|
-
* 1. **The principal axis
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
14
|
+
* 1. **The principal axis** of the block's covariance, by power iteration from every channel at
|
|
15
|
+
* once ({@link chunk_scatter_principal_axis}). Castaño notes the iteration "is very sensitive to
|
|
16
|
+
* the initial approximation", and every single seed in use has blocks it is orthogonal to: the
|
|
17
|
+
* bounding box's diagonal of `stb_dxt` and betsy leaves two channels moving against each other
|
|
18
|
+
* by equal amounts — pure red against pure blue — at their mean.
|
|
17
19
|
* 2. **The ends, then least squares.** The extreme projections on the axis start the line; two
|
|
18
20
|
* rounds of assigning each texel its nearest of the four real palette points and re-solving
|
|
19
21
|
* both ends by the normal equations — the same solve as `fit_endpoints.js`, with the weights
|
|
@@ -281,27 +283,7 @@ fn bc1_encode_block(texels: array<vec3<f32>, 16>) -> vec2<u32> {
|
|
|
281
283
|
cov[5] += d.z * d.z;
|
|
282
284
|
}
|
|
283
285
|
|
|
284
|
-
|
|
285
|
-
var axis = extent;
|
|
286
|
-
|
|
287
|
-
for (var iteration = 0u; iteration < 4u; iteration++) {
|
|
288
|
-
let next = vec3<f32>(
|
|
289
|
-
cov[0] * axis.x + cov[1] * axis.y + cov[2] * axis.z,
|
|
290
|
-
cov[1] * axis.x + cov[3] * axis.y + cov[4] * axis.z,
|
|
291
|
-
cov[2] * axis.x + cov[4] * axis.y + cov[5] * axis.z
|
|
292
|
-
);
|
|
293
|
-
|
|
294
|
-
let magnitude = length(next);
|
|
295
|
-
|
|
296
|
-
// a degenerate covariance leaves the diagonal in charge
|
|
297
|
-
if (magnitude < 1e-3) {
|
|
298
|
-
break;
|
|
299
|
-
}
|
|
300
|
-
|
|
301
|
-
axis = next / magnitude;
|
|
302
|
-
}
|
|
303
|
-
|
|
304
|
-
axis = normalize(axis);
|
|
286
|
+
let axis = scatter3_principal_axis(cov);
|
|
305
287
|
|
|
306
288
|
var t_min = 1e30;
|
|
307
289
|
var t_max = -1e30;
|
|
@@ -380,4 +362,5 @@ fn bc1_encode_block(texels: array<vec3<f32>, 16>) -> vec2<u32> {
|
|
|
380
362
|
}
|
|
381
363
|
`, [
|
|
382
364
|
chunk_bc1_pack_block,
|
|
365
|
+
chunk_scatter_principal_axis,
|
|
383
366
|
]);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"chunk_bc6h_encode_block_mode11.d.ts","sourceRoot":"","sources":["../../../../../../src/shade/renderer/texture/encode/chunk_bc6h_encode_block_mode11.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"chunk_bc6h_encode_block_mode11.d.ts","sourceRoot":"","sources":["../../../../../../src/shade/renderer/texture/encode/chunk_bc6h_encode_block_mode11.js"],"names":[],"mappings":"AAIA;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,6CAFU,SAAS,CA6SZ;0BA5UmB,oCAAoC"}
|