@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
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MipmapKernelAxis.d.ts","sourceRoot":"","sources":["../../../../../../../src/shade/renderer/texture/mipmaps/cpu/MipmapKernelAxis.js"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH;IACI;;;OAGG;IACH,yBAHW,MAAM,YACN,MAAM,EA4BhB;IAzBG;;;;OAIG;IACH,gBAFU,WAAW,CAEoB;IAEzC;;;OAGG;IACH,gBAFU,WAAW,CAEoB;IAEzC;;;;OAIG;IACH,gBAFU,WAAW,CAE+B;IAEpD;;;OAGG;IACH,iBAFU,YAAY,CAEgC;CAE7D"}
@@ -0,0 +1,43 @@
1
+ /**
2
+ * The taps of a separable reduction kernel along one axis: for each destination texel, the run of
3
+ * source texels it weighs and the f32 weight of each, in ascending source order.
4
+ *
5
+ * Taps of zero weight are left out: a tap adds its texel times its weight to the sum, and its weight
6
+ * to the weight sum, so a zero weight changes neither.
7
+ *
8
+ * @author Alex Goldring
9
+ * @copyright Company Named Limited (c) 2026
10
+ */
11
+ export class MipmapKernelAxis {
12
+ /**
13
+ * @param {number} output_size destination texels along the axis
14
+ * @param {number} capacity most taps any one destination texel can have
15
+ */
16
+ constructor(output_size, capacity) {
17
+ /**
18
+ * Index into {@link index} and {@link weight} of each destination texel's first tap.
19
+ * @readonly
20
+ * @type {Uint32Array}
21
+ */
22
+ this.first = new Uint32Array(output_size);
23
+
24
+ /**
25
+ * @readonly
26
+ * @type {Uint32Array}
27
+ */
28
+ this.count = new Uint32Array(output_size);
29
+
30
+ /**
31
+ * Source texel of each tap.
32
+ * @readonly
33
+ * @type {Uint32Array}
34
+ */
35
+ this.index = new Uint32Array(output_size * capacity);
36
+
37
+ /**
38
+ * @readonly
39
+ * @type {Float32Array}
40
+ */
41
+ this.weight = new Float32Array(output_size * capacity);
42
+ }
43
+ }
@@ -0,0 +1,17 @@
1
+ /**
2
+ * The bilinear footprint of each destination texel's centre along one axis, where a mip filter
3
+ * shader samples the source at its fragment's normalised coordinate: slot `i` placed at
4
+ * `fround((i + 0.5) / output_size)`.
5
+ *
6
+ * @param {number} output_size
7
+ * @param {number} source_size
8
+ * @param {boolean} single whether the source is sampled without this axis, as `cpu_texture_sample`
9
+ * samples a level one texel high: then every slot reads texel 0 with a weight of exactly 1
10
+ * @returns {MipmapBilinearAxis}
11
+ *
12
+ * @author Alex Goldring
13
+ * @copyright Company Named Limited (c) 2026
14
+ */
15
+ export function mipmap_bilinear_centres(output_size: number, source_size: number, single: boolean): MipmapBilinearAxis;
16
+ import { MipmapBilinearAxis } from "./MipmapBilinearAxis.js";
17
+ //# sourceMappingURL=mipmap_bilinear_centres.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mipmap_bilinear_centres.d.ts","sourceRoot":"","sources":["../../../../../../../src/shade/renderer/texture/mipmaps/cpu/mipmap_bilinear_centres.js"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;GAaG;AACH,qDATW,MAAM,eACN,MAAM,UACN,OAAO,GAEL,kBAAkB,CAiB9B;mCA5BkC,yBAAyB"}
@@ -0,0 +1,29 @@
1
+ import { MipmapBilinearAxis } from "./MipmapBilinearAxis.js";
2
+
3
+ /**
4
+ * The bilinear footprint of each destination texel's centre along one axis, where a mip filter
5
+ * shader samples the source at its fragment's normalised coordinate: slot `i` placed at
6
+ * `fround((i + 0.5) / output_size)`.
7
+ *
8
+ * @param {number} output_size
9
+ * @param {number} source_size
10
+ * @param {boolean} single whether the source is sampled without this axis, as `cpu_texture_sample`
11
+ * samples a level one texel high: then every slot reads texel 0 with a weight of exactly 1
12
+ * @returns {MipmapBilinearAxis}
13
+ *
14
+ * @author Alex Goldring
15
+ * @copyright Company Named Limited (c) 2026
16
+ */
17
+ export function mipmap_bilinear_centres(output_size, source_size, single) {
18
+ const axis = new MipmapBilinearAxis(output_size);
19
+
20
+ for (let i = 0; i < output_size; i++) {
21
+ if (single) {
22
+ axis.place_single(i);
23
+ } else {
24
+ axis.place(i, Math.fround((i + 0.5) / output_size), source_size);
25
+ }
26
+ }
27
+
28
+ return axis;
29
+ }
@@ -0,0 +1,21 @@
1
+ /**
2
+ * One bilinear sample of an RGBA level, as `cpu_texture_sample` filters with a linear sampler: the
3
+ * four texels of the footprint in order — lower row lower column, lower row upper column, upper row
4
+ * lower column, upper row upper column — each weighed by the product of its two axis weights, taken
5
+ * at double precision, and added into each channel's f32 sum, rounding the sum to f32 at each step.
6
+ * A texel of zero weight is skipped.
7
+ *
8
+ * @param {Float32Array} output receives the sample's four channels
9
+ * @param {number} output_offset
10
+ * @param {Float32Array} source RGBA, `source_width` texels a row
11
+ * @param {number} source_width
12
+ * @param {import("./MipmapBilinearAxis.js").MipmapBilinearAxis} x_axis
13
+ * @param {number} x_slot
14
+ * @param {import("./MipmapBilinearAxis.js").MipmapBilinearAxis} y_axis
15
+ * @param {number} y_slot
16
+ *
17
+ * @author Alex Goldring
18
+ * @copyright Company Named Limited (c) 2026
19
+ */
20
+ export function mipmap_bilinear_sample(output: Float32Array, output_offset: number, source: Float32Array, source_width: number, x_axis: import("./MipmapBilinearAxis.js").MipmapBilinearAxis, x_slot: number, y_axis: import("./MipmapBilinearAxis.js").MipmapBilinearAxis, y_slot: number): void;
21
+ //# sourceMappingURL=mipmap_bilinear_sample.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mipmap_bilinear_sample.d.ts","sourceRoot":"","sources":["../../../../../../../src/shade/renderer/texture/mipmaps/cpu/mipmap_bilinear_sample.js"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AACH,+CAZW,YAAY,iBACZ,MAAM,UACN,YAAY,gBACZ,MAAM,UACN,OAAO,yBAAyB,EAAE,kBAAkB,UACpD,MAAM,UACN,OAAO,yBAAyB,EAAE,kBAAkB,UACpD,MAAM,QA4EhB"}
@@ -0,0 +1,91 @@
1
+ /**
2
+ * One bilinear sample of an RGBA level, as `cpu_texture_sample` filters with a linear sampler: the
3
+ * four texels of the footprint in order — lower row lower column, lower row upper column, upper row
4
+ * lower column, upper row upper column — each weighed by the product of its two axis weights, taken
5
+ * at double precision, and added into each channel's f32 sum, rounding the sum to f32 at each step.
6
+ * A texel of zero weight is skipped.
7
+ *
8
+ * @param {Float32Array} output receives the sample's four channels
9
+ * @param {number} output_offset
10
+ * @param {Float32Array} source RGBA, `source_width` texels a row
11
+ * @param {number} source_width
12
+ * @param {import("./MipmapBilinearAxis.js").MipmapBilinearAxis} x_axis
13
+ * @param {number} x_slot
14
+ * @param {import("./MipmapBilinearAxis.js").MipmapBilinearAxis} y_axis
15
+ * @param {number} y_slot
16
+ *
17
+ * @author Alex Goldring
18
+ * @copyright Company Named Limited (c) 2026
19
+ */
20
+ export function mipmap_bilinear_sample(
21
+ output, output_offset,
22
+ source, source_width,
23
+ x_axis, x_slot,
24
+ y_axis, y_slot
25
+ ) {
26
+ const fround = Math.fround;
27
+
28
+ const x0 = x_axis.lower[x_slot];
29
+ const x1 = x_axis.upper[x_slot];
30
+ const wx0 = x_axis.lower_weight[x_slot];
31
+ const wx1 = x_axis.upper_weight[x_slot];
32
+
33
+ const row0 = y_axis.lower[y_slot] * source_width;
34
+ const row1 = y_axis.upper[y_slot] * source_width;
35
+ const wy0 = y_axis.lower_weight[y_slot];
36
+ const wy1 = y_axis.upper_weight[y_slot];
37
+
38
+ let r = 0;
39
+ let g = 0;
40
+ let b = 0;
41
+ let a = 0;
42
+
43
+ let w = wx0 * wy0;
44
+
45
+ if (w !== 0) {
46
+ const t = (row0 + x0) * 4;
47
+
48
+ r = fround(r + source[t] * w);
49
+ g = fround(g + source[t + 1] * w);
50
+ b = fround(b + source[t + 2] * w);
51
+ a = fround(a + source[t + 3] * w);
52
+ }
53
+
54
+ w = wx1 * wy0;
55
+
56
+ if (w !== 0) {
57
+ const t = (row0 + x1) * 4;
58
+
59
+ r = fround(r + source[t] * w);
60
+ g = fround(g + source[t + 1] * w);
61
+ b = fround(b + source[t + 2] * w);
62
+ a = fround(a + source[t + 3] * w);
63
+ }
64
+
65
+ w = wx0 * wy1;
66
+
67
+ if (w !== 0) {
68
+ const t = (row1 + x0) * 4;
69
+
70
+ r = fround(r + source[t] * w);
71
+ g = fround(g + source[t + 1] * w);
72
+ b = fround(b + source[t + 2] * w);
73
+ a = fround(a + source[t + 3] * w);
74
+ }
75
+
76
+ w = wx1 * wy1;
77
+
78
+ if (w !== 0) {
79
+ const t = (row1 + x1) * 4;
80
+
81
+ r = fround(r + source[t] * w);
82
+ g = fround(g + source[t + 1] * w);
83
+ b = fround(b + source[t + 2] * w);
84
+ a = fround(a + source[t + 3] * w);
85
+ }
86
+
87
+ output[output_offset] = r;
88
+ output[output_offset + 1] = g;
89
+ output[output_offset + 2] = b;
90
+ output[output_offset + 3] = a;
91
+ }
@@ -0,0 +1,32 @@
1
+ /**
2
+ * The mip chain `WebGPUMipmapGenerator` generates for a texture whose level 0 is `base`, computed on
3
+ * the CPU: the same passes in the same order, each level made from the level the generator reads,
4
+ * by the CPU twin of the fragment shader it runs, and stored as an 8-bit render target stores it
5
+ * before any pass reads it.
6
+ *
7
+ * With `srgb` the texture is `rgba8unorm-srgb`, and as through the generator's views of that format,
8
+ * every pass reads colour decoded to linear and stores its result encoded; alpha is linear either
9
+ * way. See `texels_rgba8unorm_srgb_to_f32` and `texels_f32_to_rgba8unorm_srgb`.
10
+ *
11
+ * Levels follow WebGPU's extents: each axis halves, rounded down and floored at 1, until both are 1.
12
+ * A base of 1x1 has no level to generate and comes back alone, whatever the filter, as the generator
13
+ * leaves a texture of one level.
14
+ *
15
+ * @param {Sampler2D} base 8-bit RGBA: a Uint8Array, itemSize 4
16
+ * @param {TextureFilterType} filter
17
+ * @param {boolean} srgb whether the texels are sRGB-encoded (the texture's format is `rgba8unorm-srgb`)
18
+ * @returns {Sampler2D[]} every level, base first, down to 1x1; each 8-bit RGBA. The first is `base` itself
19
+ * @throws {Error} for a filter the generator refuses (`Nearest`, or a value that is no filter), when there is a level to generate
20
+ *
21
+ * @author Alex Goldring
22
+ * @copyright Company Named Limited (c) 2026
23
+ */
24
+ export function mipmap_chain_cpu(base: Sampler2D, filter: TextureFilterType, srgb: boolean): Sampler2D[];
25
+ /**
26
+ * A pass of a mip filter: reads `source`, writes the fragment outputs of a destination
27
+ * `output_width` by `output_height`.
28
+ */
29
+ export type MipmapCpuFilter = (output: Float32Array, output_width: number, output_height: number, source: Float32Array, source_width: number, source_height: number) => void;
30
+ import { Sampler2D } from "../../../../../engine/graphics/texture/sampler/Sampler2D.js";
31
+ import { TextureFilterType } from "../../TextureFilterType.js";
32
+ //# sourceMappingURL=mipmap_chain_cpu.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mipmap_chain_cpu.d.ts","sourceRoot":"","sources":["../../../../../../../src/shade/renderer/texture/mipmaps/cpu/mipmap_chain_cpu.js"],"names":[],"mappings":"AAmHA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,uCATW,SAAS,UACT,iBAAiB,QACjB,OAAO,GACL,SAAS,EAAE,CAmFvB;;;;;uCAjMU,YAAY,gBACZ,MAAM,iBACN,MAAM,UACN,YAAY,gBACZ,MAAM,iBACN,MAAM,KACJ,IAAI;0BA1BS,6DAA6D;kCAErD,4BAA4B"}
@@ -0,0 +1,216 @@
1
+ import { assert } from "../../../../../core/assert.js";
2
+ import { objectKeyByValue } from "../../../../../core/model/object/objectKeyByValue.js";
3
+ import { Sampler2D } from "../../../../../engine/graphics/texture/sampler/Sampler2D.js";
4
+ import { texture_mip_level_count, texture_mip_size } from "../../../../util/texture_mip_extent.js";
5
+ import { TextureFilterType } from "../../TextureFilterType.js";
6
+ import { mipmap_filter_catmull_rom_cpu } from "./mipmap_filter_catmull_rom_cpu.js";
7
+ import { mipmap_filter_linear_cpu } from "./mipmap_filter_linear_cpu.js";
8
+ import { mipmap_filter_linear_normal_cpu } from "./mipmap_filter_linear_normal_cpu.js";
9
+ import { mipmap_filter_magic_kernel_cpu } from "./mipmap_filter_magic_kernel_cpu.js";
10
+ import { mipmap_filter_mitchell_cpu } from "./mipmap_filter_mitchell_cpu.js";
11
+ import { mipmap_filter_mks_cpu } from "./mipmap_filter_mks_cpu.js";
12
+ import { mipmap_filter_wronski2021_cpu } from "./mipmap_filter_wronski2021_cpu.js";
13
+ import { texels_f32_to_rgba8unorm } from "./texels_f32_to_rgba8unorm.js";
14
+ import { texels_f32_to_rgba8unorm_srgb } from "./texels_f32_to_rgba8unorm_srgb.js";
15
+ import { texels_rgba8unorm_srgb_to_f32 } from "./texels_rgba8unorm_srgb_to_f32.js";
16
+ import { texels_rgba8unorm_to_f32 } from "./texels_rgba8unorm_to_f32.js";
17
+
18
+ /**
19
+ * A pass of a mip filter: reads `source`, writes the fragment outputs of a destination
20
+ * `output_width` by `output_height`.
21
+ *
22
+ * @callback MipmapCpuFilter
23
+ * @param {Float32Array} output
24
+ * @param {number} output_width
25
+ * @param {number} output_height
26
+ * @param {Float32Array} source
27
+ * @param {number} source_width
28
+ * @param {number} source_height
29
+ * @returns {void}
30
+ */
31
+
32
+ /**
33
+ * How a chain is built for one {@link TextureFilterType}: a forward pass makes each level from the
34
+ * one above it; a filter that does not preserve energy is then run backward, from the smallest level
35
+ * up, each level made from the forward chain's level `skip_distance` above it (the base at the
36
+ * least). A skip distance of 0 reads the forward chain's level of the same size, which is kept apart
37
+ * from the levels being written.
38
+ */
39
+ class MipmapCpuProcess {
40
+ /**
41
+ * @param {MipmapCpuFilter} forward
42
+ * @param {MipmapCpuFilter|null} backward
43
+ * @param {number} skip_distance
44
+ */
45
+ constructor(forward, backward, skip_distance) {
46
+ /**
47
+ * @readonly
48
+ * @type {MipmapCpuFilter}
49
+ */
50
+ this.forward = forward;
51
+
52
+ /**
53
+ * @readonly
54
+ * @type {MipmapCpuFilter|null}
55
+ */
56
+ this.backward = backward;
57
+
58
+ /**
59
+ * @readonly
60
+ * @type {number}
61
+ */
62
+ this.skip_distance = skip_distance;
63
+ }
64
+ }
65
+
66
+ /**
67
+ * The process of every filter `WebGPUMipmapGenerator` generates with; it refuses the rest.
68
+ * @readonly
69
+ * @type {Map<TextureFilterType, MipmapCpuProcess>}
70
+ */
71
+ const MIPMAP_PROCESSES = new Map([
72
+ [TextureFilterType.Linear, new MipmapCpuProcess(mipmap_filter_linear_cpu, null, 0)],
73
+ [TextureFilterType.LinearNormal, new MipmapCpuProcess(mipmap_filter_linear_cpu, mipmap_filter_linear_normal_cpu, 0)],
74
+ [TextureFilterType.Mitchell, new MipmapCpuProcess(mipmap_filter_magic_kernel_cpu, mipmap_filter_mitchell_cpu, 2)],
75
+ [TextureFilterType.MagicKernelSharp, new MipmapCpuProcess(mipmap_filter_mks_cpu, null, 0)],
76
+ [TextureFilterType.CatmullRom, new MipmapCpuProcess(mipmap_filter_linear_cpu, mipmap_filter_catmull_rom_cpu, 2)],
77
+ [TextureFilterType.Wronski2021, new MipmapCpuProcess(mipmap_filter_linear_cpu, mipmap_filter_wronski2021_cpu, 1)],
78
+ ]);
79
+
80
+ /**
81
+ * @param {number} width of the base
82
+ * @param {number} height of the base
83
+ * @param {number} level
84
+ * @returns {Sampler2D}
85
+ */
86
+ function make_level(width, height, level) {
87
+ const w = texture_mip_size(width, level);
88
+ const h = texture_mip_size(height, level);
89
+
90
+ return new Sampler2D(new Uint8Array(w * h * 4), 4, w, h);
91
+ }
92
+
93
+ /**
94
+ * Render one level from another, as a pass of the generator does: read the source through a view of
95
+ * the texture's format, run the filter, store the outputs as the format stores them.
96
+ *
97
+ * @param {MipmapCpuFilter} filter
98
+ * @param {Sampler2D} destination
99
+ * @param {Sampler2D} source
100
+ * @param {function(Float32Array, Uint8Array, number): void} read
101
+ * @param {function(Uint8Array, Float32Array, number): void} store
102
+ * @param {Float32Array} read_scratch at least the source's values
103
+ * @param {Float32Array} output_scratch at least the destination's values
104
+ */
105
+ function render_level(filter, destination, source, read, store, read_scratch, output_scratch) {
106
+ read(read_scratch, source.data, source.width * source.height * 4);
107
+
108
+ filter(
109
+ output_scratch, destination.width, destination.height,
110
+ read_scratch, source.width, source.height
111
+ );
112
+
113
+ store(destination.data, output_scratch, destination.width * destination.height * 4);
114
+ }
115
+
116
+ /**
117
+ * The mip chain `WebGPUMipmapGenerator` generates for a texture whose level 0 is `base`, computed on
118
+ * the CPU: the same passes in the same order, each level made from the level the generator reads,
119
+ * by the CPU twin of the fragment shader it runs, and stored as an 8-bit render target stores it
120
+ * before any pass reads it.
121
+ *
122
+ * With `srgb` the texture is `rgba8unorm-srgb`, and as through the generator's views of that format,
123
+ * every pass reads colour decoded to linear and stores its result encoded; alpha is linear either
124
+ * way. See `texels_rgba8unorm_srgb_to_f32` and `texels_f32_to_rgba8unorm_srgb`.
125
+ *
126
+ * Levels follow WebGPU's extents: each axis halves, rounded down and floored at 1, until both are 1.
127
+ * A base of 1x1 has no level to generate and comes back alone, whatever the filter, as the generator
128
+ * leaves a texture of one level.
129
+ *
130
+ * @param {Sampler2D} base 8-bit RGBA: a Uint8Array, itemSize 4
131
+ * @param {TextureFilterType} filter
132
+ * @param {boolean} srgb whether the texels are sRGB-encoded (the texture's format is `rgba8unorm-srgb`)
133
+ * @returns {Sampler2D[]} every level, base first, down to 1x1; each 8-bit RGBA. The first is `base` itself
134
+ * @throws {Error} for a filter the generator refuses (`Nearest`, or a value that is no filter), when there is a level to generate
135
+ *
136
+ * @author Alex Goldring
137
+ * @copyright Company Named Limited (c) 2026
138
+ */
139
+ export function mipmap_chain_cpu(base, filter, srgb) {
140
+ assert.defined(base, 'base');
141
+ assert.equal(base.itemSize, 4, 'base.itemSize');
142
+ assert.ok(base.data instanceof Uint8Array, 'base.data must be a Uint8Array');
143
+ assert.isBoolean(srgb, 'srgb');
144
+
145
+ const width = base.width;
146
+ const height = base.height;
147
+
148
+ const level_count = texture_mip_level_count(width, height, 1, "2d");
149
+
150
+ /**
151
+ * @type {Sampler2D[]}
152
+ */
153
+ const levels = [base];
154
+
155
+ if (level_count <= 1) {
156
+ return levels;
157
+ }
158
+
159
+ const process = MIPMAP_PROCESSES.get(filter);
160
+
161
+ if (process === undefined) {
162
+ throw new Error(`Filter ${objectKeyByValue(TextureFilterType, filter) ?? filter} is not supported`);
163
+ }
164
+
165
+ for (let level = 1; level < level_count; level++) {
166
+ levels.push(make_level(width, height, level));
167
+ }
168
+
169
+ const read = srgb ? texels_rgba8unorm_srgb_to_f32 : texels_rgba8unorm_to_f32;
170
+ const store = srgb ? texels_f32_to_rgba8unorm_srgb : texels_f32_to_rgba8unorm;
171
+
172
+ // every pass reads at most the base and writes at most level 1
173
+ const read_scratch = new Float32Array(width * height * 4);
174
+ const output_scratch = new Float32Array(levels[1].width * levels[1].height * 4);
175
+
176
+ const backward = process.backward;
177
+ const skip_distance = process.skip_distance;
178
+
179
+ /**
180
+ * Where the forward pass writes: the levels themselves, unless the backward pass reads the
181
+ * forward level of the size it writes.
182
+ * @type {Sampler2D[]}
183
+ */
184
+ let forward_levels = levels;
185
+
186
+ if (backward !== null && skip_distance === 0) {
187
+ forward_levels = [base];
188
+
189
+ for (let level = 1; level < level_count; level++) {
190
+ forward_levels.push(make_level(width, height, level));
191
+ }
192
+ }
193
+
194
+ for (let level = 1; level < level_count; level++) {
195
+ render_level(
196
+ process.forward,
197
+ forward_levels[level], forward_levels[level - 1],
198
+ read, store, read_scratch, output_scratch
199
+ );
200
+ }
201
+
202
+ if (backward === null) {
203
+ return levels;
204
+ }
205
+
206
+ // smallest first, so every level a pass reads still holds the forward chain's
207
+ for (let level = level_count - 1; level > 0; level--) {
208
+ render_level(
209
+ backward,
210
+ levels[level], forward_levels[Math.max(0, level - skip_distance)],
211
+ read, store, read_scratch, output_scratch
212
+ );
213
+ }
214
+
215
+ return levels;
216
+ }
@@ -0,0 +1,30 @@
1
+ /**
2
+ * The polynomial coefficients of the Mitchell-Netravali family of cubics for parameters `B` and `C`,
3
+ * in f32, each folded as `chunk_filter_cubic` writes it: `[P, Q, R, S, T, U, V]`, where the kernel is
4
+ * `(P x^3 + Q x^2 + R) / 6` below 1 and `(S x^3 + T x^2 + U x + V) / 6` from 1 to 2.
5
+ *
6
+ * @see Mitchell, D. P. and Netravali, A. N. 1988, "Reconstruction filters in computer graphics"
7
+ * @param {number} B an f32
8
+ * @param {number} C an f32
9
+ * @returns {Float64Array}
10
+ */
11
+ export function cubic_filter_coefficients(B: number, C: number): Float64Array;
12
+ /**
13
+ * One pass of a cubic reduction, as `mipmap_shader_code_mitchell` and `mipmap_shader_code_catmull_rom`
14
+ * compute it: each destination texel is the normalised sum of the source texels within two
15
+ * destination texels of its centre, weighed separably by the cubic at their distance in
16
+ * destination texels, all in f32 — see {@link mipmap_kernel_reduce}.
17
+ *
18
+ * @param {Float32Array} output RGBA, raster order: the fragment outputs, before any store
19
+ * @param {number} output_width
20
+ * @param {number} output_height
21
+ * @param {Float32Array} source RGBA, raster order: the level read, as the shader reads it
22
+ * @param {number} source_width
23
+ * @param {number} source_height
24
+ * @param {Float64Array} coefficients the cubic, from {@link cubic_filter_coefficients}
25
+ *
26
+ * @author Alex Goldring
27
+ * @copyright Company Named Limited (c) 2026
28
+ */
29
+ export function mipmap_cubic_filter_cpu(output: Float32Array, output_width: number, output_height: number, source: Float32Array, source_width: number, source_height: number, coefficients: Float64Array): void;
30
+ //# sourceMappingURL=mipmap_cubic_filter_cpu.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mipmap_cubic_filter_cpu.d.ts","sourceRoot":"","sources":["../../../../../../../src/shade/renderer/texture/mipmaps/cpu/mipmap_cubic_filter_cpu.js"],"names":[],"mappings":"AASA;;;;;;;;;GASG;AACH,6CAJW,MAAM,KACN,MAAM,GACJ,YAAY,CAcxB;AAyED;;;;;;;;;;;;;;;;GAgBG;AACH,gDAXW,YAAY,gBACZ,MAAM,iBACN,MAAM,UACN,YAAY,gBACZ,MAAM,iBACN,MAAM,gBACN,YAAY,QAiBtB"}
@@ -0,0 +1,134 @@
1
+ import { MipmapKernelAxis } from "./MipmapKernelAxis.js";
2
+ import { mipmap_kernel_reduce } from "./mipmap_kernel_reduce.js";
3
+ import { mipmap_source_centre } from "./mipmap_source_centre.js";
4
+
5
+ /**
6
+ * @type {number}
7
+ */
8
+ const WEIGHT_SUM_THRESHOLD = Math.fround(0.00001);
9
+
10
+ /**
11
+ * The polynomial coefficients of the Mitchell-Netravali family of cubics for parameters `B` and `C`,
12
+ * in f32, each folded as `chunk_filter_cubic` writes it: `[P, Q, R, S, T, U, V]`, where the kernel is
13
+ * `(P x^3 + Q x^2 + R) / 6` below 1 and `(S x^3 + T x^2 + U x + V) / 6` from 1 to 2.
14
+ *
15
+ * @see Mitchell, D. P. and Netravali, A. N. 1988, "Reconstruction filters in computer graphics"
16
+ * @param {number} B an f32
17
+ * @param {number} C an f32
18
+ * @returns {Float64Array}
19
+ */
20
+ export function cubic_filter_coefficients(B, C) {
21
+ const fround = Math.fround;
22
+
23
+ return new Float64Array([
24
+ fround(fround(12 - fround(9 * B)) - fround(6 * C)),
25
+ fround(fround(-18 + fround(12 * B)) + fround(6 * C)),
26
+ fround(6 - fround(2 * B)),
27
+ fround(fround(-B) - fround(6 * C)),
28
+ fround(fround(6 * B) + fround(30 * C)),
29
+ fround(fround(-12 * B) - fround(48 * C)),
30
+ fround(fround(8 * B) + fround(24 * C)),
31
+ ]);
32
+ }
33
+
34
+ /**
35
+ * A Mitchell-Netravali cubic, in f32, evaluated as `chunk_filter_cubic` writes it.
36
+ *
37
+ * @param {number} x_in an f32
38
+ * @param {Float64Array} k from {@link cubic_filter_coefficients}
39
+ * @returns {number} an f32
40
+ */
41
+ function cubic_filter(x_in, k) {
42
+ const fround = Math.fround;
43
+
44
+ const x = Math.abs(x_in);
45
+
46
+ const x2 = fround(x * x);
47
+ const x3 = fround(fround(x * x) * x);
48
+
49
+ let y = 0;
50
+
51
+ if (x < 1) {
52
+ y = fround(fround(fround(k[0] * x3) + fround(k[1] * x2)) + k[2]);
53
+ } else if (x <= 2) {
54
+ y = fround(fround(fround(fround(k[3] * x3) + fround(k[4] * x2)) + fround(k[5] * x)) + k[6]);
55
+ }
56
+
57
+ return fround(y / 6);
58
+ }
59
+
60
+ /**
61
+ * @param {number} output_size
62
+ * @param {number} source_size
63
+ * @param {Float64Array} coefficients
64
+ * @returns {MipmapKernelAxis}
65
+ */
66
+ function cubic_axis(output_size, source_size, coefficients) {
67
+ const stride = Math.max(1, Math.fround(source_size / output_size));
68
+ // the kernel spans 2 destination texels either side
69
+ const radius = Math.fround(2 * stride);
70
+ const last = Math.fround(source_size - 1);
71
+
72
+ const axis = new MipmapKernelAxis(output_size, 2 * Math.ceil(radius) + 3);
73
+
74
+ let tap = 0;
75
+
76
+ for (let i = 0; i < output_size; i++) {
77
+ const centre = mipmap_source_centre(i, output_size, source_size);
78
+
79
+ const start = Math.max(Math.floor(Math.fround(centre - radius)), 0);
80
+ const end = Math.min(Math.ceil(Math.fround(centre + radius)), last);
81
+
82
+ axis.first[i] = tap;
83
+
84
+ for (let s = start; s <= end; s++) {
85
+ const distance = Math.fround(Math.abs(Math.fround(s - centre)) / stride);
86
+
87
+ const weight = cubic_filter(distance, coefficients);
88
+
89
+ if (weight === 0) {
90
+ continue;
91
+ }
92
+
93
+ axis.index[tap] = s;
94
+ axis.weight[tap] = weight;
95
+
96
+ tap++;
97
+ }
98
+
99
+ axis.count[i] = tap - axis.first[i];
100
+ }
101
+
102
+ return axis;
103
+ }
104
+
105
+ /**
106
+ * One pass of a cubic reduction, as `mipmap_shader_code_mitchell` and `mipmap_shader_code_catmull_rom`
107
+ * compute it: each destination texel is the normalised sum of the source texels within two
108
+ * destination texels of its centre, weighed separably by the cubic at their distance in
109
+ * destination texels, all in f32 — see {@link mipmap_kernel_reduce}.
110
+ *
111
+ * @param {Float32Array} output RGBA, raster order: the fragment outputs, before any store
112
+ * @param {number} output_width
113
+ * @param {number} output_height
114
+ * @param {Float32Array} source RGBA, raster order: the level read, as the shader reads it
115
+ * @param {number} source_width
116
+ * @param {number} source_height
117
+ * @param {Float64Array} coefficients the cubic, from {@link cubic_filter_coefficients}
118
+ *
119
+ * @author Alex Goldring
120
+ * @copyright Company Named Limited (c) 2026
121
+ */
122
+ export function mipmap_cubic_filter_cpu(
123
+ output, output_width, output_height,
124
+ source, source_width, source_height,
125
+ coefficients
126
+ ) {
127
+ mipmap_kernel_reduce(
128
+ output, output_width, output_height,
129
+ source, source_width,
130
+ cubic_axis(output_width, source_width, coefficients),
131
+ cubic_axis(output_height, source_height, coefficients),
132
+ WEIGHT_SUM_THRESHOLD
133
+ );
134
+ }
@@ -0,0 +1,16 @@
1
+ /**
2
+ * One pass of the Catmull-Rom reduction, the CPU twin of `mipmap_shader_code_catmull_rom`; see
3
+ * {@link mipmap_cubic_filter_cpu}.
4
+ *
5
+ * @param {Float32Array} output RGBA, raster order: the fragment outputs, before any store
6
+ * @param {number} output_width
7
+ * @param {number} output_height
8
+ * @param {Float32Array} source RGBA, raster order: the level read, as the shader reads it
9
+ * @param {number} source_width
10
+ * @param {number} source_height
11
+ *
12
+ * @author Alex Goldring
13
+ * @copyright Company Named Limited (c) 2026
14
+ */
15
+ export function mipmap_filter_catmull_rom_cpu(output: Float32Array, output_width: number, output_height: number, source: Float32Array, source_width: number, source_height: number): void;
16
+ //# sourceMappingURL=mipmap_filter_catmull_rom_cpu.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mipmap_filter_catmull_rom_cpu.d.ts","sourceRoot":"","sources":["../../../../../../../src/shade/renderer/texture/mipmaps/cpu/mipmap_filter_catmull_rom_cpu.js"],"names":[],"mappings":"AASA;;;;;;;;;;;;;GAaG;AACH,sDAVW,YAAY,gBACZ,MAAM,iBACN,MAAM,UACN,YAAY,gBACZ,MAAM,iBACN,MAAM,QAchB"}