@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,227 +1,185 @@
1
- /**
2
- * Bytes one BC7 block occupies.
3
- *
4
- * @readonly
5
- * @type {number}
6
- */
7
- export const BC7_BLOCK_BYTES = 16;
8
-
9
- /**
10
- * What one BC7 mode stores, from the specification's mode table.
11
- *
12
- * The field *order* is the same for every mode — partition, rotation, index selection, colour,
13
- * alpha, per-endpoint parity, shared parity, indices — so a mode is entirely described by how many
14
- * bits it gives each, which is what makes one writer enough for all of them.
15
- *
16
- * @typedef {object} Bc7Mode
17
- * @property {number} subsets
18
- * @property {number} partition_bits
19
- * @property {number} rotation_bits
20
- * @property {number} color_bits
21
- * @property {number} alpha_bits `0` where the mode has no alpha, which then decodes as opaque
22
- * @property {number} endpoint_parity_bits one parity bit per endpoint, `0` or `1`
23
- * @property {number} shared_parity_bits one parity bit per *subset*, shared by both its endpoints
24
- * @property {number} index_bits
25
- * @property {number} secondary_index_bits `0` unless the mode has a second index set
26
- */
27
-
28
- /**
29
- * Every BC7 mode this writes, from Table.M of the specification.
30
- *
31
- * Modes 0 and 4 are absent: no UASTC mode maps to either, so writing them would be code with no
32
- * caller and no test.
33
- *
34
- * @readonly
35
- * @type {Object<number, Bc7Mode>}
36
- */
37
- export const BC7_MODES = {
38
- 1: {
39
- subsets: 2, partition_bits: 6, rotation_bits: 0, color_bits: 6, alpha_bits: 0,
40
- endpoint_parity_bits: 0, shared_parity_bits: 1, index_bits: 3, secondary_index_bits: 0,
41
- },
42
- 2: {
43
- subsets: 3, partition_bits: 6, rotation_bits: 0, color_bits: 5, alpha_bits: 0,
44
- endpoint_parity_bits: 0, shared_parity_bits: 0, index_bits: 2, secondary_index_bits: 0,
45
- },
46
- 3: {
47
- subsets: 2, partition_bits: 6, rotation_bits: 0, color_bits: 7, alpha_bits: 0,
48
- endpoint_parity_bits: 1, shared_parity_bits: 0, index_bits: 2, secondary_index_bits: 0,
49
- },
50
- 5: {
51
- subsets: 1, partition_bits: 0, rotation_bits: 2, color_bits: 7, alpha_bits: 8,
52
- endpoint_parity_bits: 0, shared_parity_bits: 0, index_bits: 2, secondary_index_bits: 2,
53
- },
54
- 6: {
55
- subsets: 1, partition_bits: 0, rotation_bits: 0, color_bits: 7, alpha_bits: 7,
56
- endpoint_parity_bits: 1, shared_parity_bits: 0, index_bits: 4, secondary_index_bits: 0,
57
- },
58
- 7: {
59
- subsets: 2, partition_bits: 6, rotation_bits: 0, color_bits: 5, alpha_bits: 5,
60
- endpoint_parity_bits: 1, shared_parity_bits: 0, index_bits: 2, secondary_index_bits: 0,
61
- },
62
- };
63
-
64
- /**
65
- * The eight-bit value a stored endpoint component decodes to.
66
- *
67
- * The parity bit, where the mode has one, sits *below* the stored bits — so a five-bit component
68
- * with a parity bit is a six-bit value — and the result is then widened to eight by replicating its
69
- * top bits downward.
70
- *
71
- * @param {number} stored
72
- * @param {number} bits including the parity bit
73
- * @returns {number}
74
- */
75
- export function bc7_expand_endpoint(stored, bits) {
76
- if (bits >= 8) {
77
- return stored & 255;
78
- }
79
-
80
- return ((stored << (8 - bits)) | (stored >>> (2 * bits - 8))) & 255;
81
- }
82
-
83
- /**
84
- * Quantise an eight-bit value to what a mode can store, optionally forced to a parity.
85
- *
86
- * @param {number} value
87
- * @param {number} bits including the parity bit, where there is one
88
- * @param {number} parity `-1` when the mode has none
89
- * @returns {number} the value including its parity bit, so `bits` wide
90
- */
91
- export function bc7_quantise_endpoint(value, bits, parity) {
92
- const max = (1 << bits) - 1;
93
-
94
- let quantised = Math.round((value * max) / 255);
95
-
96
- if (parity >= 0 && (quantised & 1) !== parity) {
97
- /*
98
- Both neighbours are equally far, so the one that stays inside the range wins and otherwise
99
- the one nearer the original value does.
100
- */
101
- const lower = quantised - 1;
102
- const upper = quantised + 1;
103
-
104
- const ideal = (value * max) / 255;
105
-
106
- quantised = lower < 0 ? upper
107
- : upper > max ? lower
108
- : (Math.abs(ideal - lower) <= Math.abs(ideal - upper) ? lower : upper);
109
- }
110
-
111
- return quantised < 0 ? (parity < 0 ? 0 : parity)
112
- : quantised > max ? (max - ((max & 1) === parity || parity < 0 ? 0 : 1))
113
- : quantised;
114
- }
115
-
116
- /**
117
- * Write one BC7 block.
118
- *
119
- * **One writer for every mode**, because the specification says the fields are always in the same
120
- * order and only their widths change. Writing each mode out separately would be the same sequence
121
- * five times with different constants, and the constants are already a table.
122
- *
123
- * Endpoints are ordered as the specification stores them: by channel, then by subset, then by
124
- * endpoint — so red for both ends of subset 0, then both ends of subset 1, then green, and so on.
125
- *
126
- * @param {Uint8Array} out
127
- * @param {number} byte_offset of the block
128
- * @param {number} mode
129
- * @param {object} block
130
- * @param {number} [block.partition] index into BC7's partition table
131
- * @param {number} [block.rotation]
132
- * @param {Uint8Array} block.endpoints `subsets * 2 * 4` stored fields, low then high RGBA per
133
- * subset — already quantised to the mode's width, with any parity bit held separately
134
- * @param {Uint8Array} block.indices sixteen
135
- * @param {Uint8Array} [block.secondary_indices] sixteen, for a mode with two index sets
136
- * @param {Uint8Array} block.anchors one texel index per subset
137
- * @param {Int8Array} [block.parity] one bit per endpoint, or per subset for a shared-parity mode
138
- *
139
- * @author Alex Goldring
140
- * @copyright Company Named Limited (c) 2026
141
- */
142
- export function bc7_write_block(out, byte_offset, mode, block) {
143
- const spec = BC7_MODES[mode];
144
-
145
- let bit = byte_offset * 8;
146
-
147
- /**
148
- * @param {number} value
149
- * @param {number} count
150
- */
151
- const write = (value, count) => {
152
- for (let i = 0; i < count; i++) {
153
- if (((value >> i) & 1) !== 0) {
154
- out[(bit + i) >> 3] |= 1 << ((bit + i) & 7);
155
- }
156
- }
157
-
158
- bit += count;
159
- };
160
-
161
- // a mode is signalled by that many zero bits followed by a one
162
- write(1 << mode, mode + 1);
163
-
164
- write(block.partition ?? 0, spec.partition_bits);
165
- write(block.rotation ?? 0, spec.rotation_bits);
166
-
167
- for (let channel = 0; channel < 3; channel++) {
168
- for (let subset = 0; subset < spec.subsets; subset++) {
169
- for (let end = 0; end < 2; end++) {
170
- write(block.endpoints[(subset * 2 + end) * 4 + channel], spec.color_bits);
171
- }
172
- }
173
- }
174
-
175
- if (spec.alpha_bits > 0) {
176
- for (let subset = 0; subset < spec.subsets; subset++) {
177
- for (let end = 0; end < 2; end++) {
178
- write(block.endpoints[(subset * 2 + end) * 4 + 3], spec.alpha_bits);
179
- }
180
- }
181
- }
182
-
183
- if (spec.endpoint_parity_bits > 0) {
184
- for (let subset = 0; subset < spec.subsets; subset++) {
185
- for (let end = 0; end < 2; end++) {
186
- write(block.parity[subset * 2 + end], 1);
187
- }
188
- }
189
- }
190
-
191
- if (spec.shared_parity_bits > 0) {
192
- for (let subset = 0; subset < spec.subsets; subset++) {
193
- write(block.parity[subset], 1);
194
- }
195
- }
196
-
197
- write_indices(write, block.indices, block.anchors, spec.subsets, spec.index_bits);
198
-
199
- if (spec.secondary_index_bits > 0) {
200
- write_indices(
201
- write, block.secondary_indices, block.anchors, spec.subsets, spec.secondary_index_bits
202
- );
203
- }
204
- }
205
-
206
- /**
207
- * @param {function(number, number): void} write
208
- * @param {Uint8Array} indices
209
- * @param {Uint8Array} anchors one texel per subset
210
- * @param {number} subsets
211
- * @param {number} bits
212
- */
213
- function write_indices(write, indices, anchors, subsets, bits) {
214
- for (let texel = 0; texel < 16; texel++) {
215
- let anchor = false;
216
-
217
- for (let subset = 0; subset < subsets; subset++) {
218
- if (anchors[subset] === texel) {
219
- anchor = true;
220
-
221
- break;
222
- }
223
- }
224
-
225
- write(indices[texel], anchor ? bits - 1 : bits);
226
- }
227
- }
1
+ import { BC7_MODES } from "./bc7_tables.js";
2
+
3
+ /**
4
+ * Bytes one BC7 block occupies.
5
+ *
6
+ * @readonly
7
+ * @type {number}
8
+ */
9
+ export const BC7_BLOCK_BYTES = 16;
10
+
11
+ /**
12
+ * The eight-bit value a stored endpoint component decodes to.
13
+ *
14
+ * The parity bit, where the mode has one, sits *below* the stored bits — so a five-bit component
15
+ * with a parity bit is a six-bit value — and the result is then widened to eight by replicating its
16
+ * top bits downward.
17
+ *
18
+ * @param {number} stored
19
+ * @param {number} bits including the parity bit
20
+ * @returns {number}
21
+ */
22
+ export function bc7_expand_endpoint(stored, bits) {
23
+ if (bits >= 8) {
24
+ return stored & 255;
25
+ }
26
+
27
+ return ((stored << (8 - bits)) | (stored >>> (2 * bits - 8))) & 255;
28
+ }
29
+
30
+ /**
31
+ * Quantise an eight-bit value to what a mode can store, optionally forced to a parity.
32
+ *
33
+ * @param {number} value
34
+ * @param {number} bits including the parity bit, where there is one
35
+ * @param {number} parity `-1` when the mode has none
36
+ * @returns {number} the value including its parity bit, so `bits` wide
37
+ */
38
+ export function bc7_quantise_endpoint(value, bits, parity) {
39
+ const max = (1 << bits) - 1;
40
+
41
+ let quantised = Math.round((value * max) / 255);
42
+
43
+ if (parity >= 0 && (quantised & 1) !== parity) {
44
+ /*
45
+ Both neighbours are equally far, so the one that stays inside the range wins and otherwise
46
+ the one nearer the original value does.
47
+ */
48
+ const lower = quantised - 1;
49
+ const upper = quantised + 1;
50
+
51
+ const ideal = (value * max) / 255;
52
+
53
+ quantised = lower < 0 ? upper
54
+ : upper > max ? lower
55
+ : (Math.abs(ideal - lower) <= Math.abs(ideal - upper) ? lower : upper);
56
+ }
57
+
58
+ return quantised < 0 ? (parity < 0 ? 0 : parity)
59
+ : quantised > max ? (max - ((max & 1) === parity || parity < 0 ? 0 : 1))
60
+ : quantised;
61
+ }
62
+
63
+ /**
64
+ * Where the next field goes, in bits from the start of the output.
65
+ *
66
+ * @type {number}
67
+ */
68
+ let cursor = 0;
69
+
70
+ /**
71
+ * Write a field at {@link cursor}, lowest bit first, and move past it. The bits it lands on are zero.
72
+ *
73
+ * @param {Uint8Array} out
74
+ * @param {number} value
75
+ * @param {number} count
76
+ */
77
+ function write_field(out, value, count) {
78
+ for (let i = 0; i < count; i++) {
79
+ if (((value >> i) & 1) !== 0) {
80
+ out[(cursor + i) >> 3] |= 1 << ((cursor + i) & 7);
81
+ }
82
+ }
83
+
84
+ cursor += count;
85
+ }
86
+
87
+ /**
88
+ * Write one BC7 block, all sixteen of its bytes.
89
+ *
90
+ * **One writer for every mode** ({@link BC7_MODES}), because the specification says the fields are always in the
91
+ * same order and only their widths change.
92
+ *
93
+ * Endpoints are ordered as the specification stores them: by channel, then by subset, then by
94
+ * endpoint — so red for both ends of subset 0, then both ends of subset 1, then green, and so on.
95
+ *
96
+ * @param {Uint8Array} out
97
+ * @param {number} byte_offset of the block
98
+ * @param {number} mode
99
+ * @param {object} block
100
+ * @param {number} [block.partition] index into BC7's partition table
101
+ * @param {number} [block.rotation]
102
+ * @param {number} [block.index_selection] mode 4's: `1` gives colour the secondary indices and alpha the primary
103
+ * @param {Uint8Array} block.endpoints `subsets * 2 * 4` stored fields, low then high RGBA per
104
+ * subset — already quantised to the mode's width, with any parity bit held separately
105
+ * @param {Uint8Array} block.indices sixteen
106
+ * @param {Uint8Array} [block.secondary_indices] sixteen, for a mode with two index sets
107
+ * @param {Uint8Array} block.anchors one texel index per subset
108
+ * @param {Int8Array} [block.parity] one bit per endpoint, or per subset for a shared-parity mode
109
+ *
110
+ * @author Alex Goldring
111
+ * @copyright Company Named Limited (c) 2026
112
+ */
113
+ export function bc7_write_block(out, byte_offset, mode, block) {
114
+ const spec = BC7_MODES[mode];
115
+
116
+ out.fill(0, byte_offset, byte_offset + BC7_BLOCK_BYTES);
117
+
118
+ cursor = byte_offset * 8;
119
+
120
+ // a mode is signalled by that many zero bits followed by a one
121
+ write_field(out, 1 << mode, mode + 1);
122
+
123
+ write_field(out, block.partition ?? 0, spec.partition_bits);
124
+ write_field(out, block.rotation ?? 0, spec.rotation_bits);
125
+ write_field(out, block.index_selection ?? 0, spec.index_selection_bits);
126
+
127
+ for (let channel = 0; channel < 3; channel++) {
128
+ for (let subset = 0; subset < spec.subsets; subset++) {
129
+ for (let end = 0; end < 2; end++) {
130
+ write_field(out, block.endpoints[(subset * 2 + end) * 4 + channel], spec.color_bits);
131
+ }
132
+ }
133
+ }
134
+
135
+ if (spec.alpha_bits > 0) {
136
+ for (let subset = 0; subset < spec.subsets; subset++) {
137
+ for (let end = 0; end < 2; end++) {
138
+ write_field(out, block.endpoints[(subset * 2 + end) * 4 + 3], spec.alpha_bits);
139
+ }
140
+ }
141
+ }
142
+
143
+ if (spec.endpoint_parity_bits > 0) {
144
+ for (let subset = 0; subset < spec.subsets; subset++) {
145
+ for (let end = 0; end < 2; end++) {
146
+ write_field(out, block.parity[subset * 2 + end], 1);
147
+ }
148
+ }
149
+ }
150
+
151
+ if (spec.shared_parity_bits > 0) {
152
+ for (let subset = 0; subset < spec.subsets; subset++) {
153
+ write_field(out, block.parity[subset], 1);
154
+ }
155
+ }
156
+
157
+ write_indices(out, block.indices, block.anchors, spec.subsets, spec.index_bits);
158
+
159
+ if (spec.secondary_index_bits > 0) {
160
+ write_indices(out, block.secondary_indices, block.anchors, spec.subsets, spec.secondary_index_bits);
161
+ }
162
+ }
163
+
164
+ /**
165
+ * @param {Uint8Array} out
166
+ * @param {Uint8Array} indices
167
+ * @param {Uint8Array} anchors one texel per subset
168
+ * @param {number} subsets
169
+ * @param {number} bits
170
+ */
171
+ function write_indices(out, indices, anchors, subsets, bits) {
172
+ for (let texel = 0; texel < 16; texel++) {
173
+ let anchor = false;
174
+
175
+ for (let subset = 0; subset < subsets; subset++) {
176
+ if (anchors[subset] === texel) {
177
+ anchor = true;
178
+
179
+ break;
180
+ }
181
+ }
182
+
183
+ write_field(out, indices[texel], anchor ? bits - 1 : bits);
184
+ }
185
+ }
@@ -0,0 +1,50 @@
1
+ /**
2
+ * Decode one EAC block in the specification's eight-bit arithmetic, the alpha half of an ETC2 RGBA8
3
+ * block: `clamp255(base + modifier × multiplier)`, a multiplier of 0 giving every texel the base.
4
+ *
5
+ * @param {Uint8Array} source
6
+ * @param {number} offset byte offset of the eight-byte block
7
+ * @param {Uint8Array} out sixteen RGBA texels in raster order; only `channel` is written
8
+ * @param {number} channel `0..3`
9
+ *
10
+ * @see Khronos Data Format Specification 1.3, section 22.3
11
+ * @author Alex Goldring
12
+ * @copyright Company Named Limited (c) 2026
13
+ */
14
+ export function eac_decode_channel_alpha8(source: Uint8Array, offset: number, out: Uint8Array, channel: number): void;
15
+ /**
16
+ * Decode one EAC block in the specification's eleven-bit unsigned arithmetic, the R11 form:
17
+ * `clamp(base × 8 + 4 + modifier × multiplier × 8)` to `[0, 2047]`, with `modifier` alone in place
18
+ * of the product when the multiplier is 0. 2047 represents 1.0; the specification gives no rule for
19
+ * fewer than eleven bits, so each value is written as the nearest eight-bit unorm,
20
+ * `round(value × 255 / 2047)` — exact in integers, as no value lies halfway.
21
+ *
22
+ * @param {Uint8Array} source
23
+ * @param {number} offset byte offset of the eight-byte block
24
+ * @param {Uint8Array} out sixteen RGBA texels in raster order; only `channel` is written
25
+ * @param {number} channel `0..3`
26
+ *
27
+ * @see Khronos Data Format Specification 1.3, section 22.5
28
+ * @author Alex Goldring
29
+ * @copyright Company Named Limited (c) 2026
30
+ */
31
+ export function eac_decode_channel_unorm11(source: Uint8Array, offset: number, out: Uint8Array, channel: number): void;
32
+ /**
33
+ * Decode one EAC block in the specification's eleven-bit signed arithmetic, the signed R11 form:
34
+ * the base codeword a two's-complement byte read as -127 when it is -128, then
35
+ * `clamp(base × 8 + modifier × multiplier × 8)` to `[-1023, 1023]`, with `modifier` alone in place
36
+ * of the product when the multiplier is 0. 1023 represents 1.0; the specification gives no rule for
37
+ * fewer than eleven bits, so each value is written as the nearest eight-bit snorm,
38
+ * `round(value × 127 / 1023)` — exact in integers, as no value lies halfway.
39
+ *
40
+ * @param {Uint8Array} source
41
+ * @param {number} offset byte offset of the eight-byte block
42
+ * @param {Int8Array} out sixteen RGBA texels in raster order; only `channel` is written
43
+ * @param {number} channel `0..3`
44
+ *
45
+ * @see Khronos Data Format Specification 1.3, section 22.7
46
+ * @author Alex Goldring
47
+ * @copyright Company Named Limited (c) 2026
48
+ */
49
+ export function eac_decode_channel_snorm11(source: Uint8Array, offset: number, out: Int8Array, channel: number): void;
50
+ //# sourceMappingURL=eac_decode_channel.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"eac_decode_channel.d.ts","sourceRoot":"","sources":["../../../../../src/format/texture/etc/eac_decode_channel.js"],"names":[],"mappings":"AA2DA;;;;;;;;;;;;GAYG;AACH,kDATW,UAAU,UACV,MAAM,OACN,UAAU,WACV,MAAM,QAYhB;AAED;;;;;;;;;;;;;;;GAeG;AACH,mDATW,UAAU,UACV,MAAM,OACN,UAAU,WACV,MAAM,QAiBhB;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,mDATW,UAAU,UACV,MAAM,OACN,SAAS,WACT,MAAM,QAqBhB"}
@@ -0,0 +1,142 @@
1
+ import { EAC_MODIFIERS } from "./eac_modifiers.js";
2
+
3
+ /**
4
+ * Scratch: the eight values a block's indices select.
5
+ *
6
+ * @type {Int32Array}
7
+ */
8
+ const palette = new Int32Array(8);
9
+
10
+ /**
11
+ * Fill {@link palette} with the specification's sum for each of a row's eight modifiers,
12
+ * `clamp(base + modifier × multiplier)` to `[low, high]`. The two arithmetics differ only in these
13
+ * terms: the eight-bit alpha form passes the base codeword and the multiplier as they are, the
14
+ * eleven-bit form passes them scaled by 8 (with the unsigned form's +4 in the base, and a multiplier
15
+ * of 0 standing for 1/8).
16
+ *
17
+ * @param {number} table `0..15`
18
+ * @param {number} base
19
+ * @param {number} multiplier
20
+ * @param {number} low
21
+ * @param {number} high
22
+ */
23
+ function fill_palette(table, base, multiplier, low, high) {
24
+ const row = table * 8;
25
+
26
+ for (let i = 0; i < 8; i++) {
27
+ const value = base + EAC_MODIFIERS[row + i] * multiplier;
28
+
29
+ palette[i] = value < low ? low : value > high ? high : value;
30
+ }
31
+ }
32
+
33
+ /**
34
+ * Write {@link palette}'s entry for each texel's index into one channel of `out`.
35
+ *
36
+ * The forty-eight index bits are bits 47..0 of the block, three per texel from the top, the texels
37
+ * lettered a..p down each column: letter `k`, texel (k >> 2, k & 3), holds bits `47 - 3k` to
38
+ * `45 - 3k`. Letters 0..7 fill bytes 2..4 and letters 8..15 bytes 5..7.
39
+ *
40
+ * @param {Uint8Array} source
41
+ * @param {number} offset of the block
42
+ * @param {Uint8Array|Int8Array} out sixteen RGBA texels, raster order
43
+ * @param {number} channel `0..3`
44
+ */
45
+ function write_channel(source, offset, out, channel) {
46
+ const first = (source[offset + 2] << 16) | (source[offset + 3] << 8) | source[offset + 4];
47
+ const second = (source[offset + 5] << 16) | (source[offset + 6] << 8) | source[offset + 7];
48
+
49
+ for (let k = 0; k < 8; k++) {
50
+ const shift = 21 - 3 * k;
51
+
52
+ // letter k is column k >> 2, row k & 3; letter k + 8 is two columns further right
53
+ const texel = (k & 3) * 4 + (k >> 2);
54
+
55
+ out[texel * 4 + channel] = palette[(first >>> shift) & 7];
56
+ out[(texel + 2) * 4 + channel] = palette[(second >>> shift) & 7];
57
+ }
58
+ }
59
+
60
+ /**
61
+ * Decode one EAC block in the specification's eight-bit arithmetic, the alpha half of an ETC2 RGBA8
62
+ * block: `clamp255(base + modifier × multiplier)`, a multiplier of 0 giving every texel the base.
63
+ *
64
+ * @param {Uint8Array} source
65
+ * @param {number} offset byte offset of the eight-byte block
66
+ * @param {Uint8Array} out sixteen RGBA texels in raster order; only `channel` is written
67
+ * @param {number} channel `0..3`
68
+ *
69
+ * @see Khronos Data Format Specification 1.3, section 22.3
70
+ * @author Alex Goldring
71
+ * @copyright Company Named Limited (c) 2026
72
+ */
73
+ export function eac_decode_channel_alpha8(source, offset, out, channel) {
74
+ const header = source[offset + 1];
75
+
76
+ fill_palette(header & 15, source[offset], header >> 4, 0, 255);
77
+
78
+ write_channel(source, offset, out, channel);
79
+ }
80
+
81
+ /**
82
+ * Decode one EAC block in the specification's eleven-bit unsigned arithmetic, the R11 form:
83
+ * `clamp(base × 8 + 4 + modifier × multiplier × 8)` to `[0, 2047]`, with `modifier` alone in place
84
+ * of the product when the multiplier is 0. 2047 represents 1.0; the specification gives no rule for
85
+ * fewer than eleven bits, so each value is written as the nearest eight-bit unorm,
86
+ * `round(value × 255 / 2047)` — exact in integers, as no value lies halfway.
87
+ *
88
+ * @param {Uint8Array} source
89
+ * @param {number} offset byte offset of the eight-byte block
90
+ * @param {Uint8Array} out sixteen RGBA texels in raster order; only `channel` is written
91
+ * @param {number} channel `0..3`
92
+ *
93
+ * @see Khronos Data Format Specification 1.3, section 22.5
94
+ * @author Alex Goldring
95
+ * @copyright Company Named Limited (c) 2026
96
+ */
97
+ export function eac_decode_channel_unorm11(source, offset, out, channel) {
98
+ const header = source[offset + 1];
99
+ const multiplier = header >> 4;
100
+
101
+ fill_palette(header & 15, source[offset] * 8 + 4, multiplier === 0 ? 1 : multiplier * 8, 0, 2047);
102
+
103
+ for (let i = 0; i < 8; i++) {
104
+ palette[i] = ((palette[i] * 510 + 2047) / 4094) | 0;
105
+ }
106
+
107
+ write_channel(source, offset, out, channel);
108
+ }
109
+
110
+ /**
111
+ * Decode one EAC block in the specification's eleven-bit signed arithmetic, the signed R11 form:
112
+ * the base codeword a two's-complement byte read as -127 when it is -128, then
113
+ * `clamp(base × 8 + modifier × multiplier × 8)` to `[-1023, 1023]`, with `modifier` alone in place
114
+ * of the product when the multiplier is 0. 1023 represents 1.0; the specification gives no rule for
115
+ * fewer than eleven bits, so each value is written as the nearest eight-bit snorm,
116
+ * `round(value × 127 / 1023)` — exact in integers, as no value lies halfway.
117
+ *
118
+ * @param {Uint8Array} source
119
+ * @param {number} offset byte offset of the eight-byte block
120
+ * @param {Int8Array} out sixteen RGBA texels in raster order; only `channel` is written
121
+ * @param {number} channel `0..3`
122
+ *
123
+ * @see Khronos Data Format Specification 1.3, section 22.7
124
+ * @author Alex Goldring
125
+ * @copyright Company Named Limited (c) 2026
126
+ */
127
+ export function eac_decode_channel_snorm11(source, offset, out, channel) {
128
+ const header = source[offset + 1];
129
+ const multiplier = header >> 4;
130
+
131
+ const base = (source[offset] << 24) >> 24;
132
+
133
+ fill_palette(
134
+ header & 15, (base < -127 ? -127 : base) * 8, multiplier === 0 ? 1 : multiplier * 8, -1023, 1023
135
+ );
136
+
137
+ for (let i = 0; i < 8; i++) {
138
+ palette[i] = Math.floor((palette[i] * 254 + 1023) / 2046);
139
+ }
140
+
141
+ write_channel(source, offset, out, channel);
142
+ }
@@ -0,0 +1,15 @@
1
+ /**
2
+ * EAC's modifier table: sixteen rows of eight, a block's table index picking the row and a texel's three-bit index
3
+ * the entry. The same table serves the eight-bit alpha of ETC2 RGBA8 and the eleven-bit R11 and RG11 formats.
4
+ *
5
+ * Row 13 is the only one holding a zero, which is what lets a block hold one value exactly.
6
+ *
7
+ * @readonly
8
+ * @type {Int32Array}
9
+ * @see OpenGL ES 3.0, table C.10; Khronos Data Format Specification 1.3, table 22.6
10
+ *
11
+ * @author Alex Goldring
12
+ * @copyright Company Named Limited (c) 2026
13
+ */
14
+ export const EAC_MODIFIERS: Int32Array;
15
+ //# sourceMappingURL=eac_modifiers.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"eac_modifiers.d.ts","sourceRoot":"","sources":["../../../../../src/format/texture/etc/eac_modifiers.js"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AACH,4BANU,UAAU,CAuBjB"}