@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,302 @@
1
+ // Portions derived from mjurczyk/openvdb (MIT), commit 4e2d46f ("Add opt-in multi-scale density lookups for
2
+ // indirect light", after v0.29):
3
+ // src/three-openvdb/frame/webgpu/frameMultiScaleChunks.js L1–71 (all: frameMultiScaleLight, the Frisvad frame,
4
+ // the 5-point bulk per level, the diffusion of the summed bulk);
5
+ // src/three-openvdb/frame/webgpu/FrameGridMipMaterial.js (the binomial branch: weights 1 3 3 1 on 4 x 4 x 4 taps);
6
+ // src/three-openvdb/frame/webgpu/frameNeuralChunks.js (createNeuralMipNodes: sampleLevel, unit);
7
+ // scripts/neural-indirect/features.mjs (buildMips 'binomial', getMultiScaleIndirect).
8
+ // Copyright (c) mjurczyk/openvdb contributors. Licensed under the MIT License (see THIRD_PARTY_NOTICES.md).
9
+ // Changes: engine-free f64 CPU twins of the core WGSL (`core/compute/multi-scale.ts`) on 3D textures instead of
10
+ // his z-slice atlas; zero-padded binomial levels on an exactly halving layout by default (his clamped edges behind
11
+ // `edge: 'clamp'`); level k is addressed in base texels / 2^k. Divergences: DIVERGES.md (K7.3 row).
12
+ /**
13
+ * `'multi-scale'` multiple scattering (K7.3; mjurczyk 4e2d46f after Disney "Deep Scattering", Kallweit et al.
14
+ * 2017, §4.2): the scattered light of a light slot at a shadow-grid voxel comes from the density mip levels of the
15
+ * grid toward the light. Level k (0 to levels − 1) covers the segment from h (2^k − 1) to h (2^(k+1) − 1) toward
16
+ * the light (h: the grid's largest voxel side); the mean of 5 points (on the light axis and at ±h 2^k on two axes
17
+ * at right angles to it) is the occluding bulk of that scale; the 1D diffusion approximation of the summed bulk
18
+ * gives the scattered light (total − direct). The direct light stays the explicit shadow march.
19
+ *
20
+ * This module holds the CPU twins of the core GPU pieces (`@pmndrs/vdb` core internals):
21
+ * - {@link vdbFrameMultiScaleLayout}: the mip chain sizes (shared with the GPU build);
22
+ * - {@link vdbFrameMultiScaleMips}: the binomial mip chain (twin of `csMsLevel`), f64;
23
+ * - {@link vdbFrameMultiScaleToHalf}: the f16 texels the GPU writes (twin of `csMsPack`);
24
+ * - {@link vdbFrameTexture3DLinear}: the GPU's linear filter with clamp-to-edge;
25
+ * - {@link vdbFrameMultiScaleSample} / {@link vdbFrameMultiScaleLight}: the WGSL lookup
26
+ * (`vdbFrameMultiScaleSample` / `vdbFrameMultiScaleLight`);
27
+ * - K7.4a-3 {@link vdbFrameMultiScaleSampleRgb} / {@link vdbFrameSpectralMultiScaleLight}: the spectral lookup per channel
28
+ * (`vdbFrameMultiScaleSample3` / `vdbFrameMultiScaleLight3`).
29
+ *
30
+ * Layout. The base (level 0) is the host's grid texture: `size` texels per axis, at `origin` in it. Levels 1 to
31
+ * levels − 1 are the mips of one 3D texture (mip j = level j + 1). Their sizes halve exactly:
32
+ * D_k = ⌈size / 2^(levels−1)⌉ · 2^(levels−1−k), so texel x of level k covers base texels [x 2^k, (x+1) 2^k) for
33
+ * every size (no drift on odd sizes) and the zero padding past ⌈size / 2^k⌉ texels is part of the filter.
34
+ *
35
+ * Filter. Each level-k texel is Σ w_i w_j w_l · L_{k−1}(2x − 1 + i, …) / 512 with w = 1 3 3 1 (separable, x
36
+ * inner, then y, then z), a binomial (Gaussian-like) stencil: level k is the base blurred with σ ≈ 2^(k−1) voxels.
37
+ * `edge: 'zero'` (default) reads 0 outside the source level (the density outside the grid is 0, as the lookup
38
+ * reads it), so each level keeps the mass of the one below (Σ L_k · 8 = Σ L_{k−1}) as long as nothing blurs past
39
+ * the texture's faces; `'clamp'` is his clamp-to-edge (taps clamped
40
+ * to the valid ⌈size / 2^(k−1)⌉ texels; padding texels repeat the last valid one), identical to his levels when
41
+ * `size` is a multiple of 2^(levels−1).
42
+ */
43
+ import { vdbFloatToHalf } from "../nanovdb/half.js";
44
+ import { VDBToolsError } from "../errors.js";
45
+ /** Most levels (base included) the layout takes: level 7 is 128 voxels. */
46
+ export const VDB_FRAME_MULTI_SCALE_MAX_LEVELS = 8;
47
+ /** His default `multiScaleLevels` (base included). */
48
+ export const VDB_FRAME_MULTI_SCALE_DEFAULT_LEVELS = 6;
49
+ /** The mip a lookup level reads past its own index (0 for `'his'`, 1 for `'paper'`). */
50
+ export function vdbFrameMultiScaleLevelOffset(sigma) {
51
+ return sigma === "paper" ? 1 : 0;
52
+ }
53
+ const bad = (where, message) => {
54
+ throw new VDBToolsError("VDB_BAD_OPTION", `${where}: ${message}`);
55
+ };
56
+ /**
57
+ * The mip chain sizes of a base grid of `size` texels: D_k = ⌈size / 2^(levels−1)⌉ · 2^(levels−1−k) per axis,
58
+ * extent ⌈size / 2^k⌉.
59
+ *
60
+ * @param size Base texels per axis (positive integers).
61
+ * @param levels Levels including the base (default 6, his `multiScaleLevels`).
62
+ */
63
+ export function vdbFrameMultiScaleLayout(size, levels = VDB_FRAME_MULTI_SCALE_DEFAULT_LEVELS) {
64
+ const where = "vdbFrameMultiScaleLayout";
65
+ if (size.length !== 3 || size.some((v) => !Number.isInteger(v) || v < 1))
66
+ bad(where, `size must be 3 positive integers, got ${JSON.stringify(size)}.`);
67
+ if (!Number.isInteger(levels) || levels < 2 || levels > VDB_FRAME_MULTI_SCALE_MAX_LEVELS) {
68
+ bad(where, `levels must be an integer from 2 to ${VDB_FRAME_MULTI_SCALE_MAX_LEVELS} (base included), got ${JSON.stringify(levels)}.`);
69
+ }
70
+ const s = [size[0], size[1], size[2]];
71
+ const top = s.map((v) => Math.ceil(v / 2 ** (levels - 1)));
72
+ const mips = [];
73
+ for (let k = 1; k < levels; k++) {
74
+ mips.push({
75
+ level: k,
76
+ dimensions: [top[0] * 2 ** (levels - 1 - k), top[1] * 2 ** (levels - 1 - k), top[2] * 2 ** (levels - 1 - k)],
77
+ extent: [Math.ceil(s[0] / 2 ** k), Math.ceil(s[1] / 2 ** k), Math.ceil(s[2] / 2 ** k)],
78
+ });
79
+ }
80
+ return { size: s, levels, mips };
81
+ }
82
+ const weight = (i) => (i === 0 || i === 3 ? 1 : 3);
83
+ /**
84
+ * The binomial mip chain of a base grid (CPU twin of the core `csMsLevel` kernel): level 1 from the source region,
85
+ * level k from level k − 1, each texel the separable 1 3 3 1 sum over 4 × 4 × 4 taps at 2x − 1 … 2x + 2, / 512.
86
+ *
87
+ * @param source The base grid (texture order).
88
+ * @param options Levels, region, channels and edge rule.
89
+ */
90
+ export function vdbFrameMultiScaleMips(source, options = {}) {
91
+ const where = "vdbFrameMultiScaleMips";
92
+ const origin = options.origin ?? [0, 0, 0];
93
+ const size = options.size ?? [source.dimensions[0] - origin[0], source.dimensions[1] - origin[1], source.dimensions[2] - origin[2]];
94
+ if ([0, 1, 2].some((a) => origin[a] < 0 || origin[a] + size[a] > source.dimensions[a])) {
95
+ bad(where, `the region (origin ${JSON.stringify(origin)}, size ${JSON.stringify(size)}) is outside the source (${source.dimensions.join("x")}).`);
96
+ }
97
+ const select = options.channels ?? [0, 1];
98
+ if (select.length < 1 || select.length > 4 || select.some((c) => !Number.isInteger(c) || c < 0 || c >= source.channels)) {
99
+ bad(where, `channels must be 1 to 4 component indices below ${source.channels}, got ${JSON.stringify(select)}.`);
100
+ }
101
+ const edge = options.edge ?? "zero";
102
+ if (edge !== "zero" && edge !== "clamp")
103
+ bad(where, `edge must be 'zero' or 'clamp', got ${JSON.stringify(edge)}.`);
104
+ const layout = vdbFrameMultiScaleLayout(size, options.levels);
105
+ const C = select.length;
106
+ const [W, H] = source.dimensions;
107
+ const out = [];
108
+ for (const mip of layout.mips) {
109
+ const k = mip.level;
110
+ const D = mip.dimensions;
111
+ const fromBase = k === 1;
112
+ const below = fromBase ? null : out[k - 2];
113
+ const srcDims = fromBase ? size : layout.mips[k - 2].dimensions;
114
+ const srcExtent = fromBase ? size : layout.mips[k - 2].extent;
115
+ const tap = (p, c) => {
116
+ let q = p;
117
+ if (edge === "clamp") {
118
+ q = [Math.min(Math.max(p[0], 0), srcExtent[0] - 1), Math.min(Math.max(p[1], 0), srcExtent[1] - 1), Math.min(Math.max(p[2], 0), srcExtent[2] - 1)];
119
+ }
120
+ else if (p[0] < 0 || p[1] < 0 || p[2] < 0 || p[0] >= srcDims[0] || p[1] >= srcDims[1] || p[2] >= srcDims[2]) {
121
+ return 0;
122
+ }
123
+ if (fromBase) {
124
+ const i = origin[0] + q[0] + (origin[1] + q[1] + (origin[2] + q[2]) * H) * W;
125
+ return source.data[i * source.channels + select[c]];
126
+ }
127
+ return below[(q[0] + (q[1] + q[2] * srcDims[1]) * srcDims[0]) * C + c];
128
+ };
129
+ const level = new Float64Array(D[0] * D[1] * D[2] * C);
130
+ for (let z = 0; z < D[2]; z++) {
131
+ for (let y = 0; y < D[1]; y++) {
132
+ for (let x = 0; x < D[0]; x++) {
133
+ const e = edge === "clamp" ? [Math.min(x, mip.extent[0] - 1), Math.min(y, mip.extent[1] - 1), Math.min(z, mip.extent[2] - 1)] : [x, y, z];
134
+ const o = (x + (y + z * D[1]) * D[0]) * C;
135
+ for (let c = 0; c < C; c++) {
136
+ let sz = 0;
137
+ for (let l = 0; l < 4; l++) {
138
+ let sy = 0;
139
+ for (let j = 0; j < 4; j++) {
140
+ let sx = 0;
141
+ for (let i = 0; i < 4; i++)
142
+ sx += weight(i) * tap([e[0] * 2 - 1 + i, e[1] * 2 - 1 + j, e[2] * 2 - 1 + l], c);
143
+ sy += weight(j) * sx;
144
+ }
145
+ sz += weight(l) * sy;
146
+ }
147
+ level[o + c] = sz / 512;
148
+ }
149
+ }
150
+ }
151
+ }
152
+ out.push(level);
153
+ }
154
+ return { layout, channels: C, levels: out };
155
+ }
156
+ /**
157
+ * The f16 texels of a level as the GPU writes them (twin of `csMsPack`): `texelChannels` components per texel
158
+ * (1, 2 or 4: r16float, rg16float, rgba16float), the level's `channels` first and 0 after, each f32-rounded then
159
+ * rounded to the nearest half, ties to even (`vdbFloatToHalf`).
160
+ */
161
+ export function vdbFrameMultiScaleToHalf(level, channels, texelChannels) {
162
+ const texels = level.length / channels;
163
+ const out = new Uint16Array(texels * texelChannels);
164
+ for (let t = 0; t < texels; t++) {
165
+ for (let c = 0; c < texelChannels && c < channels; c++)
166
+ out[t * texelChannels + c] = vdbFloatToHalf(level[t * channels + c]);
167
+ }
168
+ return out;
169
+ }
170
+ /**
171
+ * The GPU's linear filter with clamp-to-edge at a texel-space coordinate (texel centres at i + ½): the trilinear
172
+ * blend of the 8 texels around it, f64 weights (SwiftShader filters in full precision; hardware may quantize the
173
+ * weights to 8 bits). Writes `out` (one entry per channel) and returns it.
174
+ */
175
+ export function vdbFrameTexture3DLinear(t, coord, out = []) {
176
+ const { data, dimensions: d, channels } = t;
177
+ const i0 = [];
178
+ const i1 = [];
179
+ const f = [];
180
+ for (let a = 0; a < 3; a++) {
181
+ const p = coord[a] - 0.5;
182
+ const fl = Math.floor(p);
183
+ f[a] = p - fl;
184
+ i0[a] = Math.min(d[a] - 1, Math.max(0, fl));
185
+ i1[a] = Math.min(d[a] - 1, Math.max(0, fl + 1));
186
+ }
187
+ const at = (x, y, z, c) => data[(x + (y + z * d[1]) * d[0]) * channels + c];
188
+ for (let c = 0; c < channels; c++) {
189
+ const lerp = (a, b, w) => a * (1 - w) + b * w;
190
+ const y0 = lerp(lerp(at(i0[0], i0[1], i0[2], c), at(i1[0], i0[1], i0[2], c), f[0]), lerp(at(i0[0], i1[1], i0[2], c), at(i1[0], i1[1], i0[2], c), f[0]), f[1]);
191
+ const y1 = lerp(lerp(at(i0[0], i0[1], i1[2], c), at(i1[0], i0[1], i1[2], c), f[0]), lerp(at(i0[0], i1[1], i1[2], c), at(i1[0], i1[1], i1[2], c), f[0]), f[1]);
192
+ out[c] = lerp(y0, y1, f[2]);
193
+ }
194
+ out.length = channels;
195
+ return out;
196
+ }
197
+ /**
198
+ * (extinction, absorption) of `level` at a world position (WGSL `vdbFrameMultiScaleSample`, his `sampleLevel`):
199
+ * 0 outside the box; level 0 is the base region with its edges clamped (no bleed into a neighbouring cascade);
200
+ * level k is the mip at base texel coordinate / 2^k, clamp-to-edge.
201
+ */
202
+ export function vdbFrameMultiScaleSample(textures, grid, level, world) {
203
+ const uvw = [0, 1, 2].map((a) => (world[a] - grid.boxMin[a]) / grid.boxSize[a]);
204
+ if (uvw.some((v) => v < 0 || v > 1))
205
+ return [0, 0];
206
+ const size = textures.baseSize;
207
+ const q = [uvw[0] * size[0], uvw[1] * size[1], uvw[2] * size[2]];
208
+ if (level === 0) {
209
+ const o = textures.baseOrigin ?? [0, 0, 0];
210
+ const ch = textures.baseChannels ?? [0, 1];
211
+ const c = [o[0] + Math.min(Math.max(q[0], 0.5), size[0] - 0.5), o[1] + Math.min(Math.max(q[1], 0.5), size[1] - 0.5), o[2] + Math.min(Math.max(q[2], 0.5), size[2] - 0.5)];
212
+ const s = vdbFrameTexture3DLinear(textures.base, c);
213
+ return [s[ch[0]], ch.length > 1 ? s[ch[1]] : 0];
214
+ }
215
+ const mip = textures.mips[level - 1];
216
+ const scale = 2 ** level;
217
+ const s = vdbFrameTexture3DLinear(mip, [q[0] / scale, q[1] / scale, q[2] / scale]);
218
+ return [s[0], mip.channels > 1 ? s[1] : 0];
219
+ }
220
+ /**
221
+ * The scattered light (total − direct) of a light slot at a world position (WGSL `vdbFrameMultiScaleLight`, his
222
+ * `frameMultiScaleLight`). `direction` is the unit direction to the light, `maxDistance` the distance to it
223
+ * (1e20 for a directional light). The consumer adds it to the direct transmittance of its shadow march and
224
+ * clamps the total to 1 (his transmittance pass).
225
+ *
226
+ * @param sampleLevel (extinction, absorption) of level k at a world position ({@link vdbFrameMultiScaleSample}).
227
+ */
228
+ export function vdbFrameMultiScaleLight(sampleLevel, grid, world, direction, maxDistance) {
229
+ const h = grid.unit;
230
+ const g = grid.multipleScattering;
231
+ const offset = grid.levelOffset ?? 0;
232
+ const top = grid.mipLevels ?? Infinity;
233
+ const [dx, dy, dz] = direction;
234
+ // Two unit vectors at right angles to the direction (Frisvad 2012), pole at −y (lights below are rare).
235
+ const pole = dy < -0.9999;
236
+ const a = 1 / Math.max(dy + 1, 1e-4);
237
+ const b = -dx * dz * a;
238
+ const u = pole ? [1, 0, 0] : [1 - dx * dx * a, -dx, b];
239
+ const v = pole ? [0, 0, 1] : [b, -dz, 1 - dz * dz * a];
240
+ const depths = [0, 0, 0];
241
+ for (let k = 0; k < grid.levels; k++) {
242
+ const scale = h * 2 ** k;
243
+ const start = scale - h;
244
+ const segment = Math.min(scale, maxDistance - start);
245
+ if (!(segment > 0))
246
+ continue;
247
+ const t = start + segment * 0.5;
248
+ const center = [world[0] + dx * t, world[1] + dy * t, world[2] + dz * t];
249
+ // K6.3a: the level's blur (mip k, or k + 1 for the paper's σ = 2^k), the taps stay at the level's own spacing
250
+ const read = Math.min(k + offset, top);
251
+ const at = (axis, sign) => sampleLevel(read, [center[0] + axis[0] * scale * sign, center[1] + axis[1] * scale * sign, center[2] + axis[2] * scale * sign]);
252
+ const p = [sampleLevel(read, center), at(u, 1), at(u, -1), at(v, 1), at(v, -1)];
253
+ const extinction = (p[0][0] + p[1][0] + p[2][0] + p[3][0] + p[4][0]) * 0.2;
254
+ const absorption = (p[0][1] + p[1][1] + p[2][1] + p[3][1] + p[4][1]) * 0.2;
255
+ // frameShadowStep of the bulk.
256
+ const absorbed = Math.min(absorption, extinction);
257
+ const reduced = (extinction - absorbed) * g;
258
+ depths[0] += extinction * segment;
259
+ depths[1] += Math.sqrt(absorbed * 3 * (absorbed + reduced)) * segment;
260
+ depths[2] += reduced * segment;
261
+ }
262
+ // frameShadowDepth: 1D diffusion of the summed bulk.
263
+ const total = g > 0 ? Math.min(depths[0], depths[1] + Math.log(depths[2] * 0.75 + 1)) : depths[0];
264
+ return Math.max(Math.exp(-total) - Math.exp(-depths[0]), 0);
265
+ }
266
+ /**
267
+ * K7.4a-3: channels 0–2 of `level` at a world position (one texture of WGSL `vdbFrameMultiScaleSample3`): the same
268
+ * addressing as {@link vdbFrameMultiScaleSample}, the base region's components 0–2 at level 0 and the mip's 0–2 above
269
+ * (spectral chains are made with `channels: [0, 1, 2]`). `baseChannels` is ignored.
270
+ */
271
+ export function vdbFrameMultiScaleSampleRgb(textures, grid, level, world) {
272
+ const uvw = [0, 1, 2].map((a) => (world[a] - grid.boxMin[a]) / grid.boxSize[a]);
273
+ if (uvw.some((v) => v < 0 || v > 1))
274
+ return [0, 0, 0];
275
+ const size = textures.baseSize;
276
+ const q = [uvw[0] * size[0], uvw[1] * size[1], uvw[2] * size[2]];
277
+ if (level === 0) {
278
+ const o = textures.baseOrigin ?? [0, 0, 0];
279
+ const c = [o[0] + Math.min(Math.max(q[0], 0.5), size[0] - 0.5), o[1] + Math.min(Math.max(q[1], 0.5), size[1] - 0.5), o[2] + Math.min(Math.max(q[2], 0.5), size[2] - 0.5)];
280
+ const s = vdbFrameTexture3DLinear(textures.base, c);
281
+ return [s[0], s[1], s[2]];
282
+ }
283
+ const scale = 2 ** level;
284
+ const s = vdbFrameTexture3DLinear(textures.mips[level - 1], [q[0] / scale, q[1] / scale, q[2] / scale]);
285
+ return [s[0], s[1], s[2]];
286
+ }
287
+ /**
288
+ * K7.4a-3: the scattered light (total − direct) of each colour channel (WGSL `vdbFrameMultiScaleLight3`): channel c is
289
+ * {@link vdbFrameMultiScaleLight} on channel c's (extinction, absorption) levels, with the one `multipleScattering`
290
+ * (1 − g) of the spectral march. A grey medium gives the grey lookup in every channel.
291
+ *
292
+ * @param sampleLevel Extinction rgb and absorption rgb of level k at a world position (e.g. two
293
+ * {@link vdbFrameMultiScaleSampleRgb}, one per stack and chain).
294
+ */
295
+ export function vdbFrameSpectralMultiScaleLight(sampleLevel, grid, world, direction, maxDistance) {
296
+ const channel = (c) => vdbFrameMultiScaleLight((k, p) => {
297
+ const s = sampleLevel(k, p);
298
+ return [s.extinction[c], s.absorption[c]];
299
+ }, grid, world, direction, maxDistance);
300
+ return [channel(0), channel(1), channel(2)];
301
+ }
302
+ //# sourceMappingURL=multi-scale.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"multi-scale.js","sourceRoot":"","sources":["../../../src/tools/frame/multi-scale.ts"],"names":[],"mappings":"AAAA,4GAA4G;AAC5G,iCAAiC;AACjC,iHAAiH;AACjH,mEAAmE;AACnE,qHAAqH;AACrH,mGAAmG;AACnG,wFAAwF;AACxF,4GAA4G;AA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;IAEnB,MAAM,OAAO,GAAG,CAAC,CAAS,EAAE,EAAE,CAC5B,uBAAuB,CACrB,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE;QACP,MAAM,CAAC,GAAG,WAAW,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;QAC5B,OAAO,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAE,EAAE,CAAC,CAAC,UAAU,CAAC,CAAC,CAAE,CAAC,CAAC;IAC9C,CAAC,EACD,IAAI,EACJ,KAAK,EACL,SAAS,EACT,WAAW,CACZ,CAAC;IACJ,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,OAAO,CAAC,CAAC,CAAC,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC;AAC9C,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 (all: frameMultiScaleLight, the Frisvad frame,\n// the 5-point bulk per level, the diffusion of the summed bulk);\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// scripts/neural-indirect/features.mjs (buildMips 'binomial', getMultiScaleIndirect).\n// Copyright (c) mjurczyk/openvdb contributors. Licensed under the MIT License (see THIRD_PARTY_NOTICES.md).\n// Changes: engine-free f64 CPU twins of the core WGSL (`core/compute/multi-scale.ts`) on 3D textures instead of\n// his z-slice atlas; zero-padded binomial levels on an exactly halving layout by default (his clamped edges behind\n// `edge: 'clamp'`); level k is addressed in base texels / 2^k. Divergences: DIVERGES.md (K7.3 row).\n\n/**\n * `'multi-scale'` multiple scattering (K7.3; mjurczyk 4e2d46f after Disney \"Deep Scattering\", Kallweit et al.\n * 2017, §4.2): the scattered light of a light slot at a shadow-grid voxel comes from the density mip levels of the\n * grid toward the light. Level k (0 to levels − 1) covers the segment from h (2^k − 1) to h (2^(k+1) − 1) toward\n * the light (h: the grid's largest voxel side); the mean of 5 points (on the light axis and at ±h 2^k on two axes\n * at right angles to it) is the occluding bulk of that scale; the 1D diffusion approximation of the summed bulk\n * gives the scattered light (total − direct). The direct light stays the explicit shadow march.\n *\n * This module holds the CPU twins of the core GPU pieces (`@pmndrs/vdb` core internals):\n * - {@link vdbFrameMultiScaleLayout}: the mip chain sizes (shared with the GPU build);\n * - {@link vdbFrameMultiScaleMips}: the binomial mip chain (twin of `csMsLevel`), f64;\n * - {@link vdbFrameMultiScaleToHalf}: the f16 texels the GPU writes (twin of `csMsPack`);\n * - {@link vdbFrameTexture3DLinear}: the GPU's linear filter with clamp-to-edge;\n * - {@link vdbFrameMultiScaleSample} / {@link vdbFrameMultiScaleLight}: the WGSL lookup\n * (`vdbFrameMultiScaleSample` / `vdbFrameMultiScaleLight`);\n * - K7.4a-3 {@link vdbFrameMultiScaleSampleRgb} / {@link vdbFrameSpectralMultiScaleLight}: the spectral lookup per channel\n * (`vdbFrameMultiScaleSample3` / `vdbFrameMultiScaleLight3`).\n *\n * Layout. The base (level 0) is the host's grid texture: `size` texels per axis, at `origin` in it. Levels 1 to\n * levels − 1 are the mips of one 3D texture (mip j = level j + 1). Their sizes halve exactly:\n * D_k = ⌈size / 2^(levels−1)⌉ · 2^(levels−1−k), so texel x of level k covers base texels [x 2^k, (x+1) 2^k) for\n * every size (no drift on odd sizes) and the zero padding past ⌈size / 2^k⌉ texels is part of the filter.\n *\n * Filter. Each level-k texel is Σ w_i w_j w_l · L_{k−1}(2x − 1 + i, …) / 512 with w = 1 3 3 1 (separable, x\n * inner, then y, then z), a binomial (Gaussian-like) stencil: level k is the base blurred with σ ≈ 2^(k−1) voxels.\n * `edge: 'zero'` (default) reads 0 outside the source level (the density outside the grid is 0, as the lookup\n * reads it), so each level keeps the mass of the one below (Σ L_k · 8 = Σ L_{k−1}) as long as nothing blurs past\n * the texture's faces; `'clamp'` is his clamp-to-edge (taps clamped\n * to the valid ⌈size / 2^(k−1)⌉ texels; padding texels repeat the last valid one), identical to his levels when\n * `size` is a multiple of 2^(levels−1).\n */\n\nimport { vdbFloatToHalf } from \"../nanovdb/half.js\";\nimport { VDBToolsError } from \"../errors.js\";\nimport type { Vec2, Vec3 } from \"./index.js\";\n\n/** Most levels (base included) the layout takes: level 7 is 128 voxels. */\nexport const VDB_FRAME_MULTI_SCALE_MAX_LEVELS = 8;\n\n/** His default `multiScaleLevels` (base included). */\nexport const VDB_FRAME_MULTI_SCALE_DEFAULT_LEVELS = 6;\n\n/** Edge rule of the mip build: zero outside the grid (default), or his clamp-to-edge. */\nexport type VDBFrameMultiScaleEdge = \"zero\" | \"clamp\";\n\n/**\n * K6.3a: the blur of each lookup level (V75 item 5). `'his'` (default): level k reads mip k, the binomial chain's\n * σ ≈ 2^(k−1) voxels (σ_k² = (4^k − 1) / 4; his 4e2d46f). `'paper'`: level k reads mip k + 1, σ ≈ 2^k voxels, the\n * Gaussian width of Disney \"Deep Scattering\" §4.2 (its stencil spacing at level k is 2^k voxels); the chain holds one\n * more mip (at most {@link VDB_FRAME_MULTI_SCALE_MAX_LEVELS} levels: past it the last level reads the last mip).\n */\nexport type VDBFrameMultiScaleSigma = \"his\" | \"paper\";\n\n/** The mip a lookup level reads past its own index (0 for `'his'`, 1 for `'paper'`). */\nexport function vdbFrameMultiScaleLevelOffset(sigma: VDBFrameMultiScaleSigma | undefined): number {\n return sigma === \"paper\" ? 1 : 0;\n}\n\n/** One mip level (1 to levels − 1). */\nexport interface VDBFrameMultiScaleMipLevel {\n /** The level k (1 = first mip). */\n level: number;\n /** Texels per axis of the level (exactly halving; mip level k − 1 of the mip texture). */\n dimensions: Vec3;\n /** Texels that cover the base (⌈size / 2^k⌉); the rest is padding. */\n extent: Vec3;\n}\n\n/** The sizes of the mip chain of a base grid. */\nexport interface VDBFrameMultiScaleLayout {\n /** Base texels per axis (the grid region the levels filter). */\n size: Vec3;\n /** Levels including the base (2 to {@link VDB_FRAME_MULTI_SCALE_MAX_LEVELS}). */\n levels: number;\n /** Levels 1 to levels − 1. */\n mips: VDBFrameMultiScaleMipLevel[];\n}\n\nconst bad = (where: string, message: string): never => {\n throw new VDBToolsError(\"VDB_BAD_OPTION\", `${where}: ${message}`);\n};\n\n/**\n * The mip chain sizes of a base grid of `size` texels: D_k = ⌈size / 2^(levels−1)⌉ · 2^(levels−1−k) per axis,\n * extent ⌈size / 2^k⌉.\n *\n * @param size Base texels per axis (positive integers).\n * @param levels Levels including the base (default 6, his `multiScaleLevels`).\n */\nexport function vdbFrameMultiScaleLayout(size: readonly number[], levels: number = VDB_FRAME_MULTI_SCALE_DEFAULT_LEVELS): VDBFrameMultiScaleLayout {\n const where = \"vdbFrameMultiScaleLayout\";\n if (size.length !== 3 || size.some((v) => !Number.isInteger(v) || v < 1)) bad(where, `size must be 3 positive integers, got ${JSON.stringify(size)}.`);\n if (!Number.isInteger(levels) || levels < 2 || levels > VDB_FRAME_MULTI_SCALE_MAX_LEVELS) {\n bad(where, `levels must be an integer from 2 to ${VDB_FRAME_MULTI_SCALE_MAX_LEVELS} (base included), got ${JSON.stringify(levels)}.`);\n }\n const s: Vec3 = [size[0]!, size[1]!, size[2]!];\n const top = s.map((v) => Math.ceil(v / 2 ** (levels - 1)));\n const mips: VDBFrameMultiScaleMipLevel[] = [];\n for (let k = 1; k < levels; k++) {\n mips.push({\n level: k,\n dimensions: [top[0]! * 2 ** (levels - 1 - k), top[1]! * 2 ** (levels - 1 - k), top[2]! * 2 ** (levels - 1 - k)],\n extent: [Math.ceil(s[0] / 2 ** k), Math.ceil(s[1] / 2 ** k), Math.ceil(s[2] / 2 ** k)],\n });\n }\n return { size: s, levels, mips };\n}\n\n/** A grid on the CPU in texture order: x fastest, then y, then z; `channels` components per texel, interleaved. */\nexport interface VDBFrameTexture3D {\n data: ArrayLike<number>;\n dimensions: Vec3;\n channels: number;\n}\n\n/** Options of {@link vdbFrameMultiScaleMips}. */\nexport interface VDBFrameMultiScaleMipOptions {\n /** Levels including the base (default 6). */\n levels?: number;\n /** Base texels per axis to filter (default: the source's dimensions minus `origin`). */\n size?: Vec3;\n /** First texel of the region in the source (default 0, 0, 0): one cascade of a stacked grid. */\n origin?: Vec3;\n /** Source components that become the level channels, in order (default [0, 1]: extinction, absorption). */\n channels?: readonly number[];\n /** Edge rule (default `'zero'`). */\n edge?: VDBFrameMultiScaleEdge;\n}\n\n/** The f64 mip chain: `levels[k − 1]` is level k (`dimensions` texels × `channels`, interleaved). */\nexport interface VDBFrameMultiScaleMips {\n layout: VDBFrameMultiScaleLayout;\n channels: number;\n levels: Float64Array[];\n}\n\nconst weight = (i: number) => (i === 0 || i === 3 ? 1 : 3);\n\n/**\n * The binomial mip chain of a base grid (CPU twin of the core `csMsLevel` kernel): level 1 from the source region,\n * level k from level k − 1, each texel the separable 1 3 3 1 sum over 4 × 4 × 4 taps at 2x − 1 … 2x + 2, / 512.\n *\n * @param source The base grid (texture order).\n * @param options Levels, region, channels and edge rule.\n */\nexport function vdbFrameMultiScaleMips(source: VDBFrameTexture3D, options: VDBFrameMultiScaleMipOptions = {}): VDBFrameMultiScaleMips {\n const where = \"vdbFrameMultiScaleMips\";\n const origin = options.origin ?? [0, 0, 0];\n const size = options.size ?? [source.dimensions[0] - origin[0], source.dimensions[1] - origin[1], source.dimensions[2] - origin[2]];\n if ([0, 1, 2].some((a) => origin[a]! < 0 || origin[a]! + size[a]! > source.dimensions[a]!)) {\n bad(where, `the region (origin ${JSON.stringify(origin)}, size ${JSON.stringify(size)}) is outside the source (${source.dimensions.join(\"x\")}).`);\n }\n const select = options.channels ?? [0, 1];\n if (select.length < 1 || select.length > 4 || select.some((c) => !Number.isInteger(c) || c < 0 || c >= source.channels)) {\n bad(where, `channels must be 1 to 4 component indices below ${source.channels}, got ${JSON.stringify(select)}.`);\n }\n const edge = options.edge ?? \"zero\";\n if (edge !== \"zero\" && edge !== \"clamp\") bad(where, `edge must be 'zero' or 'clamp', got ${JSON.stringify(edge)}.`);\n const layout = vdbFrameMultiScaleLayout(size, options.levels);\n const C = select.length;\n const [W, H] = source.dimensions;\n const out: Float64Array[] = [];\n\n for (const mip of layout.mips) {\n const k = mip.level;\n const D = mip.dimensions;\n const fromBase = k === 1;\n const below = fromBase ? null : out[k - 2]!;\n const srcDims = fromBase ? size : layout.mips[k - 2]!.dimensions;\n const srcExtent = fromBase ? size : layout.mips[k - 2]!.extent;\n const tap = (p: Vec3, c: number): number => {\n let q: Vec3 = p;\n if (edge === \"clamp\") {\n q = [Math.min(Math.max(p[0], 0), srcExtent[0] - 1), Math.min(Math.max(p[1], 0), srcExtent[1] - 1), Math.min(Math.max(p[2], 0), srcExtent[2] - 1)];\n } else if (p[0] < 0 || p[1] < 0 || p[2] < 0 || p[0] >= srcDims[0] || p[1] >= srcDims[1] || p[2] >= srcDims[2]) {\n return 0;\n }\n if (fromBase) {\n const i = origin[0] + q[0] + (origin[1] + q[1] + (origin[2] + q[2]) * H) * W;\n return source.data[i * source.channels + select[c]!]!;\n }\n return below![(q[0] + (q[1] + q[2] * srcDims[1]) * srcDims[0]) * C + c]!;\n };\n const level = new Float64Array(D[0] * D[1] * D[2] * C);\n for (let z = 0; z < D[2]; z++) {\n for (let y = 0; y < D[1]; y++) {\n for (let x = 0; x < D[0]; x++) {\n const e: Vec3 = edge === \"clamp\" ? [Math.min(x, mip.extent[0] - 1), Math.min(y, mip.extent[1] - 1), Math.min(z, mip.extent[2] - 1)] : [x, y, z];\n const o = (x + (y + z * D[1]) * D[0]) * C;\n for (let c = 0; c < C; c++) {\n let sz = 0;\n for (let l = 0; l < 4; l++) {\n let sy = 0;\n for (let j = 0; j < 4; j++) {\n let sx = 0;\n for (let i = 0; i < 4; i++) sx += weight(i) * tap([e[0] * 2 - 1 + i, e[1] * 2 - 1 + j, e[2] * 2 - 1 + l], c);\n sy += weight(j) * sx;\n }\n sz += weight(l) * sy;\n }\n level[o + c] = sz / 512;\n }\n }\n }\n }\n out.push(level);\n }\n return { layout, channels: C, levels: out };\n}\n\n/**\n * The f16 texels of a level as the GPU writes them (twin of `csMsPack`): `texelChannels` components per texel\n * (1, 2 or 4: r16float, rg16float, rgba16float), the level's `channels` first and 0 after, each f32-rounded then\n * rounded to the nearest half, ties to even (`vdbFloatToHalf`).\n */\nexport function vdbFrameMultiScaleToHalf(level: ArrayLike<number>, channels: number, texelChannels: number): Uint16Array {\n const texels = level.length / channels;\n const out = new Uint16Array(texels * texelChannels);\n for (let t = 0; t < texels; t++) {\n for (let c = 0; c < texelChannels && c < channels; c++) out[t * texelChannels + c] = vdbFloatToHalf(level[t * channels + c]!);\n }\n return out;\n}\n\n/**\n * The GPU's linear filter with clamp-to-edge at a texel-space coordinate (texel centres at i + ½): the trilinear\n * blend of the 8 texels around it, f64 weights (SwiftShader filters in full precision; hardware may quantize the\n * weights to 8 bits). Writes `out` (one entry per channel) and returns it.\n */\nexport function vdbFrameTexture3DLinear(t: VDBFrameTexture3D, coord: Vec3, out: number[] = []): number[] {\n const { data, dimensions: d, channels } = t;\n const i0: number[] = [];\n const i1: number[] = [];\n const f: number[] = [];\n for (let a = 0; a < 3; a++) {\n const p = coord[a]! - 0.5;\n const fl = Math.floor(p);\n f[a] = p - fl;\n i0[a] = Math.min(d[a]! - 1, Math.max(0, fl));\n i1[a] = Math.min(d[a]! - 1, Math.max(0, fl + 1));\n }\n const at = (x: number, y: number, z: number, c: number) => data[(x + (y + z * d[1]) * d[0]) * channels + c]!;\n for (let c = 0; c < channels; c++) {\n const lerp = (a: number, b: number, w: number) => a * (1 - w) + b * w;\n const y0 = lerp(lerp(at(i0[0]!, i0[1]!, i0[2]!, c), at(i1[0]!, i0[1]!, i0[2]!, c), f[0]!), lerp(at(i0[0]!, i1[1]!, i0[2]!, c), at(i1[0]!, i1[1]!, i0[2]!, c), f[0]!), f[1]!);\n const y1 = lerp(lerp(at(i0[0]!, i0[1]!, i1[2]!, c), at(i1[0]!, i0[1]!, i1[2]!, c), f[0]!), lerp(at(i0[0]!, i1[1]!, i1[2]!, c), at(i1[0]!, i1[1]!, i1[2]!, c), f[0]!), f[1]!);\n out[c] = lerp(y0, y1, f[2]!);\n }\n out.length = channels;\n return out;\n}\n\n/** The lookup's grid: the WGSL `VdbFrameMultiScale` struct (core `vdbFrameMultiScaleParams`). */\nexport interface VDBFrameMultiScaleGrid {\n /** World box of the base region: `boxMin` to `boxMin + boxSize` (his last cascade: gridMin, gridSize). */\n boxMin: Vec3;\n boxSize: Vec3;\n /** h: the largest voxel side of the grid, world units (his `unit`). */\n unit: number;\n /** Levels read, base included (his `multiScaleLevels`; at most the chain's levels). */\n levels: number;\n /** 1 − g of the phase function (his `frameMultipleScattering`); 0 is single scattering (no scattered light). */\n multipleScattering: number;\n /**\n * K6.3a: level k reads mip level min(k + levelOffset, mipLevels) (default 0; 1 is `multiScaleSigma: 'paper'`,\n * {@link vdbFrameMultiScaleLevelOffset}).\n */\n levelOffset?: number;\n /** K6.3a: the chain's mip count (levels − 1 of its layout): the highest level a lookup reads (default: no clamp). */\n mipLevels?: number;\n}\n\n/** The textures the lookup reads: the base region and the mip levels. */\nexport interface VDBFrameMultiScaleTextures {\n /** The host's grid texture (level 0). */\n base: VDBFrameTexture3D;\n /** First texel of the base region in `base` (default 0, 0, 0). */\n baseOrigin?: Vec3;\n /** Base region texels per axis (the layout's `size`). */\n baseSize: Vec3;\n /** Base components of extinction and absorption (default [0, 1]; one entry: no absorption). */\n baseChannels?: readonly number[];\n /** Levels 1 to levels − 1 (channel 0 extinction, channel 1 absorption when present). */\n mips: readonly VDBFrameTexture3D[];\n}\n\n/**\n * (extinction, absorption) of `level` at a world position (WGSL `vdbFrameMultiScaleSample`, his `sampleLevel`):\n * 0 outside the box; level 0 is the base region with its edges clamped (no bleed into a neighbouring cascade);\n * level k is the mip at base texel coordinate / 2^k, clamp-to-edge.\n */\nexport function vdbFrameMultiScaleSample(textures: VDBFrameMultiScaleTextures, grid: Pick<VDBFrameMultiScaleGrid, \"boxMin\" | \"boxSize\">, level: number, world: Vec3): Vec2 {\n const uvw = [0, 1, 2].map((a) => (world[a]! - grid.boxMin[a]!) / grid.boxSize[a]!);\n if (uvw.some((v) => v < 0 || v > 1)) return [0, 0];\n const size = textures.baseSize;\n const q: Vec3 = [uvw[0]! * size[0], uvw[1]! * size[1], uvw[2]! * size[2]];\n if (level === 0) {\n const o = textures.baseOrigin ?? [0, 0, 0];\n const ch = textures.baseChannels ?? [0, 1];\n const c: Vec3 = [o[0] + Math.min(Math.max(q[0], 0.5), size[0] - 0.5), o[1] + Math.min(Math.max(q[1], 0.5), size[1] - 0.5), o[2] + Math.min(Math.max(q[2], 0.5), size[2] - 0.5)];\n const s = vdbFrameTexture3DLinear(textures.base, c);\n return [s[ch[0]!]!, ch.length > 1 ? s[ch[1]!]! : 0];\n }\n const mip = textures.mips[level - 1]!;\n const scale = 2 ** level;\n const s = vdbFrameTexture3DLinear(mip, [q[0] / scale, q[1] / scale, q[2] / scale]);\n return [s[0]!, mip.channels > 1 ? s[1]! : 0];\n}\n\n/**\n * The scattered light (total − direct) of a light slot at a world position (WGSL `vdbFrameMultiScaleLight`, his\n * `frameMultiScaleLight`). `direction` is the unit direction to the light, `maxDistance` the distance to it\n * (1e20 for a directional light). The consumer adds it to the direct transmittance of its shadow march and\n * clamps the total to 1 (his transmittance pass).\n *\n * @param sampleLevel (extinction, absorption) of level k at a world position ({@link vdbFrameMultiScaleSample}).\n */\nexport function vdbFrameMultiScaleLight(\n sampleLevel: (level: number, world: Vec3) => Vec2,\n grid: Pick<VDBFrameMultiScaleGrid, \"unit\" | \"levels\" | \"multipleScattering\" | \"levelOffset\" | \"mipLevels\">,\n world: Vec3,\n direction: Vec3,\n maxDistance: number,\n): number {\n const h = grid.unit;\n const g = grid.multipleScattering;\n const offset = grid.levelOffset ?? 0;\n const top = grid.mipLevels ?? Infinity;\n const [dx, dy, dz] = direction;\n // Two unit vectors at right angles to the direction (Frisvad 2012), pole at −y (lights below are rare).\n const pole = dy < -0.9999;\n const a = 1 / Math.max(dy + 1, 1e-4);\n const b = -dx * dz * a;\n const u: Vec3 = pole ? [1, 0, 0] : [1 - dx * dx * a, -dx, b];\n const v: Vec3 = pole ? [0, 0, 1] : [b, -dz, 1 - dz * dz * a];\n const depths: Vec3 = [0, 0, 0];\n for (let k = 0; k < grid.levels; k++) {\n const scale = h * 2 ** k;\n const start = scale - h;\n const segment = Math.min(scale, maxDistance - start);\n if (!(segment > 0)) continue;\n const t = start + segment * 0.5;\n const center: Vec3 = [world[0] + dx * t, world[1] + dy * t, world[2] + dz * t];\n // K6.3a: the level's blur (mip k, or k + 1 for the paper's σ = 2^k), the taps stay at the level's own spacing\n const read = Math.min(k + offset, top);\n const at = (axis: Vec3, sign: number): Vec2 => sampleLevel(read, [center[0] + axis[0] * scale * sign, center[1] + axis[1] * scale * sign, center[2] + axis[2] * scale * sign]);\n const p = [sampleLevel(read, center), at(u, 1), at(u, -1), at(v, 1), at(v, -1)];\n const extinction = (p[0]![0] + p[1]![0] + p[2]![0] + p[3]![0] + p[4]![0]) * 0.2;\n const absorption = (p[0]![1] + p[1]![1] + p[2]![1] + p[3]![1] + p[4]![1]) * 0.2;\n // frameShadowStep of the bulk.\n const absorbed = Math.min(absorption, extinction);\n const reduced = (extinction - absorbed) * g;\n depths[0] += extinction * segment;\n depths[1] += Math.sqrt(absorbed * 3 * (absorbed + reduced)) * segment;\n depths[2] += reduced * segment;\n }\n // frameShadowDepth: 1D diffusion of the summed bulk.\n const total = g > 0 ? Math.min(depths[0], depths[1] + Math.log(depths[2] * 0.75 + 1)) : depths[0];\n return Math.max(Math.exp(-total) - Math.exp(-depths[0]), 0);\n}\n\n/**\n * K7.4a-3: channels 0–2 of `level` at a world position (one texture of WGSL `vdbFrameMultiScaleSample3`): the same\n * addressing as {@link vdbFrameMultiScaleSample}, the base region's components 0–2 at level 0 and the mip's 0–2 above\n * (spectral chains are made with `channels: [0, 1, 2]`). `baseChannels` is ignored.\n */\nexport function vdbFrameMultiScaleSampleRgb(textures: VDBFrameMultiScaleTextures, grid: Pick<VDBFrameMultiScaleGrid, \"boxMin\" | \"boxSize\">, level: number, world: Vec3): Vec3 {\n const uvw = [0, 1, 2].map((a) => (world[a]! - grid.boxMin[a]!) / grid.boxSize[a]!);\n if (uvw.some((v) => v < 0 || v > 1)) return [0, 0, 0];\n const size = textures.baseSize;\n const q: Vec3 = [uvw[0]! * size[0], uvw[1]! * size[1], uvw[2]! * size[2]];\n if (level === 0) {\n const o = textures.baseOrigin ?? [0, 0, 0];\n const c: Vec3 = [o[0] + Math.min(Math.max(q[0], 0.5), size[0] - 0.5), o[1] + Math.min(Math.max(q[1], 0.5), size[1] - 0.5), o[2] + Math.min(Math.max(q[2], 0.5), size[2] - 0.5)];\n const s = vdbFrameTexture3DLinear(textures.base, c);\n return [s[0]!, s[1]!, s[2]!];\n }\n const scale = 2 ** level;\n const s = vdbFrameTexture3DLinear(textures.mips[level - 1]!, [q[0] / scale, q[1] / scale, q[2] / scale]);\n return [s[0]!, s[1]!, s[2]!];\n}\n\n/**\n * K7.4a-3: the scattered light (total − direct) of each colour channel (WGSL `vdbFrameMultiScaleLight3`): channel c is\n * {@link vdbFrameMultiScaleLight} on channel c's (extinction, absorption) levels, with the one `multipleScattering`\n * (1 − g) of the spectral march. A grey medium gives the grey lookup in every channel.\n *\n * @param sampleLevel Extinction rgb and absorption rgb of level k at a world position (e.g. two\n * {@link vdbFrameMultiScaleSampleRgb}, one per stack and chain).\n */\nexport function vdbFrameSpectralMultiScaleLight(\n sampleLevel: (level: number, world: Vec3) => { extinction: Vec3; absorption: Vec3 },\n grid: Pick<VDBFrameMultiScaleGrid, \"unit\" | \"levels\" | \"multipleScattering\" | \"levelOffset\" | \"mipLevels\">,\n world: Vec3,\n direction: Vec3,\n maxDistance: number,\n): Vec3 {\n const channel = (c: number) =>\n vdbFrameMultiScaleLight(\n (k, p) => {\n const s = sampleLevel(k, p);\n return [s.extinction[c]!, s.absorption[c]!];\n },\n grid,\n world,\n direction,\n maxDistance,\n );\n return [channel(0), channel(1), channel(2)];\n}\n"]}
@@ -0,0 +1,10 @@
1
+ import type { VDBFrameNeuralNetwork } from "./neural.js";
2
+ /**
3
+ * The default network (ours, K6.N; D36): 20 inputs → 32 (ReLU) → 32 (ReLU) → 1, output
4
+ * exp(min(o, 4)): the scattered light of a shadow slot (total − direct) per unit of light, for Henyey-Greenstein
5
+ * g 0.8. Inputs: for each of the 6 box mip levels k of the last shadow grid cascade, log(1 + σ h 2^k) at the
6
+ * voxel, h 2^k toward the light and h 2^k away from it (h: the largest voxel side); then log(1 + direct optical depth)
7
+ * and √(absorption / extinction) at level 1. Input scaling is folded into w1 and b1. vec4 layout: w1 rows, b1, w2
8
+ * rows, b2, w3, b3 (x). Use it as `renderer.mlp = vdbFrameMlpFromNeural(vdbFrameNeuralWeights)`.
9
+ */
10
+ export declare const vdbFrameNeuralWeights: VDBFrameNeuralNetwork;