@pmndrs/vdb 0.0.0-stage → 0.1.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 (390) hide show
  1. package/CHANGELOG.md +137 -0
  2. package/LICENSE +21 -0
  3. package/README.md +448 -2
  4. package/THIRD_PARTY_NOTICES.md +147 -0
  5. package/dist/core/compute/atlas.d.ts +94 -0
  6. package/dist/core/compute/atlas.js +98 -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/pyramid.d.ts +105 -0
  12. package/dist/core/compute/pyramid.js +455 -0
  13. package/dist/core/compute/pyramid.js.map +1 -0
  14. package/dist/core/compute/shared.d.ts +115 -0
  15. package/dist/core/compute/shared.js +211 -0
  16. package/dist/core/compute/shared.js.map +1 -0
  17. package/dist/core/compute/stats.d.ts +71 -0
  18. package/dist/core/compute/stats.js +188 -0
  19. package/dist/core/compute/stats.js.map +1 -0
  20. package/dist/core/compute/value-transform.d.ts +23 -0
  21. package/dist/core/compute/value-transform.js +58 -0
  22. package/dist/core/compute/value-transform.js.map +1 -0
  23. package/dist/core/errors.d.ts +11 -0
  24. package/dist/core/errors.js +9 -0
  25. package/dist/core/errors.js.map +1 -0
  26. package/dist/core/index.d.ts +30 -0
  27. package/dist/core/index.js +27 -0
  28. package/dist/core/index.js.map +1 -0
  29. package/dist/core/internal.d.ts +15 -0
  30. package/dist/core/internal.js +15 -0
  31. package/dist/core/internal.js.map +1 -0
  32. package/dist/core/pool/affine.d.ts +34 -0
  33. package/dist/core/pool/affine.js +100 -0
  34. package/dist/core/pool/affine.js.map +1 -0
  35. package/dist/core/pool/allocator.d.ts +32 -0
  36. package/dist/core/pool/allocator.js +81 -0
  37. package/dist/core/pool/allocator.js.map +1 -0
  38. package/dist/core/pool/image-header.d.ts +82 -0
  39. package/dist/core/pool/image-header.js +175 -0
  40. package/dist/core/pool/image-header.js.map +1 -0
  41. package/dist/core/pool/layout.d.ts +164 -0
  42. package/dist/core/pool/layout.js +267 -0
  43. package/dist/core/pool/layout.js.map +1 -0
  44. package/dist/core/pool/limits.d.ts +40 -0
  45. package/dist/core/pool/limits.js +79 -0
  46. package/dist/core/pool/limits.js.map +1 -0
  47. package/dist/core/pool/pool.d.ts +279 -0
  48. package/dist/core/pool/pool.js +953 -0
  49. package/dist/core/pool/pool.js.map +1 -0
  50. package/dist/core/source/dense.d.ts +19 -0
  51. package/dist/core/source/dense.js +287 -0
  52. package/dist/core/source/dense.js.map +1 -0
  53. package/dist/core/source/types.d.ts +63 -0
  54. package/dist/core/source/types.js +9 -0
  55. package/dist/core/source/types.js.map +1 -0
  56. package/dist/core/types.d.ts +28 -0
  57. package/dist/core/types.js +28 -0
  58. package/dist/core/types.js.map +1 -0
  59. package/dist/core/wgsl/api.d.ts +41 -0
  60. package/dist/core/wgsl/api.js +463 -0
  61. package/dist/core/wgsl/api.js.map +1 -0
  62. package/dist/core/wgsl/generate.d.ts +82 -0
  63. package/dist/core/wgsl/generate.js +505 -0
  64. package/dist/core/wgsl/generate.js.map +1 -0
  65. package/dist/core/wgsl/level-set.d.ts +54 -0
  66. package/dist/core/wgsl/level-set.js +194 -0
  67. package/dist/core/wgsl/level-set.js.map +1 -0
  68. package/dist/core/wgsl/pnanovdb.chunks.generated.d.ts +14 -0
  69. package/dist/core/wgsl/pnanovdb.chunks.generated.js +330 -0
  70. package/dist/core/wgsl/pnanovdb.chunks.generated.js.map +1 -0
  71. package/dist/core/wgsl/reserved.d.ts +9 -0
  72. package/dist/core/wgsl/reserved.js +26 -0
  73. package/dist/core/wgsl/reserved.js.map +1 -0
  74. package/dist/core/wgsl/types.d.ts +104 -0
  75. package/dist/core/wgsl/types.js +2 -0
  76. package/dist/core/wgsl/types.js.map +1 -0
  77. package/dist/three/coarse-first.d.ts +162 -0
  78. package/dist/three/coarse-first.js +187 -0
  79. package/dist/three/coarse-first.js.map +1 -0
  80. package/dist/three/compute.d.ts +63 -0
  81. package/dist/three/compute.js +56 -0
  82. package/dist/three/compute.js.map +1 -0
  83. package/dist/three/device.d.ts +59 -0
  84. package/dist/three/device.js +59 -0
  85. package/dist/three/device.js.map +1 -0
  86. package/dist/three/frame/blackbody.d.ts +42 -0
  87. package/dist/three/frame/blackbody.js +74 -0
  88. package/dist/three/frame/blackbody.js.map +1 -0
  89. package/dist/three/frame/chunks.d.ts +157 -0
  90. package/dist/three/frame/chunks.js +559 -0
  91. package/dist/three/frame/chunks.js.map +1 -0
  92. package/dist/three/frame/density-material.d.ts +53 -0
  93. package/dist/three/frame/density-material.js +353 -0
  94. package/dist/three/frame/density-material.js.map +1 -0
  95. package/dist/three/frame/emission-light.d.ts +167 -0
  96. package/dist/three/frame/emission-light.js +655 -0
  97. package/dist/three/frame/emission-light.js.map +1 -0
  98. package/dist/three/frame/environment-grid-material.d.ts +21 -0
  99. package/dist/three/frame/environment-grid-material.js +184 -0
  100. package/dist/three/frame/environment-grid-material.js.map +1 -0
  101. package/dist/three/frame/environment-material.d.ts +22 -0
  102. package/dist/three/frame/environment-material.js +87 -0
  103. package/dist/three/frame/environment-material.js.map +1 -0
  104. package/dist/three/frame/grid-mip-material.d.ts +12 -0
  105. package/dist/three/frame/grid-mip-material.js +61 -0
  106. package/dist/three/frame/grid-mip-material.js.map +1 -0
  107. package/dist/three/frame/index.d.ts +39 -0
  108. package/dist/three/frame/index.js +35 -0
  109. package/dist/three/frame/index.js.map +1 -0
  110. package/dist/three/frame/inject-material.d.ts +56 -0
  111. package/dist/three/frame/inject-material.js +424 -0
  112. package/dist/three/frame/inject-material.js.map +1 -0
  113. package/dist/three/frame/integrate-material.d.ts +26 -0
  114. package/dist/three/frame/integrate-material.js +198 -0
  115. package/dist/three/frame/integrate-material.js.map +1 -0
  116. package/dist/three/frame/layout.d.ts +34 -0
  117. package/dist/three/frame/layout.js +48 -0
  118. package/dist/three/frame/layout.js.map +1 -0
  119. package/dist/three/frame/lighting-material.d.ts +41 -0
  120. package/dist/three/frame/lighting-material.js +257 -0
  121. package/dist/three/frame/lighting-material.js.map +1 -0
  122. package/dist/three/frame/lights.d.ts +11 -0
  123. package/dist/three/frame/lights.js +16 -0
  124. package/dist/three/frame/lights.js.map +1 -0
  125. package/dist/three/frame/medium.d.ts +21 -0
  126. package/dist/three/frame/medium.js +29 -0
  127. package/dist/three/frame/medium.js.map +1 -0
  128. package/dist/three/frame/neural.d.ts +14 -0
  129. package/dist/three/frame/neural.js +105 -0
  130. package/dist/three/frame/neural.js.map +1 -0
  131. package/dist/three/frame/phase.d.ts +44 -0
  132. package/dist/three/frame/phase.js +80 -0
  133. package/dist/three/frame/phase.js.map +1 -0
  134. package/dist/three/frame/renderer.d.ts +493 -0
  135. package/dist/three/frame/renderer.js +1498 -0
  136. package/dist/three/frame/renderer.js.map +1 -0
  137. package/dist/three/frame/shadow-density-material.d.ts +30 -0
  138. package/dist/three/frame/shadow-density-material.js +123 -0
  139. package/dist/three/frame/shadow-density-material.js.map +1 -0
  140. package/dist/three/frame/spectrum.d.ts +18 -0
  141. package/dist/three/frame/spectrum.js +36 -0
  142. package/dist/three/frame/spectrum.js.map +1 -0
  143. package/dist/three/frame/temporal-material.d.ts +29 -0
  144. package/dist/three/frame/temporal-material.js +152 -0
  145. package/dist/three/frame/temporal-material.js.map +1 -0
  146. package/dist/three/frame/three-internals.d.ts +65 -0
  147. package/dist/three/frame/three-internals.js +150 -0
  148. package/dist/three/frame/three-internals.js.map +1 -0
  149. package/dist/three/frame/transmittance-material.d.ts +31 -0
  150. package/dist/three/frame/transmittance-material.js +315 -0
  151. package/dist/three/frame/transmittance-material.js.map +1 -0
  152. package/dist/three/frame/view.d.ts +103 -0
  153. package/dist/three/frame/view.js +296 -0
  154. package/dist/three/frame/view.js.map +1 -0
  155. package/dist/three/frame/volume-shadow-material.d.ts +36 -0
  156. package/dist/three/frame/volume-shadow-material.js +128 -0
  157. package/dist/three/frame/volume-shadow-material.js.map +1 -0
  158. package/dist/three/frame/volume-shadows.d.ts +153 -0
  159. package/dist/three/frame/volume-shadows.js +756 -0
  160. package/dist/three/frame/volume-shadows.js.map +1 -0
  161. package/dist/three/frame/volume.d.ts +172 -0
  162. package/dist/three/frame/volume.js +256 -0
  163. package/dist/three/frame/volume.js.map +1 -0
  164. package/dist/three/grid-node.d.ts +196 -0
  165. package/dist/three/grid-node.js +510 -0
  166. package/dist/three/grid-node.js.map +1 -0
  167. package/dist/three/index.d.ts +43 -0
  168. package/dist/three/index.js +49 -0
  169. package/dist/three/index.js.map +1 -0
  170. package/dist/three/internal.d.ts +14 -0
  171. package/dist/three/internal.js +14 -0
  172. package/dist/three/internal.js.map +1 -0
  173. package/dist/three/level-set-material.d.ts +112 -0
  174. package/dist/three/level-set-material.js +204 -0
  175. package/dist/three/level-set-material.js.map +1 -0
  176. package/dist/three/material.d.ts +194 -0
  177. package/dist/three/material.js +359 -0
  178. package/dist/three/material.js.map +1 -0
  179. package/dist/three/points.d.ts +84 -0
  180. package/dist/three/points.js +130 -0
  181. package/dist/three/points.js.map +1 -0
  182. package/dist/three/sequence.d.ts +317 -0
  183. package/dist/three/sequence.js +526 -0
  184. package/dist/three/sequence.js.map +1 -0
  185. package/dist/three/sparse-source.d.ts +233 -0
  186. package/dist/three/sparse-source.js +876 -0
  187. package/dist/three/sparse-source.js.map +1 -0
  188. package/dist/three/volume-source.d.ts +167 -0
  189. package/dist/three/volume-source.js +353 -0
  190. package/dist/three/volume-source.js.map +1 -0
  191. package/dist/tools/cpu/compute.d.ts +97 -0
  192. package/dist/tools/cpu/compute.js +218 -0
  193. package/dist/tools/cpu/compute.js.map +1 -0
  194. package/dist/tools/cpu/level-set.d.ts +72 -0
  195. package/dist/tools/cpu/level-set.js +261 -0
  196. package/dist/tools/cpu/level-set.js.map +1 -0
  197. package/dist/tools/cpu/march.d.ts +206 -0
  198. package/dist/tools/cpu/march.js +575 -0
  199. package/dist/tools/cpu/march.js.map +1 -0
  200. package/dist/tools/cpu/probe-coords.d.ts +70 -0
  201. package/dist/tools/cpu/probe-coords.js +116 -0
  202. package/dist/tools/cpu/probe-coords.js.map +1 -0
  203. package/dist/tools/cpu/read-value.d.ts +31 -0
  204. package/dist/tools/cpu/read-value.js +336 -0
  205. package/dist/tools/cpu/read-value.js.map +1 -0
  206. package/dist/tools/cpu/sample-trilinear.d.ts +30 -0
  207. package/dist/tools/cpu/sample-trilinear.js +156 -0
  208. package/dist/tools/cpu/sample-trilinear.js.map +1 -0
  209. package/dist/tools/cpu/stride-tables.d.ts +56 -0
  210. package/dist/tools/cpu/stride-tables.generated.d.ts +1058 -0
  211. package/dist/tools/cpu/stride-tables.generated.js +1266 -0
  212. package/dist/tools/cpu/stride-tables.generated.js.map +1 -0
  213. package/dist/tools/cpu/stride-tables.js +78 -0
  214. package/dist/tools/cpu/stride-tables.js.map +1 -0
  215. package/dist/tools/errors.d.ts +57 -0
  216. package/dist/tools/errors.js +58 -0
  217. package/dist/tools/errors.js.map +1 -0
  218. package/dist/tools/frame/blackbody.d.ts +42 -0
  219. package/dist/tools/frame/blackbody.js +116 -0
  220. package/dist/tools/frame/blackbody.js.map +1 -0
  221. package/dist/tools/frame/emission.d.ts +128 -0
  222. package/dist/tools/frame/emission.js +282 -0
  223. package/dist/tools/frame/emission.js.map +1 -0
  224. package/dist/tools/frame/environment.d.ts +105 -0
  225. package/dist/tools/frame/environment.js +268 -0
  226. package/dist/tools/frame/environment.js.map +1 -0
  227. package/dist/tools/frame/grid.d.ts +302 -0
  228. package/dist/tools/frame/grid.js +703 -0
  229. package/dist/tools/frame/grid.js.map +1 -0
  230. package/dist/tools/frame/index.d.ts +136 -0
  231. package/dist/tools/frame/index.js +348 -0
  232. package/dist/tools/frame/index.js.map +1 -0
  233. package/dist/tools/frame/medium.d.ts +61 -0
  234. package/dist/tools/frame/medium.js +99 -0
  235. package/dist/tools/frame/medium.js.map +1 -0
  236. package/dist/tools/frame/mie-table.d.ts +6 -0
  237. package/dist/tools/frame/mie-table.js +16 -0
  238. package/dist/tools/frame/mie-table.js.map +1 -0
  239. package/dist/tools/frame/mie.d.ts +54 -0
  240. package/dist/tools/frame/mie.js +176 -0
  241. package/dist/tools/frame/mie.js.map +1 -0
  242. package/dist/tools/frame/neural-weights.d.ts +9 -0
  243. package/dist/tools/frame/neural-weights.js +245 -0
  244. package/dist/tools/frame/neural-weights.js.map +1 -0
  245. package/dist/tools/frame/neural.d.ts +80 -0
  246. package/dist/tools/frame/neural.js +150 -0
  247. package/dist/tools/frame/neural.js.map +1 -0
  248. package/dist/tools/frame/pyramid-layout.d.ts +38 -0
  249. package/dist/tools/frame/pyramid-layout.js +53 -0
  250. package/dist/tools/frame/pyramid-layout.js.map +1 -0
  251. package/dist/tools/frame/shadows.d.ts +80 -0
  252. package/dist/tools/frame/shadows.js +182 -0
  253. package/dist/tools/frame/shadows.js.map +1 -0
  254. package/dist/tools/frame/sparse.d.ts +65 -0
  255. package/dist/tools/frame/sparse.js +191 -0
  256. package/dist/tools/frame/sparse.js.map +1 -0
  257. package/dist/tools/frame/spectral.d.ts +203 -0
  258. package/dist/tools/frame/spectral.js +550 -0
  259. package/dist/tools/frame/spectral.js.map +1 -0
  260. package/dist/tools/index.d.ts +106 -0
  261. package/dist/tools/index.js +88 -0
  262. package/dist/tools/index.js.map +1 -0
  263. package/dist/tools/internal.d.ts +46 -0
  264. package/dist/tools/internal.js +31 -0
  265. package/dist/tools/internal.js.map +1 -0
  266. package/dist/tools/nanovdb/build-from-vdb.d.ts +50 -0
  267. package/dist/tools/nanovdb/build-from-vdb.js +92 -0
  268. package/dist/tools/nanovdb/build-from-vdb.js.map +1 -0
  269. package/dist/tools/nanovdb/bytes.d.ts +220 -0
  270. package/dist/tools/nanovdb/bytes.js +345 -0
  271. package/dist/tools/nanovdb/bytes.js.map +1 -0
  272. package/dist/tools/nanovdb/coarse-first.d.ts +62 -0
  273. package/dist/tools/nanovdb/coarse-first.js +86 -0
  274. package/dist/tools/nanovdb/coarse-first.js.map +1 -0
  275. package/dist/tools/nanovdb/index.d.ts +32 -0
  276. package/dist/tools/nanovdb/index.js +24 -0
  277. package/dist/tools/nanovdb/index.js.map +1 -0
  278. package/dist/tools/nanovdb/inspect.d.ts +24 -0
  279. package/dist/tools/nanovdb/inspect.js +63 -0
  280. package/dist/tools/nanovdb/inspect.js.map +1 -0
  281. package/dist/tools/nanovdb/leaf-codec.d.ts +85 -0
  282. package/dist/tools/nanovdb/leaf-codec.js +320 -0
  283. package/dist/tools/nanovdb/leaf-codec.js.map +1 -0
  284. package/dist/tools/nanovdb/quantize.d.ts +43 -0
  285. package/dist/tools/nanovdb/quantize.js +277 -0
  286. package/dist/tools/nanovdb/quantize.js.map +1 -0
  287. package/dist/tools/nanovdb/resample.d.ts +160 -0
  288. package/dist/tools/nanovdb/resample.js +679 -0
  289. package/dist/tools/nanovdb/resample.js.map +1 -0
  290. package/dist/tools/nanovdb/serialize.d.ts +145 -0
  291. package/dist/tools/nanovdb/serialize.js +395 -0
  292. package/dist/tools/nanovdb/serialize.js.map +1 -0
  293. package/dist/tools/nanovdb/stats.d.ts +58 -0
  294. package/dist/tools/nanovdb/stats.js +149 -0
  295. package/dist/tools/nanovdb/stats.js.map +1 -0
  296. package/dist/tools/nanovdb/transform.d.ts +26 -0
  297. package/dist/tools/nanovdb/transform.js +91 -0
  298. package/dist/tools/nanovdb/transform.js.map +1 -0
  299. package/dist/tools/nanovdb/tree.d.ts +175 -0
  300. package/dist/tools/nanovdb/tree.js +518 -0
  301. package/dist/tools/nanovdb/tree.js.map +1 -0
  302. package/dist/tools/nanovdb/write-nvdb.d.ts +39 -0
  303. package/dist/tools/nanovdb/write-nvdb.js +210 -0
  304. package/dist/tools/nanovdb/write-nvdb.js.map +1 -0
  305. package/dist/tools/nvdb-file.d.ts +195 -0
  306. package/dist/tools/nvdb-file.js +606 -0
  307. package/dist/tools/nvdb-file.js.map +1 -0
  308. package/dist/tools/nvdb-stream.d.ts +138 -0
  309. package/dist/tools/nvdb-stream.js +365 -0
  310. package/dist/tools/nvdb-stream.js.map +1 -0
  311. package/dist/tools/vdb/bit-utils.d.ts +20 -0
  312. package/dist/tools/vdb/bit-utils.js +42 -0
  313. package/dist/tools/vdb/bit-utils.js.map +1 -0
  314. package/dist/tools/vdb/blosc.d.ts +56 -0
  315. package/dist/tools/vdb/blosc.js +231 -0
  316. package/dist/tools/vdb/blosc.js.map +1 -0
  317. package/dist/tools/vdb/byte-reader.d.ts +40 -0
  318. package/dist/tools/vdb/byte-reader.js +139 -0
  319. package/dist/tools/vdb/byte-reader.js.map +1 -0
  320. package/dist/tools/vdb/compression.d.ts +73 -0
  321. package/dist/tools/vdb/compression.js +249 -0
  322. package/dist/tools/vdb/compression.js.map +1 -0
  323. package/dist/tools/vdb/errors.d.ts +10 -0
  324. package/dist/tools/vdb/errors.js +11 -0
  325. package/dist/tools/vdb/errors.js.map +1 -0
  326. package/dist/tools/vdb/grid.d.ts +37 -0
  327. package/dist/tools/vdb/grid.js +147 -0
  328. package/dist/tools/vdb/grid.js.map +1 -0
  329. package/dist/tools/vdb/half-float.d.ts +9 -0
  330. package/dist/tools/vdb/half-float.js +24 -0
  331. package/dist/tools/vdb/half-float.js.map +1 -0
  332. package/dist/tools/vdb/index.d.ts +3 -0
  333. package/dist/tools/vdb/index.js +3 -0
  334. package/dist/tools/vdb/index.js.map +1 -0
  335. package/dist/tools/vdb/inflate.d.ts +24 -0
  336. package/dist/tools/vdb/inflate.js +334 -0
  337. package/dist/tools/vdb/inflate.js.map +1 -0
  338. package/dist/tools/vdb/metadata.d.ts +17 -0
  339. package/dist/tools/vdb/metadata.js +72 -0
  340. package/dist/tools/vdb/metadata.js.map +1 -0
  341. package/dist/tools/vdb/parse.d.ts +25 -0
  342. package/dist/tools/vdb/parse.js +171 -0
  343. package/dist/tools/vdb/parse.js.map +1 -0
  344. package/dist/tools/vdb/point-render-data.d.ts +31 -0
  345. package/dist/tools/vdb/point-render-data.js +57 -0
  346. package/dist/tools/vdb/point-render-data.js.map +1 -0
  347. package/dist/tools/vdb/points.d.ts +160 -0
  348. package/dist/tools/vdb/points.js +794 -0
  349. package/dist/tools/vdb/points.js.map +1 -0
  350. package/dist/tools/vdb/transform.d.ts +23 -0
  351. package/dist/tools/vdb/transform.js +54 -0
  352. package/dist/tools/vdb/transform.js.map +1 -0
  353. package/dist/tools/vdb/tree.d.ts +111 -0
  354. package/dist/tools/vdb/tree.js +228 -0
  355. package/dist/tools/vdb/tree.js.map +1 -0
  356. package/dist/tools/vdb/types.d.ts +138 -0
  357. package/dist/tools/vdb/types.js +3 -0
  358. package/dist/tools/vdb/types.js.map +1 -0
  359. package/dist/tools/wvdb/bake.d.ts +116 -0
  360. package/dist/tools/wvdb/bake.js +311 -0
  361. package/dist/tools/wvdb/bake.js.map +1 -0
  362. package/dist/tools/wvdb/dense.d.ts +112 -0
  363. package/dist/tools/wvdb/dense.js +309 -0
  364. package/dist/tools/wvdb/dense.js.map +1 -0
  365. package/dist/tools/wvdb/format.d.ts +161 -0
  366. package/dist/tools/wvdb/format.js +303 -0
  367. package/dist/tools/wvdb/format.js.map +1 -0
  368. package/dist/tools/wvdb/index.d.ts +13 -0
  369. package/dist/tools/wvdb/index.js +14 -0
  370. package/dist/tools/wvdb/index.js.map +1 -0
  371. package/dist/tools/wvdb/level-set.d.ts +48 -0
  372. package/dist/tools/wvdb/level-set.js +153 -0
  373. package/dist/tools/wvdb/level-set.js.map +1 -0
  374. package/dist/tools/wvdb/nanovdb.d.ts +54 -0
  375. package/dist/tools/wvdb/nanovdb.js +60 -0
  376. package/dist/tools/wvdb/nanovdb.js.map +1 -0
  377. package/dist/tools/wvdb/read.d.ts +260 -0
  378. package/dist/tools/wvdb/read.js +743 -0
  379. package/dist/tools/wvdb/read.js.map +1 -0
  380. package/dist/tools/wvdb/sha256.d.ts +7 -0
  381. package/dist/tools/wvdb/sha256.js +76 -0
  382. package/dist/tools/wvdb/sha256.js.map +1 -0
  383. package/dist/tools/wvdb/write.d.ts +127 -0
  384. package/dist/tools/wvdb/write.js +396 -0
  385. package/dist/tools/wvdb/write.js.map +1 -0
  386. package/package.json +82 -4
  387. package/vendor/LICENSE +201 -0
  388. package/vendor/NOTICE +19 -0
  389. package/vendor/VENDOR.md +85 -0
  390. package/vendor/pnanovdb.wgsl +1539 -0
@@ -0,0 +1,147 @@
1
+ # Third-party notices for `@pmndrs/vdb`
2
+
3
+ `@pmndrs/vdb` is MIT licensed (see [LICENSE](./LICENSE)). The components below are third-party code, data or
4
+ published formulas that the package contains, derives from or depends on, with their licences. The repository
5
+ copy of this list is [THIRD_PARTY.md](https://github.com/pmndrs/vdb/blob/main/THIRD_PARTY.md).
6
+
7
+ ## mjurczyk/openvdb (MIT)
8
+
9
+ Parts of the `.wvdb` reader, writer and baker, the dense and sparse volume sources, the froxel renderer, level sets
10
+ and points are ported from [mjurczyk/openvdb](https://github.com/mjurczyk/openvdb) (pinned commit `75e7345`,
11
+ v0.26.0). The upstream repository has no LICENSE file; its npm packages declare MIT and the author has confirmed the
12
+ licence. This notice applies to the files listed below, each of which carries a header "Portions derived from
13
+ mjurczyk/openvdb (MIT)" (or "derived from") naming its upstream paths.
14
+
15
+ ```
16
+ MIT License
17
+
18
+ Copyright (c) mjurczyk/openvdb contributors
19
+
20
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
21
+ documentation files (the "Software"), to deal in the Software without restriction, including without limitation
22
+ the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and
23
+ to permit persons to whom the Software is furnished to do so, subject to the following conditions:
24
+
25
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of
26
+ the Software.
27
+
28
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO
29
+ THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
30
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
31
+ CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
32
+ DEALINGS IN THE SOFTWARE.
33
+ ```
34
+
35
+ Source files in this package that derive from it (paths are in the source tree; the package ships them compiled
36
+ under `dist/`):
37
+
38
+ - `src/core/compute/pyramid.ts`
39
+ - `src/core/source/dense.ts`
40
+ - `src/core/wgsl/level-set.ts`
41
+ - `src/three/frame/blackbody.ts`
42
+ - `src/three/frame/chunks.ts`
43
+ - `src/three/frame/density-material.ts`
44
+ - `src/three/frame/emission-light.ts`
45
+ - `src/three/frame/environment-grid-material.ts`
46
+ - `src/three/frame/environment-material.ts`
47
+ - `src/three/frame/grid-mip-material.ts`
48
+ - `src/three/frame/inject-material.ts`
49
+ - `src/three/frame/integrate-material.ts`
50
+ - `src/three/frame/layout.ts`
51
+ - `src/three/frame/lighting-material.ts`
52
+ - `src/three/frame/lights.ts`
53
+ - `src/three/frame/medium.ts`
54
+ - `src/three/frame/neural.ts`
55
+ - `src/three/frame/phase.ts`
56
+ - `src/three/frame/renderer.ts`
57
+ - `src/three/frame/shadow-density-material.ts`
58
+ - `src/three/frame/spectrum.ts`
59
+ - `src/three/frame/temporal-material.ts`
60
+ - `src/three/frame/transmittance-material.ts`
61
+ - `src/three/frame/view.ts`
62
+ - `src/three/frame/volume-shadow-material.ts`
63
+ - `src/three/frame/volume-shadows.ts`
64
+ - `src/three/frame/volume.ts`
65
+ - `src/three/level-set-material.ts`
66
+ - `src/three/points.ts`
67
+ - `src/three/sparse-source.ts`
68
+ - `src/three/volume-source.ts`
69
+ - `src/tools/cpu/level-set.ts`
70
+ - `src/tools/frame/blackbody.ts`
71
+ - `src/tools/frame/emission.ts`
72
+ - `src/tools/frame/environment.ts`
73
+ - `src/tools/frame/grid.ts`
74
+ - `src/tools/frame/index.ts`
75
+ - `src/tools/frame/medium.ts`
76
+ - `src/tools/frame/mie.ts`
77
+ - `src/tools/frame/neural.ts`
78
+ - `src/tools/frame/pyramid-layout.ts`
79
+ - `src/tools/frame/shadows.ts`
80
+ - `src/tools/frame/sparse.ts`
81
+ - `src/tools/frame/spectral.ts`
82
+ - `src/tools/vdb/point-render-data.ts`
83
+ - `src/tools/vdb/points.ts`
84
+ - `src/tools/wvdb/bake.ts`
85
+ - `src/tools/wvdb/dense.ts`
86
+ - `src/tools/wvdb/format.ts`
87
+ - `src/tools/wvdb/level-set.ts`
88
+ - `src/tools/wvdb/read.ts`
89
+ - `src/tools/wvdb/write.ts`
90
+ - `src/tools/frame/neural-weights.ts` (data, see below)
91
+
92
+ `src/tools/frame/mie-table.ts` is the output of our port of his Mie table generator (after Bohren and Huffman's
93
+ BHMIE). The numbers are identical to his tables, but the file is generated, not copied.
94
+
95
+ ### Neural indirect-light weights
96
+
97
+ `src/tools/frame/neural-weights.ts` holds the weights of his `multipleScattering: 'neural'` network, copied unchanged
98
+ from `frameNeuralIndirect.js`. They are covered by the MIT notice above. **Training-data caveat:** his training set
99
+ includes procedural media and example volumes (`bunny_cloud.wvdb`, `smoke.wvdb`) that derive from openvdb.org
100
+ samples (CC BY-SA 4.0). The weights carry no separate licence. They live in their own module so you can swap them
101
+ (`VDBFrameRenderer.neuralNetwork`) or leave them out (`null`: `'neural'` then runs as 1D diffusion).
102
+
103
+ ## @pmndrs/bvh (MIT)
104
+
105
+ The WGSL name checker used by the tests, and the reserved-word list in `src/core/wgsl/reserved.ts` that it shares,
106
+ follow `@pmndrs/bvh` (`src/wgsl-names.ts`).
107
+
108
+ ```
109
+ MIT License
110
+
111
+ Copyright (c) 2026 Dennis Smolek
112
+
113
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
114
+ documentation files (the "Software"), to deal in the Software without restriction, including without limitation
115
+ the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and
116
+ to permit persons to whom the Software is furnished to do so, subject to the following conditions:
117
+
118
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of
119
+ the Software.
120
+
121
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO
122
+ THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
123
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
124
+ CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
125
+ DEALINGS IN THE SOFTWARE.
126
+ ```
127
+
128
+ ## Wyman, Sloan and Shirley, 2013 (published formula)
129
+
130
+ Blackbody emission colours (`vdbCie1931Fit`, `src/tools/frame/blackbody.ts`) use the multi-lobe piecewise Gaussian
131
+ fit of the CIE 1931 2-degree colour matching functions from C. Wyman, P.-P. Sloan and P. Shirley, "Simple Analytic
132
+ Approximations to the CIE XYZ Color Matching Functions", Journal of Computer Graphics Techniques 2(2), 1-11, 2013
133
+ (https://jcgt.org/published/0002/02/01/), Equation 4 and Table 1. Only the published formula and coefficients are
134
+ used; no code or data was copied. The tabulated CIE data (CC BY-SA 4.0) is not part of this package.
135
+
136
+ ## Vendored `pnanovdb.wgsl` (Apache-2.0)
137
+
138
+ `vendor/pnanovdb.wgsl` (also `@pmndrs/vdb/pnanovdb.wgsl`, and the source of the generated WGSL modules) is a
139
+ vendored, extended fork of emcfarlane's WGSL port of NanoVDB's `PNanoVDB.h` (OpenVDB, Apache-2.0). The original
140
+ copyright and attribution are in [vendor/NOTICE](./vendor/NOTICE), the licence text is
141
+ [vendor/LICENSE](./vendor/LICENSE), and every local change is logged in [vendor/VENDOR.md](./vendor/VENDOR.md).
142
+ These files must stay with any redistribution of the WGSL.
143
+
144
+ ## fflate (MIT, runtime dependency)
145
+
146
+ [fflate](https://github.com/101arrowz/fflate), Copyright (c) 2023 Arjun Barrett, provides zlib in
147
+ `@pmndrs/vdb/tools`. It is installed as a dependency, not bundled.
@@ -0,0 +1,94 @@
1
+ /**
2
+ * `decodeToAtlas`: dense decode of one pool grid's index bbox into a flat f32
3
+ * array (x fastest), recorded into the host's encoder (K2.3, ported from v1
4
+ * `three/compute.ts`). CPU twin: `vdbDecodeToAtlasCpu` + `atlasFromRaw` in
5
+ * `@pmndrs/vdb/tools`.
6
+ *
7
+ * One thread per output voxel samples the index bbox at the voxel-centre
8
+ * position of its cell (below) with `vdbReadValue(floor(p + 0.5))`
9
+ * (`'nearest'`) or `vdbSample` (`'trilinear'`, the vendored trilinear,
10
+ * `outside: 'background'`).
11
+ *
12
+ * **Sampling convention (K2.6; voxel centres).** NanoVDB voxel centres sit at
13
+ * integer index coordinates, and the bbox `[min, max]` (inclusive) holds
14
+ * `size = max - min + 1` voxels, i.e. the cells `[min - 0.5, max + 0.5]`.
15
+ * Cell `i` of an axis with `n` cells over `[min, max]` samples the index-space
16
+ * position
17
+ *
18
+ * p = min + (i + 0.5) * (max - min + 1) / n - 0.5
19
+ *
20
+ * (the centre of the i-th of `n` equal slices of `[min - 0.5, max + 0.5]`).
21
+ * At full resolution (`n == size`) that is `p = min + i`: `'nearest'` reads
22
+ * exactly voxel `min + i` (the last cell is voxel `max`) and `'trilinear'`
23
+ * reads that voxel's value unblended. Downsampled, each cell samples the
24
+ * centre of its slice. The atlas is a texture over the voxel-centred box
25
+ * `[min - 0.5, max + 0.5]`: texel `i`'s centre `(i + 0.5) / n` maps to `p`
26
+ * above. (Before K2.6 this was v1's `min + (i + 0.5) / n * size`, half a voxel
27
+ * past the centres.) The GPU writes raw f32; normalizing and quantizing to
28
+ * `uint8` happen on the CPU after readback, as in v1.
29
+ *
30
+ * The raw buffer is also the GPU-side output: with `readback: false` the
31
+ * host keeps `buffer` (`STORAGE | COPY_SRC`, `dims` product f32s) for its own
32
+ * passes and calls `dispose()` when done.
33
+ */
34
+ import type { VDBGridPool } from "../pool/pool.js";
35
+ import { type VDBReadback } from "./shared.js";
36
+ import { type VDBAtlasFilter, type VDBAtlasFormat } from "../../tools/cpu/compute.js";
37
+ export type { VDBAtlasFilter, VDBAtlasFormat };
38
+ /** Options of {@link vdbDecodeToAtlasGpu} (v1's, plus `encoder` and `readback`). */
39
+ export interface VDBDecodeToAtlasOptions {
40
+ /** Per-axis output resolution cap (a literal clamp, not a proportional downscale). Default 256. */
41
+ maxDim?: number;
42
+ /** Default `'trilinear'`. */
43
+ filter?: VDBAtlasFilter;
44
+ /** Element type of `read()`'s `data`. Default `'uint8'`. */
45
+ format?: VDBAtlasFormat;
46
+ /** Map `range` to `[0, 1]` (`float32`) or `[0, 255]` (`uint8`) in `read()`. Default `true`. */
47
+ normalize?: boolean;
48
+ /** Normalization range. Default: the grid's root min/max statistics (`pool.info(id).rootMin/rootMax`). */
49
+ range?: {
50
+ min: number;
51
+ max: number;
52
+ };
53
+ /**
54
+ * Record into this encoder. The host submits it, then calls
55
+ * `job.submitted().read()` (`read()` before `submitted()` rejects with
56
+ * `VDB_BAD_OPTION`). Omitted: the tool submits its own.
57
+ */
58
+ encoder?: GPUCommandEncoder;
59
+ /** `false`: no readback; keep `buffer` for GPU use and `dispose()` it. Default `true`. */
60
+ readback?: boolean;
61
+ }
62
+ /** What `read()` resolves with (v1's `DecodeToAtlasResult`). */
63
+ export interface VDBAtlas {
64
+ /** `dims` product values, x fastest. */
65
+ data: Uint8Array | Float32Array;
66
+ dims: [number, number, number];
67
+ /** The range used for normalization (echoed so the caller can undo it). */
68
+ range: {
69
+ min: number;
70
+ max: number;
71
+ };
72
+ }
73
+ /** The pending atlas: a {@link VDBReadback} plus the GPU output. */
74
+ export interface VDBAtlasReadback extends VDBReadback<VDBAtlas> {
75
+ readonly dims: [number, number, number];
76
+ readonly range: {
77
+ min: number;
78
+ max: number;
79
+ };
80
+ /** Raw f32 values on the GPU (`STORAGE | COPY_SRC`); freed by `read()` / `dispose()`. */
81
+ readonly buffer: GPUBuffer;
82
+ }
83
+ /**
84
+ * Records the decode of grid `gridId` of `pool` and returns a
85
+ * {@link VDBAtlasReadback}: `const { data, dims } = await decodeToAtlas(device, pool, id).read()`
86
+ * (with a host encoder: submit it, then `await job.submitted().read()`).
87
+ * Cell `i` samples index position `min + (i + 0.5) * size / n - 0.5`, voxel
88
+ * centres at full resolution (see the file comment).
89
+ *
90
+ * The grid must be resident and the pool must live on `device` (as for
91
+ * `gridStats`). The tool frees only its own parameter, output and readback
92
+ * buffers.
93
+ */
94
+ export declare function vdbDecodeToAtlasGpu(device: GPUDevice, pool: VDBGridPool, gridId: number, options?: VDBDecodeToAtlasOptions): VDBAtlasReadback;
@@ -0,0 +1,98 @@
1
+ import { VDBError } from "../errors.js";
2
+ import { checkPositiveInt, checkTarget, ComputeJob, createInitialized, hostEncoder, kernelPipeline, packParams, USAGE, workgroups, WORKGROUP_AXIS, } from "./shared.js";
3
+ import { atlasDims, atlasFromRaw, bboxSize } from "../../tools/cpu/compute.js";
4
+ const W = WORKGROUP_AXIS;
5
+ const ATLAS = {
6
+ entryPoint: "csAtlas",
7
+ outputs: 1,
8
+ footer: /* wgsl */ `
9
+ @group(1) @binding(0) var<storage, read_write> csAtlasOut: array<f32>;
10
+
11
+ @compute @workgroup_size(${W}, ${W}, ${W})
12
+ fn csAtlas(@builtin(global_invocation_id) gid: vec3u) {
13
+ let dims = csParams.dims;
14
+ if any(gid >= dims) {
15
+ return;
16
+ }
17
+ // Voxel-centre position: min + (i + 0.5) * size / dims - 0.5. Multiply
18
+ // before dividing and subtract the half voxel before adding min, so at
19
+ // full resolution the offset is exactly i (the CPU twin does the same).
20
+ let pos = vec3f(csParams.regionMin) + ((vec3f(gid) + vec3f(0.5)) * vec3f(csParams.regionSize) / vec3f(dims) - vec3f(0.5));
21
+ var acc = vdbAccessorInit(csParams.grid);
22
+ var value: f32;
23
+ if csParams.filterMode == 1u {
24
+ value = vdbSample(&acc, pos);
25
+ } else {
26
+ value = vdbReadValue(&acc, vec3i(floor(pos + vec3f(0.5))));
27
+ }
28
+ csAtlasOut[gid.x + gid.y * dims.x + gid.z * dims.x * dims.y] = value;
29
+ }
30
+ `,
31
+ };
32
+ const WHERE = "decodeToAtlas";
33
+ function checkAtlasOptions(o) {
34
+ checkPositiveInt(WHERE, "maxDim", o.maxDim ?? 256);
35
+ if (o.filter !== undefined && o.filter !== "nearest" && o.filter !== "trilinear") {
36
+ throw new VDBError("VDB_BAD_OPTION", `${WHERE}: filter must be "nearest" or "trilinear", got ${JSON.stringify(o.filter)}.`);
37
+ }
38
+ if (o.format !== undefined && o.format !== "uint8" && o.format !== "float32") {
39
+ throw new VDBError("VDB_BAD_OPTION", `${WHERE}: format must be "uint8" or "float32", got ${JSON.stringify(o.format)}.`);
40
+ }
41
+ if (o.range !== undefined && !(Number.isFinite(o.range?.min) && Number.isFinite(o.range?.max))) {
42
+ throw new VDBError("VDB_BAD_OPTION", `${WHERE}: range must be { min, max } with finite numbers, got ${JSON.stringify(o.range)}.`);
43
+ }
44
+ }
45
+ /**
46
+ * Records the decode of grid `gridId` of `pool` and returns a
47
+ * {@link VDBAtlasReadback}: `const { data, dims } = await decodeToAtlas(device, pool, id).read()`
48
+ * (with a host encoder: submit it, then `await job.submitted().read()`).
49
+ * Cell `i` samples index position `min + (i + 0.5) * size / n - 0.5`, voxel
50
+ * centres at full resolution (see the file comment).
51
+ *
52
+ * The grid must be resident and the pool must live on `device` (as for
53
+ * `gridStats`). The tool frees only its own parameter, output and readback
54
+ * buffers.
55
+ */
56
+ export function vdbDecodeToAtlasGpu(device, pool, gridId, options = {}) {
57
+ checkAtlasOptions(options);
58
+ const info = checkTarget(WHERE, device, pool, gridId);
59
+ const maxDim = options.maxDim ?? 256;
60
+ const filter = options.filter ?? "trilinear";
61
+ const format = options.format ?? "uint8";
62
+ const normalize = options.normalize ?? true;
63
+ const range = options.range ? { min: options.range.min, max: options.range.max } : normalize ? { min: info.rootMin, max: info.rootMax } : { min: 0, max: 1 };
64
+ const regionSize = bboxSize(info.indexBBox);
65
+ const dims = atlasDims(info.indexBBox, maxDim);
66
+ const cached = kernelPipeline(device, ATLAS, info.type);
67
+ const params = createInitialized(device, "vdb decodeToAtlas params", USAGE.UNIFORM, new Uint8Array(packParams({ grid: gridId, filter: filter === "trilinear" ? 1 : 0, regionMin: info.indexBBox.min, regionSize, dims })));
68
+ const bytes = dims[0] * dims[1] * dims[2] * 4;
69
+ const out = device.createBuffer({ label: "vdb decodeToAtlas", size: bytes, usage: USAGE.STORAGE | USAGE.COPY_SRC });
70
+ const readback = options.readback ?? true;
71
+ const staging = readback ? device.createBuffer({ label: "vdb decodeToAtlas readback", size: bytes, usage: USAGE.MAP_READ | USAGE.COPY_DST }) : null;
72
+ const group0 = device.createBindGroup({ layout: cached.group0, entries: [pool.bindGroupEntry({ group: 0, firstBinding: 0 }), { binding: 1, resource: { buffer: params } }] });
73
+ const group1 = device.createBindGroup({ layout: cached.group1, entries: [{ binding: 0, resource: { buffer: out } }] });
74
+ const host = hostEncoder(device, options.encoder, "vdb decodeToAtlas");
75
+ const pass = host.encoder.beginComputePass({ label: "vdb decodeToAtlas" });
76
+ pass.setPipeline(cached.pipeline);
77
+ pass.setBindGroup(0, group0);
78
+ pass.setBindGroup(1, group1);
79
+ pass.dispatchWorkgroups(...workgroups(dims));
80
+ pass.end();
81
+ if (staging)
82
+ host.encoder.copyBufferToBuffer(out, 0, staging, 0, bytes);
83
+ host.submit();
84
+ const finish = (raw) => ({ data: atlasFromRaw(new Float32Array(raw), { format, normalize, range }), dims: [...dims], range });
85
+ return new AtlasJob([params, out], staging, cached.error, finish, dims, range, out, host.selfSubmitted);
86
+ }
87
+ class AtlasJob extends ComputeJob {
88
+ dims;
89
+ range;
90
+ buffer;
91
+ constructor(owned, staging, error, finish, dims, range, buffer, selfSubmitted) {
92
+ super(WHERE, owned, staging, error, finish, selfSubmitted);
93
+ this.dims = dims;
94
+ this.range = range;
95
+ this.buffer = buffer;
96
+ }
97
+ }
98
+ //# sourceMappingURL=atlas.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"atlas.js","sourceRoot":"","sources":["../../../src/core/compute/atlas.ts"],"names":[],"mappings":"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","sourcesContent":["/**\n * `decodeToAtlas`: dense decode of one pool grid's index bbox into a flat f32\n * array (x fastest), recorded into the host's encoder (K2.3, ported from v1\n * `three/compute.ts`). CPU twin: `vdbDecodeToAtlasCpu` + `atlasFromRaw` in\n * `@pmndrs/vdb/tools`.\n *\n * One thread per output voxel samples the index bbox at the voxel-centre\n * position of its cell (below) with `vdbReadValue(floor(p + 0.5))`\n * (`'nearest'`) or `vdbSample` (`'trilinear'`, the vendored trilinear,\n * `outside: 'background'`).\n *\n * **Sampling convention (K2.6; voxel centres).** NanoVDB voxel centres sit at\n * integer index coordinates, and the bbox `[min, max]` (inclusive) holds\n * `size = max - min + 1` voxels, i.e. the cells `[min - 0.5, max + 0.5]`.\n * Cell `i` of an axis with `n` cells over `[min, max]` samples the index-space\n * position\n *\n * p = min + (i + 0.5) * (max - min + 1) / n - 0.5\n *\n * (the centre of the i-th of `n` equal slices of `[min - 0.5, max + 0.5]`).\n * At full resolution (`n == size`) that is `p = min + i`: `'nearest'` reads\n * exactly voxel `min + i` (the last cell is voxel `max`) and `'trilinear'`\n * reads that voxel's value unblended. Downsampled, each cell samples the\n * centre of its slice. The atlas is a texture over the voxel-centred box\n * `[min - 0.5, max + 0.5]`: texel `i`'s centre `(i + 0.5) / n` maps to `p`\n * above. (Before K2.6 this was v1's `min + (i + 0.5) / n * size`, half a voxel\n * past the centres.) The GPU writes raw f32; normalizing and quantizing to\n * `uint8` happen on the CPU after readback, as in v1.\n *\n * The raw buffer is also the GPU-side output: with `readback: false` the\n * host keeps `buffer` (`STORAGE | COPY_SRC`, `dims` product f32s) for its own\n * passes and calls `dispose()` when done.\n */\nimport type { VDBGridPool } from \"../pool/pool.js\";\nimport { VDBError } from \"../errors.js\";\nimport {\n checkPositiveInt,\n checkTarget,\n ComputeJob,\n createInitialized,\n hostEncoder,\n kernelPipeline,\n packParams,\n USAGE,\n workgroups,\n WORKGROUP_AXIS,\n type KernelSource,\n type VDBReadback,\n} from \"./shared.js\";\nimport { atlasDims, atlasFromRaw, bboxSize, type VDBAtlasFilter, type VDBAtlasFormat } from \"../../tools/cpu/compute.js\";\n\nexport type { VDBAtlasFilter, VDBAtlasFormat };\n\nconst W = WORKGROUP_AXIS;\n\nconst ATLAS: KernelSource = {\n entryPoint: \"csAtlas\",\n outputs: 1,\n footer: /* wgsl */ `\n@group(1) @binding(0) var<storage, read_write> csAtlasOut: array<f32>;\n\n@compute @workgroup_size(${W}, ${W}, ${W})\nfn csAtlas(@builtin(global_invocation_id) gid: vec3u) {\n let dims = csParams.dims;\n if any(gid >= dims) {\n return;\n }\n // Voxel-centre position: min + (i + 0.5) * size / dims - 0.5. Multiply\n // before dividing and subtract the half voxel before adding min, so at\n // full resolution the offset is exactly i (the CPU twin does the same).\n let pos = vec3f(csParams.regionMin) + ((vec3f(gid) + vec3f(0.5)) * vec3f(csParams.regionSize) / vec3f(dims) - vec3f(0.5));\n var acc = vdbAccessorInit(csParams.grid);\n var value: f32;\n if csParams.filterMode == 1u {\n value = vdbSample(&acc, pos);\n } else {\n value = vdbReadValue(&acc, vec3i(floor(pos + vec3f(0.5))));\n }\n csAtlasOut[gid.x + gid.y * dims.x + gid.z * dims.x * dims.y] = value;\n}\n`,\n};\n\n/** Options of {@link vdbDecodeToAtlasGpu} (v1's, plus `encoder` and `readback`). */\nexport interface VDBDecodeToAtlasOptions {\n /** Per-axis output resolution cap (a literal clamp, not a proportional downscale). Default 256. */\n maxDim?: number;\n /** Default `'trilinear'`. */\n filter?: VDBAtlasFilter;\n /** Element type of `read()`'s `data`. Default `'uint8'`. */\n format?: VDBAtlasFormat;\n /** Map `range` to `[0, 1]` (`float32`) or `[0, 255]` (`uint8`) in `read()`. Default `true`. */\n normalize?: boolean;\n /** Normalization range. Default: the grid's root min/max statistics (`pool.info(id).rootMin/rootMax`). */\n range?: { min: number; max: number };\n /**\n * Record into this encoder. The host submits it, then calls\n * `job.submitted().read()` (`read()` before `submitted()` rejects with\n * `VDB_BAD_OPTION`). Omitted: the tool submits its own.\n */\n encoder?: GPUCommandEncoder;\n /** `false`: no readback; keep `buffer` for GPU use and `dispose()` it. Default `true`. */\n readback?: boolean;\n}\n\n/** What `read()` resolves with (v1's `DecodeToAtlasResult`). */\nexport interface VDBAtlas {\n /** `dims` product values, x fastest. */\n data: Uint8Array | Float32Array;\n dims: [number, number, number];\n /** The range used for normalization (echoed so the caller can undo it). */\n range: { min: number; max: number };\n}\n\n/** The pending atlas: a {@link VDBReadback} plus the GPU output. */\nexport interface VDBAtlasReadback extends VDBReadback<VDBAtlas> {\n readonly dims: [number, number, number];\n readonly range: { min: number; max: number };\n /** Raw f32 values on the GPU (`STORAGE | COPY_SRC`); freed by `read()` / `dispose()`. */\n readonly buffer: GPUBuffer;\n}\n\nconst WHERE = \"decodeToAtlas\";\n\nfunction checkAtlasOptions(o: VDBDecodeToAtlasOptions): void {\n checkPositiveInt(WHERE, \"maxDim\", o.maxDim ?? 256);\n if (o.filter !== undefined && o.filter !== \"nearest\" && o.filter !== \"trilinear\") {\n throw new VDBError(\"VDB_BAD_OPTION\", `${WHERE}: filter must be \"nearest\" or \"trilinear\", got ${JSON.stringify(o.filter)}.`);\n }\n if (o.format !== undefined && o.format !== \"uint8\" && o.format !== \"float32\") {\n throw new VDBError(\"VDB_BAD_OPTION\", `${WHERE}: format must be \"uint8\" or \"float32\", got ${JSON.stringify(o.format)}.`);\n }\n if (o.range !== undefined && !(Number.isFinite(o.range?.min) && Number.isFinite(o.range?.max))) {\n throw new VDBError(\"VDB_BAD_OPTION\", `${WHERE}: range must be { min, max } with finite numbers, got ${JSON.stringify(o.range)}.`);\n }\n}\n\n/**\n * Records the decode of grid `gridId` of `pool` and returns a\n * {@link VDBAtlasReadback}: `const { data, dims } = await decodeToAtlas(device, pool, id).read()`\n * (with a host encoder: submit it, then `await job.submitted().read()`).\n * Cell `i` samples index position `min + (i + 0.5) * size / n - 0.5`, voxel\n * centres at full resolution (see the file comment).\n *\n * The grid must be resident and the pool must live on `device` (as for\n * `gridStats`). The tool frees only its own parameter, output and readback\n * buffers.\n */\nexport function vdbDecodeToAtlasGpu(device: GPUDevice, pool: VDBGridPool, gridId: number, options: VDBDecodeToAtlasOptions = {}): VDBAtlasReadback {\n checkAtlasOptions(options);\n const info = checkTarget(WHERE, device, pool, gridId);\n const maxDim = options.maxDim ?? 256;\n const filter = options.filter ?? \"trilinear\";\n const format = options.format ?? \"uint8\";\n const normalize = options.normalize ?? true;\n const range = options.range ? { min: options.range.min, max: options.range.max } : normalize ? { min: info.rootMin, max: info.rootMax } : { min: 0, max: 1 };\n const regionSize = bboxSize(info.indexBBox);\n const dims = atlasDims(info.indexBBox, maxDim);\n const cached = kernelPipeline(device, ATLAS, info.type);\n\n const params = createInitialized(\n device,\n \"vdb decodeToAtlas params\",\n USAGE.UNIFORM,\n new Uint8Array(packParams({ grid: gridId, filter: filter === \"trilinear\" ? 1 : 0, regionMin: info.indexBBox.min, regionSize, dims })),\n );\n const bytes = dims[0] * dims[1] * dims[2] * 4;\n const out = device.createBuffer({ label: \"vdb decodeToAtlas\", size: bytes, usage: USAGE.STORAGE | USAGE.COPY_SRC });\n const readback = options.readback ?? true;\n const staging = readback ? device.createBuffer({ label: \"vdb decodeToAtlas readback\", size: bytes, usage: USAGE.MAP_READ | USAGE.COPY_DST }) : null;\n\n const group0 = device.createBindGroup({ layout: cached.group0, entries: [pool.bindGroupEntry({ group: 0, firstBinding: 0 }), { binding: 1, resource: { buffer: params } }] });\n const group1 = device.createBindGroup({ layout: cached.group1, entries: [{ binding: 0, resource: { buffer: out } }] });\n\n const host = hostEncoder(device, options.encoder, \"vdb decodeToAtlas\");\n const pass = host.encoder.beginComputePass({ label: \"vdb decodeToAtlas\" });\n pass.setPipeline(cached.pipeline);\n pass.setBindGroup(0, group0);\n pass.setBindGroup(1, group1);\n pass.dispatchWorkgroups(...workgroups(dims));\n pass.end();\n if (staging) host.encoder.copyBufferToBuffer(out, 0, staging, 0, bytes);\n host.submit();\n\n const finish = (raw: ArrayBuffer): VDBAtlas => ({ data: atlasFromRaw(new Float32Array(raw), { format, normalize, range }), dims: [...dims], range });\n return new AtlasJob([params, out], staging, cached.error, finish, dims, range, out, host.selfSubmitted);\n}\n\nclass AtlasJob extends ComputeJob<VDBAtlas> implements VDBAtlasReadback {\n constructor(\n owned: GPUBuffer[],\n staging: GPUBuffer | null,\n error: Promise<GPUError | null>,\n finish: (bytes: ArrayBuffer) => VDBAtlas,\n readonly dims: [number, number, number],\n readonly range: { min: number; max: number },\n readonly buffer: GPUBuffer,\n selfSubmitted: boolean,\n ) {\n super(WHERE, owned, staging, error, finish, selfSubmitted);\n }\n}\n"]}
@@ -0,0 +1,13 @@
1
+ /**
2
+ * Core compute tools (K2.3): engine-free compute passes over pool grids,
3
+ * recorded into the host's encoder, plus the CPU value transform.
4
+ */
5
+ export { vdbGridStatsGpu } from "./stats.js";
6
+ export type { VDBGridStats, VDBGridStatsOptions } from "./stats.js";
7
+ export { vdbDecodeToAtlasGpu } from "./atlas.js";
8
+ export type { VDBAtlasFilter, VDBAtlasFormat, VDBAtlas, VDBAtlasReadback, VDBDecodeToAtlasOptions } from "./atlas.js";
9
+ export { vdbApplyValueTransform, VDB_VALUE_TRANSFORM_PRESETS } from "./value-transform.js";
10
+ export type { VDBValueTransform, VDBValueTransformPreset } from "./value-transform.js";
11
+ export type { VDBReadback } from "./shared.js";
12
+ export { boxPyramidWgsl, vdbCreateBoxPyramid } from "./pyramid.js";
13
+ export type { VDBBoxPyramidGpu, VDBBoxPyramidGpuOptions, VDBBoxPyramidRecordOptions } from "./pyramid.js";
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Core compute tools (K2.3): engine-free compute passes over pool grids,
3
+ * recorded into the host's encoder, plus the CPU value transform.
4
+ */
5
+ export { vdbGridStatsGpu } from "./stats.js";
6
+ export { vdbDecodeToAtlasGpu } from "./atlas.js";
7
+ export { vdbApplyValueTransform, VDB_VALUE_TRANSFORM_PRESETS } from "./value-transform.js";
8
+ export { boxPyramidWgsl, vdbCreateBoxPyramid } from "./pyramid.js";
9
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/core/compute/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAE7C,OAAO,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AAEjD,OAAO,EAAE,sBAAsB,EAAE,2BAA2B,EAAE,MAAM,sBAAsB,CAAC;AAG3F,OAAO,EAAE,cAAc,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC","sourcesContent":["/**\n * Core compute tools (K2.3): engine-free compute passes over pool grids,\n * recorded into the host's encoder, plus the CPU value transform.\n */\nexport { vdbGridStatsGpu } from \"./stats.js\";\nexport type { VDBGridStats, VDBGridStatsOptions } from \"./stats.js\";\nexport { vdbDecodeToAtlasGpu } from \"./atlas.js\";\nexport type { VDBAtlasFilter, VDBAtlasFormat, VDBAtlas, VDBAtlasReadback, VDBDecodeToAtlasOptions } from \"./atlas.js\";\nexport { vdbApplyValueTransform, VDB_VALUE_TRANSFORM_PRESETS } from \"./value-transform.js\";\nexport type { VDBValueTransform, VDBValueTransformPreset } from \"./value-transform.js\";\nexport type { VDBReadback } from \"./shared.js\";\nexport { boxPyramidWgsl, vdbCreateBoxPyramid } from \"./pyramid.js\";\nexport type { VDBBoxPyramidGpu, VDBBoxPyramidGpuOptions, VDBBoxPyramidRecordOptions } from \"./pyramid.js\";\n"]}
@@ -0,0 +1,105 @@
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 VDBBoxPyramidGpuOptions {
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`, the layout's sizes; `atlas` null exactly when the
51
+ * layout has no atlas) instead of allocating. The pyramid never destroys them (a three texture's
52
+ * `GPUTexture`, for example).
53
+ */
54
+ targets?: {
55
+ base: GPUTexture;
56
+ atlas: GPUTexture | null;
57
+ };
58
+ label?: string;
59
+ }
60
+ /** Options of {@link VDBBoxPyramidGpu.record}. */
61
+ export interface VDBBoxPyramidRecordOptions {
62
+ /** Timestamps around the build's one compute pass (the `timestamp-query` feature). */
63
+ timestampWrites?: GPUComputePassTimestampWrites;
64
+ }
65
+ /** A coarse pyramid on the GPU (see the file comment). */
66
+ export interface VDBBoxPyramidGpu {
67
+ readonly gridId: number;
68
+ readonly layout: VDBBoxPyramidLayout;
69
+ /** r16float, the base level (`layout.dimensions`). */
70
+ readonly base: GPUTexture;
71
+ /** r16float, his atlas of the levels above (`layout.atlas.dimensions`), or null. */
72
+ readonly atlas: GPUTexture | null;
73
+ /** Bytes: `textures` (r16f; counted whoever owns them) and `scratch` (this pyramid's buffers). */
74
+ readonly gpuBytes: {
75
+ readonly textures: number;
76
+ readonly scratch: number;
77
+ };
78
+ /** The grid's `imageRevision` the last recorded build read, or null before the first. */
79
+ readonly builtRevision: number | null;
80
+ /** True when the grid's image changed since the last recorded build (or none was recorded). */
81
+ readonly stale: boolean;
82
+ /** Pipeline validation (null = valid); the first build's errors surface here. */
83
+ readonly error: Promise<GPUError | null>;
84
+ /**
85
+ * Records a (re)build into `encoder`. The grid must be resident (`pool.update(encoder)` recorded
86
+ * earlier in this encoder or submitted before); call after the pool's update, as for bind groups.
87
+ */
88
+ record(encoder: GPUCommandEncoder, options?: VDBBoxPyramidRecordOptions): void;
89
+ /** Records a rebuild when {@link stale} and the grid is resident; returns whether it did. */
90
+ update(encoder: GPUCommandEncoder): boolean;
91
+ /** Frees the scratch buffers and the textures this pyramid allocated (not `targets`). Idempotent. */
92
+ destroy(): void;
93
+ }
94
+ /**
95
+ * Creates the coarse pyramid of pool grid `gridId` on the GPU (see the file comment) and returns it
96
+ * unbuilt: record the build with `pyramid.record(encoder)` (the grid must be resident), submit, and
97
+ * rebuild with `pyramid.update(encoder)` after the grid's image changes (`imageRevision`). The pool
98
+ * must live on `device`. Frees only what it allocated (`destroy()`).
99
+ *
100
+ * const pyramid = vdbCreateBoxPyramid(device, pool, id);
101
+ * pool.update(encoder);
102
+ * pyramid.update(encoder); // first build, then only on a replace
103
+ * device.queue.submit([encoder.finish()]);
104
+ */
105
+ export declare function vdbCreateBoxPyramid(device: GPUDevice, pool: VDBGridPool, gridId: number, options?: VDBBoxPyramidGpuOptions): VDBBoxPyramidGpu;