@pmndrs/vdb 0.0.0-stage → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (570) hide show
  1. package/CHANGELOG.md +727 -0
  2. package/LICENSE +21 -0
  3. package/README.md +496 -2
  4. package/THIRD_PARTY_NOTICES.md +315 -0
  5. package/dist/core/compute/atlas.d.ts +102 -0
  6. package/dist/core/compute/atlas.js +103 -0
  7. package/dist/core/compute/atlas.js.map +1 -0
  8. package/dist/core/compute/index.d.ts +13 -0
  9. package/dist/core/compute/index.js +9 -0
  10. package/dist/core/compute/index.js.map +1 -0
  11. package/dist/core/compute/majorant-build.d.ts +45 -0
  12. package/dist/core/compute/majorant-build.js +193 -0
  13. package/dist/core/compute/majorant-build.js.map +1 -0
  14. package/dist/core/compute/multi-scale.d.ts +155 -0
  15. package/dist/core/compute/multi-scale.js +684 -0
  16. package/dist/core/compute/multi-scale.js.map +1 -0
  17. package/dist/core/compute/pyramid.d.ts +120 -0
  18. package/dist/core/compute/pyramid.js +468 -0
  19. package/dist/core/compute/pyramid.js.map +1 -0
  20. package/dist/core/compute/shared.d.ts +116 -0
  21. package/dist/core/compute/shared.js +211 -0
  22. package/dist/core/compute/shared.js.map +1 -0
  23. package/dist/core/compute/stats.d.ts +78 -0
  24. package/dist/core/compute/stats.js +193 -0
  25. package/dist/core/compute/stats.js.map +1 -0
  26. package/dist/core/compute/value-transform.d.ts +30 -0
  27. package/dist/core/compute/value-transform.js +64 -0
  28. package/dist/core/compute/value-transform.js.map +1 -0
  29. package/dist/core/errors.d.ts +21 -0
  30. package/dist/core/errors.js +17 -0
  31. package/dist/core/errors.js.map +1 -0
  32. package/dist/core/frame/emission.d.ts +85 -0
  33. package/dist/core/frame/emission.js +422 -0
  34. package/dist/core/frame/emission.js.map +1 -0
  35. package/dist/core/frame/environment.d.ts +47 -0
  36. package/dist/core/frame/environment.js +178 -0
  37. package/dist/core/frame/environment.js.map +1 -0
  38. package/dist/core/frame/index.d.ts +39 -0
  39. package/dist/core/frame/index.js +27 -0
  40. package/dist/core/frame/index.js.map +1 -0
  41. package/dist/core/frame/kernels.d.ts +115 -0
  42. package/dist/core/frame/kernels.js +496 -0
  43. package/dist/core/frame/kernels.js.map +1 -0
  44. package/dist/core/frame/limits.d.ts +67 -0
  45. package/dist/core/frame/limits.js +109 -0
  46. package/dist/core/frame/limits.js.map +1 -0
  47. package/dist/core/frame/phase.d.ts +17 -0
  48. package/dist/core/frame/phase.js +53 -0
  49. package/dist/core/frame/phase.js.map +1 -0
  50. package/dist/core/frame/pipelines.d.ts +49 -0
  51. package/dist/core/frame/pipelines.js +147 -0
  52. package/dist/core/frame/pipelines.js.map +1 -0
  53. package/dist/core/frame/renderer.d.ts +122 -0
  54. package/dist/core/frame/renderer.js +1712 -0
  55. package/dist/core/frame/renderer.js.map +1 -0
  56. package/dist/core/frame/resources.d.ts +71 -0
  57. package/dist/core/frame/resources.js +100 -0
  58. package/dist/core/frame/resources.js.map +1 -0
  59. package/dist/core/frame/scattering.d.ts +97 -0
  60. package/dist/core/frame/scattering.js +332 -0
  61. package/dist/core/frame/scattering.js.map +1 -0
  62. package/dist/core/frame/settings.d.ts +243 -0
  63. package/dist/core/frame/settings.js +67 -0
  64. package/dist/core/frame/settings.js.map +1 -0
  65. package/dist/core/frame/shadows.d.ts +55 -0
  66. package/dist/core/frame/shadows.js +460 -0
  67. package/dist/core/frame/shadows.js.map +1 -0
  68. package/dist/core/frame/types.d.ts +415 -0
  69. package/dist/core/frame/types.js +49 -0
  70. package/dist/core/frame/types.js.map +1 -0
  71. package/dist/core/frame/uniforms.d.ts +105 -0
  72. package/dist/core/frame/uniforms.js +276 -0
  73. package/dist/core/frame/uniforms.js.map +1 -0
  74. package/dist/core/frame/wgsl/chunks.d.ts +4 -0
  75. package/dist/core/frame/wgsl/chunks.js +728 -0
  76. package/dist/core/frame/wgsl/chunks.js.map +1 -0
  77. package/dist/core/frame/wgsl/emission.d.ts +82 -0
  78. package/dist/core/frame/wgsl/emission.js +353 -0
  79. package/dist/core/frame/wgsl/emission.js.map +1 -0
  80. package/dist/core/frame/wgsl/environment.d.ts +42 -0
  81. package/dist/core/frame/wgsl/environment.js +711 -0
  82. package/dist/core/frame/wgsl/environment.js.map +1 -0
  83. package/dist/core/frame/wgsl/gather.d.ts +55 -0
  84. package/dist/core/frame/wgsl/gather.js +850 -0
  85. package/dist/core/frame/wgsl/gather.js.map +1 -0
  86. package/dist/core/frame/wgsl/integrate.d.ts +78 -0
  87. package/dist/core/frame/wgsl/integrate.js +213 -0
  88. package/dist/core/frame/wgsl/integrate.js.map +1 -0
  89. package/dist/core/frame/wgsl/lighting.d.ts +103 -0
  90. package/dist/core/frame/wgsl/lighting.js +1636 -0
  91. package/dist/core/frame/wgsl/lighting.js.map +1 -0
  92. package/dist/core/frame/wgsl/occluders.d.ts +20 -0
  93. package/dist/core/frame/wgsl/occluders.js +95 -0
  94. package/dist/core/frame/wgsl/occluders.js.map +1 -0
  95. package/dist/core/frame/wgsl/resolve.d.ts +19 -0
  96. package/dist/core/frame/wgsl/resolve.js +205 -0
  97. package/dist/core/frame/wgsl/resolve.js.map +1 -0
  98. package/dist/core/frame/wgsl/shadows.d.ts +35 -0
  99. package/dist/core/frame/wgsl/shadows.js +328 -0
  100. package/dist/core/frame/wgsl/shadows.js.map +1 -0
  101. package/dist/core/half.d.ts +11 -0
  102. package/dist/core/half.js +22 -0
  103. package/dist/core/half.js.map +1 -0
  104. package/dist/core/index.d.ts +52 -0
  105. package/dist/core/index.js +46 -0
  106. package/dist/core/index.js.map +1 -0
  107. package/dist/core/internal.d.ts +31 -0
  108. package/dist/core/internal.js +32 -0
  109. package/dist/core/internal.js.map +1 -0
  110. package/dist/core/pool/affine.d.ts +34 -0
  111. package/dist/core/pool/affine.js +100 -0
  112. package/dist/core/pool/affine.js.map +1 -0
  113. package/dist/core/pool/allocator.d.ts +32 -0
  114. package/dist/core/pool/allocator.js +81 -0
  115. package/dist/core/pool/allocator.js.map +1 -0
  116. package/dist/core/pool/image-header.d.ts +93 -0
  117. package/dist/core/pool/image-header.js +194 -0
  118. package/dist/core/pool/image-header.js.map +1 -0
  119. package/dist/core/pool/layout.d.ts +198 -0
  120. package/dist/core/pool/layout.js +316 -0
  121. package/dist/core/pool/layout.js.map +1 -0
  122. package/dist/core/pool/limits.d.ts +41 -0
  123. package/dist/core/pool/limits.js +80 -0
  124. package/dist/core/pool/limits.js.map +1 -0
  125. package/dist/core/pool/pool.d.ts +384 -0
  126. package/dist/core/pool/pool.js +1184 -0
  127. package/dist/core/pool/pool.js.map +1 -0
  128. package/dist/core/reference/index.d.ts +6 -0
  129. package/dist/core/reference/index.js +7 -0
  130. package/dist/core/reference/index.js.map +1 -0
  131. package/dist/core/reference/renderer.d.ts +105 -0
  132. package/dist/core/reference/renderer.js +474 -0
  133. package/dist/core/reference/renderer.js.map +1 -0
  134. package/dist/core/reference/wgsl.d.ts +65 -0
  135. package/dist/core/reference/wgsl.js +803 -0
  136. package/dist/core/reference/wgsl.js.map +1 -0
  137. package/dist/core/sequence.d.ts +347 -0
  138. package/dist/core/sequence.js +548 -0
  139. package/dist/core/sequence.js.map +1 -0
  140. package/dist/core/source/brick-cache.d.ts +165 -0
  141. package/dist/core/source/brick-cache.js +627 -0
  142. package/dist/core/source/brick-cache.js.map +1 -0
  143. package/dist/core/source/dense-fill.d.ts +53 -0
  144. package/dist/core/source/dense-fill.js +377 -0
  145. package/dist/core/source/dense-fill.js.map +1 -0
  146. package/dist/core/source/dense.d.ts +50 -0
  147. package/dist/core/source/dense.js +384 -0
  148. package/dist/core/source/dense.js.map +1 -0
  149. package/dist/core/source/sparse-wgsl.d.ts +92 -0
  150. package/dist/core/source/sparse-wgsl.js +481 -0
  151. package/dist/core/source/sparse-wgsl.js.map +1 -0
  152. package/dist/core/source/sparse.d.ts +192 -0
  153. package/dist/core/source/sparse.js +762 -0
  154. package/dist/core/source/sparse.js.map +1 -0
  155. package/dist/core/source/types.d.ts +120 -0
  156. package/dist/core/source/types.js +9 -0
  157. package/dist/core/source/types.js.map +1 -0
  158. package/dist/core/surface/index.d.ts +10 -0
  159. package/dist/core/surface/index.js +9 -0
  160. package/dist/core/surface/index.js.map +1 -0
  161. package/dist/core/surface/level-set-pass.d.ts +140 -0
  162. package/dist/core/surface/level-set-pass.js +291 -0
  163. package/dist/core/surface/level-set-pass.js.map +1 -0
  164. package/dist/core/surface/level-set-wgsl.d.ts +46 -0
  165. package/dist/core/surface/level-set-wgsl.js +99 -0
  166. package/dist/core/surface/level-set-wgsl.js.map +1 -0
  167. package/dist/core/surface/points.d.ts +109 -0
  168. package/dist/core/surface/points.js +226 -0
  169. package/dist/core/surface/points.js.map +1 -0
  170. package/dist/core/types.d.ts +37 -0
  171. package/dist/core/types.js +32 -0
  172. package/dist/core/types.js.map +1 -0
  173. package/dist/core/wgsl/api.d.ts +65 -0
  174. package/dist/core/wgsl/api.js +546 -0
  175. package/dist/core/wgsl/api.js.map +1 -0
  176. package/dist/core/wgsl/generate.d.ts +90 -0
  177. package/dist/core/wgsl/generate.js +678 -0
  178. package/dist/core/wgsl/generate.js.map +1 -0
  179. package/dist/core/wgsl/lean.d.ts +50 -0
  180. package/dist/core/wgsl/lean.js +327 -0
  181. package/dist/core/wgsl/lean.js.map +1 -0
  182. package/dist/core/wgsl/level-set.d.ts +58 -0
  183. package/dist/core/wgsl/level-set.js +200 -0
  184. package/dist/core/wgsl/level-set.js.map +1 -0
  185. package/dist/core/wgsl/majorant.d.ts +62 -0
  186. package/dist/core/wgsl/majorant.js +381 -0
  187. package/dist/core/wgsl/majorant.js.map +1 -0
  188. package/dist/core/wgsl/pnanovdb.chunks.generated.d.ts +14 -0
  189. package/dist/core/wgsl/pnanovdb.chunks.generated.js +333 -0
  190. package/dist/core/wgsl/pnanovdb.chunks.generated.js.map +1 -0
  191. package/dist/core/wgsl/reserved.d.ts +9 -0
  192. package/dist/core/wgsl/reserved.js +26 -0
  193. package/dist/core/wgsl/reserved.js.map +1 -0
  194. package/dist/core/wgsl/types.d.ts +198 -0
  195. package/dist/core/wgsl/types.js +2 -0
  196. package/dist/core/wgsl/types.js.map +1 -0
  197. package/dist/three/coarse-first.d.ts +207 -0
  198. package/dist/three/coarse-first.js +205 -0
  199. package/dist/three/coarse-first.js.map +1 -0
  200. package/dist/three/compute.d.ts +73 -0
  201. package/dist/three/compute.js +66 -0
  202. package/dist/three/compute.js.map +1 -0
  203. package/dist/three/device.d.ts +66 -0
  204. package/dist/three/device.js +62 -0
  205. package/dist/three/device.js.map +1 -0
  206. package/dist/three/frame/core-environment.d.ts +38 -0
  207. package/dist/three/frame/core-environment.js +154 -0
  208. package/dist/three/frame/core-environment.js.map +1 -0
  209. package/dist/three/frame/core-integrate-material.d.ts +34 -0
  210. package/dist/three/frame/core-integrate-material.js +162 -0
  211. package/dist/three/frame/core-integrate-material.js.map +1 -0
  212. package/dist/three/frame/core-occluders.d.ts +53 -0
  213. package/dist/three/frame/core-occluders.js +193 -0
  214. package/dist/three/frame/core-occluders.js.map +1 -0
  215. package/dist/three/frame/core-structs.d.ts +34 -0
  216. package/dist/three/frame/core-structs.js +61 -0
  217. package/dist/three/frame/core-structs.js.map +1 -0
  218. package/dist/three/frame/core-textures.d.ts +41 -0
  219. package/dist/three/frame/core-textures.js +114 -0
  220. package/dist/three/frame/core-textures.js.map +1 -0
  221. package/dist/three/frame/emission-light.d.ts +117 -0
  222. package/dist/three/frame/emission-light.js +276 -0
  223. package/dist/three/frame/emission-light.js.map +1 -0
  224. package/dist/three/frame/index.d.ts +19 -0
  225. package/dist/three/frame/index.js +15 -0
  226. package/dist/three/frame/index.js.map +1 -0
  227. package/dist/three/frame/medium.d.ts +33 -0
  228. package/dist/three/frame/medium.js +29 -0
  229. package/dist/three/frame/medium.js.map +1 -0
  230. package/dist/three/frame/renderer.d.ts +97 -0
  231. package/dist/three/frame/renderer.js +480 -0
  232. package/dist/three/frame/renderer.js.map +1 -0
  233. package/dist/three/frame/spectrum.d.ts +4 -0
  234. package/dist/three/frame/spectrum.js +15 -0
  235. package/dist/three/frame/spectrum.js.map +1 -0
  236. package/dist/three/frame/three-internals.d.ts +60 -0
  237. package/dist/three/frame/three-internals.js +152 -0
  238. package/dist/three/frame/three-internals.js.map +1 -0
  239. package/dist/three/frame/volume-shadows.d.ts +139 -0
  240. package/dist/three/frame/volume-shadows.js +403 -0
  241. package/dist/three/frame/volume-shadows.js.map +1 -0
  242. package/dist/three/frame/volume.d.ts +230 -0
  243. package/dist/three/frame/volume.js +268 -0
  244. package/dist/three/frame/volume.js.map +1 -0
  245. package/dist/three/grid-node.d.ts +229 -0
  246. package/dist/three/grid-node.js +545 -0
  247. package/dist/three/grid-node.js.map +1 -0
  248. package/dist/three/index.d.ts +52 -0
  249. package/dist/three/index.js +58 -0
  250. package/dist/three/index.js.map +1 -0
  251. package/dist/three/internal.d.ts +20 -0
  252. package/dist/three/internal.js +18 -0
  253. package/dist/three/internal.js.map +1 -0
  254. package/dist/three/level-set-material.d.ts +185 -0
  255. package/dist/three/level-set-material.js +241 -0
  256. package/dist/three/level-set-material.js.map +1 -0
  257. package/dist/three/level-set-physical-material.d.ts +154 -0
  258. package/dist/three/level-set-physical-material.js +253 -0
  259. package/dist/three/level-set-physical-material.js.map +1 -0
  260. package/dist/three/level-set-velocity.d.ts +94 -0
  261. package/dist/three/level-set-velocity.js +208 -0
  262. package/dist/three/level-set-velocity.js.map +1 -0
  263. package/dist/three/material.d.ts +324 -0
  264. package/dist/three/material.js +502 -0
  265. package/dist/three/material.js.map +1 -0
  266. package/dist/three/points.d.ts +140 -0
  267. package/dist/three/points.js +261 -0
  268. package/dist/three/points.js.map +1 -0
  269. package/dist/three/sparse-source.d.ts +165 -0
  270. package/dist/three/sparse-source.js +405 -0
  271. package/dist/three/sparse-source.js.map +1 -0
  272. package/dist/three/volume-source.d.ts +22 -0
  273. package/dist/three/volume-source.js +110 -0
  274. package/dist/three/volume-source.js.map +1 -0
  275. package/dist/tools/cpu/brick-atlas.d.ts +36 -0
  276. package/dist/tools/cpu/brick-atlas.js +129 -0
  277. package/dist/tools/cpu/brick-atlas.js.map +1 -0
  278. package/dist/tools/cpu/compute.d.ts +116 -0
  279. package/dist/tools/cpu/compute.js +239 -0
  280. package/dist/tools/cpu/compute.js.map +1 -0
  281. package/dist/tools/cpu/lean-reads.d.ts +81 -0
  282. package/dist/tools/cpu/lean-reads.js +262 -0
  283. package/dist/tools/cpu/lean-reads.js.map +1 -0
  284. package/dist/tools/cpu/level-set.d.ts +111 -0
  285. package/dist/tools/cpu/level-set.js +313 -0
  286. package/dist/tools/cpu/level-set.js.map +1 -0
  287. package/dist/tools/cpu/majorant.d.ts +265 -0
  288. package/dist/tools/cpu/majorant.js +541 -0
  289. package/dist/tools/cpu/majorant.js.map +1 -0
  290. package/dist/tools/cpu/march.d.ts +297 -0
  291. package/dist/tools/cpu/march.js +726 -0
  292. package/dist/tools/cpu/march.js.map +1 -0
  293. package/dist/tools/cpu/mesh-decimate.d.ts +124 -0
  294. package/dist/tools/cpu/mesh-decimate.js +1225 -0
  295. package/dist/tools/cpu/mesh-decimate.js.map +1 -0
  296. package/dist/tools/cpu/points.d.ts +29 -0
  297. package/dist/tools/cpu/points.js +38 -0
  298. package/dist/tools/cpu/points.js.map +1 -0
  299. package/dist/tools/cpu/probe-coords.d.ts +70 -0
  300. package/dist/tools/cpu/probe-coords.js +116 -0
  301. package/dist/tools/cpu/probe-coords.js.map +1 -0
  302. package/dist/tools/cpu/read-value.d.ts +44 -0
  303. package/dist/tools/cpu/read-value.js +351 -0
  304. package/dist/tools/cpu/read-value.js.map +1 -0
  305. package/dist/tools/cpu/sample-trilinear.d.ts +43 -0
  306. package/dist/tools/cpu/sample-trilinear.js +168 -0
  307. package/dist/tools/cpu/sample-trilinear.js.map +1 -0
  308. package/dist/tools/cpu/stride-tables.d.ts +56 -0
  309. package/dist/tools/cpu/stride-tables.generated.d.ts +1059 -0
  310. package/dist/tools/cpu/stride-tables.generated.js +1267 -0
  311. package/dist/tools/cpu/stride-tables.generated.js.map +1 -0
  312. package/dist/tools/cpu/stride-tables.js +78 -0
  313. package/dist/tools/cpu/stride-tables.js.map +1 -0
  314. package/dist/tools/cpu/surface-nets.d.ts +90 -0
  315. package/dist/tools/cpu/surface-nets.js +597 -0
  316. package/dist/tools/cpu/surface-nets.js.map +1 -0
  317. package/dist/tools/errors.d.ts +66 -0
  318. package/dist/tools/errors.js +67 -0
  319. package/dist/tools/errors.js.map +1 -0
  320. package/dist/tools/frame/ambient.d.ts +98 -0
  321. package/dist/tools/frame/ambient.js +274 -0
  322. package/dist/tools/frame/ambient.js.map +1 -0
  323. package/dist/tools/frame/blackbody.d.ts +57 -0
  324. package/dist/tools/frame/blackbody.js +151 -0
  325. package/dist/tools/frame/blackbody.js.map +1 -0
  326. package/dist/tools/frame/brick-cache.d.ts +165 -0
  327. package/dist/tools/frame/brick-cache.js +326 -0
  328. package/dist/tools/frame/brick-cache.js.map +1 -0
  329. package/dist/tools/frame/emission.d.ts +137 -0
  330. package/dist/tools/frame/emission.js +290 -0
  331. package/dist/tools/frame/emission.js.map +1 -0
  332. package/dist/tools/frame/environment-gpu.d.ts +111 -0
  333. package/dist/tools/frame/environment-gpu.js +280 -0
  334. package/dist/tools/frame/environment-gpu.js.map +1 -0
  335. package/dist/tools/frame/environment.d.ts +106 -0
  336. package/dist/tools/frame/environment.js +272 -0
  337. package/dist/tools/frame/environment.js.map +1 -0
  338. package/dist/tools/frame/froxel.d.ts +58 -0
  339. package/dist/tools/frame/froxel.js +115 -0
  340. package/dist/tools/frame/froxel.js.map +1 -0
  341. package/dist/tools/frame/grid.d.ts +392 -0
  342. package/dist/tools/frame/grid.js +802 -0
  343. package/dist/tools/frame/grid.js.map +1 -0
  344. package/dist/tools/frame/index.d.ts +150 -0
  345. package/dist/tools/frame/index.js +389 -0
  346. package/dist/tools/frame/index.js.map +1 -0
  347. package/dist/tools/frame/medium.d.ts +77 -0
  348. package/dist/tools/frame/medium.js +101 -0
  349. package/dist/tools/frame/medium.js.map +1 -0
  350. package/dist/tools/frame/mie-table.d.ts +6 -0
  351. package/dist/tools/frame/mie-table.js +16 -0
  352. package/dist/tools/frame/mie-table.js.map +1 -0
  353. package/dist/tools/frame/mie.d.ts +63 -0
  354. package/dist/tools/frame/mie.js +194 -0
  355. package/dist/tools/frame/mie.js.map +1 -0
  356. package/dist/tools/frame/mlp-nn.d.ts +36 -0
  357. package/dist/tools/frame/mlp-nn.js +159 -0
  358. package/dist/tools/frame/mlp-nn.js.map +1 -0
  359. package/dist/tools/frame/mlp-tza.d.ts +29 -0
  360. package/dist/tools/frame/mlp-tza.js +186 -0
  361. package/dist/tools/frame/mlp-tza.js.map +1 -0
  362. package/dist/tools/frame/mlp.d.ts +183 -0
  363. package/dist/tools/frame/mlp.js +434 -0
  364. package/dist/tools/frame/mlp.js.map +1 -0
  365. package/dist/tools/frame/ms-exit.d.ts +42 -0
  366. package/dist/tools/frame/ms-exit.js +90 -0
  367. package/dist/tools/frame/ms-exit.js.map +1 -0
  368. package/dist/tools/frame/multi-scale.d.ts +152 -0
  369. package/dist/tools/frame/multi-scale.js +302 -0
  370. package/dist/tools/frame/multi-scale.js.map +1 -0
  371. package/dist/tools/frame/neural-weights.d.ts +10 -0
  372. package/dist/tools/frame/neural-weights.js +244 -0
  373. package/dist/tools/frame/neural-weights.js.map +1 -0
  374. package/dist/tools/frame/neural.d.ts +80 -0
  375. package/dist/tools/frame/neural.js +150 -0
  376. package/dist/tools/frame/neural.js.map +1 -0
  377. package/dist/tools/frame/occluders.d.ts +51 -0
  378. package/dist/tools/frame/occluders.js +72 -0
  379. package/dist/tools/frame/occluders.js.map +1 -0
  380. package/dist/tools/frame/pyramid-layout.d.ts +55 -0
  381. package/dist/tools/frame/pyramid-layout.js +100 -0
  382. package/dist/tools/frame/pyramid-layout.js.map +1 -0
  383. package/dist/tools/frame/shadows.d.ts +190 -0
  384. package/dist/tools/frame/shadows.js +468 -0
  385. package/dist/tools/frame/shadows.js.map +1 -0
  386. package/dist/tools/frame/sparse.d.ts +147 -0
  387. package/dist/tools/frame/sparse.js +432 -0
  388. package/dist/tools/frame/sparse.js.map +1 -0
  389. package/dist/tools/frame/spectral-stack.d.ts +159 -0
  390. package/dist/tools/frame/spectral-stack.js +391 -0
  391. package/dist/tools/frame/spectral-stack.js.map +1 -0
  392. package/dist/tools/frame/spectral.d.ts +222 -0
  393. package/dist/tools/frame/spectral.js +572 -0
  394. package/dist/tools/frame/spectral.js.map +1 -0
  395. package/dist/tools/frame/stack.d.ts +115 -0
  396. package/dist/tools/frame/stack.js +290 -0
  397. package/dist/tools/frame/stack.js.map +1 -0
  398. package/dist/tools/frame/view.d.ts +131 -0
  399. package/dist/tools/frame/view.js +337 -0
  400. package/dist/tools/frame/view.js.map +1 -0
  401. package/dist/tools/index.d.ts +157 -0
  402. package/dist/tools/index.js +132 -0
  403. package/dist/tools/index.js.map +1 -0
  404. package/dist/tools/internal.d.ts +87 -0
  405. package/dist/tools/internal.js +85 -0
  406. package/dist/tools/internal.js.map +1 -0
  407. package/dist/tools/nanovdb/build-from-vdb.d.ts +59 -0
  408. package/dist/tools/nanovdb/build-from-vdb.js +100 -0
  409. package/dist/tools/nanovdb/build-from-vdb.js.map +1 -0
  410. package/dist/tools/nanovdb/bytes.d.ts +233 -0
  411. package/dist/tools/nanovdb/bytes.js +388 -0
  412. package/dist/tools/nanovdb/bytes.js.map +1 -0
  413. package/dist/tools/nanovdb/coarse-first.d.ts +78 -0
  414. package/dist/tools/nanovdb/coarse-first.js +92 -0
  415. package/dist/tools/nanovdb/coarse-first.js.map +1 -0
  416. package/dist/tools/nanovdb/half.d.ts +22 -0
  417. package/dist/tools/nanovdb/half.js +73 -0
  418. package/dist/tools/nanovdb/half.js.map +1 -0
  419. package/dist/tools/nanovdb/index.d.ts +34 -0
  420. package/dist/tools/nanovdb/index.js +25 -0
  421. package/dist/tools/nanovdb/index.js.map +1 -0
  422. package/dist/tools/nanovdb/inspect.d.ts +33 -0
  423. package/dist/tools/nanovdb/inspect.js +70 -0
  424. package/dist/tools/nanovdb/inspect.js.map +1 -0
  425. package/dist/tools/nanovdb/leaf-codec.d.ts +119 -0
  426. package/dist/tools/nanovdb/leaf-codec.js +356 -0
  427. package/dist/tools/nanovdb/leaf-codec.js.map +1 -0
  428. package/dist/tools/nanovdb/quantize.d.ts +72 -0
  429. package/dist/tools/nanovdb/quantize.js +329 -0
  430. package/dist/tools/nanovdb/quantize.js.map +1 -0
  431. package/dist/tools/nanovdb/resample.d.ts +177 -0
  432. package/dist/tools/nanovdb/resample.js +692 -0
  433. package/dist/tools/nanovdb/resample.js.map +1 -0
  434. package/dist/tools/nanovdb/serialize.d.ts +176 -0
  435. package/dist/tools/nanovdb/serialize.js +439 -0
  436. package/dist/tools/nanovdb/serialize.js.map +1 -0
  437. package/dist/tools/nanovdb/stats.d.ts +87 -0
  438. package/dist/tools/nanovdb/stats.js +225 -0
  439. package/dist/tools/nanovdb/stats.js.map +1 -0
  440. package/dist/tools/nanovdb/transform.d.ts +30 -0
  441. package/dist/tools/nanovdb/transform.js +94 -0
  442. package/dist/tools/nanovdb/transform.js.map +1 -0
  443. package/dist/tools/nanovdb/tree.d.ts +186 -0
  444. package/dist/tools/nanovdb/tree.js +530 -0
  445. package/dist/tools/nanovdb/tree.js.map +1 -0
  446. package/dist/tools/nanovdb/write-nvdb.d.ts +74 -0
  447. package/dist/tools/nanovdb/write-nvdb.js +290 -0
  448. package/dist/tools/nanovdb/write-nvdb.js.map +1 -0
  449. package/dist/tools/nvdb-file.d.ts +265 -0
  450. package/dist/tools/nvdb-file.js +763 -0
  451. package/dist/tools/nvdb-file.js.map +1 -0
  452. package/dist/tools/nvdb-stream.d.ts +154 -0
  453. package/dist/tools/nvdb-stream.js +409 -0
  454. package/dist/tools/nvdb-stream.js.map +1 -0
  455. package/dist/tools/reference/analytic.d.ts +41 -0
  456. package/dist/tools/reference/analytic.js +95 -0
  457. package/dist/tools/reference/analytic.js.map +1 -0
  458. package/dist/tools/reference/environment.d.ts +62 -0
  459. package/dist/tools/reference/environment.js +154 -0
  460. package/dist/tools/reference/environment.js.map +1 -0
  461. package/dist/tools/reference/index.d.ts +12 -0
  462. package/dist/tools/reference/index.js +13 -0
  463. package/dist/tools/reference/index.js.map +1 -0
  464. package/dist/tools/reference/media.d.ts +14 -0
  465. package/dist/tools/reference/media.js +30 -0
  466. package/dist/tools/reference/media.js.map +1 -0
  467. package/dist/tools/reference/rng.d.ts +20 -0
  468. package/dist/tools/reference/rng.js +30 -0
  469. package/dist/tools/reference/rng.js.map +1 -0
  470. package/dist/tools/reference/scene.d.ts +312 -0
  471. package/dist/tools/reference/scene.js +169 -0
  472. package/dist/tools/reference/scene.js.map +1 -0
  473. package/dist/tools/reference/tables.d.ts +98 -0
  474. package/dist/tools/reference/tables.js +264 -0
  475. package/dist/tools/reference/tables.js.map +1 -0
  476. package/dist/tools/reference/trace.d.ts +160 -0
  477. package/dist/tools/reference/trace.js +497 -0
  478. package/dist/tools/reference/trace.js.map +1 -0
  479. package/dist/tools/vdb/bit-utils.d.ts +20 -0
  480. package/dist/tools/vdb/bit-utils.js +42 -0
  481. package/dist/tools/vdb/bit-utils.js.map +1 -0
  482. package/dist/tools/vdb/blosc-write.d.ts +43 -0
  483. package/dist/tools/vdb/blosc-write.js +197 -0
  484. package/dist/tools/vdb/blosc-write.js.map +1 -0
  485. package/dist/tools/vdb/blosc.d.ts +86 -0
  486. package/dist/tools/vdb/blosc.js +287 -0
  487. package/dist/tools/vdb/blosc.js.map +1 -0
  488. package/dist/tools/vdb/blosclz.d.ts +33 -0
  489. package/dist/tools/vdb/blosclz.js +112 -0
  490. package/dist/tools/vdb/blosclz.js.map +1 -0
  491. package/dist/tools/vdb/byte-reader.d.ts +50 -0
  492. package/dist/tools/vdb/byte-reader.js +161 -0
  493. package/dist/tools/vdb/byte-reader.js.map +1 -0
  494. package/dist/tools/vdb/compression.d.ts +81 -0
  495. package/dist/tools/vdb/compression.js +260 -0
  496. package/dist/tools/vdb/compression.js.map +1 -0
  497. package/dist/tools/vdb/errors.d.ts +10 -0
  498. package/dist/tools/vdb/errors.js +11 -0
  499. package/dist/tools/vdb/errors.js.map +1 -0
  500. package/dist/tools/vdb/grid.d.ts +37 -0
  501. package/dist/tools/vdb/grid.js +153 -0
  502. package/dist/tools/vdb/grid.js.map +1 -0
  503. package/dist/tools/vdb/half-float.d.ts +9 -0
  504. package/dist/tools/vdb/half-float.js +24 -0
  505. package/dist/tools/vdb/half-float.js.map +1 -0
  506. package/dist/tools/vdb/index.d.ts +4 -0
  507. package/dist/tools/vdb/index.js +3 -0
  508. package/dist/tools/vdb/index.js.map +1 -0
  509. package/dist/tools/vdb/inflate.d.ts +24 -0
  510. package/dist/tools/vdb/inflate.js +334 -0
  511. package/dist/tools/vdb/inflate.js.map +1 -0
  512. package/dist/tools/vdb/lz4.d.ts +30 -0
  513. package/dist/tools/vdb/lz4.js +228 -0
  514. package/dist/tools/vdb/lz4.js.map +1 -0
  515. package/dist/tools/vdb/metadata.d.ts +17 -0
  516. package/dist/tools/vdb/metadata.js +72 -0
  517. package/dist/tools/vdb/metadata.js.map +1 -0
  518. package/dist/tools/vdb/parse.d.ts +47 -0
  519. package/dist/tools/vdb/parse.js +241 -0
  520. package/dist/tools/vdb/parse.js.map +1 -0
  521. package/dist/tools/vdb/point-render-data.d.ts +79 -0
  522. package/dist/tools/vdb/point-render-data.js +137 -0
  523. package/dist/tools/vdb/point-render-data.js.map +1 -0
  524. package/dist/tools/vdb/points.d.ts +186 -0
  525. package/dist/tools/vdb/points.js +835 -0
  526. package/dist/tools/vdb/points.js.map +1 -0
  527. package/dist/tools/vdb/transform.d.ts +23 -0
  528. package/dist/tools/vdb/transform.js +54 -0
  529. package/dist/tools/vdb/transform.js.map +1 -0
  530. package/dist/tools/vdb/tree.d.ts +111 -0
  531. package/dist/tools/vdb/tree.js +228 -0
  532. package/dist/tools/vdb/tree.js.map +1 -0
  533. package/dist/tools/vdb/types.d.ts +195 -0
  534. package/dist/tools/vdb/types.js +3 -0
  535. package/dist/tools/vdb/types.js.map +1 -0
  536. package/dist/tools/wvdb/bake.d.ts +145 -0
  537. package/dist/tools/wvdb/bake.js +361 -0
  538. package/dist/tools/wvdb/bake.js.map +1 -0
  539. package/dist/tools/wvdb/dense.d.ts +191 -0
  540. package/dist/tools/wvdb/dense.js +368 -0
  541. package/dist/tools/wvdb/dense.js.map +1 -0
  542. package/dist/tools/wvdb/format.d.ts +220 -0
  543. package/dist/tools/wvdb/format.js +306 -0
  544. package/dist/tools/wvdb/format.js.map +1 -0
  545. package/dist/tools/wvdb/index.d.ts +14 -0
  546. package/dist/tools/wvdb/index.js +15 -0
  547. package/dist/tools/wvdb/index.js.map +1 -0
  548. package/dist/tools/wvdb/level-set.d.ts +56 -0
  549. package/dist/tools/wvdb/level-set.js +153 -0
  550. package/dist/tools/wvdb/level-set.js.map +1 -0
  551. package/dist/tools/wvdb/nanovdb.d.ts +59 -0
  552. package/dist/tools/wvdb/nanovdb.js +64 -0
  553. package/dist/tools/wvdb/nanovdb.js.map +1 -0
  554. package/dist/tools/wvdb/partial.d.ts +74 -0
  555. package/dist/tools/wvdb/partial.js +233 -0
  556. package/dist/tools/wvdb/partial.js.map +1 -0
  557. package/dist/tools/wvdb/read.d.ts +336 -0
  558. package/dist/tools/wvdb/read.js +766 -0
  559. package/dist/tools/wvdb/read.js.map +1 -0
  560. package/dist/tools/wvdb/sha256.d.ts +7 -0
  561. package/dist/tools/wvdb/sha256.js +76 -0
  562. package/dist/tools/wvdb/sha256.js.map +1 -0
  563. package/dist/tools/wvdb/write.d.ts +149 -0
  564. package/dist/tools/wvdb/write.js +403 -0
  565. package/dist/tools/wvdb/write.js.map +1 -0
  566. package/package.json +83 -4
  567. package/vendor/LICENSE +201 -0
  568. package/vendor/NOTICE +19 -0
  569. package/vendor/VENDOR.md +100 -0
  570. package/vendor/pnanovdb.wgsl +1577 -0
@@ -0,0 +1 @@
1
+ {"version":3,"file":"multi-scale.js","sourceRoot":"","sources":["../../../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,GAAG,CAAC,EAAE,CAAC;QACzE,MAAM,IAAI,QAAQ,CAAC,gBAAgB,EAAE,2DAA2D,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC;IAC1I,CAAC;IACD,MAAM,SAAS,GAAG,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,WAAW,UAAU,CAAC,IAAI,CAAC,CAAC,CAAE,CAAE,OAAO,UAAU,CAAC,IAAI,CAAC,CAAC,CAAE,CAAE,GAAG,CAAC,CAAC,CAAC,WAAW,UAAU,CAAC,IAAI,CAAC,CAAC,CAAE,CAAE,QAAQ,CAAC;IAC/I,MAAM,QAAQ,GAAG,WAAW,GAAG,CAAC,CAAC,CAAC,CAAC,iBAAiB,CAAC,CAAC,CAAC,iBAAiB,CAAC;IACzE,OAAO,UAAU,CAAC,GAAG,uBAAuB;;;;;;;;;;;;iBAY7B,SAAS;;;;aAIb,QAAQ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA6CpB,CAAC;AACF,CAAC","sourcesContent":["// Portions derived from mjurczyk/openvdb (MIT), commit 4e2d46f (\"Add opt-in multi-scale density lookups for\n// indirect light\", after v0.29):\n// src/three-openvdb/frame/webgpu/frameMultiScaleChunks.js L1–71 (frameMultiScaleLight);\n// src/three-openvdb/frame/webgpu/FrameGridMipMaterial.js (the binomial branch: weights 1 3 3 1 on 4 x 4 x 4 taps);\n// src/three-openvdb/frame/webgpu/frameNeuralChunks.js (createNeuralMipNodes: sampleLevel, unit).\n// Copyright (c) mjurczyk/openvdb contributors. Licensed under the MIT License (see THIRD_PARTY_NOTICES.md).\n// Changes: WGSL compute on 3D textures (his levels are z-slice atlases drawn by a fragment pass); the chain is\n// built in f32 and written as f16 by buffer copies (rg16float in core WebGPU, no storage-texture format needed);\n// zero-padded binomial levels on an exactly halving layout by default (his clamped edges behind `edge: 'clamp'`);\n// the lookup is a text WGSL function over host-bound textures. CPU twins: `tools/frame/multi-scale.ts`.\n// Divergences: DIVERGES.md (K7.3 row).\n\n/**\n * `vdbCreateMultiScaleMips` (K7.3): the binomial mip chain of a 3D grid texture for `'multi-scale'` multiple\n * scattering (mjurczyk 4e2d46f, Disney \"Deep Scattering\" §4.2), recorded into the host's encoder, plus the WGSL\n * lookup a transmittance kernel calls (`vdbFrameMultiScaleWgsl`). Engine-free; internal (K6.3 consumes it).\n *\n * Build, one compute pass (dispatches see each other's writes):\n * 1. **level** k = 1 … levels − 1 (one thread per texel of level k): the separable 1 3 3 1 sum of the 4 × 4 × 4\n * taps 2x − 1 … 2x + 2 of level k − 1, / 512, in f32 into a scratch chain. Level 1 reads the host's texture\n * (`textureLoad`, any float format, the selected channels, a region at `origin`); level k ≥ 2 reads the chain.\n * 2. **pack** (one thread per output word): f32 → f16 (round to nearest even, `vdbFloatToHalf`) into rows of\n * 256-byte multiples, then `copyBufferToTexture` into mip k − 1 of the output texture.\n *\n * Output: one 3D texture, mip j = level j + 1, sizes halving exactly (`vdbFrameMultiScaleLayout`). Format\n * r16float / rg16float / rgba16float by channel count; all three are filterable and copy targets in core WebGPU,\n * so no optional feature is needed (rg16float is not storage-capable without `texture-formats-tier1`, which is\n * why the kernel writes a buffer, not a storage texture). The texture is the chain's own\n * (`TEXTURE_BINDING | COPY_DST | COPY_SRC`) or the host's (`target`, never destroyed here).\n *\n * Lifetime: `resize` replaces the texture and the scratch (`version` bumps); the old ones are retired, as the\n * pool's buffers: destroyed after two more `record`s, once `queue.onSubmittedWorkDone()` asked then resolves, so\n * a bind group the host built on the old `view` for the frame in flight stays valid. `destroy()` frees everything\n * this object allocated (retired included), never `target`.\n */\nimport { VDBError } from \"../errors.js\";\nimport { USAGE, WORKGROUP_AXIS } from \"./shared.js\";\nimport {\n VDB_FRAME_MULTI_SCALE_DEFAULT_LEVELS,\n vdbFrameMultiScaleLayout,\n type VDBFrameMultiScaleEdge,\n type VDBFrameMultiScaleLayout,\n} from \"../../tools/frame/multi-scale.js\";\n\nconst W = WORKGROUP_AXIS;\nconst STAGE_COMPUTE = 0x4;\nconst TEXTURE_USAGE = { COPY_SRC: 0x1, COPY_DST: 0x2, TEXTURE_BINDING: 0x4 } as const;\n/** Uniform slot stride (minUniformBufferOffsetAlignment's default). */\nconst SLOT = 256;\nconst PARAMS_BYTES = 112;\n\n/** Output formats of the chain: components per texel. */\nexport type VDBMultiScaleFormat = \"r16float\" | \"rg16float\" | \"rgba16float\";\nconst FORMAT_CHANNELS: Record<VDBMultiScaleFormat, number> = { r16float: 1, rg16float: 2, rgba16float: 4 };\n\nconst BUILD_WGSL = /* wgsl */ `\nstruct MsParams {\n srcOrigin: vec3u,\n fromTexture: u32,\n srcDims: vec3u,\n srcOffset: u32,\n srcExtent: vec3u,\n dstOffset: u32,\n dims: vec3u,\n edgeClamp: u32,\n dstExtent: vec3u,\n channels: u32,\n select: vec4u,\n rowWords: u32,\n texelChannels: u32,\n packOffset: u32,\n pad0: u32,\n};\n@group(0) @binding(0) var<uniform> ms: MsParams;\n@group(0) @binding(1) var msSource: texture_3d<f32>;\n@group(0) @binding(2) var<storage, read_write> msScratch: array<u32>;\n\nfn msWeight(i: i32) -> f32 {\n return select(3.0, 1.0, i == 0 || i == 3);\n}\n\n// Tap p of the source level, channel c: 0 outside it ('zero'), or clamped to its valid texels ('clamp').\nfn msTap(p: vec3i, c: u32) -> f32 {\n var q = p;\n if ms.edgeClamp != 0u {\n q = clamp(p, vec3i(0), vec3i(ms.srcExtent) - vec3i(1));\n } else if any(p < vec3i(0)) || any(p >= vec3i(ms.srcDims)) {\n return 0.0;\n }\n if ms.fromTexture != 0u {\n let t = textureLoad(msSource, vec3u(q) + ms.srcOrigin, 0);\n return t[ms.select[c]];\n }\n let i = (u32(q.x) + (u32(q.y) + u32(q.z) * ms.srcDims.y) * ms.srcDims.x) * ms.channels + c;\n return bitcast<f32>(msScratch[ms.srcOffset + i]);\n}\n\n// One texel of level k: the 1 3 3 1 binomial of the 4 x 4 x 4 taps 2x - 1 ... 2x + 2 (x, then y, then z), / 512.\n@compute @workgroup_size(${W}, ${W}, ${W})\nfn csMsLevel(@builtin(global_invocation_id) id: vec3u) {\n if any(id >= ms.dims) {\n return;\n }\n var e = id;\n if ms.edgeClamp != 0u {\n e = min(id, ms.dstExtent - vec3u(1u));\n }\n let b = vec3i(e) * 2 - vec3i(1);\n let o = (id.x + (id.y + id.z * ms.dims.y) * ms.dims.x) * ms.channels;\n for (var c = 0u; c < ms.channels; c++) {\n var sz = 0.0;\n for (var l = 0; l < 4; l++) {\n var sy = 0.0;\n for (var j = 0; j < 4; j++) {\n var sx = 0.0;\n for (var i = 0; i < 4; i++) {\n sx += msWeight(i) * msTap(b + vec3i(i, j, l), c);\n }\n sy += msWeight(j) * sx;\n }\n sz += msWeight(l) * sy;\n }\n msScratch[ms.dstOffset + o + c] = bitcast<u32>(sz / 512.0);\n }\n}\n\n// f32 -> f16 bits, round to nearest even (tools vdbFloatToHalf, after NanoVDB HalfLite).\nfn msHalf(v: f32) -> u32 {\n let bits = bitcast<u32>(v);\n let ui = bits & 0x7fffffffu;\n var h = (bits >> 16u) & 0x8000u;\n if ui >= 0x38800000u {\n if ui >= 0x7f800000u {\n h = h | 0x7c00u;\n if ui == 0x7f800000u {\n return h;\n }\n let m = (ui & 0x7fffffu) >> 13u;\n return h | m | select(0u, 1u, m == 0u);\n }\n if ui > 0x477fefffu {\n return h | 0x7c00u;\n }\n let r = ui - 0x38000000u;\n return h | ((r + 0x00000fffu + ((r >> 13u) & 1u)) >> 13u);\n }\n if ui < 0x33000001u {\n return h;\n }\n let shift = 0x7eu - (ui >> 23u);\n let m = 0x800000u | (ui & 0x7fffffu);\n let r = m << (32u - shift);\n h = h | (m >> shift);\n if r > 0x80000000u || (r == 0x80000000u && (h & 1u) != 0u) {\n h = h + 1u;\n }\n return h;\n}\n\n// Half number n of a row: texel n / texelChannels, component n % texelChannels (0 past the level's channels).\nfn msRowHalf(y: u32, z: u32, n: u32) -> u32 {\n let x = n / ms.texelChannels;\n let c = n % ms.texelChannels;\n if x >= ms.dims.x || c >= ms.channels {\n return 0u;\n }\n let i = (x + (y + z * ms.dims.y) * ms.dims.x) * ms.channels + c;\n return msHalf(bitcast<f32>(msScratch[ms.dstOffset + i]));\n}\n\n// Two halves per word, rows of rowWords words (bytesPerRow a multiple of 256), at packOffset words.\n@compute @workgroup_size(${W}, ${W}, ${W})\nfn csMsPack(@builtin(global_invocation_id) id: vec3u) {\n let words = (ms.dims.x * ms.texelChannels + 1u) / 2u;\n if id.x >= words || id.y >= ms.dims.y || id.z >= ms.dims.z {\n return;\n }\n let lo = msRowHalf(id.y, id.z, id.x * 2u);\n let hi = msRowHalf(id.y, id.z, id.x * 2u + 1u);\n msScratch[ms.packOffset + (id.y + id.z * ms.dims.y) * ms.rowWords + id.x] = lo | (hi << 16u);\n}\n`;\n\n/** The WGSL of the mip build kernels (exported for tests). */\nexport function multiScaleMipsWgsl(): string {\n return BUILD_WGSL;\n}\n\ninterface Pipelines {\n level: GPUComputePipeline;\n pack: GPUComputePipeline;\n group0: GPUBindGroupLayout;\n error: Promise<GPUError | null>;\n}\n\nconst pipelines = new WeakMap<GPUDevice, Pipelines>();\n\nfunction multiScalePipelines(device: GPUDevice): Pipelines {\n const cached = pipelines.get(device);\n if (cached) return cached;\n device.pushErrorScope(\"validation\");\n const group0 = device.createBindGroupLayout({\n label: \"vdb multiScaleMips group 0\",\n entries: [\n { binding: 0, visibility: STAGE_COMPUTE, buffer: { type: \"uniform\", hasDynamicOffset: true, minBindingSize: PARAMS_BYTES } },\n { binding: 1, visibility: STAGE_COMPUTE, texture: { sampleType: \"unfilterable-float\", viewDimension: \"3d\" } },\n { binding: 2, visibility: STAGE_COMPUTE, buffer: { type: \"storage\" } },\n ],\n });\n const module = device.createShaderModule({ label: \"vdb multiScaleMips\", code: BUILD_WGSL });\n const layout = device.createPipelineLayout({ bindGroupLayouts: [group0] });\n const make = (entryPoint: string) => device.createComputePipeline({ label: `vdb multiScaleMips ${entryPoint}`, layout, compute: { module, entryPoint } });\n const p: Pipelines = { level: make(\"csMsLevel\"), pack: make(\"csMsPack\"), group0, error: device.popErrorScope() };\n pipelines.set(device, p);\n return p;\n}\n\n/** Options of {@link vdbCreateMultiScaleMips}. */\nexport interface VDBMultiScaleMipsOptions {\n /** Base texels per axis: the grid region the levels filter (one cascade of the shadow grid). */\n size: readonly [number, number, number];\n /** Levels including the base (2 to 8, default 6: his `multiScaleLevels` maximum). */\n levels?: number;\n /** Source components that become the level channels, in order (default [0, 1]: extinction, absorption). */\n channels?: readonly number[];\n /** Output format (default by channel count: 1 r16float, 2 rg16float, 3–4 rgba16float). */\n format?: VDBMultiScaleFormat;\n /** Edge rule (default `'zero'`; `'clamp'` is his clamp-to-edge). */\n edge?: VDBFrameMultiScaleEdge;\n /**\n * Write into this 3D texture instead of allocating: `format`, the layout's level-1 size, levels − 1 mips,\n * `COPY_DST`. Never destroyed here.\n */\n target?: GPUTexture;\n /** Debug label of the GPU objects. */\n label?: string;\n}\n\n/** Options of {@link VDBMultiScaleMips.record}. */\nexport interface VDBMultiScaleRecordOptions {\n /** First texel of the base region in the source texture (default 0, 0, 0): a cascade of a stacked grid. */\n origin?: readonly [number, number, number];\n /** Timestamps around the build's one compute pass (the `timestamp-query` feature). */\n timestampWrites?: GPUComputePassTimestampWrites;\n}\n\n/** Options of {@link VDBMultiScaleMips.resize}. */\nexport interface VDBMultiScaleResizeOptions {\n /** Levels (default: unchanged). */\n levels?: number;\n /** The host texture for the new size (required when the chain was made with `target`). */\n target?: GPUTexture;\n}\n\n/** The mip chain of a grid texture on the GPU (see the file comment). */\nexport interface VDBMultiScaleMips {\n /** The level sizes (levels 1 … levels − 1 = mips 0 … levels − 2 of {@link texture}). */\n readonly layout: VDBFrameMultiScaleLayout;\n /** Components per level texel (the `channels` option's length). */\n readonly channels: number;\n /** The texture's format. */\n readonly format: VDBMultiScaleFormat;\n /** The levels as one 3D texture with levels − 1 mips. */\n readonly texture: GPUTexture;\n /** A 3D view of every mip of {@link texture}: bind it as the lookup's `mips`. */\n readonly view: GPUTextureView;\n /** Bumps when `resize` replaces {@link texture}: rebuild bind groups that hold {@link view}. */\n readonly version: number;\n /** Bytes: `textures` (counted whoever owns them) and `scratch` (this chain's buffers). */\n readonly gpuBytes: { readonly textures: number; readonly scratch: number };\n /** Pipeline validation (null = valid). */\n readonly error: Promise<GPUError | null>;\n /**\n * Records a build of every level from `source` into `encoder`; the host submits it. Record it after the\n * pass that writes `source` (in the same encoder or an earlier submit).\n *\n * @param encoder The host's encoder.\n * @param source The base grid: a 3D texture with `TEXTURE_BINDING` and a float sample type, or a 3D view of\n * one (then the size and format are the host's to check). Holds the region at `origin`.\n * @param options Region origin and timestamps. The origin lives in a uniform written with `queue.writeBuffer`,\n * so builds from two origins need two submits.\n */\n record(encoder: GPUCommandEncoder, source: GPUTexture | GPUTextureView, options?: VDBMultiScaleRecordOptions): void;\n /** New base size (and levels): new texture and scratch, `version` bumps, the old ones retired (file comment). */\n resize(size: readonly [number, number, number], options?: VDBMultiScaleResizeOptions): void;\n /** Frees what this chain allocated, retired resources included (never `target`). Idempotent. */\n destroy(): void;\n}\n\nconst align = (n: number, a: number) => Math.ceil(n / a) * a;\nconst bad = (message: string): never => {\n throw new VDBError(\"VDB_BAD_OPTION\", `vdbCreateMultiScaleMips: ${message}`);\n};\n\n/** Updates a retired texture must outlive before the chain asks the queue about it (the pool's rule). */\nconst RETIRE_AFTER_RECORDS = 2;\n\ninterface Resources {\n layout: VDBFrameMultiScaleLayout;\n texture: GPUTexture;\n view: GPUTextureView;\n owned: (GPUBuffer | GPUTexture)[];\n scratch: GPUBuffer;\n params: GPUBuffer;\n /** Per level: chain word offset, packed word offset, packed row words. */\n offsets: { chain: number; pack: number; rowWords: number }[];\n gpuBytes: { textures: number; scratch: number };\n}\n\nconst isTexture = (s: GPUTexture | GPUTextureView): s is GPUTexture => typeof (s as GPUTexture).createView === \"function\";\n\nclass MultiScaleMips implements VDBMultiScaleMips {\n readonly channels: number;\n readonly format: VDBMultiScaleFormat;\n readonly error: Promise<GPUError | null>;\n version = 0;\n readonly #device: GPUDevice;\n readonly #select: readonly number[];\n readonly #edge: VDBFrameMultiScaleEdge;\n readonly #label: string;\n readonly #hostTarget: boolean;\n #r: Resources;\n #records = 0;\n #retired: { resources: (GPUBuffer | GPUTexture)[]; since: number; waiting: boolean }[] = [];\n #destroyed = false;\n\n constructor(device: GPUDevice, o: VDBMultiScaleMipsOptions) {\n if (!device || typeof (device as { createBuffer?: unknown }).createBuffer !== \"function\") bad(\"expected a GPUDevice as the first argument.\");\n if (!o || typeof o !== \"object\") bad(\"expected an options object with size.\");\n const select = o.channels ?? [0, 1];\n if (!Array.isArray(select) || select.length < 1 || select.length > 4 || select.some((c) => !Number.isInteger(c) || c < 0 || c > 3)) {\n bad(`channels must be 1 to 4 component indices from 0 to 3, got ${JSON.stringify(o.channels)}.`);\n }\n const format = o.format ?? (select.length === 1 ? \"r16float\" : select.length === 2 ? \"rg16float\" : \"rgba16float\");\n if (!(format in FORMAT_CHANNELS)) bad(`format must be r16float, rg16float or rgba16float, got ${JSON.stringify(o.format)}.`);\n if (FORMAT_CHANNELS[format] < select.length) bad(`format ${format} holds ${FORMAT_CHANNELS[format]} channel(s); channels has ${select.length}.`);\n const edge = o.edge ?? \"zero\";\n if (edge !== \"zero\" && edge !== \"clamp\") bad(`edge must be 'zero' or 'clamp', got ${JSON.stringify(o.edge)}.`);\n this.#device = device;\n this.#select = [...select];\n this.channels = select.length;\n this.format = format;\n this.#edge = edge;\n this.#label = o.label ?? \"vdb multiScaleMips\";\n this.#hostTarget = !!o.target;\n this.#r = this.#allocate(o.size, o.levels ?? VDB_FRAME_MULTI_SCALE_DEFAULT_LEVELS, o.target);\n this.error = multiScalePipelines(device).error;\n }\n\n get layout(): VDBFrameMultiScaleLayout {\n return this.#r.layout;\n }\n get texture(): GPUTexture {\n return this.#r.texture;\n }\n get view(): GPUTextureView {\n return this.#r.view;\n }\n get gpuBytes(): { textures: number; scratch: number } {\n return this.#r.gpuBytes;\n }\n\n #allocate(size: readonly number[], levels: number, target: GPUTexture | undefined): Resources {\n let layout: VDBFrameMultiScaleLayout;\n try {\n layout = vdbFrameMultiScaleLayout(size, levels);\n } catch (e) {\n return bad(e instanceof Error ? e.message.replace(/^.*?vdbFrameMultiScaleLayout: /, \"\") : String(e));\n }\n const device = this.#device;\n const F = FORMAT_CHANNELS[this.format];\n const C = this.channels;\n const top = layout.mips[0]!.dimensions;\n const mipCount = layout.levels - 1;\n const owned: (GPUBuffer | GPUTexture)[] = [];\n let texture: GPUTexture;\n if (target) {\n if (target.format !== this.format || target.dimension !== \"3d\" || target.width !== top[0] || target.height !== top[1] || target.depthOrArrayLayers !== top[2] || target.mipLevelCount !== mipCount || (target.usage & TEXTURE_USAGE.COPY_DST) === 0) {\n bad(\n `target must be a ${this.format} 3D texture of ${top.join(\"x\")} with ${mipCount} mip levels and COPY_DST ` +\n `(got ${target.format} ${target.dimension} ${target.width}x${target.height}x${target.depthOrArrayLayers}, ${target.mipLevelCount} mips, usage ${target.usage}).`,\n );\n }\n texture = target;\n } else {\n if (this.#hostTarget) bad(\"this chain writes into a host target: pass options.target for the new size.\");\n texture = device.createTexture({\n label: `${this.#label} levels`,\n size: [top[0], top[1], top[2]],\n dimension: \"3d\",\n format: this.format,\n mipLevelCount: mipCount,\n usage: TEXTURE_USAGE.TEXTURE_BINDING | TEXTURE_USAGE.COPY_DST | TEXTURE_USAGE.COPY_SRC,\n });\n owned.push(texture);\n }\n const offsets: Resources[\"offsets\"] = [];\n let chain = 0;\n for (const m of layout.mips) {\n offsets.push({ chain, pack: 0, rowWords: align(m.dimensions[0] * F * 2, 256) / 4 });\n chain += m.dimensions[0] * m.dimensions[1] * m.dimensions[2] * C;\n }\n let pack = align(chain, 64);\n layout.mips.forEach((m, i) => {\n offsets[i]!.pack = pack;\n pack = align(pack + offsets[i]!.rowWords * m.dimensions[1] * m.dimensions[2], 64);\n });\n const scratch = device.createBuffer({ label: `${this.#label} scratch`, size: Math.max(4, pack * 4), usage: USAGE.STORAGE | USAGE.COPY_SRC });\n const params = device.createBuffer({ label: `${this.#label} params`, size: 2 * mipCount * SLOT, usage: USAGE.UNIFORM | USAGE.COPY_DST });\n owned.push(scratch, params);\n const textureBytes = layout.mips.reduce((s, m) => s + m.dimensions[0] * m.dimensions[1] * m.dimensions[2] * F * 2, 0);\n const r: Resources = {\n layout,\n texture,\n view: texture.createView({ label: `${this.#label} view`, dimension: \"3d\" }),\n owned,\n scratch,\n params,\n offsets,\n gpuBytes: { textures: textureBytes, scratch: scratch.size + params.size },\n };\n this.#writeParams(r, [0, 0, 0]);\n return r;\n }\n\n /** Slots: level k at 2(k − 1), its pack at 2(k − 1) + 1. Only the level-1 slot depends on `origin`. */\n #writeParams(r: Resources, origin: readonly number[]): void {\n const { layout, offsets } = r;\n const bytes = new ArrayBuffer(2 * layout.mips.length * SLOT);\n const F = FORMAT_CHANNELS[this.format];\n layout.mips.forEach((m, i) => {\n const fromBase = i === 0;\n const srcDims = fromBase ? layout.size : layout.mips[i - 1]!.dimensions;\n const srcExtent = fromBase ? layout.size : layout.mips[i - 1]!.extent;\n for (const pack of [false, true]) {\n const u = new Uint32Array(bytes, (2 * i + (pack ? 1 : 0)) * SLOT, PARAMS_BYTES / 4);\n for (let a = 0; a < 3; a++) {\n u[a] = fromBase ? origin[a]! : 0;\n u[4 + a] = srcDims[a]!;\n u[8 + a] = srcExtent[a]!;\n u[12 + a] = m.dimensions[a]!;\n u[16 + a] = m.extent[a]!;\n }\n u[3] = fromBase ? 1 : 0;\n u[7] = fromBase ? 0 : offsets[i - 1]!.chain;\n u[11] = offsets[i]!.chain;\n u[15] = this.#edge === \"clamp\" ? 1 : 0;\n u[19] = this.channels;\n for (let c = 0; c < 4; c++) u[20 + c] = this.#select[c] ?? 0;\n u[24] = offsets[i]!.rowWords;\n u[25] = F;\n u[26] = offsets[i]!.pack;\n }\n });\n this.#device.queue.writeBuffer(r.params, 0, bytes);\n }\n\n #origin: readonly number[] = [0, 0, 0];\n\n record(encoder: GPUCommandEncoder, source: GPUTexture | GPUTextureView, options: VDBMultiScaleRecordOptions = {}): void {\n if (this.#destroyed) throw new VDBError(\"VDB_DISPOSED\", \"vdbCreateMultiScaleMips: record() after destroy().\");\n if (!source || typeof source !== \"object\") bad(\"record: expected the source GPUTexture or GPUTextureView.\");\n const origin = options.origin ?? [0, 0, 0];\n if (origin.length !== 3 || origin.some((v) => !Number.isInteger(v) || v < 0)) bad(`record: origin must be 3 integers >= 0, got ${JSON.stringify(origin)}.`);\n const r = this.#r;\n const size = r.layout.size;\n let view: GPUTextureView;\n if (isTexture(source)) {\n const f = source.format;\n if (source.dimension !== \"3d\" || (source.usage & TEXTURE_USAGE.TEXTURE_BINDING) === 0 || /int|depth|stencil/.test(f)) {\n bad(`record: the source must be a 3D texture with TEXTURE_BINDING and a float format (got ${source.dimension} ${f}, usage ${source.usage}).`);\n }\n const extent = [source.width, source.height, source.depthOrArrayLayers];\n if ([0, 1, 2].some((a) => origin[a]! + size[a]! > extent[a]!)) {\n bad(`record: the region (origin ${origin.join(\",\")}, size ${size.join(\"x\")}) is outside the source (${extent.join(\"x\")}).`);\n }\n view = source.createView({ dimension: \"3d\", baseMipLevel: 0, mipLevelCount: 1 });\n } else {\n view = source;\n }\n this.#records++;\n this.#reap();\n if (origin.some((v, a) => v !== this.#origin[a])) {\n this.#origin = [...origin];\n this.#writeParams(r, origin);\n }\n const device = this.#device;\n const p = multiScalePipelines(device);\n const group = device.createBindGroup({\n label: `${this.#label} group`,\n layout: p.group0,\n entries: [\n { binding: 0, resource: { buffer: r.params, size: PARAMS_BYTES } },\n { binding: 1, resource: view },\n { binding: 2, resource: { buffer: r.scratch } },\n ],\n });\n const F = FORMAT_CHANNELS[this.format];\n const groups = (s: readonly number[]): [number, number, number] => [Math.ceil(s[0]! / W), Math.ceil(s[1]! / W), Math.ceil(s[2]! / W)];\n const pass = encoder.beginComputePass({ label: \"vdb multiScaleMips\", ...(options.timestampWrites ? { timestampWrites: options.timestampWrites } : {}) });\n r.layout.mips.forEach((m, i) => {\n pass.setPipeline(p.level);\n pass.setBindGroup(0, group, [2 * i * SLOT]);\n pass.dispatchWorkgroups(...groups(m.dimensions));\n });\n r.layout.mips.forEach((m, i) => {\n pass.setPipeline(p.pack);\n pass.setBindGroup(0, group, [(2 * i + 1) * SLOT]);\n pass.dispatchWorkgroups(...groups([Math.ceil((m.dimensions[0] * F) / 2), m.dimensions[1], m.dimensions[2]]));\n });\n pass.end();\n r.layout.mips.forEach((m, i) => {\n const o = r.offsets[i]!;\n encoder.copyBufferToTexture(\n { buffer: r.scratch, offset: o.pack * 4, bytesPerRow: o.rowWords * 4, rowsPerImage: m.dimensions[1] },\n { texture: r.texture, mipLevel: i },\n [m.dimensions[0], m.dimensions[1], m.dimensions[2]],\n );\n });\n }\n\n resize(size: readonly [number, number, number], options: VDBMultiScaleResizeOptions = {}): void {\n if (this.#destroyed) throw new VDBError(\"VDB_DISPOSED\", \"vdbCreateMultiScaleMips: resize() after destroy().\");\n const next = this.#allocate(size, options.levels ?? this.#r.layout.levels, options.target);\n this.#retired.push({ resources: this.#r.owned, since: this.#records, waiting: false });\n this.#r = next;\n this.#origin = [0, 0, 0];\n this.version++;\n }\n\n /** The pool's rule: retired at least two records ago, then destroyed once the queue says that work is done. */\n #reap(): void {\n const ready = this.#retired.filter((r) => !r.waiting && this.#records - r.since >= RETIRE_AFTER_RECORDS);\n if (ready.length === 0) return;\n for (const r of ready) r.waiting = true;\n const destroy = (): void => {\n if (this.#destroyed) return; // destroy() freed them\n this.#retired = this.#retired.filter((r) => !ready.includes(r));\n for (const r of ready) for (const x of r.resources) x.destroy();\n };\n this.#device.queue.onSubmittedWorkDone().then(destroy, destroy);\n }\n\n destroy(): void {\n if (this.#destroyed) return;\n this.#destroyed = true;\n for (const r of this.#retired) for (const x of r.resources) x.destroy();\n this.#retired = [];\n for (const x of this.#r.owned) x.destroy();\n }\n}\n\n/**\n * Creates the binomial mip chain of a grid texture for `'multi-scale'` multiple scattering (see the file comment)\n * and returns it unbuilt: record a build with `mips.record(encoder, source)` after the pass that writes the grid,\n * then bind `mips.view` as the lookup's `mips` (`vdbFrameMultiScaleWgsl`).\n *\n * const mips = vdbCreateMultiScaleMips(device, { size: [64, 64, 64] });\n * mips.record(encoder, shadowGrid, { origin: [0, 0, 64 * lastCascade] });\n * device.queue.submit([encoder.finish()]);\n *\n * @param device The host's `GPUDevice`.\n * @param options Size, levels, channels, format, edge rule, target and label ({@link VDBMultiScaleMipsOptions}).\n */\nexport function vdbCreateMultiScaleMips(device: GPUDevice, options: VDBMultiScaleMipsOptions): VDBMultiScaleMips {\n return new MultiScaleMips(device, options);\n}\n\n/** Bytes of the WGSL `VdbFrameMultiScale` struct ({@link vdbFrameMultiScaleParams}). */\nexport const VDB_FRAME_MULTI_SCALE_PARAMS_BYTES = 64;\n\n/** The lookup's sampler: linear, clamp-to-edge (the lookup picks each mip with an explicit level). */\nexport const VDB_FRAME_MULTI_SCALE_SAMPLER: GPUSamplerDescriptor = {\n label: \"vdb multiScale sampler\",\n magFilter: \"linear\",\n minFilter: \"linear\",\n mipmapFilter: \"nearest\",\n addressModeU: \"clamp-to-edge\",\n addressModeV: \"clamp-to-edge\",\n addressModeW: \"clamp-to-edge\",\n};\n\n/** The lookup's grid (WGSL `VdbFrameMultiScale`; the CPU twin's `VDBFrameMultiScaleGrid` plus the base region). */\nexport interface VDBFrameMultiScaleParams {\n /** World box of the base region (his last cascade: gridMin, gridSize). */\n boxMin: readonly [number, number, number];\n boxSize: readonly [number, number, number];\n /** h: the grid's largest voxel side, world units. */\n unit: number;\n /** Levels read, base included (clamped in WGSL to the mips present + 1). */\n levels: number;\n /** 1 − g; 0 gives no scattered light. */\n multipleScattering: number;\n /** First texel of the base region in the base texture (default 0, 0, 0). */\n baseOrigin?: readonly [number, number, number];\n /** Base region texels per axis (the chain's `layout.size`). */\n baseSize: readonly [number, number, number];\n /**\n * K6.3a: level k of the lookup reads mip level min(k + levelOffset, the chain's mips) (default 0, his; 1 is the\n * paper's σ = 2^k, `multiScaleSigma: 'paper'`, with one more level in the chain).\n */\n levelOffset?: number;\n}\n\n/**\n * The 64 bytes of a WGSL `VdbFrameMultiScale` (into `target` at `byteOffset`, or a new buffer): boxMin, levels,\n * boxSize, unit, baseOrigin, multipleScattering, baseSize, levelOffset (K6.3a; was padding, 0 = unchanged).\n */\nexport function vdbFrameMultiScaleParams(p: VDBFrameMultiScaleParams, target: ArrayBuffer = new ArrayBuffer(VDB_FRAME_MULTI_SCALE_PARAMS_BYTES), byteOffset = 0): ArrayBuffer {\n const f = new Float32Array(target, byteOffset, 16);\n const u = new Uint32Array(target, byteOffset, 16);\n const o = p.baseOrigin ?? [0, 0, 0];\n for (let a = 0; a < 3; a++) {\n f[a] = p.boxMin[a]!;\n f[4 + a] = p.boxSize[a]!;\n f[8 + a] = o[a]!;\n f[12 + a] = p.baseSize[a]!;\n }\n u[3] = p.levels;\n f[7] = p.unit;\n f[11] = p.multipleScattering;\n u[15] = p.levelOffset ?? 0;\n return target;\n}\n\nconst MULTI_SCALE_STRUCT_WGSL = /* wgsl */ `\nstruct VdbFrameMultiScale {\n boxMin: vec3f,\n levels: u32,\n boxSize: vec3f,\n unit: f32,\n baseOrigin: vec3f,\n multipleScattering: f32,\n baseSize: vec3f,\n levelOffset: u32,\n};\n`;\n\n/**\n * K7.4a-3: the spectral lookup, the grey one (below) of each colour channel: two bases and two chains, one fetch of each\n * per point serving the three channels; the per-channel sums, depths and diffusion are the grey expressions on vec3s.\n */\nconst MULTI_SCALE_SPECTRAL_WGSL = /* wgsl */ `\n// (extinction rgb, absorption rgb) of a level at a world position\nstruct VdbFrameMultiScaleRgb {\n e: vec3f,\n a: vec3f,\n};\n\n// vdbFrameMultiScaleSample of each channel: 0 outside the box; level 0 the two bases (edges clamped), level k mip k - 1\n// of the two chains at base texel / 2^k\nfn vdbFrameMultiScaleSample3(baseE: texture_3d<f32>, baseA: texture_3d<f32>, mipsE: texture_3d<f32>, mipsA: texture_3d<f32>, smp: sampler, ms: VdbFrameMultiScale, level: u32, world: vec3f) -> VdbFrameMultiScaleRgb {\n let uvw = (world - ms.boxMin) / ms.boxSize;\n if any(uvw < vec3f(0.0)) || any(uvw > vec3f(1.0)) {\n return VdbFrameMultiScaleRgb(vec3f(0.0), vec3f(0.0));\n }\n let q = uvw * ms.baseSize;\n if level == 0u {\n let c = ms.baseOrigin + clamp(q, vec3f(0.5), ms.baseSize - vec3f(0.5));\n let p = c / vec3f(textureDimensions(baseE, 0u));\n return VdbFrameMultiScaleRgb(textureSampleLevel(baseE, smp, p, 0.0).xyz, textureSampleLevel(baseA, smp, p, 0.0).xyz);\n }\n let dims = vec3f(textureDimensions(mipsE, level - 1u));\n let p = q / (exp2(f32(level)) * dims);\n return VdbFrameMultiScaleRgb(textureSampleLevel(mipsE, smp, p, f32(level - 1u)).xyz, textureSampleLevel(mipsA, smp, p, f32(level - 1u)).xyz);\n}\n\n// vdbFrameMultiScaleLight of each channel: scattered light (total - direct) of a light slot\nfn vdbFrameMultiScaleLight3(baseE: texture_3d<f32>, baseA: texture_3d<f32>, mipsE: texture_3d<f32>, mipsA: texture_3d<f32>, smp: sampler, ms: VdbFrameMultiScale, world: vec3f, direction: vec3f, maxDistance: f32) -> vec3f {\n let h = ms.unit;\n let g = ms.multipleScattering;\n // Frisvad frame, pole at -y.\n let a = 1.0 / max(direction.y + 1.0, 1e-4);\n let b = -direction.x * direction.z * a;\n var u = vec3f(1.0 - direction.x * direction.x * a, -direction.x, b);\n var v = vec3f(b, -direction.z, 1.0 - direction.z * direction.z * a);\n if direction.y < -0.9999 {\n u = vec3f(1.0, 0.0, 0.0);\n v = vec3f(0.0, 0.0, 1.0);\n }\n // extinction, effective and reduced depths of each channel\n var dx = vec3f(0.0);\n var dy = vec3f(0.0);\n var dz = vec3f(0.0);\n let top = textureNumLevels(mipsE);\n let count = min(ms.levels, top + 1u);\n for (var k = 0u; k < count; k++) {\n let scale = h * exp2(f32(k));\n let start = scale - h;\n let segment = min(scale, maxDistance - start);\n if segment > 0.0 {\n let center = world + direction * (start + segment * 0.5);\n let read = min(k + ms.levelOffset, top);\n let s0 = vdbFrameMultiScaleSample3(baseE, baseA, mipsE, mipsA, smp, ms, read, center);\n let s1 = vdbFrameMultiScaleSample3(baseE, baseA, mipsE, mipsA, smp, ms, read, center + u * scale);\n let s2 = vdbFrameMultiScaleSample3(baseE, baseA, mipsE, mipsA, smp, ms, read, center - u * scale);\n let s3 = vdbFrameMultiScaleSample3(baseE, baseA, mipsE, mipsA, smp, ms, read, center + v * scale);\n let s4 = vdbFrameMultiScaleSample3(baseE, baseA, mipsE, mipsA, smp, ms, read, center - v * scale);\n let e = (s0.e + s1.e + s2.e + s3.e + s4.e) * 0.2;\n let absorbed = min((s0.a + s1.a + s2.a + s3.a + s4.a) * 0.2, e);\n let reduced = (e - absorbed) * g;\n dx += e * segment;\n dy += sqrt(absorbed * 3.0 * (absorbed + reduced)) * segment;\n dz += reduced * segment;\n }\n }\n var total = dx;\n if g > 0.0 {\n total = min(dx, dy + log(dz * 0.75 + vec3f(1.0)));\n }\n return max(exp(-total) - exp(-dx), vec3f(0.0));\n}\n`;\n\n/** Options of {@link vdbFrameMultiScaleWgsl}. */\nexport interface VDBFrameMultiScaleWgslOptions {\n /** Base texture components of extinction and absorption (default [0, 1]; one entry: no absorption). */\n baseChannels?: readonly number[];\n /** Components of the mip texture (default: as many as `baseChannels`; 1 reads no absorption). */\n mipChannels?: number;\n /**\n * K7.4a-3: the per-channel lookup of spectral media instead of the grey one: `vdbFrameMultiScaleSample3` /\n * `vdbFrameMultiScaleLight3` over two bases (extinction rgb, absorption rgb in xyz) and their two chains (made with\n * `channels: [0, 1, 2]`). Each channel runs the grey arithmetic in the grey order, so a grey medium gives the grey\n * lookup's value in every channel. `baseChannels` / `mipChannels` are ignored.\n */\n spectral?: boolean;\n}\n\nconst COMPONENTS = [\"x\", \"y\", \"z\", \"w\"];\n\n/**\n * The WGSL lookup of `'multi-scale'` multiple scattering, as text to paste into a host shader once (not part of\n * the VDB module, so module bytes and the size snapshot never move). Declares:\n *\n * struct VdbFrameMultiScale { boxMin: vec3f, levels: u32, boxSize: vec3f, unit: f32,\n * baseOrigin: vec3f, multipleScattering: f32, baseSize: vec3f, levelOffset: u32 }\n * fn vdbFrameMultiScaleSample(base: texture_3d<f32>, mips: texture_3d<f32>, smp: sampler,\n * ms: VdbFrameMultiScale, level: u32, world: vec3f) -> vec2f\n * fn vdbFrameMultiScaleLight(base: texture_3d<f32>, mips: texture_3d<f32>, smp: sampler,\n * ms: VdbFrameMultiScale, world: vec3f, direction: vec3f, maxDistance: f32) -> f32\n *\n * `base` is the host's grid texture (filterable float), `mips` the chain's `view`, `smp` a sampler made from\n * {@link VDB_FRAME_MULTI_SCALE_SAMPLER}; the host binds all three at its own slots and fills the struct with\n * {@link vdbFrameMultiScaleParams}. `vdbFrameMultiScaleLight` returns the scattered light (total − direct) for a\n * unit direction to the light; the caller adds its march's direct transmittance and clamps to 1. No derivatives\n * (`textureSampleLevel`), so it runs in compute and in non-uniform control flow. CPU twins:\n * `tools/frame/multi-scale.ts`. K7.4a-3 `spectral: true` declares the per-channel lookup instead,\n * `vdbFrameMultiScaleSample3` / `vdbFrameMultiScaleLight3(baseE, baseA, mipsE, mipsA, smp, ms, world, direction,\n * maxDistance) -> vec3f` over the extinction rgb and absorption rgb bases and their chains (twins\n * `vdbFrameMultiScaleSampleRgb` / `vdbFrameSpectralMultiScaleLight`).\n */\nexport function vdbFrameMultiScaleWgsl(options: VDBFrameMultiScaleWgslOptions = {}): string {\n if (options.spectral) return `${MULTI_SCALE_STRUCT_WGSL}${MULTI_SCALE_SPECTRAL_WGSL}`;\n const base = options.baseChannels ?? [0, 1];\n if (base.length < 1 || base.length > 2 || base.some((c) => !Number.isInteger(c) || c < 0 || c > 3)) {\n throw new VDBError(\"VDB_BAD_OPTION\", `vdbFrameMultiScaleWgsl: baseChannels must be 1 or 2 component indices from 0 to 3, got ${JSON.stringify(options.baseChannels)}.`);\n }\n const mipChannels = options.mipChannels ?? base.length;\n if (!Number.isInteger(mipChannels) || mipChannels < 1 || mipChannels > 4) {\n throw new VDBError(\"VDB_BAD_OPTION\", `vdbFrameMultiScaleWgsl: mipChannels must be 1 to 4, got ${JSON.stringify(options.mipChannels)}.`);\n }\n const baseValue = base.length > 1 ? `vec2f(s.${COMPONENTS[base[0]!]!}, s.${COMPONENTS[base[1]!]!})` : `vec2f(s.${COMPONENTS[base[0]!]!}, 0.0)`;\n const mipValue = mipChannels > 1 ? \"vec2f(s.x, s.y)\" : \"vec2f(s.x, 0.0)\";\n return /* wgsl */ `${MULTI_SCALE_STRUCT_WGSL}\n// (extinction, absorption) of a level at a world position: 0 outside the box; level 0 is the base region with\n// its edges clamped; level k is mip k - 1 at base texel / 2^k.\nfn vdbFrameMultiScaleSample(base: texture_3d<f32>, mips: texture_3d<f32>, smp: sampler, ms: VdbFrameMultiScale, level: u32, world: vec3f) -> vec2f {\n let uvw = (world - ms.boxMin) / ms.boxSize;\n if any(uvw < vec3f(0.0)) || any(uvw > vec3f(1.0)) {\n return vec2f(0.0);\n }\n let q = uvw * ms.baseSize;\n if level == 0u {\n let c = ms.baseOrigin + clamp(q, vec3f(0.5), ms.baseSize - vec3f(0.5));\n let s = textureSampleLevel(base, smp, c / vec3f(textureDimensions(base, 0u)), 0.0);\n return ${baseValue};\n }\n let dims = vec3f(textureDimensions(mips, level - 1u));\n let s = textureSampleLevel(mips, smp, q / (exp2(f32(level)) * dims), f32(level - 1u));\n return ${mipValue};\n}\n\n// Scattered light (total - direct) of a light slot: level k reads the bulk of the segment h (2^k - 1) to\n// h (2^(k+1) - 1) toward the light (5 points: the axis and +-h 2^k on two axes at right angles), the 1D diffusion\n// of the summed bulk gives total - its direct part (mjurczyk 4e2d46f, after Disney \"Deep Scattering\" 4.2). K6.3a:\n// the points read mip level min(k + levelOffset, mips): offset 1 blurs level k with sigma ~ 2^k voxels (the paper).\nfn vdbFrameMultiScaleLight(base: texture_3d<f32>, mips: texture_3d<f32>, smp: sampler, ms: VdbFrameMultiScale, world: vec3f, direction: vec3f, maxDistance: f32) -> f32 {\n let h = ms.unit;\n let g = ms.multipleScattering;\n // Frisvad frame, pole at -y.\n let a = 1.0 / max(direction.y + 1.0, 1e-4);\n let b = -direction.x * direction.z * a;\n var u = vec3f(1.0 - direction.x * direction.x * a, -direction.x, b);\n var v = vec3f(b, -direction.z, 1.0 - direction.z * direction.z * a);\n if direction.y < -0.9999 {\n u = vec3f(1.0, 0.0, 0.0);\n v = vec3f(0.0, 0.0, 1.0);\n }\n var depths = vec3f(0.0);\n let top = textureNumLevels(mips);\n let count = min(ms.levels, top + 1u);\n for (var k = 0u; k < count; k++) {\n let scale = h * exp2(f32(k));\n let start = scale - h;\n let segment = min(scale, maxDistance - start);\n if segment > 0.0 {\n let center = world + direction * (start + segment * 0.5);\n let read = min(k + ms.levelOffset, top);\n let bulk = (vdbFrameMultiScaleSample(base, mips, smp, ms, read, center)\n + vdbFrameMultiScaleSample(base, mips, smp, ms, read, center + u * scale)\n + vdbFrameMultiScaleSample(base, mips, smp, ms, read, center - u * scale)\n + vdbFrameMultiScaleSample(base, mips, smp, ms, read, center + v * scale)\n + vdbFrameMultiScaleSample(base, mips, smp, ms, read, center - v * scale)) * 0.2;\n let absorbed = min(bulk.y, bulk.x);\n let reduced = (bulk.x - absorbed) * g;\n depths += vec3f(bulk.x, sqrt(absorbed * 3.0 * (absorbed + reduced)), reduced) * segment;\n }\n }\n var total = depths.x;\n if g > 0.0 {\n total = min(depths.x, depths.y + log(depths.z * 0.75 + 1.0));\n }\n return max(exp(-total) - exp(-depths.x), 0.0);\n}\n`;\n}\n"]}
@@ -0,0 +1,120 @@
1
+ /**
2
+ * `vdbCreateBoxPyramid` (K3.2a): the sparse source's coarse pyramid (K3.2 `'coarse-pyramid'`) built on
3
+ * the GPU from a pool grid, recorded into the host's encoder. CPU twin: `@pmndrs/vdb/tools`
4
+ * `vdbBoxPyramid` + three's `DataUtils.toHalfFloat` (the K3.2 CPU path); parity ≤ 1 f16 ulp
5
+ * (e2e/k3-pyramid.spec.ts).
6
+ *
7
+ * Passes, one compute pass (dispatches see each other's writes):
8
+ * 1. **base** (one thread per base texel): the area-weighted box mean of the grid's voxels over the
9
+ * texel's cell, `vdbResampleGrid`'s `'box'` filter on the index cell box `[min − ½, max + ½]` with
10
+ * `⌈texels / 2^L₀⌉` texels. Overlaps are exact integers in units of 1/dims voxel (no f32 rounding
11
+ * of the footprint), summed separably x → y → z in the CPU's order. A texel whose taps touch an
12
+ * active voxel flags its 8³ texel block (atomicOr). A texel whose footprint lies in inactive
13
+ * zero tiles only (no leaf: `vdbGetDim` > 1) is 0 without the voxel loop, as on the CPU.
14
+ * 2. **mask**: texels of an unflagged block become 0 (the CPU path drops leaves with no active voxel,
15
+ * and its dense readout fills them with 0).
16
+ * 3. **levels**: his 2x2x2 box mips with clamped edge taps, level by level, into his atlas layout
17
+ * (`vdbBoxPyramidLayout`), from the f32 base (not the f16 one, as the CPU).
18
+ * 4. **pack**: f32 → f16 (three's `toHalfFloat`: truncation, its denormal and overflow tables) into
19
+ * 256-byte rows, then `copyBufferToTexture` into the r16float base and atlas textures.
20
+ *
21
+ * The textures are the pyramid's own (`TEXTURE_BINDING | COPY_DST | COPY_SRC`) or, with `targets`,
22
+ * the host's (a three texture's `GPUTexture`): r16float, `COPY_DST`, the layout's sizes; then the
23
+ * pyramid never destroys them. Scratch buffers (f32 levels, block flags, the packed rows, parameters)
24
+ * stay alive for rebuilds (a sequence replaces the grid every frame) until `destroy()`.
25
+ */
26
+ import type { VDBGridPool } from "../pool/pool.js";
27
+ import type { VDBVec3 } from "../pool/layout.js";
28
+ import type { VDBGridTypeName } from "../types.js";
29
+ import { type VDBBoxPyramidLayout } from "../../tools/frame/pyramid-layout.js";
30
+ /** The WGSL of the pyramid kernels for grids of `type` (exported for tests and the size of the shader). */
31
+ export declare function boxPyramidWgsl(type: VDBGridTypeName): string;
32
+ /**
33
+ * @internal Compiles (once per device and type, cached) the pyramid pipelines for grids of `types`, so a later
34
+ * pyramid over a grid of one of them (G16a: a sparse source following a coarse-first swap to another grid type)
35
+ * creates no pipeline. Returns the pipelines' validation results.
36
+ */
37
+ export declare function warmBoxPyramidPipelines(device: GPUDevice, types: Iterable<VDBGridTypeName>): Promise<GPUError | null>[];
38
+ /** Options of {@link vdbCreateBoxPyramid}. */
39
+ export interface VDBBoxPyramidOptions {
40
+ /** Inclusive voxel index box the pyramid covers. Default: the grid's index bbox now (fixed afterwards). */
41
+ indexBox?: {
42
+ min: VDBVec3;
43
+ max: VDBVec3;
44
+ };
45
+ /** Texels on the longest side of the base level at most (default 128). */
46
+ pyramidMax?: number;
47
+ /** Base level override (default `vdbPyramidBaseLevel`). */
48
+ level?: number;
49
+ /**
50
+ * Write into these r16float textures (`COPY_DST`; `atlas` null exactly when the layout has no atlas)
51
+ * instead of allocating. The pyramid never destroys them (a three texture's `GPUTexture`, for example).
52
+ * Without origins they must have the layout's sizes; with `baseOrigin` / `atlasOrigin` (K6.7: the core
53
+ * sparse source packs every volume's pyramid into one texture) the block at the origin must fit, and
54
+ * `base` and `atlas` may be the same texture.
55
+ */
56
+ targets?: {
57
+ base: GPUTexture;
58
+ atlas: GPUTexture | null;
59
+ baseOrigin?: VDBVec3;
60
+ atlasOrigin?: VDBVec3;
61
+ };
62
+ /** Debug label of the GPU objects. */
63
+ label?: string;
64
+ }
65
+ /** Options of {@link VDBBoxPyramid.record}. */
66
+ export interface VDBBoxPyramidRecordOptions {
67
+ /** Timestamps around the build's one compute pass (the `timestamp-query` feature). */
68
+ timestampWrites?: GPUComputePassTimestampWrites;
69
+ }
70
+ /** A coarse pyramid on the GPU (see the file comment). */
71
+ export interface VDBBoxPyramid {
72
+ /** The pool id of the grid the pyramid is built from. */
73
+ readonly gridId: number;
74
+ /** The sizes and level layout of the textures. */
75
+ readonly layout: VDBBoxPyramidLayout;
76
+ /** r16float, the base level (`layout.dimensions`). */
77
+ readonly base: GPUTexture;
78
+ /** r16float, his atlas of the levels above (`layout.atlas.dimensions`), or null. */
79
+ readonly atlas: GPUTexture | null;
80
+ /** Bytes: `textures` (r16f; counted whoever owns them) and `scratch` (this pyramid's buffers). */
81
+ readonly gpuBytes: {
82
+ readonly textures: number;
83
+ readonly scratch: number;
84
+ };
85
+ /** The grid's `imageRevision` the last recorded build read, or null before the first. */
86
+ readonly builtRevision: number | null;
87
+ /** True when the grid's image changed since the last recorded build (or none was recorded). */
88
+ readonly stale: boolean;
89
+ /** Pipeline validation (null = valid); the first build's errors surface here. */
90
+ readonly error: Promise<GPUError | null>;
91
+ /**
92
+ * Records a (re)build into `encoder`. The grid must be resident (`pool.update(encoder)` recorded
93
+ * earlier in this encoder or submitted before); call after the pool's update, as for bind groups.
94
+ *
95
+ * @param encoder The encoder the build is recorded into; the host submits it.
96
+ * @param options Timestamp writes for the build pass.
97
+ */
98
+ record(encoder: GPUCommandEncoder, options?: VDBBoxPyramidRecordOptions): void;
99
+ /** Records a rebuild when {@link stale} and the grid is resident; returns whether it did. */
100
+ update(encoder: GPUCommandEncoder): boolean;
101
+ /** Frees the scratch buffers and the textures this pyramid allocated (not `targets`). Idempotent. */
102
+ destroy(): void;
103
+ }
104
+ /**
105
+ * Creates the coarse pyramid of pool grid `gridId` on the GPU (see the file comment) and returns it
106
+ * unbuilt: record the build with `pyramid.record(encoder)` (the grid must be resident), submit, and
107
+ * rebuild with `pyramid.update(encoder)` after the grid's image changes (`imageRevision`). The pool
108
+ * must live on `device`. Frees only what it allocated (`destroy()`).
109
+ *
110
+ * const pyramid = vdbCreateBoxPyramid(device, pool, id);
111
+ * pool.update(encoder);
112
+ * pyramid.update(encoder); // first build, then only on a replace
113
+ * device.queue.submit([encoder.finish()]);
114
+ *
115
+ * @param device The host's `GPUDevice`; the pool must live on it.
116
+ * @param pool The pool that holds the grid.
117
+ * @param gridId The grid's pool id.
118
+ * @param options Index box, size cap, level, target textures and label ({@link VDBBoxPyramidOptions}).
119
+ */
120
+ export declare function vdbCreateBoxPyramid(device: GPUDevice, pool: VDBGridPool, gridId: number, options?: VDBBoxPyramidOptions): VDBBoxPyramid;