@woosh/meep-engine 3.78.4 → 3.80.0
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 +93 -0
- package/README.md +1 -1
- package/package.json +1 -1
- package/src/engine/asset/GameAssetType.d.ts +2 -0
- package/src/engine/asset/GameAssetType.js +10 -0
- package/src/engine/asset/guessAssetType.d.ts.map +1 -1
- package/src/engine/asset/guessAssetType.js +4 -0
- package/src/engine/asset/load_model_scene_bundle.d.ts +1 -1
- package/src/engine/asset/load_model_scene_bundle.js +2 -2
- package/src/engine/asset/loaders/MTFSceneBundleAssetLoader.d.ts +42 -0
- package/src/engine/asset/loaders/MTFSceneBundleAssetLoader.d.ts.map +1 -0
- package/src/engine/asset/loaders/MTFSceneBundleAssetLoader.js +83 -0
- package/src/engine/asset/loaders/MTFTextureAssetLoader.d.ts +36 -0
- package/src/engine/asset/loaders/MTFTextureAssetLoader.d.ts.map +1 -0
- package/src/engine/asset/loaders/MTFTextureAssetLoader.js +78 -0
- package/src/engine/ecs/storage/binary/collection/BinaryCollectionSerializer.d.ts +6 -1
- package/src/engine/ecs/storage/binary/collection/BinaryCollectionSerializer.d.ts.map +1 -1
- package/src/engine/ecs/storage/binary/collection/BinaryCollectionSerializer.js +8 -2
- package/src/engine/physics/fluid/ecs/FluidObstacleSystem.d.ts +4 -4
- 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/GPUAcousticProbes.d.ts +1 -1
- package/src/shade/renderer/acoustics/GPUAcoustics.d.ts +1 -1
- package/src/shade/renderer/animation/ShadeAnimationClipSerializationAdapter.d.ts +33 -0
- package/src/shade/renderer/animation/ShadeAnimationClipSerializationAdapter.d.ts.map +1 -0
- package/src/shade/renderer/animation/ShadeAnimationClipSerializationAdapter.js +196 -0
- package/src/shade/renderer/animation/SkinSerializationAdapter.d.ts +25 -0
- package/src/shade/renderer/animation/SkinSerializationAdapter.d.ts.map +1 -0
- package/src/shade/renderer/animation/SkinSerializationAdapter.js +85 -0
- package/src/shade/renderer/hair/GPUHairSystem.d.ts.map +1 -1
- package/src/shade/renderer/hair/GPUHairSystem.js +16 -7
- package/src/shade/renderer/hair/HAIR.d.ts +5 -3
- package/src/shade/renderer/hair/HAIR.d.ts.map +1 -1
- package/src/shade/renderer/hair/HAIR.js +6 -4
- package/src/shade/renderer/hair/hair_shadow_draw.d.ts +10 -10
- package/src/shade/renderer/hair/hair_shadow_draw.d.ts.map +1 -1
- package/src/shade/renderer/hair/hair_shadow_draw.js +21 -17
- package/src/shade/renderer/hair/shader_hair_cull.d.ts.map +1 -1
- package/src/shade/renderer/hair/shader_hair_cull.js +6 -2
- package/src/shade/renderer/hair/shader_hair_shadow_list.d.ts +5 -4
- package/src/shade/renderer/hair/shader_hair_shadow_list.d.ts.map +1 -1
- package/src/shade/renderer/hair/shader_hair_shadow_list.js +10 -12
- package/src/shade/renderer/loader/SceneNodeSerializationAdapter.d.ts +38 -0
- package/src/shade/renderer/loader/SceneNodeSerializationAdapter.d.ts.map +1 -0
- package/src/shade/renderer/loader/SceneNodeSerializationAdapter.js +198 -0
- package/src/shade/renderer/loader/mtf/MTFTexture.d.ts +88 -0
- package/src/shade/renderer/loader/mtf/MTFTexture.d.ts.map +1 -0
- package/src/shade/renderer/loader/mtf/MTFTexture.js +159 -0
- package/src/shade/renderer/loader/mtf/MTFTextureSerializationAdapter.d.ts +30 -0
- package/src/shade/renderer/loader/mtf/MTFTextureSerializationAdapter.d.ts.map +1 -0
- package/src/shade/renderer/loader/mtf/MTFTextureSerializationAdapter.js +136 -0
- package/src/shade/renderer/loader/mtf/MTF_PACKAGE_MAGIC.d.ts +7 -0
- package/src/shade/renderer/loader/mtf/MTF_PACKAGE_MAGIC.d.ts.map +1 -0
- package/src/shade/renderer/loader/mtf/MTF_PACKAGE_MAGIC.js +6 -0
- package/src/shade/renderer/loader/mtf/MTF_PACKAGE_VERSION.d.ts +8 -0
- package/src/shade/renderer/loader/mtf/MTF_PACKAGE_VERSION.d.ts.map +1 -0
- package/src/shade/renderer/loader/mtf/MTF_PACKAGE_VERSION.js +7 -0
- package/src/shade/renderer/loader/mtf/MTF_TEXTURE_MAGIC.d.ts +7 -0
- package/src/shade/renderer/loader/mtf/MTF_TEXTURE_MAGIC.d.ts.map +1 -0
- package/src/shade/renderer/loader/mtf/MTF_TEXTURE_MAGIC.js +6 -0
- package/src/shade/renderer/loader/mtf/MTF_TEXTURE_VERSION.d.ts +7 -0
- package/src/shade/renderer/loader/mtf/MTF_TEXTURE_VERSION.d.ts.map +1 -0
- package/src/shade/renderer/loader/mtf/MTF_TEXTURE_VERSION.js +6 -0
- package/src/shade/renderer/loader/mtf/load_mtf.d.ts +41 -0
- package/src/shade/renderer/loader/mtf/load_mtf.d.ts.map +1 -0
- package/src/shade/renderer/loader/mtf/load_mtf.js +73 -0
- package/src/shade/renderer/loader/mtf/mtf_bundle_textures.d.ts +19 -0
- package/src/shade/renderer/loader/mtf/mtf_bundle_textures.d.ts.map +1 -0
- package/src/shade/renderer/loader/mtf/mtf_bundle_textures.js +57 -0
- package/src/shade/renderer/loader/mtf/mtf_encode_texture.d.ts +10 -0
- package/src/shade/renderer/loader/mtf/mtf_encode_texture.d.ts.map +1 -0
- package/src/shade/renderer/loader/mtf/mtf_encode_texture.js +152 -0
- package/src/shade/renderer/loader/mtf/mtf_export.d.ts +45 -0
- package/src/shade/renderer/loader/mtf/mtf_export.d.ts.map +1 -0
- package/src/shade/renderer/loader/mtf/mtf_export.js +161 -0
- package/src/shade/renderer/loader/mtf/mtf_is_texture.d.ts +9 -0
- package/src/shade/renderer/loader/mtf/mtf_is_texture.d.ts.map +1 -0
- package/src/shade/renderer/loader/mtf/mtf_is_texture.js +12 -0
- package/src/shade/renderer/loader/mtf/mtf_read_collection.d.ts +24 -0
- package/src/shade/renderer/loader/mtf/mtf_read_collection.d.ts.map +1 -0
- package/src/shade/renderer/loader/mtf/mtf_read_collection.js +37 -0
- package/src/shade/renderer/loader/mtf/mtf_read_scene.d.ts +27 -0
- package/src/shade/renderer/loader/mtf/mtf_read_scene.d.ts.map +1 -0
- package/src/shade/renderer/loader/mtf/mtf_read_scene.js +121 -0
- package/src/shade/renderer/loader/mtf/mtf_read_textures.d.ts +18 -0
- package/src/shade/renderer/loader/mtf/mtf_read_textures.d.ts.map +1 -0
- package/src/shade/renderer/loader/mtf/mtf_read_textures.js +51 -0
- 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_resolve_uri.d.ts +21 -0
- package/src/shade/renderer/loader/mtf/mtf_resolve_uri.d.ts.map +1 -0
- package/src/shade/renderer/loader/mtf/mtf_resolve_uri.js +98 -0
- package/src/shade/renderer/loader/mtf/mtf_serialization_registry.d.ts +25 -0
- package/src/shade/renderer/loader/mtf/mtf_serialization_registry.d.ts.map +1 -0
- package/src/shade/renderer/loader/mtf/mtf_serialization_registry.js +51 -0
- package/src/shade/renderer/loader/mtf/mtf_texture_read.d.ts +20 -0
- package/src/shade/renderer/loader/mtf/mtf_texture_read.d.ts.map +1 -0
- package/src/shade/renderer/loader/mtf/mtf_texture_read.js +80 -0
- package/src/shade/renderer/loader/mtf/mtf_texture_select.d.ts +24 -0
- package/src/shade/renderer/loader/mtf/mtf_texture_select.d.ts.map +1 -0
- package/src/shade/renderer/loader/mtf/mtf_texture_select.js +42 -0
- package/src/shade/renderer/loader/mtf/mtf_texture_write.d.ts +31 -0
- package/src/shade/renderer/loader/mtf/mtf_texture_write.d.ts.map +1 -0
- package/src/shade/renderer/loader/mtf/mtf_texture_write.js +87 -0
- package/src/shade/renderer/loader/mtf/mtf_write.d.ts +36 -0
- package/src/shade/renderer/loader/mtf/mtf_write.d.ts.map +1 -0
- package/src/shade/renderer/loader/mtf/mtf_write.js +137 -0
- 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/material/StandardShadeMaterialSerializationAdapter.d.ts +39 -0
- package/src/shade/renderer/material/StandardShadeMaterialSerializationAdapter.d.ts.map +1 -0
- package/src/shade/renderer/material/StandardShadeMaterialSerializationAdapter.js +207 -0
- package/src/shade/renderer/scene/optimization/source_to_sampler2d.d.ts.map +1 -1
- package/src/shade/renderer/scene/optimization/source_to_sampler2d.js +3 -1
- package/src/shade/renderer/scene/serialization/STANDARD_MATERIAL_SERIALIZED_BYTE_SIZE.d.ts +5 -5
- package/src/shade/renderer/scene/serialization/STANDARD_MATERIAL_SERIALIZED_BYTE_SIZE.js +5 -5
- package/src/shade/renderer/scene/serialization/deserialize_scene.d.ts.map +1 -1
- package/src/shade/renderer/scene/serialization/deserialize_scene.js +491 -528
- package/src/shade/renderer/scene/serialization/serialize_scene.d.ts +0 -10
- package/src/shade/renderer/scene/serialization/serialize_scene.d.ts.map +1 -1
- package/src/shade/renderer/scene/serialization/serialize_scene.js +15 -71
- 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/gpu_texture_format_without_srgb.d.ts +11 -0
- package/src/shade/renderer/texture/format/gpu_texture_format_without_srgb.d.ts.map +1 -0
- package/src/shade/renderer/texture/format/gpu_texture_format_without_srgb.js +14 -0
- 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/shade/renderer/texture/texture_role_image_quality.d.ts +10 -0
- package/src/shade/renderer/texture/texture_role_image_quality.d.ts.map +1 -0
- package/src/shade/renderer/texture/texture_role_image_quality.js +29 -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,602 +1,604 @@
|
|
|
1
|
-
import {
|
|
2
|
-
bc7_expand_endpoint,
|
|
3
|
-
bc7_quantise_endpoint,
|
|
4
|
-
bc7_write_block,
|
|
5
|
-
BC7_BLOCK_BYTES,
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
*
|
|
27
|
-
*
|
|
28
|
-
*
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
*
|
|
40
|
-
*
|
|
41
|
-
* BC7.
|
|
42
|
-
*
|
|
43
|
-
*
|
|
44
|
-
*
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
*
|
|
80
|
-
*
|
|
81
|
-
*
|
|
82
|
-
*
|
|
83
|
-
*
|
|
84
|
-
*
|
|
85
|
-
*
|
|
86
|
-
*
|
|
87
|
-
*
|
|
88
|
-
*
|
|
89
|
-
*
|
|
90
|
-
* |
|
|
91
|
-
*
|
|
92
|
-
* |
|
|
93
|
-
* |
|
|
94
|
-
* |
|
|
95
|
-
* |
|
|
96
|
-
* |
|
|
97
|
-
* |
|
|
98
|
-
*
|
|
99
|
-
*
|
|
100
|
-
*
|
|
101
|
-
*
|
|
102
|
-
*
|
|
103
|
-
*
|
|
104
|
-
*
|
|
105
|
-
* @
|
|
106
|
-
*
|
|
107
|
-
* @
|
|
108
|
-
*
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
const
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
const
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
} else {
|
|
134
|
-
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
*
|
|
145
|
-
*
|
|
146
|
-
* @param {number}
|
|
147
|
-
* @
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
const
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
*
|
|
174
|
-
*
|
|
175
|
-
*
|
|
176
|
-
*
|
|
177
|
-
*
|
|
178
|
-
*
|
|
179
|
-
* @param {Uint8Array}
|
|
180
|
-
* @param {number}
|
|
181
|
-
* @param {Uint8Array}
|
|
182
|
-
* @param {
|
|
183
|
-
* @param {
|
|
184
|
-
* @param {
|
|
185
|
-
* @param {number}
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
const
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
const
|
|
208
|
-
|
|
209
|
-
const
|
|
210
|
-
|
|
211
|
-
const
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
const
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
parity[parity_offset] = chosen[
|
|
260
|
-
}
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
*
|
|
267
|
-
*
|
|
268
|
-
* @param {
|
|
269
|
-
* @param {number}
|
|
270
|
-
* @param {
|
|
271
|
-
* @param {number}
|
|
272
|
-
* @
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
const
|
|
284
|
-
|
|
285
|
-
const
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
*
|
|
298
|
-
*
|
|
299
|
-
* @param {
|
|
300
|
-
* @param {
|
|
301
|
-
* @param {
|
|
302
|
-
* @param {
|
|
303
|
-
* @param {
|
|
304
|
-
* @param {
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
const
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
}
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
*
|
|
342
|
-
*
|
|
343
|
-
* @param {
|
|
344
|
-
* @param {
|
|
345
|
-
* @param {
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
const
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
anchors[1] =
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
*
|
|
470
|
-
*
|
|
471
|
-
* @
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
*
|
|
481
|
-
*
|
|
482
|
-
* @param {
|
|
483
|
-
* @param {
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
const
|
|
489
|
-
|
|
490
|
-
subset_of_texel
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
*
|
|
516
|
-
*
|
|
517
|
-
* @param {
|
|
518
|
-
* @param {
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
const
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
source
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
1
|
+
import {
|
|
2
|
+
bc7_expand_endpoint,
|
|
3
|
+
bc7_quantise_endpoint,
|
|
4
|
+
bc7_write_block,
|
|
5
|
+
BC7_BLOCK_BYTES,
|
|
6
|
+
} from "../../bc/bc7_write_block.js";
|
|
7
|
+
import {
|
|
8
|
+
BC7_ANCHOR_2,
|
|
9
|
+
BC7_ANCHOR_3_SECOND,
|
|
10
|
+
BC7_ANCHOR_3_THIRD,
|
|
11
|
+
BC7_MODES,
|
|
12
|
+
BC7_PARTITIONS_2,
|
|
13
|
+
BC7_PARTITIONS_3,
|
|
14
|
+
} from "../../bc/bc7_tables.js";
|
|
15
|
+
import {
|
|
16
|
+
bc7_fold_subset_3_to_2,
|
|
17
|
+
SUBSET_PERMUTATIONS,
|
|
18
|
+
UASTC_TO_BC7_2,
|
|
19
|
+
UASTC_TO_BC7_2_VIA_3,
|
|
20
|
+
UASTC_TO_BC7_3,
|
|
21
|
+
} from "./uastc_bc7_tables.js";
|
|
22
|
+
import { uastc_decode_block, UASTC_BLOCK_BYTES } from "./uastc_decode_block.js";
|
|
23
|
+
import { UASTC_WEIGHT_VALUE } from "./uastc_tables.js";
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* BC7's interpolation weights, by index width. Two- and three-bit are ASTC's tables exactly, which
|
|
27
|
+
* is what lets most weights cross over untouched.
|
|
28
|
+
*
|
|
29
|
+
* @readonly
|
|
30
|
+
* @type {Object<number, Int32Array>}
|
|
31
|
+
*/
|
|
32
|
+
const BC7_WEIGHTS = {
|
|
33
|
+
2: new Int32Array([0, 21, 43, 64]),
|
|
34
|
+
3: new Int32Array([0, 9, 18, 27, 37, 46, 55, 64]),
|
|
35
|
+
4: new Int32Array([0, 4, 8, 12, 17, 21, 25, 29, 35, 39, 43, 47, 52, 56, 60, 64]),
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Which BC7 mode each UASTC mode is carried into, and how its partition maps.
|
|
40
|
+
*
|
|
41
|
+
* Taken from the specification, which names a BC7 mode against every UASTC mode. `via` says which
|
|
42
|
+
* of the three partition mappings applies — the odd one is mode 7, two subsets in UASTC and three in
|
|
43
|
+
* BC7.
|
|
44
|
+
*
|
|
45
|
+
* @readonly
|
|
46
|
+
* @type {Object<number, {bc7: number, via: string}>}
|
|
47
|
+
*/
|
|
48
|
+
const MODE_MAP = {
|
|
49
|
+
0: { bc7: 6, via: "single" },
|
|
50
|
+
|
|
51
|
+
/*
|
|
52
|
+
One subset, and the specification still pairs it with a *two*-subset BC7 mode — written as
|
|
53
|
+
partition zero with both subsets given the same endpoints. That is not a quirk: mode 1 carries
|
|
54
|
+
eight-bit endpoints and two-bit weights, and BC7 mode 3 is the only mode that holds eight-bit
|
|
55
|
+
endpoints without also having an alpha channel whose parity bit would have to be traded against
|
|
56
|
+
colour. Mode 6 would cost a bit of every channel to keep alpha at 255.
|
|
57
|
+
*/
|
|
58
|
+
1: { bc7: 3, via: "single_as_two" },
|
|
59
|
+
2: { bc7: 1, via: "two" },
|
|
60
|
+
3: { bc7: 2, via: "three" },
|
|
61
|
+
4: { bc7: 3, via: "two" },
|
|
62
|
+
5: { bc7: 6, via: "single" },
|
|
63
|
+
6: { bc7: 5, via: "dual" },
|
|
64
|
+
7: { bc7: 2, via: "two_via_three" },
|
|
65
|
+
8: { bc7: 6, via: "single" },
|
|
66
|
+
9: { bc7: 7, via: "two" },
|
|
67
|
+
10: { bc7: 6, via: "single" },
|
|
68
|
+
11: { bc7: 5, via: "dual" },
|
|
69
|
+
12: { bc7: 6, via: "single" },
|
|
70
|
+
13: { bc7: 5, via: "dual" },
|
|
71
|
+
14: { bc7: 6, via: "single" },
|
|
72
|
+
15: { bc7: 6, via: "single" },
|
|
73
|
+
16: { bc7: 7, via: "two" },
|
|
74
|
+
17: { bc7: 5, via: "dual" },
|
|
75
|
+
18: { bc7: 6, via: "single" },
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* Transcode UASTC blocks to BC7.
|
|
80
|
+
*
|
|
81
|
+
* **Every UASTC mode is carried into the BC7 mode the specification pairs it with**, rather than
|
|
82
|
+
* decoded to texels and re-encoded. A UASTC block already *is* a partition, a pair of endpoints per
|
|
83
|
+
* subset and a weight per texel, which is exactly what BC7 stores — so the transcode is a change of
|
|
84
|
+
* representation and the only loss is endpoint precision. Re-fitting from texels instead costs
|
|
85
|
+
* around eighteen decibels on the dual plane modes and far more on the partitioned ones, because it
|
|
86
|
+
* throws away the answer the encoder already found.
|
|
87
|
+
*
|
|
88
|
+
* The pairings, all from the specification's mode table:
|
|
89
|
+
*
|
|
90
|
+
* | UASTC | BC7 | why |
|
|
91
|
+
* |---|---|---|
|
|
92
|
+
* | 0, 1, 5, 10, 12, 14, 15, 18 | 6 | one subset, one index set |
|
|
93
|
+
* | 8 | 6 | a solid colour, which BC7 has no mode for and mode 6 holds exactly |
|
|
94
|
+
* | 6, 11, 13, 17 | 5 | dual plane — one channel with its own weights, which BC7 spells as a rotation |
|
|
95
|
+
* | 2 | 1 | two subsets, three-bit weights |
|
|
96
|
+
* | 4 | 3 | two subsets, two-bit weights, seven-bit endpoints |
|
|
97
|
+
* | 9, 16 | 7 | two subsets with alpha |
|
|
98
|
+
* | 3 | 2 | three subsets |
|
|
99
|
+
* | 7 | 2 | two subsets in UASTC, three in BC7 — two of BC7's endpoint pairs are written alike |
|
|
100
|
+
*
|
|
101
|
+
* **The weights need no remapping.** ASTC's two- and three-bit weight tables are BC7's, and the
|
|
102
|
+
* four-bit ones agree too, so an index crosses over as itself. Where a UASTC mode's weight range is
|
|
103
|
+
* finer than the BC7 mode's index — only mode 18, at five bits — the nearest is taken.
|
|
104
|
+
*
|
|
105
|
+
* @param {Uint8Array} blocks UASTC blocks, tightly packed
|
|
106
|
+
* @param {number} block_count
|
|
107
|
+
* @returns {Uint8Array} tightly packed BC7 blocks, in raster order
|
|
108
|
+
*
|
|
109
|
+
* @author Alex Goldring
|
|
110
|
+
* @copyright Company Named Limited (c) 2026
|
|
111
|
+
*/
|
|
112
|
+
export function uastc_to_bc7(blocks, block_count) {
|
|
113
|
+
const out = new Uint8Array(block_count * BC7_BLOCK_BYTES);
|
|
114
|
+
|
|
115
|
+
const scratch = {
|
|
116
|
+
endpoints: new Uint8Array(3 * 2 * 4),
|
|
117
|
+
decoded: new Uint8Array(3 * 2 * 4),
|
|
118
|
+
parity: new Int8Array(6),
|
|
119
|
+
indices: new Uint8Array(16),
|
|
120
|
+
secondary_indices: new Uint8Array(16),
|
|
121
|
+
anchors: new Uint8Array(3),
|
|
122
|
+
subset_of_texel: new Uint8Array(16),
|
|
123
|
+
source_subset: new Uint8Array(3),
|
|
124
|
+
};
|
|
125
|
+
|
|
126
|
+
for (let block = 0; block < block_count; block++) {
|
|
127
|
+
const decoded = uastc_decode_block(blocks, block * UASTC_BLOCK_BYTES);
|
|
128
|
+
|
|
129
|
+
const mapping = MODE_MAP[decoded.mode];
|
|
130
|
+
|
|
131
|
+
if (mapping.via === "dual") {
|
|
132
|
+
write_dual_plane(out, block * BC7_BLOCK_BYTES, decoded, scratch);
|
|
133
|
+
} else if (mapping.via === "single") {
|
|
134
|
+
write_single_subset(out, block * BC7_BLOCK_BYTES, decoded, scratch);
|
|
135
|
+
} else {
|
|
136
|
+
write_partitioned(out, block * BC7_BLOCK_BYTES, decoded, mapping, scratch);
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
return out;
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
/**
|
|
144
|
+
* Map a UASTC weight index into a BC7 index of the given width.
|
|
145
|
+
*
|
|
146
|
+
* @param {number} index
|
|
147
|
+
* @param {number} weight_range
|
|
148
|
+
* @param {number} bits
|
|
149
|
+
* @returns {number}
|
|
150
|
+
*/
|
|
151
|
+
function map_index(index, weight_range, bits) {
|
|
152
|
+
const from = UASTC_WEIGHT_VALUE[weight_range];
|
|
153
|
+
const to = BC7_WEIGHTS[bits];
|
|
154
|
+
|
|
155
|
+
const weight = from[index];
|
|
156
|
+
|
|
157
|
+
let best = 0;
|
|
158
|
+
let best_error = Infinity;
|
|
159
|
+
|
|
160
|
+
for (let i = 0; i < to.length; i++) {
|
|
161
|
+
const error = Math.abs(to[i] - weight);
|
|
162
|
+
|
|
163
|
+
if (error < best_error) {
|
|
164
|
+
best_error = error;
|
|
165
|
+
best = i;
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
return best;
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
/**
|
|
173
|
+
* Quantise one subset's two endpoints, choosing the parity that suits them best.
|
|
174
|
+
*
|
|
175
|
+
* A parity bit is shared — by an endpoint's four channels, or by a subset's two endpoints — so it
|
|
176
|
+
* cannot be fitted per channel. Both values are tried and the one with less total error kept, which
|
|
177
|
+
* is what the specification means by an "optimal p-bit".
|
|
178
|
+
*
|
|
179
|
+
* @param {Uint8Array} source eight bytes, low then high RGBA
|
|
180
|
+
* @param {number} source_offset
|
|
181
|
+
* @param {Uint8Array} out stored fields, written
|
|
182
|
+
* @param {number} out_offset
|
|
183
|
+
* @param {Uint8Array} decoded what those fields decode to, written
|
|
184
|
+
* @param {Int8Array} parity written
|
|
185
|
+
* @param {number} parity_offset
|
|
186
|
+
* @param {Bc7Mode} spec
|
|
187
|
+
* @param {number} channels how many carry data — three where the mode has no alpha
|
|
188
|
+
*/
|
|
189
|
+
function quantise_subset(
|
|
190
|
+
source, source_offset, out, out_offset, decoded, parity, parity_offset, spec, channels
|
|
191
|
+
) {
|
|
192
|
+
const per_endpoint = spec.endpoint_parity_bits > 0;
|
|
193
|
+
const shared = spec.shared_parity_bits > 0;
|
|
194
|
+
|
|
195
|
+
const color_width = spec.color_bits + (per_endpoint || shared ? 1 : 0);
|
|
196
|
+
const alpha_width = spec.alpha_bits + (per_endpoint || shared ? 1 : 0);
|
|
197
|
+
|
|
198
|
+
/**
|
|
199
|
+
* @param {number[]} candidate one parity per endpoint
|
|
200
|
+
* @returns {number} total squared error
|
|
201
|
+
*/
|
|
202
|
+
const error_of = candidate => {
|
|
203
|
+
let total = 0;
|
|
204
|
+
|
|
205
|
+
for (let end = 0; end < 2; end++) {
|
|
206
|
+
for (let c = 0; c < channels; c++) {
|
|
207
|
+
const width = c === 3 ? alpha_width : color_width;
|
|
208
|
+
|
|
209
|
+
const value = source[source_offset + end * 4 + c];
|
|
210
|
+
|
|
211
|
+
const stored = bc7_quantise_endpoint(value, width, candidate[end]);
|
|
212
|
+
|
|
213
|
+
const delta = bc7_expand_endpoint(stored, width) - value;
|
|
214
|
+
|
|
215
|
+
total += delta * delta;
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
return total;
|
|
220
|
+
};
|
|
221
|
+
|
|
222
|
+
let chosen = [-1, -1];
|
|
223
|
+
|
|
224
|
+
if (per_endpoint) {
|
|
225
|
+
// one bit each, so the two endpoints are independent and each takes its own better value
|
|
226
|
+
for (let end = 0; end < 2; end++) {
|
|
227
|
+
chosen[end] = error_of_end(source, source_offset, end, 0, spec, channels)
|
|
228
|
+
<= error_of_end(source, source_offset, end, 1, spec, channels) ? 0 : 1;
|
|
229
|
+
}
|
|
230
|
+
} else if (shared) {
|
|
231
|
+
// one bit for the whole subset, so both endpoints have to agree
|
|
232
|
+
chosen = error_of([0, 0]) <= error_of([1, 1]) ? [0, 0] : [1, 1];
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
for (let end = 0; end < 2; end++) {
|
|
236
|
+
for (let c = 0; c < 4; c++) {
|
|
237
|
+
const width = c === 3 ? alpha_width : color_width;
|
|
238
|
+
|
|
239
|
+
if (c === 3 && spec.alpha_bits === 0) {
|
|
240
|
+
out[out_offset + end * 4 + c] = 0;
|
|
241
|
+
decoded[out_offset + end * 4 + c] = 255;
|
|
242
|
+
|
|
243
|
+
continue;
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
const value = source[source_offset + end * 4 + c];
|
|
247
|
+
|
|
248
|
+
const stored = bc7_quantise_endpoint(value, width, chosen[end]);
|
|
249
|
+
|
|
250
|
+
decoded[out_offset + end * 4 + c] = bc7_expand_endpoint(stored, width);
|
|
251
|
+
|
|
252
|
+
// the parity bit is carried separately, so the stored field is the rest
|
|
253
|
+
out[out_offset + end * 4 + c] = (per_endpoint || shared) ? stored >> 1 : stored;
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
if (per_endpoint) {
|
|
258
|
+
parity[parity_offset] = chosen[0];
|
|
259
|
+
parity[parity_offset + 1] = chosen[1];
|
|
260
|
+
} else if (shared) {
|
|
261
|
+
parity[parity_offset] = chosen[0];
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
/**
|
|
266
|
+
* Total squared error of one endpoint under a candidate parity.
|
|
267
|
+
*
|
|
268
|
+
* @param {Uint8Array} source
|
|
269
|
+
* @param {number} source_offset
|
|
270
|
+
* @param {number} end
|
|
271
|
+
* @param {number} parity
|
|
272
|
+
* @param {Bc7Mode} spec
|
|
273
|
+
* @param {number} channels
|
|
274
|
+
* @returns {number}
|
|
275
|
+
*/
|
|
276
|
+
function error_of_end(source, source_offset, end, parity, spec, channels) {
|
|
277
|
+
const color_width = spec.color_bits + 1;
|
|
278
|
+
const alpha_width = spec.alpha_bits + 1;
|
|
279
|
+
|
|
280
|
+
let total = 0;
|
|
281
|
+
|
|
282
|
+
for (let c = 0; c < channels; c++) {
|
|
283
|
+
const width = c === 3 ? alpha_width : color_width;
|
|
284
|
+
|
|
285
|
+
const value = source[source_offset + end * 4 + c];
|
|
286
|
+
|
|
287
|
+
const delta = bc7_expand_endpoint(bc7_quantise_endpoint(value, width, parity), width)
|
|
288
|
+
- value;
|
|
289
|
+
|
|
290
|
+
total += delta * delta;
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
return total;
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
/**
|
|
297
|
+
* Flip a subset's endpoints and invert its indices, so its anchor index fits the bit it is given.
|
|
298
|
+
*
|
|
299
|
+
* @param {Uint8Array} endpoints stored fields
|
|
300
|
+
* @param {Uint8Array} decoded
|
|
301
|
+
* @param {Int8Array} parity
|
|
302
|
+
* @param {number} subset
|
|
303
|
+
* @param {Bc7Mode} spec
|
|
304
|
+
* @param {Uint8Array} indices
|
|
305
|
+
* @param {Uint8Array} subset_of_texel
|
|
306
|
+
* @param {number} index_count
|
|
307
|
+
*/
|
|
308
|
+
function flip_subset(
|
|
309
|
+
endpoints, decoded, parity, subset, spec, indices, subset_of_texel, index_count
|
|
310
|
+
) {
|
|
311
|
+
for (let c = 0; c < 4; c++) {
|
|
312
|
+
const low = (subset * 2) * 4 + c;
|
|
313
|
+
const high = (subset * 2 + 1) * 4 + c;
|
|
314
|
+
|
|
315
|
+
const swap = endpoints[low];
|
|
316
|
+
|
|
317
|
+
endpoints[low] = endpoints[high];
|
|
318
|
+
endpoints[high] = swap;
|
|
319
|
+
|
|
320
|
+
const swap_decoded = decoded[low];
|
|
321
|
+
|
|
322
|
+
decoded[low] = decoded[high];
|
|
323
|
+
decoded[high] = swap_decoded;
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
if (spec.endpoint_parity_bits > 0) {
|
|
327
|
+
const swap = parity[subset * 2];
|
|
328
|
+
|
|
329
|
+
parity[subset * 2] = parity[subset * 2 + 1];
|
|
330
|
+
parity[subset * 2 + 1] = swap;
|
|
331
|
+
}
|
|
332
|
+
|
|
333
|
+
for (let texel = 0; texel < 16; texel++) {
|
|
334
|
+
if (subset_of_texel[texel] === subset) {
|
|
335
|
+
indices[texel] = index_count - 1 - indices[texel];
|
|
336
|
+
}
|
|
337
|
+
}
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
/**
|
|
341
|
+
* Carry a partitioned block — two or three subsets — into its BC7 counterpart.
|
|
342
|
+
*
|
|
343
|
+
* @param {Uint8Array} out
|
|
344
|
+
* @param {number} offset
|
|
345
|
+
* @param {UastcBlock} block
|
|
346
|
+
* @param {{bc7: number, via: string}} mapping
|
|
347
|
+
* @param {object} scratch
|
|
348
|
+
*/
|
|
349
|
+
function write_partitioned(out, offset, block, mapping, scratch) {
|
|
350
|
+
const spec = BC7_MODES[mapping.bc7];
|
|
351
|
+
|
|
352
|
+
const { endpoints, decoded, parity, indices, anchors, subset_of_texel, source_subset } = scratch;
|
|
353
|
+
|
|
354
|
+
/*
|
|
355
|
+
Which BC7 subset each texel lands in, and which UASTC subset each BC7 subset draws its endpoints
|
|
356
|
+
from. The two questions have different answers for mode 7, where BC7 has a subset UASTC does not
|
|
357
|
+
— two of its three endpoint pairs end up identical.
|
|
358
|
+
*/
|
|
359
|
+
if (mapping.via === "single_as_two") {
|
|
360
|
+
/*
|
|
361
|
+
One UASTC subset written as two identical BC7 ones. Partition zero divides the block, and
|
|
362
|
+
giving both halves the same endpoints makes that division invisible — which is how a
|
|
363
|
+
one-subset block reaches a mode that has no one-subset form.
|
|
364
|
+
*/
|
|
365
|
+
scratch.partition = 0;
|
|
366
|
+
|
|
367
|
+
subset_of_texel.set(BC7_PARTITIONS_2.subarray(0, 16));
|
|
368
|
+
|
|
369
|
+
source_subset[0] = 0;
|
|
370
|
+
source_subset[1] = 0;
|
|
371
|
+
} else if (mapping.via === "two") {
|
|
372
|
+
const { bc7, invert } = UASTC_TO_BC7_2[block.pattern];
|
|
373
|
+
|
|
374
|
+
scratch.partition = bc7;
|
|
375
|
+
|
|
376
|
+
for (let texel = 0; texel < 16; texel++) {
|
|
377
|
+
subset_of_texel[texel] = invert ? 1 - block.partition[texel] : block.partition[texel];
|
|
378
|
+
}
|
|
379
|
+
|
|
380
|
+
source_subset[0] = invert ? 1 : 0;
|
|
381
|
+
source_subset[1] = invert ? 0 : 1;
|
|
382
|
+
} else if (mapping.via === "three") {
|
|
383
|
+
const { bc7, permutation } = UASTC_TO_BC7_3[block.pattern];
|
|
384
|
+
|
|
385
|
+
scratch.partition = bc7;
|
|
386
|
+
|
|
387
|
+
const perm = SUBSET_PERMUTATIONS[permutation];
|
|
388
|
+
|
|
389
|
+
for (let texel = 0; texel < 16; texel++) {
|
|
390
|
+
subset_of_texel[texel] = perm[block.partition[texel]];
|
|
391
|
+
}
|
|
392
|
+
|
|
393
|
+
for (let s = 0; s < 3; s++) {
|
|
394
|
+
source_subset[perm[s]] = s;
|
|
395
|
+
}
|
|
396
|
+
} else {
|
|
397
|
+
const { bc7, fold } = UASTC_TO_BC7_2_VIA_3[block.pattern];
|
|
398
|
+
|
|
399
|
+
scratch.partition = bc7;
|
|
400
|
+
|
|
401
|
+
/*
|
|
402
|
+
BC7's three subsets fold onto UASTC's two, so two of them share a source — and writing the
|
|
403
|
+
same endpoints twice is exactly what makes a three-subset BC7 block describe two.
|
|
404
|
+
*/
|
|
405
|
+
for (let s = 0; s < 3; s++) {
|
|
406
|
+
source_subset[s] = bc7_fold_subset_3_to_2(s, fold);
|
|
407
|
+
}
|
|
408
|
+
|
|
409
|
+
for (let texel = 0; texel < 16; texel++) {
|
|
410
|
+
// the BC7 pattern is the authority here; UASTC's is what it folds to
|
|
411
|
+
subset_of_texel[texel] = bc7_subset_of(bc7, texel);
|
|
412
|
+
}
|
|
413
|
+
}
|
|
414
|
+
|
|
415
|
+
/*
|
|
416
|
+
**The parity is chosen over the channels that carry something.** It is shared by an endpoint's
|
|
417
|
+
four, so choosing it by total error across all four lets a constant alpha outvote the colour —
|
|
418
|
+
and on an RGB source that alpha is 255 by construction, invented by the colour endpoint mode
|
|
419
|
+
rather than authored. Letting it vote costs 1.66 dB of colour on the photographic fixture, to
|
|
420
|
+
perfect a channel nothing reads: meep declares a texture's alpha mode rather than inferring it
|
|
421
|
+
from texels (§9.2), so an opaque source decoding to 254 changes no decision anywhere. The
|
|
422
|
+
reference transcoder makes the same trade.
|
|
423
|
+
*/
|
|
424
|
+
const channels = (spec.alpha_bits > 0 && block.has_alpha) ? 4 : 3;
|
|
425
|
+
|
|
426
|
+
for (let s = 0; s < spec.subsets; s++) {
|
|
427
|
+
quantise_subset(
|
|
428
|
+
block.endpoints, source_subset[s] * 8,
|
|
429
|
+
endpoints, s * 8, decoded, parity, spec.endpoint_parity_bits > 0 ? s * 2 : s,
|
|
430
|
+
spec, channels
|
|
431
|
+
);
|
|
432
|
+
}
|
|
433
|
+
|
|
434
|
+
for (let texel = 0; texel < 16; texel++) {
|
|
435
|
+
indices[texel] = map_index(
|
|
436
|
+
block.weight_indices[texel], block.weight_range, spec.index_bits
|
|
437
|
+
);
|
|
438
|
+
}
|
|
439
|
+
|
|
440
|
+
anchors[0] = 0;
|
|
441
|
+
|
|
442
|
+
if (spec.subsets === 2) {
|
|
443
|
+
anchors[1] = BC7_ANCHOR_2[scratch.partition];
|
|
444
|
+
} else {
|
|
445
|
+
anchors[1] = BC7_ANCHOR_3_SECOND[scratch.partition];
|
|
446
|
+
anchors[2] = BC7_ANCHOR_3_THIRD[scratch.partition];
|
|
447
|
+
}
|
|
448
|
+
|
|
449
|
+
const index_count = 1 << spec.index_bits;
|
|
450
|
+
|
|
451
|
+
for (let s = 0; s < spec.subsets; s++) {
|
|
452
|
+
if (indices[anchors[s]] >= index_count / 2) {
|
|
453
|
+
flip_subset(
|
|
454
|
+
endpoints, decoded, parity, s, spec, indices, subset_of_texel, index_count
|
|
455
|
+
);
|
|
456
|
+
}
|
|
457
|
+
}
|
|
458
|
+
|
|
459
|
+
bc7_write_block(out, offset, mapping.bc7, {
|
|
460
|
+
partition: scratch.partition,
|
|
461
|
+
endpoints,
|
|
462
|
+
indices,
|
|
463
|
+
anchors,
|
|
464
|
+
parity,
|
|
465
|
+
});
|
|
466
|
+
}
|
|
467
|
+
|
|
468
|
+
/**
|
|
469
|
+
* Which BC7 three-subset subset a texel is in, for a given partition.
|
|
470
|
+
*
|
|
471
|
+
* @param {number} partition
|
|
472
|
+
* @param {number} texel
|
|
473
|
+
* @returns {number}
|
|
474
|
+
*/
|
|
475
|
+
function bc7_subset_of(partition, texel) {
|
|
476
|
+
return BC7_PARTITIONS_3[partition * 16 + texel];
|
|
477
|
+
}
|
|
478
|
+
|
|
479
|
+
/**
|
|
480
|
+
* Carry a single-subset block into BC7 mode 6.
|
|
481
|
+
*
|
|
482
|
+
* @param {Uint8Array} out
|
|
483
|
+
* @param {number} offset
|
|
484
|
+
* @param {UastcBlock} block
|
|
485
|
+
* @param {object} scratch
|
|
486
|
+
*/
|
|
487
|
+
function write_single_subset(out, offset, block, scratch) {
|
|
488
|
+
const spec = BC7_MODES[6];
|
|
489
|
+
|
|
490
|
+
const { endpoints, decoded, parity, indices, anchors, subset_of_texel } = scratch;
|
|
491
|
+
|
|
492
|
+
subset_of_texel.fill(0);
|
|
493
|
+
quantise_subset(
|
|
494
|
+
block.endpoints, 0, endpoints, 0, decoded, parity, 0, spec, block.has_alpha ? 4 : 3
|
|
495
|
+
);
|
|
496
|
+
|
|
497
|
+
for (let texel = 0; texel < 16; texel++) {
|
|
498
|
+
indices[texel] = map_index(
|
|
499
|
+
block.weight_indices[texel], block.weight_range, spec.index_bits
|
|
500
|
+
);
|
|
501
|
+
}
|
|
502
|
+
|
|
503
|
+
anchors[0] = 0;
|
|
504
|
+
|
|
505
|
+
const index_count = 1 << spec.index_bits;
|
|
506
|
+
|
|
507
|
+
if (indices[0] >= index_count / 2) {
|
|
508
|
+
flip_subset(endpoints, decoded, parity, 0, spec, indices, subset_of_texel, index_count);
|
|
509
|
+
}
|
|
510
|
+
|
|
511
|
+
bc7_write_block(out, offset, 6, { endpoints, indices, anchors, parity });
|
|
512
|
+
}
|
|
513
|
+
|
|
514
|
+
/**
|
|
515
|
+
* Carry a dual plane block into BC7 mode 5.
|
|
516
|
+
*
|
|
517
|
+
* @param {Uint8Array} out
|
|
518
|
+
* @param {number} offset
|
|
519
|
+
* @param {UastcBlock} block
|
|
520
|
+
* @param {object} scratch
|
|
521
|
+
*/
|
|
522
|
+
function write_dual_plane(out, offset, block, scratch) {
|
|
523
|
+
const spec = BC7_MODES[5];
|
|
524
|
+
|
|
525
|
+
const {
|
|
526
|
+
endpoints, decoded, parity, indices, secondary_indices, anchors, subset_of_texel,
|
|
527
|
+
} = scratch;
|
|
528
|
+
|
|
529
|
+
subset_of_texel.fill(0);
|
|
530
|
+
|
|
531
|
+
const selector = block.component_selector;
|
|
532
|
+
|
|
533
|
+
/*
|
|
534
|
+
BC7 always interpolates *alpha* with the second index set, so the channel ASTC nominated is
|
|
535
|
+
swapped into alpha's place — endpoints included — and the rotation tells the decoder to swap it
|
|
536
|
+
back. This is the one place the two formats disagree about dual planes rather than merely
|
|
537
|
+
spelling them differently.
|
|
538
|
+
*/
|
|
539
|
+
const source = new Uint8Array(8);
|
|
540
|
+
|
|
541
|
+
source.set(block.endpoints.subarray(0, 8));
|
|
542
|
+
|
|
543
|
+
if (selector !== 3) {
|
|
544
|
+
for (let end = 0; end < 2; end++) {
|
|
545
|
+
const swap = source[end * 4 + selector];
|
|
546
|
+
|
|
547
|
+
source[end * 4 + selector] = source[end * 4 + 3];
|
|
548
|
+
source[end * 4 + 3] = swap;
|
|
549
|
+
}
|
|
550
|
+
}
|
|
551
|
+
|
|
552
|
+
quantise_subset(source, 0, endpoints, 0, decoded, parity, 0, spec, 4);
|
|
553
|
+
|
|
554
|
+
for (let texel = 0; texel < 16; texel++) {
|
|
555
|
+
indices[texel] = map_index(
|
|
556
|
+
block.weight_indices[texel * 2], block.weight_range, spec.index_bits
|
|
557
|
+
);
|
|
558
|
+
|
|
559
|
+
secondary_indices[texel] = map_index(
|
|
560
|
+
block.weight_indices[texel * 2 + 1], block.weight_range, spec.secondary_index_bits
|
|
561
|
+
);
|
|
562
|
+
}
|
|
563
|
+
|
|
564
|
+
anchors[0] = 0;
|
|
565
|
+
|
|
566
|
+
const index_count = 1 << spec.index_bits;
|
|
567
|
+
|
|
568
|
+
/*
|
|
569
|
+
Mode 5's two index sets each have their own anchor, and flipping one must not disturb the other
|
|
570
|
+
— the colour flip swaps only the three colour channels and the alpha flip only alpha.
|
|
571
|
+
*/
|
|
572
|
+
if (indices[0] >= index_count / 2) {
|
|
573
|
+
for (let c = 0; c < 3; c++) {
|
|
574
|
+
const swap = endpoints[c];
|
|
575
|
+
|
|
576
|
+
endpoints[c] = endpoints[4 + c];
|
|
577
|
+
endpoints[4 + c] = swap;
|
|
578
|
+
}
|
|
579
|
+
|
|
580
|
+
for (let texel = 0; texel < 16; texel++) {
|
|
581
|
+
indices[texel] = index_count - 1 - indices[texel];
|
|
582
|
+
}
|
|
583
|
+
}
|
|
584
|
+
|
|
585
|
+
if (secondary_indices[0] >= index_count / 2) {
|
|
586
|
+
const swap = endpoints[3];
|
|
587
|
+
|
|
588
|
+
endpoints[3] = endpoints[7];
|
|
589
|
+
endpoints[7] = swap;
|
|
590
|
+
|
|
591
|
+
for (let texel = 0; texel < 16; texel++) {
|
|
592
|
+
secondary_indices[texel] = index_count - 1 - secondary_indices[texel];
|
|
593
|
+
}
|
|
594
|
+
}
|
|
595
|
+
|
|
596
|
+
bc7_write_block(out, offset, 5, {
|
|
597
|
+
rotation: selector + 1,
|
|
598
|
+
endpoints,
|
|
599
|
+
indices,
|
|
600
|
+
secondary_indices,
|
|
601
|
+
anchors,
|
|
602
|
+
parity,
|
|
603
|
+
});
|
|
604
|
+
}
|