@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.
Files changed (309) hide show
  1. package/CHANGELOG.md +62 -3
  2. package/README.md +1 -1
  3. package/package.json +1 -1
  4. package/src/format/image/webp/vp8/VP8BoolDecoder.d.ts +45 -0
  5. package/src/format/image/webp/vp8/VP8BoolDecoder.d.ts.map +1 -0
  6. package/src/format/image/webp/vp8/VP8BoolDecoder.js +137 -0
  7. package/src/format/image/webp/vp8/vp8_decode.d.ts +21 -0
  8. package/src/format/image/webp/vp8/vp8_decode.d.ts.map +1 -0
  9. package/src/format/image/webp/vp8/vp8_decode.js +756 -0
  10. package/src/format/image/webp/vp8/vp8_loop_filter.d.ts +31 -0
  11. package/src/format/image/webp/vp8/vp8_loop_filter.d.ts.map +1 -0
  12. package/src/format/image/webp/vp8/vp8_loop_filter.js +189 -0
  13. package/src/format/image/webp/vp8/vp8_predict.d.ts +48 -0
  14. package/src/format/image/webp/vp8/vp8_predict.d.ts.map +1 -0
  15. package/src/format/image/webp/vp8/vp8_predict.js +290 -0
  16. package/src/format/image/webp/vp8/vp8_tables.d.ts +34 -0
  17. package/src/format/image/webp/vp8/vp8_tables.d.ts.map +1 -0
  18. package/src/format/image/webp/vp8/vp8_tables.js +350 -0
  19. package/src/format/image/webp/vp8/vp8_transform.d.ts +22 -0
  20. package/src/format/image/webp/vp8/vp8_transform.d.ts.map +1 -0
  21. package/src/format/image/webp/vp8/vp8_transform.js +114 -0
  22. package/src/format/image/webp/vp8/vp8_yuv_to_rgba.d.ts +23 -0
  23. package/src/format/image/webp/vp8/vp8_yuv_to_rgba.d.ts.map +1 -0
  24. package/src/format/image/webp/vp8/vp8_yuv_to_rgba.js +133 -0
  25. package/src/format/image/webp/vp8l/VP8LBitReader.d.ts +47 -0
  26. package/src/format/image/webp/vp8l/VP8LBitReader.d.ts.map +1 -0
  27. package/src/format/image/webp/vp8l/VP8LBitReader.js +84 -0
  28. package/src/format/image/webp/vp8l/VP8LPrefixCode.d.ts +27 -0
  29. package/src/format/image/webp/vp8l/VP8LPrefixCode.d.ts.map +1 -0
  30. package/src/format/image/webp/vp8l/VP8LPrefixCode.js +184 -0
  31. package/src/format/image/webp/vp8l/vp8l_decode.d.ts +28 -0
  32. package/src/format/image/webp/vp8l/vp8l_decode.d.ts.map +1 -0
  33. package/src/format/image/webp/vp8l/vp8l_decode.js +261 -0
  34. package/src/format/image/webp/vp8l/vp8l_distance.d.ts +22 -0
  35. package/src/format/image/webp/vp8l/vp8l_distance.d.ts.map +1 -0
  36. package/src/format/image/webp/vp8l/vp8l_distance.js +62 -0
  37. package/src/format/image/webp/vp8l/vp8l_inverse_transforms.d.ts +50 -0
  38. package/src/format/image/webp/vp8l/vp8l_inverse_transforms.d.ts.map +1 -0
  39. package/src/format/image/webp/vp8l/vp8l_inverse_transforms.js +267 -0
  40. package/src/format/image/webp/vp8l/vp8l_read_prefix_code.d.ts +14 -0
  41. package/src/format/image/webp/vp8l/vp8l_read_prefix_code.d.ts.map +1 -0
  42. package/src/format/image/webp/vp8l/vp8l_read_prefix_code.js +99 -0
  43. package/src/format/image/webp/webp_decode.d.ts +23 -0
  44. package/src/format/image/webp/webp_decode.d.ts.map +1 -0
  45. package/src/format/image/webp/webp_decode.js +179 -0
  46. package/src/format/image/webp/webp_decode_alpha.d.ts +18 -0
  47. package/src/format/image/webp/webp_decode_alpha.d.ts.map +1 -0
  48. package/src/format/image/webp/webp_decode_alpha.js +84 -0
  49. package/src/format/texture/{basis → astc}/astc_block.d.ts +41 -0
  50. package/src/format/texture/astc/astc_block.d.ts.map +1 -0
  51. package/src/format/texture/{basis → astc}/astc_block.js +284 -164
  52. package/src/format/texture/astc/astc_decode_block.d.ts +68 -0
  53. package/src/format/texture/astc/astc_decode_block.d.ts.map +1 -0
  54. package/src/format/texture/astc/astc_decode_block.js +1119 -0
  55. package/src/format/texture/astc/astc_encode_block_4x4.d.ts +32 -0
  56. package/src/format/texture/astc/astc_encode_block_4x4.d.ts.map +1 -0
  57. package/src/format/texture/astc/astc_encode_block_4x4.js +181 -0
  58. package/src/format/texture/astc/astc_encode_block_4x4_rgba.d.ts +32 -0
  59. package/src/format/texture/astc/astc_encode_block_4x4_rgba.d.ts.map +1 -0
  60. package/src/format/texture/astc/astc_encode_block_4x4_rgba.js +337 -0
  61. package/src/format/texture/astc/astc_integer_sequence.d.ts.map +1 -0
  62. package/src/format/texture/{basis → astc}/astc_integer_sequence.js +251 -251
  63. package/src/format/texture/astc/astc_partition.d.ts.map +1 -0
  64. package/src/format/texture/{basis → astc}/astc_partition.js +199 -199
  65. package/src/format/texture/basis/transcode/etc1s_to_astc.js +329 -329
  66. package/src/format/texture/basis/transcode/etc1s_to_etc2.d.ts.map +1 -1
  67. package/src/format/texture/basis/transcode/etc1s_to_etc2.js +305 -332
  68. package/src/format/texture/basis/transcode/fit_endpoints.d.ts.map +1 -1
  69. package/src/format/texture/basis/transcode/fit_endpoints.js +14 -27
  70. package/src/format/texture/basis/uastc/uastc_bc7_tables.d.ts +66 -0
  71. package/src/format/texture/basis/uastc/uastc_bc7_tables.d.ts.map +1 -0
  72. package/src/format/texture/basis/uastc/uastc_bc7_tables.js +148 -0
  73. package/src/format/texture/basis/uastc/uastc_decode_block.js +463 -463
  74. package/src/format/texture/basis/uastc/uastc_to_astc.js +421 -421
  75. package/src/format/texture/basis/uastc/uastc_to_bc5.d.ts +1 -6
  76. package/src/format/texture/basis/uastc/uastc_to_bc5.d.ts.map +1 -1
  77. package/src/format/texture/basis/uastc/uastc_to_bc5.js +48 -115
  78. package/src/format/texture/basis/uastc/uastc_to_bc7.d.ts.map +1 -1
  79. package/src/format/texture/basis/uastc/uastc_to_bc7.js +604 -602
  80. package/src/format/texture/bc/bc1_decode_block.d.ts +19 -0
  81. package/src/format/texture/bc/bc1_decode_block.d.ts.map +1 -0
  82. package/src/format/texture/bc/bc1_decode_block.js +22 -0
  83. package/src/format/texture/bc/bc1_decode_colors.d.ts +27 -0
  84. package/src/format/texture/bc/bc1_decode_colors.d.ts.map +1 -0
  85. package/src/format/texture/bc/bc1_decode_colors.js +100 -0
  86. package/src/format/texture/bc/bc2_decode_block.d.ts +18 -0
  87. package/src/format/texture/bc/bc2_decode_block.d.ts.map +1 -0
  88. package/src/format/texture/bc/bc2_decode_block.js +28 -0
  89. package/src/format/texture/bc/bc3_decode_block.d.ts +18 -0
  90. package/src/format/texture/bc/bc3_decode_block.d.ts.map +1 -0
  91. package/src/format/texture/bc/bc3_decode_block.js +23 -0
  92. package/src/format/texture/bc/bc4_decode_channel.d.ts +56 -0
  93. package/src/format/texture/bc/bc4_decode_channel.d.ts.map +1 -0
  94. package/src/format/texture/bc/bc4_decode_channel.js +138 -0
  95. package/src/format/texture/bc/bc4_encode_block.d.ts +43 -0
  96. package/src/format/texture/bc/bc4_encode_block.d.ts.map +1 -0
  97. package/src/format/texture/bc/bc4_encode_block.js +324 -0
  98. package/src/format/texture/bc/bc4_snorm_decode_block.d.ts +18 -0
  99. package/src/format/texture/bc/bc4_snorm_decode_block.d.ts.map +1 -0
  100. package/src/format/texture/bc/bc4_snorm_decode_block.js +27 -0
  101. package/src/format/texture/bc/bc4_unorm_decode_block.d.ts +17 -0
  102. package/src/format/texture/bc/bc4_unorm_decode_block.d.ts.map +1 -0
  103. package/src/format/texture/bc/bc4_unorm_decode_block.js +26 -0
  104. package/src/format/texture/bc/bc5_encode_block.d.ts +25 -0
  105. package/src/format/texture/bc/bc5_encode_block.d.ts.map +1 -0
  106. package/src/format/texture/bc/bc5_encode_block.js +34 -0
  107. package/src/format/texture/bc/bc5_snorm_decode_block.d.ts +18 -0
  108. package/src/format/texture/bc/bc5_snorm_decode_block.d.ts.map +1 -0
  109. package/src/format/texture/bc/bc5_snorm_decode_block.js +27 -0
  110. package/src/format/texture/bc/bc5_unorm_decode_block.d.ts +17 -0
  111. package/src/format/texture/bc/bc5_unorm_decode_block.d.ts.map +1 -0
  112. package/src/format/texture/bc/bc5_unorm_decode_block.js +26 -0
  113. package/src/format/texture/bc/bc6h_decode_texels.d.ts +30 -0
  114. package/src/format/texture/bc/bc6h_decode_texels.d.ts.map +1 -0
  115. package/src/format/texture/bc/bc6h_decode_texels.js +430 -0
  116. package/src/format/texture/bc/bc6h_sfloat_decode_block.d.ts +20 -0
  117. package/src/format/texture/bc/bc6h_sfloat_decode_block.d.ts.map +1 -0
  118. package/src/format/texture/bc/bc6h_sfloat_decode_block.js +23 -0
  119. package/src/format/texture/bc/bc6h_ufloat_decode_block.d.ts +18 -0
  120. package/src/format/texture/bc/bc6h_ufloat_decode_block.d.ts.map +1 -0
  121. package/src/format/texture/bc/bc6h_ufloat_decode_block.js +21 -0
  122. package/src/format/texture/bc/bc7_decode_block.d.ts +30 -0
  123. package/src/format/texture/bc/bc7_decode_block.d.ts.map +1 -0
  124. package/src/format/texture/bc/bc7_decode_block.js +232 -0
  125. package/src/format/texture/bc/bc7_encode_block.d.ts +39 -0
  126. package/src/format/texture/bc/bc7_encode_block.d.ts.map +1 -0
  127. package/src/format/texture/bc/bc7_encode_block.js +423 -0
  128. package/src/format/texture/bc/bc7_tables.d.ts +126 -0
  129. package/src/format/texture/bc/bc7_tables.d.ts.map +1 -0
  130. package/src/format/texture/{basis/uastc → bc}/bc7_tables.js +225 -276
  131. package/src/format/texture/bc/bc7_write_block.d.ts +65 -0
  132. package/src/format/texture/bc/bc7_write_block.d.ts.map +1 -0
  133. package/src/format/texture/{basis/uastc → bc}/bc7_write_block.js +185 -227
  134. package/src/format/texture/etc/eac_decode_channel.d.ts +50 -0
  135. package/src/format/texture/etc/eac_decode_channel.d.ts.map +1 -0
  136. package/src/format/texture/etc/eac_decode_channel.js +142 -0
  137. package/src/format/texture/etc/eac_modifiers.d.ts +15 -0
  138. package/src/format/texture/etc/eac_modifiers.d.ts.map +1 -0
  139. package/src/format/texture/etc/eac_modifiers.js +31 -0
  140. package/src/format/texture/etc/eac_r11_snorm_decode_block.d.ts +21 -0
  141. package/src/format/texture/etc/eac_r11_snorm_decode_block.d.ts.map +1 -0
  142. package/src/format/texture/etc/eac_r11_snorm_decode_block.js +30 -0
  143. package/src/format/texture/etc/eac_r11_unorm_decode_block.d.ts +20 -0
  144. package/src/format/texture/etc/eac_r11_unorm_decode_block.d.ts.map +1 -0
  145. package/src/format/texture/etc/eac_r11_unorm_decode_block.js +29 -0
  146. package/src/format/texture/etc/eac_rg11_snorm_decode_block.d.ts +19 -0
  147. package/src/format/texture/etc/eac_rg11_snorm_decode_block.d.ts.map +1 -0
  148. package/src/format/texture/etc/eac_rg11_snorm_decode_block.js +28 -0
  149. package/src/format/texture/etc/eac_rg11_unorm_decode_block.d.ts +19 -0
  150. package/src/format/texture/etc/eac_rg11_unorm_decode_block.d.ts.map +1 -0
  151. package/src/format/texture/etc/eac_rg11_unorm_decode_block.js +28 -0
  152. package/src/format/texture/etc/etc2_decode_color.d.ts +25 -0
  153. package/src/format/texture/etc/etc2_decode_color.d.ts.map +1 -0
  154. package/src/format/texture/etc/etc2_decode_color.js +370 -0
  155. package/src/format/texture/etc/etc2_rgb8_decode_block.d.ts +18 -0
  156. package/src/format/texture/etc/etc2_rgb8_decode_block.d.ts.map +1 -0
  157. package/src/format/texture/etc/etc2_rgb8_decode_block.js +21 -0
  158. package/src/format/texture/etc/etc2_rgb8a1_decode_block.d.ts +21 -0
  159. package/src/format/texture/etc/etc2_rgb8a1_decode_block.d.ts.map +1 -0
  160. package/src/format/texture/etc/etc2_rgb8a1_decode_block.js +24 -0
  161. package/src/format/texture/etc/etc2_rgba8_decode_block.d.ts +18 -0
  162. package/src/format/texture/etc/etc2_rgba8_decode_block.d.ts.map +1 -0
  163. package/src/format/texture/etc/etc2_rgba8_decode_block.js +24 -0
  164. package/src/format/texture/fit/fit_line.d.ts +23 -0
  165. package/src/format/texture/fit/fit_line.d.ts.map +1 -0
  166. package/src/format/texture/fit/fit_line.js +123 -0
  167. package/src/format/texture/fit/fit_line_refine.d.ts +21 -0
  168. package/src/format/texture/fit/fit_line_refine.d.ts.map +1 -0
  169. package/src/format/texture/fit/fit_line_refine.js +69 -0
  170. package/src/format/texture/fit/fit_line_solve.d.ts +23 -0
  171. package/src/format/texture/fit/fit_line_solve.d.ts.map +1 -0
  172. package/src/format/texture/fit/fit_line_solve.js +71 -0
  173. package/src/format/texture/texel_decode_image.d.ts +44 -0
  174. package/src/format/texture/texel_decode_image.d.ts.map +1 -0
  175. package/src/format/texture/texel_decode_image.js +251 -0
  176. package/src/format/texture/texel_encode_image.d.ts +77 -0
  177. package/src/format/texture/texel_encode_image.d.ts.map +1 -0
  178. package/src/format/texture/texel_encode_image.js +187 -0
  179. package/src/shade/renderer/ShadeIndirectLightingMode.js +2 -0
  180. package/src/shade/renderer/acoustics/GPUAcousticLattice.d.ts +1 -1
  181. package/src/shade/renderer/acoustics/GPUAcoustics.d.ts +1 -1
  182. package/src/shade/renderer/loader/mtf/mtf_encode_texture.d.ts +1 -0
  183. package/src/shade/renderer/loader/mtf/mtf_encode_texture.d.ts.map +1 -1
  184. package/src/shade/renderer/loader/mtf/mtf_encode_texture.js +102 -28
  185. package/src/shade/renderer/loader/mtf/mtf_replace_textures.d.ts +19 -0
  186. package/src/shade/renderer/loader/mtf/mtf_replace_textures.d.ts.map +1 -0
  187. package/src/shade/renderer/loader/mtf/mtf_replace_textures.js +60 -0
  188. package/src/shade/renderer/loader/mtf/mtf_write.d.ts.map +1 -1
  189. package/src/shade/renderer/loader/mtf/mtf_write.js +7 -31
  190. package/src/shade/renderer/loader/mtf/mtf_write_collection.d.ts +23 -0
  191. package/src/shade/renderer/loader/mtf/mtf_write_collection.d.ts.map +1 -0
  192. package/src/shade/renderer/loader/mtf/mtf_write_collection.js +36 -0
  193. package/src/shade/renderer/texture/encode/chunk_astc_encode_block_4x4.d.ts +13 -0
  194. package/src/shade/renderer/texture/encode/chunk_astc_encode_block_4x4.d.ts.map +1 -0
  195. package/src/shade/renderer/texture/encode/chunk_astc_encode_block_4x4.js +39 -0
  196. package/src/shade/renderer/texture/encode/chunk_astc_encode_block_4x4_rgb.d.ts +3 -2
  197. package/src/shade/renderer/texture/encode/chunk_astc_encode_block_4x4_rgb.d.ts.map +1 -1
  198. package/src/shade/renderer/texture/encode/chunk_astc_encode_block_4x4_rgb.js +6 -21
  199. package/src/shade/renderer/texture/encode/chunk_astc_encode_block_4x4_rgba.d.ts +42 -0
  200. package/src/shade/renderer/texture/encode/chunk_astc_encode_block_4x4_rgba.d.ts.map +1 -0
  201. package/src/shade/renderer/texture/encode/chunk_astc_encode_block_4x4_rgba.js +612 -0
  202. package/src/shade/renderer/texture/encode/chunk_bc1_encode_block.d.ts +5 -4
  203. package/src/shade/renderer/texture/encode/chunk_bc1_encode_block.d.ts.map +1 -1
  204. package/src/shade/renderer/texture/encode/chunk_bc1_encode_block.js +8 -25
  205. package/src/shade/renderer/texture/encode/chunk_bc6h_encode_block_mode11.d.ts.map +1 -1
  206. package/src/shade/renderer/texture/encode/chunk_bc6h_encode_block_mode11.js +3 -19
  207. package/src/shade/renderer/texture/encode/chunk_bc7_encode_block.d.ts +14 -4
  208. package/src/shade/renderer/texture/encode/chunk_bc7_encode_block.d.ts.map +1 -1
  209. package/src/shade/renderer/texture/encode/chunk_bc7_encode_block.js +65 -54
  210. package/src/shade/renderer/texture/encode/chunk_bc7_encode_block_mode6.d.ts +2 -2
  211. package/src/shade/renderer/texture/encode/chunk_bc7_encode_block_mode6.d.ts.map +1 -1
  212. package/src/shade/renderer/texture/encode/chunk_bc7_encode_block_mode6.js +5 -22
  213. package/src/shade/renderer/texture/encode/chunk_bc7_partition_2.js +1 -1
  214. package/src/shade/renderer/texture/encode/chunk_scatter_principal_axis.d.ts +27 -0
  215. package/src/shade/renderer/texture/encode/chunk_scatter_principal_axis.d.ts.map +1 -0
  216. package/src/shade/renderer/texture/encode/chunk_scatter_principal_axis.js +147 -0
  217. package/src/shade/renderer/texture/encode/shader_texture_encode_astc_4x4.d.ts +3 -4
  218. package/src/shade/renderer/texture/encode/shader_texture_encode_astc_4x4.d.ts.map +1 -1
  219. package/src/shade/renderer/texture/encode/shader_texture_encode_astc_4x4.js +6 -13
  220. package/src/shade/renderer/texture/encode/shader_texture_encode_bc7_rgb.d.ts +13 -0
  221. package/src/shade/renderer/texture/encode/shader_texture_encode_bc7_rgb.d.ts.map +1 -0
  222. package/src/shade/renderer/texture/encode/shader_texture_encode_bc7_rgb.js +66 -0
  223. package/src/shade/renderer/texture/encode/texture_encode.d.ts +28 -1
  224. package/src/shade/renderer/texture/encode/texture_encode.d.ts.map +1 -1
  225. package/src/shade/renderer/texture/encode/texture_encode.js +202 -168
  226. package/src/shade/renderer/texture/encode/texture_encode_shader.d.ts +13 -1
  227. package/src/shade/renderer/texture/encode/texture_encode_shader.d.ts.map +1 -1
  228. package/src/shade/renderer/texture/encode/texture_encode_shader.js +146 -108
  229. package/src/shade/renderer/texture/format/texture_formats_to_build.d.ts +20 -0
  230. package/src/shade/renderer/texture/format/texture_formats_to_build.d.ts.map +1 -0
  231. package/src/shade/renderer/texture/format/texture_formats_to_build.js +98 -0
  232. package/src/shade/renderer/texture/mipmaps/WebGPUMipmapGenerator.d.ts.map +1 -1
  233. package/src/shade/renderer/texture/mipmaps/WebGPUMipmapGenerator.js +4 -23
  234. package/src/shade/renderer/texture/mipmaps/cpu/MipmapBilinearAxis.d.ts +53 -0
  235. package/src/shade/renderer/texture/mipmaps/cpu/MipmapBilinearAxis.d.ts.map +1 -0
  236. package/src/shade/renderer/texture/mipmaps/cpu/MipmapBilinearAxis.js +76 -0
  237. package/src/shade/renderer/texture/mipmaps/cpu/MipmapKernelAxis.d.ts +40 -0
  238. package/src/shade/renderer/texture/mipmaps/cpu/MipmapKernelAxis.d.ts.map +1 -0
  239. package/src/shade/renderer/texture/mipmaps/cpu/MipmapKernelAxis.js +43 -0
  240. package/src/shade/renderer/texture/mipmaps/cpu/mipmap_bilinear_centres.d.ts +17 -0
  241. package/src/shade/renderer/texture/mipmaps/cpu/mipmap_bilinear_centres.d.ts.map +1 -0
  242. package/src/shade/renderer/texture/mipmaps/cpu/mipmap_bilinear_centres.js +29 -0
  243. package/src/shade/renderer/texture/mipmaps/cpu/mipmap_bilinear_sample.d.ts +21 -0
  244. package/src/shade/renderer/texture/mipmaps/cpu/mipmap_bilinear_sample.d.ts.map +1 -0
  245. package/src/shade/renderer/texture/mipmaps/cpu/mipmap_bilinear_sample.js +91 -0
  246. package/src/shade/renderer/texture/mipmaps/cpu/mipmap_chain_cpu.d.ts +32 -0
  247. package/src/shade/renderer/texture/mipmaps/cpu/mipmap_chain_cpu.d.ts.map +1 -0
  248. package/src/shade/renderer/texture/mipmaps/cpu/mipmap_chain_cpu.js +216 -0
  249. package/src/shade/renderer/texture/mipmaps/cpu/mipmap_cubic_filter_cpu.d.ts +30 -0
  250. package/src/shade/renderer/texture/mipmaps/cpu/mipmap_cubic_filter_cpu.d.ts.map +1 -0
  251. package/src/shade/renderer/texture/mipmaps/cpu/mipmap_cubic_filter_cpu.js +134 -0
  252. package/src/shade/renderer/texture/mipmaps/cpu/mipmap_filter_catmull_rom_cpu.d.ts +16 -0
  253. package/src/shade/renderer/texture/mipmaps/cpu/mipmap_filter_catmull_rom_cpu.d.ts.map +1 -0
  254. package/src/shade/renderer/texture/mipmaps/cpu/mipmap_filter_catmull_rom_cpu.js +33 -0
  255. package/src/shade/renderer/texture/mipmaps/cpu/mipmap_filter_linear_cpu.d.ts +18 -0
  256. package/src/shade/renderer/texture/mipmaps/cpu/mipmap_filter_linear_cpu.d.ts.map +1 -0
  257. package/src/shade/renderer/texture/mipmaps/cpu/mipmap_filter_linear_cpu.js +71 -0
  258. package/src/shade/renderer/texture/mipmaps/cpu/mipmap_filter_linear_normal_cpu.d.ts +20 -0
  259. package/src/shade/renderer/texture/mipmaps/cpu/mipmap_filter_linear_normal_cpu.d.ts.map +1 -0
  260. package/src/shade/renderer/texture/mipmaps/cpu/mipmap_filter_linear_normal_cpu.js +57 -0
  261. package/src/shade/renderer/texture/mipmaps/cpu/mipmap_filter_magic_kernel_cpu.d.ts +18 -0
  262. package/src/shade/renderer/texture/mipmaps/cpu/mipmap_filter_magic_kernel_cpu.d.ts.map +1 -0
  263. package/src/shade/renderer/texture/mipmaps/cpu/mipmap_filter_magic_kernel_cpu.js +111 -0
  264. package/src/shade/renderer/texture/mipmaps/cpu/mipmap_filter_mitchell_cpu.d.ts +16 -0
  265. package/src/shade/renderer/texture/mipmaps/cpu/mipmap_filter_mitchell_cpu.d.ts.map +1 -0
  266. package/src/shade/renderer/texture/mipmaps/cpu/mipmap_filter_mitchell_cpu.js +33 -0
  267. package/src/shade/renderer/texture/mipmaps/cpu/mipmap_filter_mks_cpu.d.ts +18 -0
  268. package/src/shade/renderer/texture/mipmaps/cpu/mipmap_filter_mks_cpu.d.ts.map +1 -0
  269. package/src/shade/renderer/texture/mipmaps/cpu/mipmap_filter_mks_cpu.js +128 -0
  270. package/src/shade/renderer/texture/mipmaps/cpu/mipmap_filter_wronski2021_cpu.d.ts +21 -0
  271. package/src/shade/renderer/texture/mipmaps/cpu/mipmap_filter_wronski2021_cpu.d.ts.map +1 -0
  272. package/src/shade/renderer/texture/mipmaps/cpu/mipmap_filter_wronski2021_cpu.js +169 -0
  273. package/src/shade/renderer/texture/mipmaps/cpu/mipmap_kernel_reduce.d.ts +21 -0
  274. package/src/shade/renderer/texture/mipmaps/cpu/mipmap_kernel_reduce.d.ts.map +1 -0
  275. package/src/shade/renderer/texture/mipmaps/cpu/mipmap_kernel_reduce.js +119 -0
  276. package/src/shade/renderer/texture/mipmaps/cpu/mipmap_source_centre.d.ts +16 -0
  277. package/src/shade/renderer/texture/mipmaps/cpu/mipmap_source_centre.d.ts.map +1 -0
  278. package/src/shade/renderer/texture/mipmaps/cpu/mipmap_source_centre.js +19 -0
  279. package/src/shade/renderer/texture/mipmaps/cpu/texels_f32_to_rgba8unorm.d.ts +24 -0
  280. package/src/shade/renderer/texture/mipmaps/cpu/texels_f32_to_rgba8unorm.d.ts.map +1 -0
  281. package/src/shade/renderer/texture/mipmaps/cpu/texels_f32_to_rgba8unorm.js +41 -0
  282. package/src/shade/renderer/texture/mipmaps/cpu/texels_f32_to_rgba8unorm_srgb.d.ts +24 -0
  283. package/src/shade/renderer/texture/mipmaps/cpu/texels_f32_to_rgba8unorm_srgb.d.ts.map +1 -0
  284. package/src/shade/renderer/texture/mipmaps/cpu/texels_f32_to_rgba8unorm_srgb.js +140 -0
  285. package/src/shade/renderer/texture/mipmaps/cpu/texels_rgba8unorm_srgb_to_f32.d.ts +21 -0
  286. package/src/shade/renderer/texture/mipmaps/cpu/texels_rgba8unorm_srgb_to_f32.d.ts.map +1 -0
  287. package/src/shade/renderer/texture/mipmaps/cpu/texels_rgba8unorm_srgb_to_f32.js +35 -0
  288. package/src/shade/renderer/texture/mipmaps/cpu/texels_rgba8unorm_to_f32.d.ts +19 -0
  289. package/src/shade/renderer/texture/mipmaps/cpu/texels_rgba8unorm_to_f32.d.ts.map +1 -0
  290. package/src/shade/renderer/texture/mipmaps/cpu/texels_rgba8unorm_to_f32.js +27 -0
  291. package/src/shade/renderer/texture/mipmaps/filters/mipmap_shader_code_catmull_rom.js +4 -4
  292. package/src/shade/renderer/texture/mipmaps/filters/mipmap_shader_code_linear.d.ts +13 -0
  293. package/src/shade/renderer/texture/mipmaps/filters/mipmap_shader_code_linear.d.ts.map +1 -1
  294. package/src/shade/renderer/texture/mipmaps/filters/mipmap_shader_code_linear.js +54 -4
  295. package/src/shade/renderer/texture/mipmaps/filters/mipmap_shader_code_mitchell.js +4 -4
  296. package/src/shade/renderer/texture/mipmaps/filters/mipmap_shader_code_mks.d.ts.map +1 -1
  297. package/src/shade/renderer/texture/mipmaps/filters/mipmap_shader_code_mks.js +9 -13
  298. package/src/shade/renderer/texture/texture_block_encodings.d.ts +33 -0
  299. package/src/shade/renderer/texture/texture_block_encodings.d.ts.map +1 -0
  300. package/src/shade/renderer/texture/texture_block_encodings.js +89 -0
  301. package/src/format/texture/basis/astc_block.d.ts.map +0 -1
  302. package/src/format/texture/basis/astc_integer_sequence.d.ts.map +0 -1
  303. package/src/format/texture/basis/astc_partition.d.ts.map +0 -1
  304. package/src/format/texture/basis/uastc/bc7_tables.d.ts +0 -111
  305. package/src/format/texture/basis/uastc/bc7_tables.d.ts.map +0 -1
  306. package/src/format/texture/basis/uastc/bc7_write_block.d.ts +0 -124
  307. package/src/format/texture/basis/uastc/bc7_write_block.d.ts.map +0 -1
  308. /package/src/format/texture/{basis → astc}/astc_integer_sequence.d.ts +0 -0
  309. /package/src/format/texture/{basis → astc}/astc_partition.d.ts +0 -0
@@ -1,6 +1,12 @@
1
1
  import { Sampler2D } from "../../../../engine/graphics/texture/sampler/Sampler2D.js";
2
+ import { texel_decode_image, texel_decode_image_reads } from "../../../../format/texture/texel_decode_image.js";
2
3
  import { gpu_texture_format_feature } from "../../../descriptor/texture/format/gpu_texture_format_feature.js";
4
+ import { texture_mip_size } from "../../../util/texture_mip_extent.js";
3
5
  import { write_image_source } from "../../scene/serialization/write_image_source.js";
6
+ import { ColorSpace } from "../../texture/ColorSpace.js";
7
+ import { gpu_texture_format_without_srgb } from "../../texture/format/gpu_texture_format_without_srgb.js";
8
+ import { ShadeTextureFlags } from "../../texture/ShadeTextureFlags.js";
9
+ import { texture_block_encodings } from "../../texture/texture_block_encodings.js";
4
10
  import { texture_role_image_quality } from "../../texture/texture_role_image_quality.js";
5
11
  import { TextureVariantSet } from "../../texture/TextureVariantSet.js";
6
12
  import { mtf_texture_write } from "./mtf_texture_write.js";
@@ -8,6 +14,7 @@ import { mtf_texture_write } from "./mtf_texture_write.js";
8
14
  /**
9
15
  * @typedef {import("../../texture/ShadeTexture.js").ShadeTexture} ShadeTexture
10
16
  * @typedef {import("../../texture/TextureRole.js").TextureRole} TextureRole
17
+ * @typedef {import("../../texture/source/ShadeTexelData.js").ShadeTexelData} ShadeTexelData
11
18
  */
12
19
 
13
20
  /**
@@ -24,16 +31,68 @@ import { mtf_texture_write } from "./mtf_texture_write.js";
24
31
  */
25
32
 
26
33
  /**
27
- * The files of a texture when nothing builds block formats for it: its fallback, and no formats.
34
+ * The pixels of an `ImageBitmap`, read back through a canvas.
28
35
  *
29
- * - Decoded pixels become an AVIF, at the quality its role calls for ({@link texture_role_image_quality}). The
30
- * encoder is given a copy: it keeps what it is handed, and the model's own pixels are left as they were.
31
- * - Texels in a format every device samples become a texture file, as they are.
36
+ * @param {ImageBitmap} bitmap
37
+ * @param {string} label for the refusal
38
+ * @returns {Sampler2D} eight-bit RGBA
39
+ */
40
+ function bitmap_pixels(bitmap, label) {
41
+ if (typeof OffscreenCanvas === "undefined") {
42
+ throw new Error(`texture '${label}' is over an ImageBitmap, and reading its pixels needs OffscreenCanvas, which this environment does not have`);
43
+ }
44
+
45
+ const canvas = new OffscreenCanvas(bitmap.width, bitmap.height);
46
+ const context = canvas.getContext("2d");
47
+
48
+ context.drawImage(bitmap, 0, 0);
49
+
50
+ const image = context.getImageData(0, 0, bitmap.width, bitmap.height);
51
+
52
+ return new Sampler2D(new Uint8Array(image.data.buffer, image.data.byteOffset, image.data.byteLength), 4, bitmap.width, bitmap.height);
53
+ }
54
+
55
+ /**
56
+ * Every level of texels, as eight-bit pixels.
57
+ *
58
+ * @param {ShadeTexelData} texels
59
+ * @param {string} label for the refusal
60
+ * @returns {Sampler2D[]}
61
+ */
62
+ function texel_pixels(texels, label) {
63
+ const levels = [];
64
+
65
+ for (let level = 0; level < texels.level_count; level++) {
66
+ const width = texture_mip_size(texels.width, level);
67
+ const height = texture_mip_size(texels.height, level);
68
+
69
+ const pixels = texel_decode_image_reads(texels.format)
70
+ ? texel_decode_image(texels.format, width, height, texels.levels[level])
71
+ : null;
72
+
73
+ if (pixels === null || !(pixels.data instanceof Uint8Array)) {
74
+ throw new Error(`texture '${label}' brings '${texels.format}' texels, which decode to no eight-bit picture: neither a fallback nor another format can be made of them`);
75
+ }
76
+
77
+ levels.push(pixels);
78
+ }
79
+
80
+ return levels;
81
+ }
82
+
83
+ /**
84
+ * The files of a texture: its fallback, and a texture file in each block format it is built in.
32
85
  *
33
- * Texels in a block format are refused. A fallback is for a device that cannot sample them, and making one would
34
- * take decoding them.
86
+ * - **The fallback**, which every device can read: texels in a format every device samples are their own fallback,
87
+ * a texture file as they are; anything else becomes an AVIF of its base level, at the quality its role calls for
88
+ * ({@link texture_role_image_quality}).
89
+ * - **The block formats** are {@link texture_block_encodings}: those the role is built in, with the chain the
90
+ * texture asked for. Texels already in one of those formats are written in it as they are.
35
91
  *
36
- * A tool that builds block formats passes {@link mtf_export} its own {@link MTFTextureEncoder}.
92
+ * Texels in a block format are decoded for the rest. Texels that decode to no eight-bit picture (BC6H, the snorm
93
+ * formats) are refused.
94
+ *
95
+ * The model's own pixels are left as they were.
37
96
  *
38
97
  * @type {MTFTextureEncoder}
39
98
  *
@@ -42,37 +101,52 @@ import { mtf_texture_write } from "./mtf_texture_write.js";
42
101
  */
43
102
  export async function mtf_encode_texture(texture, role, stem, files) {
44
103
  const source = texture.image.source;
104
+ const label = texture.label;
45
105
 
46
- if (source !== undefined && source !== null && source.isShadeTexelData === true) {
47
- const format = source.format;
106
+ const texels = source !== undefined && source !== null && source.isShadeTexelData === true ? source : null;
48
107
 
49
- if (gpu_texture_format_feature(format) !== undefined) {
50
- throw new Error(`texture '${texture.label}' brings only '${format}' texels, which not every device samples: a fallback cannot be made of them without decoding them. Give it an encoder that has its pixels`);
51
- }
108
+ /** @type {Sampler2D[]} */
109
+ let levels;
52
110
 
53
- const uri = `${stem}.mtt`;
111
+ if (texels !== null) {
112
+ levels = texel_pixels(texels, label);
113
+ } else if (source !== undefined && source !== null && source.isSampler2D === true) {
114
+ levels = [source];
115
+ } else if (typeof ImageBitmap !== "undefined" && source instanceof ImageBitmap) {
116
+ levels = [bitmap_pixels(source, label)];
117
+ } else {
118
+ throw new Error(`texture '${label}' is over an image that is neither texels nor decoded pixels, and nothing here encodes it`);
119
+ }
54
120
 
55
- files.set(uri, mtf_texture_write(source));
121
+ let fallback;
56
122
 
57
- return new TextureVariantSet(uri, []);
58
- }
123
+ if (texels !== null && gpu_texture_format_feature(texels.format) === undefined) {
124
+ fallback = `${stem}.mtt`;
59
125
 
60
- const is_pixels = source !== undefined && source !== null
61
- && (source.isSampler2D === true || (typeof ImageBitmap !== "undefined" && source instanceof ImageBitmap));
126
+ files.set(fallback, mtf_texture_write(texels));
127
+ } else {
128
+ fallback = `${stem}.avif`;
62
129
 
63
- if (!is_pixels) {
64
- throw new Error(`texture '${texture.label}' is over an image that is neither texels nor decoded pixels, and nothing here encodes it`);
130
+ // the encoder keeps what it is given: a copy, so the model is still whole after its files are written
131
+ const base = levels[0];
132
+
133
+ files.set(fallback, await write_image_source(new Sampler2D(base.data.slice(), base.itemSize, base.width, base.height), texture_role_image_quality(role)));
65
134
  }
66
135
 
67
- const uri = `${stem}.avif`;
136
+ const generate = (texture.flags & ShadeTextureFlags.GenerateMipMaps) !== 0;
137
+ const srgb = (texture.color_space ?? texture.image.color_space) === ColorSpace.SRGB;
138
+
139
+ const own_format = texels !== null ? gpu_texture_format_without_srgb(texels.format) : null;
68
140
 
69
- // the encoder keeps what it is given: a copy, so the model is still whole after its files are written, and
70
- // an image met under two roles can be encoded twice
71
- const pixels = source.isSampler2D === true
72
- ? new Sampler2D(source.data.slice(), source.itemSize, source.width, source.height)
73
- : await createImageBitmap(source);
141
+ const by_format = [];
74
142
 
75
- files.set(uri, await write_image_source(pixels, texture_role_image_quality(role)));
143
+ for (const [format, encoded] of texture_block_encodings(levels, role, generate, texture.mipmapGenerationFilter, srgb)) {
144
+ const uri = `${stem}.${format}.mtt`;
145
+
146
+ files.set(uri, mtf_texture_write(format === own_format ? texels : encoded));
147
+
148
+ by_format.push([format, uri]);
149
+ }
76
150
 
77
- return new TextureVariantSet(uri, []);
151
+ return new TextureVariantSet(fallback, by_format);
78
152
  }
@@ -0,0 +1,19 @@
1
+ /**
2
+ * A package with its texture records replaced and everything after them as it was: the materials, geometries, nodes,
3
+ * skins and clips are carried over byte for byte, never read.
4
+ *
5
+ * This is how a package gains or loses encodings of its textures, a block format built after it was written say,
6
+ * without the model it was made from. The package keeps its version: what follows the records is as that version
7
+ * wrote it.
8
+ *
9
+ * @param {ArrayBuffer} file the package
10
+ * @param {MTFTexture[]} records one for each record the package holds, in its order: materials name records by index
11
+ * @returns {ArrayBuffer} the new package
12
+ * @throws {Error} if the bytes are not a package, or `records` is not as many as the package holds
13
+ *
14
+ * @author Alex Goldring
15
+ * @copyright Company Named Limited (c) 2026
16
+ */
17
+ export function mtf_replace_textures(file: ArrayBuffer, records: MTFTexture[]): ArrayBuffer;
18
+ export type MTFTexture = import("./MTFTexture.js").MTFTexture;
19
+ //# sourceMappingURL=mtf_replace_textures.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mtf_replace_textures.d.ts","sourceRoot":"","sources":["../../../../../../src/shade/renderer/loader/mtf/mtf_replace_textures.js"],"names":[],"mappings":"AAaA;;;;;;;;;;;;;;;GAeG;AACH,2CARW,WAAW,WACX,UAAU,EAAE,GACV,WAAW,CAoCvB;yBAnDY,OAAO,iBAAiB,EAAE,UAAU"}
@@ -0,0 +1,60 @@
1
+ import { BinaryBuffer } from "../../../../core/binary/BinaryBuffer.js";
2
+ import { BinaryCollectionSerializer } from "../../../../engine/ecs/storage/binary/collection/BinaryCollectionSerializer.js";
3
+ import { MTF_PACKAGE_MAGIC } from "./MTF_PACKAGE_MAGIC.js";
4
+ import { mtf_read_textures } from "./mtf_read_textures.js";
5
+ import { MTF_CLASS_TEXTURE, mtf_serialization_registry } from "./mtf_serialization_registry.js";
6
+ import { mtf_write_collection } from "./mtf_write_collection.js";
7
+
8
+ /**
9
+ * @typedef {import("./MTFTexture.js").MTFTexture} MTFTexture
10
+ */
11
+
12
+ const NO_OPTIONS = [];
13
+
14
+ /**
15
+ * A package with its texture records replaced and everything after them as it was: the materials, geometries, nodes,
16
+ * skins and clips are carried over byte for byte, never read.
17
+ *
18
+ * This is how a package gains or loses encodings of its textures, a block format built after it was written say,
19
+ * without the model it was made from. The package keeps its version: what follows the records is as that version
20
+ * wrote it.
21
+ *
22
+ * @param {ArrayBuffer} file the package
23
+ * @param {MTFTexture[]} records one for each record the package holds, in its order: materials name records by index
24
+ * @returns {ArrayBuffer} the new package
25
+ * @throws {Error} if the bytes are not a package, or `records` is not as many as the package holds
26
+ *
27
+ * @author Alex Goldring
28
+ * @copyright Company Named Limited (c) 2026
29
+ */
30
+ export function mtf_replace_textures(file, records) {
31
+ const source = BinaryBuffer.fromArrayBuffer(file);
32
+
33
+ const held = mtf_read_textures(source);
34
+
35
+ if (records.length !== held.length) {
36
+ throw new Error(`the package holds ${held.length} texture records, and ${records.length} were given to replace them`);
37
+ }
38
+
39
+ const rest_start = source.position;
40
+
41
+ const version = new DataView(file).getUint32(4, true);
42
+
43
+ const buffer = new BinaryBuffer();
44
+
45
+ buffer.writeUint32(MTF_PACKAGE_MAGIC);
46
+ buffer.writeUint32(version);
47
+
48
+ const serializer = new BinaryCollectionSerializer();
49
+
50
+ serializer.setRegistry(mtf_serialization_registry());
51
+ serializer.setBuffer(buffer);
52
+
53
+ mtf_write_collection(serializer, MTF_CLASS_TEXTURE, records, NO_OPTIONS);
54
+
55
+ buffer.writeBytes(new Uint8Array(file, rest_start), 0, file.byteLength - rest_start);
56
+
57
+ buffer.trim();
58
+
59
+ return buffer.data;
60
+ }
@@ -1 +1 @@
1
- {"version":3,"file":"mtf_write.d.ts","sourceRoot":"","sources":["../../../../../../src/shade/renderer/loader/mtf/mtf_write.js"],"names":[],"mappings":"AAiDA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH,kCAXW,WAAW,oBACX,IAAI,YAAY,EAAE,iBAAiB,CAAC,GAElC,WAAW,CAwFvB;0BA/IY,OAAO,mBAAmB,EAAE,WAAW;2BACvC,OAAO,+BAA+B,EAAE,YAAY;gCACpD,OAAO,oCAAoC,EAAE,iBAAiB"}
1
+ {"version":3,"file":"mtf_write.d.ts","sourceRoot":"","sources":["../../../../../../src/shade/renderer/loader/mtf/mtf_write.js"],"names":[],"mappings":"AAyBA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH,kCAXW,WAAW,oBACX,IAAI,YAAY,EAAE,iBAAiB,CAAC,GAElC,WAAW,CAwFvB;0BAtHY,OAAO,mBAAmB,EAAE,WAAW;2BACvC,OAAO,+BAA+B,EAAE,YAAY;gCACpD,OAAO,oCAAoC,EAAE,iBAAiB"}
@@ -12,6 +12,7 @@ import {
12
12
  MTF_CLASS_TEXTURE,
13
13
  mtf_serialization_registry
14
14
  } from "./mtf_serialization_registry.js";
15
+ import { mtf_write_collection } from "./mtf_write_collection.js";
15
16
  import { MTFTexture } from "./MTFTexture.js";
16
17
 
17
18
  /**
@@ -22,31 +23,6 @@ import { MTFTexture } from "./MTFTexture.js";
22
23
 
23
24
  const NO_OPTIONS = [];
24
25
 
25
- /**
26
- * @param {BinaryCollectionSerializer} serializer
27
- * @param {string} class_name
28
- * @param {Array} elements
29
- * @param {Array} adapter_options what the class's adapter is initialized with
30
- */
31
- function write_collection(serializer, class_name, elements, adapter_options) {
32
- serializer.setClass(class_name);
33
-
34
- // no dictionary: each object is written once already, by which object it is. A material's own equality does
35
- // not look at its name or its draw side, nor a geometry's at its name or its tree, and a dictionary would
36
- // write one of two such as a reference to the other
37
- const ready = serializer.initialize({ adapterOptionsSupplier: () => adapter_options, dictionary: false });
38
-
39
- if (!ready) {
40
- throw new Error(`no adapter is registered for '${class_name}'`);
41
- }
42
-
43
- for (let i = 0; i < elements.length; i++) {
44
- serializer.write(i, elements[i]);
45
- }
46
-
47
- serializer.finalize();
48
- }
49
-
50
26
  /**
51
27
  * A model as an MTF package: a header, then six collections in the order each needs the ones before it.
52
28
  *
@@ -148,12 +124,12 @@ export function mtf_write(bundle, texture_variants) {
148
124
  serializer.setRegistry(mtf_serialization_registry());
149
125
  serializer.setBuffer(buffer);
150
126
 
151
- write_collection(serializer, MTF_CLASS_TEXTURE, records, NO_OPTIONS);
152
- write_collection(serializer, MTF_CLASS_MATERIAL, materials, [textures]);
153
- write_collection(serializer, MTF_CLASS_GEOMETRY, geometries, NO_OPTIONS);
154
- write_collection(serializer, MTF_CLASS_NODE, nodes, [geometries, materials]);
155
- write_collection(serializer, MTF_CLASS_SKIN, bundle.skins, NO_OPTIONS);
156
- write_collection(serializer, MTF_CLASS_CLIP, bundle.clips, NO_OPTIONS);
127
+ mtf_write_collection(serializer, MTF_CLASS_TEXTURE, records, NO_OPTIONS);
128
+ mtf_write_collection(serializer, MTF_CLASS_MATERIAL, materials, [textures]);
129
+ mtf_write_collection(serializer, MTF_CLASS_GEOMETRY, geometries, NO_OPTIONS);
130
+ mtf_write_collection(serializer, MTF_CLASS_NODE, nodes, [geometries, materials]);
131
+ mtf_write_collection(serializer, MTF_CLASS_SKIN, bundle.skins, NO_OPTIONS);
132
+ mtf_write_collection(serializer, MTF_CLASS_CLIP, bundle.clips, NO_OPTIONS);
157
133
 
158
134
  buffer.trim();
159
135
 
@@ -0,0 +1,23 @@
1
+ /**
2
+ * @typedef {import("../../../../engine/ecs/storage/binary/collection/BinaryCollectionSerializer.js").BinaryCollectionSerializer} BinaryCollectionSerializer
3
+ */
4
+ /**
5
+ * One collection of an MTF package: the class's name and adapter version, the count, and each element by its adapter,
6
+ * keyed by its index.
7
+ *
8
+ * The serializer's dictionary is off: each object is written once already, by which object it is. A material's own
9
+ * equality does not look at its name or its draw side, nor a geometry's at its name or its tree, and a dictionary
10
+ * would write one of two such as a reference to the other.
11
+ *
12
+ * @param {BinaryCollectionSerializer} serializer with the package registry and buffer set
13
+ * @param {string} class_name
14
+ * @param {Array} elements
15
+ * @param {Array} adapter_options what the class's adapter is initialized with
16
+ * @throws {Error} if no adapter is registered for the class
17
+ *
18
+ * @author Alex Goldring
19
+ * @copyright Company Named Limited (c) 2026
20
+ */
21
+ export function mtf_write_collection(serializer: BinaryCollectionSerializer, class_name: string, elements: any[], adapter_options: any[]): void;
22
+ export type BinaryCollectionSerializer = import("../../../../engine/ecs/storage/binary/collection/BinaryCollectionSerializer.js").BinaryCollectionSerializer;
23
+ //# sourceMappingURL=mtf_write_collection.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mtf_write_collection.d.ts","sourceRoot":"","sources":["../../../../../../src/shade/renderer/loader/mtf/mtf_write_collection.js"],"names":[],"mappings":"AAAA;;GAEG;AAEH;;;;;;;;;;;;;;;;GAgBG;AACH,iDATW,0BAA0B,cAC1B,MAAM,iDAsBhB;yCAlCY,OAAO,gFAAgF,EAAE,0BAA0B"}
@@ -0,0 +1,36 @@
1
+ /**
2
+ * @typedef {import("../../../../engine/ecs/storage/binary/collection/BinaryCollectionSerializer.js").BinaryCollectionSerializer} BinaryCollectionSerializer
3
+ */
4
+
5
+ /**
6
+ * One collection of an MTF package: the class's name and adapter version, the count, and each element by its adapter,
7
+ * keyed by its index.
8
+ *
9
+ * The serializer's dictionary is off: each object is written once already, by which object it is. A material's own
10
+ * equality does not look at its name or its draw side, nor a geometry's at its name or its tree, and a dictionary
11
+ * would write one of two such as a reference to the other.
12
+ *
13
+ * @param {BinaryCollectionSerializer} serializer with the package registry and buffer set
14
+ * @param {string} class_name
15
+ * @param {Array} elements
16
+ * @param {Array} adapter_options what the class's adapter is initialized with
17
+ * @throws {Error} if no adapter is registered for the class
18
+ *
19
+ * @author Alex Goldring
20
+ * @copyright Company Named Limited (c) 2026
21
+ */
22
+ export function mtf_write_collection(serializer, class_name, elements, adapter_options) {
23
+ serializer.setClass(class_name);
24
+
25
+ const ready = serializer.initialize({ adapterOptionsSupplier: () => adapter_options, dictionary: false });
26
+
27
+ if (!ready) {
28
+ throw new Error(`no adapter is registered for '${class_name}'`);
29
+ }
30
+
31
+ for (let i = 0; i < elements.length; i++) {
32
+ serializer.write(i, elements[i]);
33
+ }
34
+
35
+ serializer.finalize();
36
+ }
@@ -0,0 +1,13 @@
1
+ /**
2
+ * Encode sixteen RGBA texels as one ASTC 4x4 block, alpha included.
3
+ *
4
+ * A block whose every alpha rounds to 255 is opaque and is written by
5
+ * {@link chunk_astc_encode_block_4x4_rgb}: colour endpoint mode 8, eight-bit ends, which decodes to an
6
+ * alpha of 255 — the nearest a block can come to such texels. Any other block is written by
7
+ * {@link chunk_astc_encode_block_4x4_rgba}, in colour endpoint mode 12, which stores the alpha.
8
+ *
9
+ * @type {CodeChunk}
10
+ */
11
+ export const chunk_astc_encode_block_4x4: CodeChunk;
12
+ import { CodeChunk } from "../../shader/compiler/CodeChunk.js";
13
+ //# sourceMappingURL=chunk_astc_encode_block_4x4.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"chunk_astc_encode_block_4x4.d.ts","sourceRoot":"","sources":["../../../../../../src/shade/renderer/texture/encode/chunk_astc_encode_block_4x4.js"],"names":[],"mappings":"AAIA;;;;;;;;;GASG;AACH,0CAFU,SAAS,CA0BZ;0BAtCmB,oCAAoC"}
@@ -0,0 +1,39 @@
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_astc_encode_block_4x4_rgba } from "./chunk_astc_encode_block_4x4_rgba.js";
4
+
5
+ /**
6
+ * Encode sixteen RGBA texels as one ASTC 4x4 block, alpha included.
7
+ *
8
+ * A block whose every alpha rounds to 255 is opaque and is written by
9
+ * {@link chunk_astc_encode_block_4x4_rgb}: colour endpoint mode 8, eight-bit ends, which decodes to an
10
+ * alpha of 255 — the nearest a block can come to such texels. Any other block is written by
11
+ * {@link chunk_astc_encode_block_4x4_rgba}, in colour endpoint mode 12, which stores the alpha.
12
+ *
13
+ * @type {CodeChunk}
14
+ */
15
+ export const chunk_astc_encode_block_4x4 = CodeChunk.from(
16
+ //language=WGSL
17
+ `
18
+ fn astc_encode_block_4x4(texels: array<vec4<f32>, 16>) -> vec4<u32> {
19
+ var rgb: array<vec3<f32>, 16>;
20
+ var opaque = true;
21
+
22
+ for (var i = 0u; i < 16u; i++) {
23
+ rgb[i] = texels[i].xyz;
24
+
25
+ if (round(clamp(texels[i].w, 0.0, 1.0) * 255.0) < 255.0) {
26
+ opaque = false;
27
+ }
28
+ }
29
+
30
+ if (opaque) {
31
+ return astc_encode_block_4x4_rgb(rgb);
32
+ }
33
+
34
+ return astc_encode_block_4x4_rgba(texels);
35
+ }
36
+ `, [
37
+ chunk_astc_encode_block_4x4_rgb,
38
+ chunk_astc_encode_block_4x4_rgba,
39
+ ]);
@@ -19,9 +19,10 @@
19
19
  *
20
20
  * Eight weight levels, unevenly spaced — `0, 9, 18, 27, 37, 46, 55, 64` of 64 — over eight-bit
21
21
  * ends: between BC1 and BC7 mode 6 in what it can hold, at BC7's eight bits a texel. The fit is
22
- * the principal axis, the extreme projections, two rounds of least squares with those weights, and
22
+ * the principal axis ({@link chunk_scatter_principal_axis}), the extreme projections, two rounds of least squares with those weights, and
23
23
  * one round of coordinate descent over the six stored bytes against the decoder's palette. Alpha
24
- * is not read: mode 8 carries none, and a cut-out wants the RGBA mode, which is a later chunk.
24
+ * is not read: mode 8 carries none. `astc_encode_block_4x4` gives this chunk the opaque blocks and
25
+ * the others to `chunk_astc_encode_block_4x4_rgba`.
25
26
  *
26
27
  * This is the only target here that no device in reach can sample, so it rests on the CPU decoder
27
28
  * alone — the decoder that §9.17 held against the reference encoder's blocks before trusting it.
@@ -1 +1 @@
1
- {"version":3,"file":"chunk_astc_encode_block_4x4_rgb.d.ts","sourceRoot":"","sources":["../../../../../../src/shade/renderer/texture/encode/chunk_astc_encode_block_4x4_rgb.js"],"names":[],"mappings":"AAGA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,8CAFU,SAAS,CAwRZ;0BAvTmB,oCAAoC"}
1
+ {"version":3,"file":"chunk_astc_encode_block_4x4_rgb.d.ts","sourceRoot":"","sources":["../../../../../../src/shade/renderer/texture/encode/chunk_astc_encode_block_4x4_rgb.js"],"names":[],"mappings":"AAIA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH,8CAFU,SAAS,CAuQZ;0BAxSmB,oCAAoC"}
@@ -1,5 +1,6 @@
1
1
  import { CodeChunk } from "../../shader/compiler/CodeChunk.js";
2
2
  import { chunk_astc_pack_4x4_rgb } from "./chunk_astc_pack_4x4_rgb.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 ASTC 4x4 block: one partition, eight-bit endpoints, three-bit
@@ -22,9 +23,10 @@ import { chunk_astc_pack_4x4_rgb } from "./chunk_astc_pack_4x4_rgb.js";
22
23
  *
23
24
  * Eight weight levels, unevenly spaced — `0, 9, 18, 27, 37, 46, 55, 64` of 64 — over eight-bit
24
25
  * ends: between BC1 and BC7 mode 6 in what it can hold, at BC7's eight bits a texel. The fit is
25
- * the principal axis, the extreme projections, two rounds of least squares with those weights, and
26
+ * the principal axis ({@link chunk_scatter_principal_axis}), the extreme projections, two rounds of least squares with those weights, and
26
27
  * one round of coordinate descent over the six stored bytes against the decoder's palette. Alpha
27
- * is not read: mode 8 carries none, and a cut-out wants the RGBA mode, which is a later chunk.
28
+ * is not read: mode 8 carries none. `astc_encode_block_4x4` gives this chunk the opaque blocks and
29
+ * the others to `chunk_astc_encode_block_4x4_rgba`.
28
30
  *
29
31
  * This is the only target here that no device in reach can sample, so it rests on the CPU decoder
30
32
  * alone — the decoder that §9.17 held against the reference encoder's blocks before trusting it.
@@ -207,25 +209,7 @@ fn astc_encode_block_4x4_rgb(texels: array<vec3<f32>, 16>) -> vec4<u32> {
207
209
  cov[5] += d.z * d.z;
208
210
  }
209
211
 
210
- var axis = extent;
211
-
212
- for (var iteration = 0u; iteration < 4u; iteration++) {
213
- let next = vec3<f32>(
214
- cov[0] * axis.x + cov[1] * axis.y + cov[2] * axis.z,
215
- cov[1] * axis.x + cov[3] * axis.y + cov[4] * axis.z,
216
- cov[2] * axis.x + cov[4] * axis.y + cov[5] * axis.z
217
- );
218
-
219
- let magnitude = length(next);
220
-
221
- if (magnitude < 1e-3) {
222
- break;
223
- }
224
-
225
- axis = next / magnitude;
226
- }
227
-
228
- axis = normalize(axis);
212
+ let axis = scatter3_principal_axis(cov);
229
213
 
230
214
  var t_min = 1e30;
231
215
  var t_max = -1e30;
@@ -309,4 +293,5 @@ fn astc_encode_block_4x4_rgb(texels: array<vec3<f32>, 16>) -> vec4<u32> {
309
293
  }
310
294
  `, [
311
295
  chunk_astc_pack_4x4_rgb,
296
+ chunk_scatter_principal_axis,
312
297
  ]);
@@ -0,0 +1,42 @@
1
+ /**
2
+ * Encode sixteen RGBA texels as one ASTC 4x4 block that holds their alpha: one partition, colour
3
+ * endpoint mode 12 (LDR RGBA, direct), in whichever of two layouts decodes nearer the texels.
4
+ *
5
+ * **The two layouts, and why these.** After the seventeen bits of block mode, partition count and
6
+ * endpoint mode, 111 bits remain for eight endpoint values and the weights, and a weight range fixes
7
+ * the endpoint range: the decoder takes the finest range whose integer sequence fits what the
8
+ * weights leave.
9
+ *
10
+ * 1. **One plane**: a single line through all four channels, sixteen weights of eight levels
11
+ * (48 bits), so the endpoints get 192 levels (six bits and a trit each, 61 bits). The weights are
12
+ * mode 8's own, and the ends nearly as fine as its eight bits. It holds an alpha that is constant,
13
+ * or that moves with the colour.
14
+ * 2. **Two planes**, the colour on one line and alpha on a second plane of weights of its own
15
+ * (colour component selector 3): thirty-two weights of five levels (75 bits as quints) and two
16
+ * bits of selector leave the endpoints 16 levels (four bits each). It holds an alpha that moves
17
+ * independently of the colour — a cut-out's edge, where the alpha crosses its whole range inside
18
+ * a block. There a weight's error, the range over the steps between levels, outweighs an end's:
19
+ * with eight weight levels the ends would get three, with four they would get 48 levels and the
20
+ * alpha only four levels across its range.
21
+ *
22
+ * Both are fitted and the one whose decoded squared error over all four channels is smaller is
23
+ * written; an equal error keeps the single plane. That is how ARM's astcenc chooses between the
24
+ * layouts it tries, restricted to two.
25
+ *
26
+ * **The fit** is the RGB encoder's, generalised over which channels a line carries: the principal
27
+ * axis of the scatter (`chunk_scatter_principal_axis`), the extreme projections, two rounds of least
28
+ * squares with each texel at its nearest weight, then the ends on the endpoint range and one round of
29
+ * coordinate descent over the eight stored values, one level either way, scored against the colours
30
+ * the format decodes. The two-plane layout fits the colour and the alpha as separate lines. Both
31
+ * write the pair the way round colour endpoint mode 12 reads without swapping — the second end's
32
+ * colour sum not below the first's — by swapping the ends and inverting every weight, which decodes
33
+ * identically.
34
+ *
35
+ * Every texel is clamped to [0, 1]. The opaque block is not this chunk's: `astc_encode_block_4x4`
36
+ * gives it the RGB block, whose ends are finer.
37
+ *
38
+ * @type {CodeChunk}
39
+ */
40
+ export const chunk_astc_encode_block_4x4_rgba: CodeChunk;
41
+ import { CodeChunk } from "../../shader/compiler/CodeChunk.js";
42
+ //# sourceMappingURL=chunk_astc_encode_block_4x4_rgba.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"chunk_astc_encode_block_4x4_rgba.d.ts","sourceRoot":"","sources":["../../../../../../src/shade/renderer/texture/encode/chunk_astc_encode_block_4x4_rgba.js"],"names":[],"mappings":"AAIA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsCG;AACH,+CAFU,SAAS,CA0jBZ;0BAnmBmB,oCAAoC"}