@pmndrs/vdb 0.1.0 → 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 (576) hide show
  1. package/CHANGELOG.md +592 -2
  2. package/README.md +85 -37
  3. package/THIRD_PARTY_NOTICES.md +197 -29
  4. package/dist/core/compute/atlas.d.ts +10 -2
  5. package/dist/core/compute/atlas.js +6 -1
  6. package/dist/core/compute/atlas.js.map +1 -1
  7. package/dist/core/compute/index.d.ts +3 -3
  8. package/dist/core/compute/index.js +2 -2
  9. package/dist/core/compute/index.js.map +1 -1
  10. package/dist/core/compute/majorant-build.d.ts +45 -0
  11. package/dist/core/compute/majorant-build.js +193 -0
  12. package/dist/core/compute/majorant-build.js.map +1 -0
  13. package/dist/core/compute/multi-scale.d.ts +155 -0
  14. package/dist/core/compute/multi-scale.js +684 -0
  15. package/dist/core/compute/multi-scale.js.map +1 -0
  16. package/dist/core/compute/pyramid.d.ts +22 -7
  17. package/dist/core/compute/pyramid.js +22 -9
  18. package/dist/core/compute/pyramid.js.map +1 -1
  19. package/dist/core/compute/shared.d.ts +1 -0
  20. package/dist/core/compute/shared.js.map +1 -1
  21. package/dist/core/compute/stats.d.ts +10 -3
  22. package/dist/core/compute/stats.js +6 -1
  23. package/dist/core/compute/stats.js.map +1 -1
  24. package/dist/core/compute/value-transform.d.ts +8 -1
  25. package/dist/core/compute/value-transform.js +9 -3
  26. package/dist/core/compute/value-transform.js.map +1 -1
  27. package/dist/core/errors.d.ts +10 -0
  28. package/dist/core/errors.js +8 -0
  29. package/dist/core/errors.js.map +1 -1
  30. package/dist/core/frame/emission.d.ts +85 -0
  31. package/dist/core/frame/emission.js +422 -0
  32. package/dist/core/frame/emission.js.map +1 -0
  33. package/dist/core/frame/environment.d.ts +47 -0
  34. package/dist/core/frame/environment.js +178 -0
  35. package/dist/core/frame/environment.js.map +1 -0
  36. package/dist/core/frame/index.d.ts +39 -0
  37. package/dist/core/frame/index.js +27 -0
  38. package/dist/core/frame/index.js.map +1 -0
  39. package/dist/core/frame/kernels.d.ts +115 -0
  40. package/dist/core/frame/kernels.js +496 -0
  41. package/dist/core/frame/kernels.js.map +1 -0
  42. package/dist/core/frame/limits.d.ts +67 -0
  43. package/dist/core/frame/limits.js +109 -0
  44. package/dist/core/frame/limits.js.map +1 -0
  45. package/dist/core/frame/phase.d.ts +17 -0
  46. package/dist/core/frame/phase.js +53 -0
  47. package/dist/core/frame/phase.js.map +1 -0
  48. package/dist/core/frame/pipelines.d.ts +49 -0
  49. package/dist/core/frame/pipelines.js +147 -0
  50. package/dist/core/frame/pipelines.js.map +1 -0
  51. package/dist/core/frame/renderer.d.ts +122 -0
  52. package/dist/core/frame/renderer.js +1712 -0
  53. package/dist/core/frame/renderer.js.map +1 -0
  54. package/dist/core/frame/resources.d.ts +71 -0
  55. package/dist/core/frame/resources.js +100 -0
  56. package/dist/core/frame/resources.js.map +1 -0
  57. package/dist/core/frame/scattering.d.ts +97 -0
  58. package/dist/core/frame/scattering.js +332 -0
  59. package/dist/core/frame/scattering.js.map +1 -0
  60. package/dist/core/frame/settings.d.ts +243 -0
  61. package/dist/core/frame/settings.js +67 -0
  62. package/dist/core/frame/settings.js.map +1 -0
  63. package/dist/core/frame/shadows.d.ts +55 -0
  64. package/dist/core/frame/shadows.js +460 -0
  65. package/dist/core/frame/shadows.js.map +1 -0
  66. package/dist/core/frame/types.d.ts +415 -0
  67. package/dist/core/frame/types.js +49 -0
  68. package/dist/core/frame/types.js.map +1 -0
  69. package/dist/core/frame/uniforms.d.ts +105 -0
  70. package/dist/core/frame/uniforms.js +276 -0
  71. package/dist/core/frame/uniforms.js.map +1 -0
  72. package/dist/core/frame/wgsl/chunks.d.ts +4 -0
  73. package/dist/core/frame/wgsl/chunks.js +728 -0
  74. package/dist/core/frame/wgsl/chunks.js.map +1 -0
  75. package/dist/core/frame/wgsl/emission.d.ts +82 -0
  76. package/dist/core/frame/wgsl/emission.js +353 -0
  77. package/dist/core/frame/wgsl/emission.js.map +1 -0
  78. package/dist/core/frame/wgsl/environment.d.ts +42 -0
  79. package/dist/core/frame/wgsl/environment.js +711 -0
  80. package/dist/core/frame/wgsl/environment.js.map +1 -0
  81. package/dist/core/frame/wgsl/gather.d.ts +55 -0
  82. package/dist/core/frame/wgsl/gather.js +850 -0
  83. package/dist/core/frame/wgsl/gather.js.map +1 -0
  84. package/dist/core/frame/wgsl/integrate.d.ts +78 -0
  85. package/dist/core/frame/wgsl/integrate.js +213 -0
  86. package/dist/core/frame/wgsl/integrate.js.map +1 -0
  87. package/dist/core/frame/wgsl/lighting.d.ts +103 -0
  88. package/dist/core/frame/wgsl/lighting.js +1636 -0
  89. package/dist/core/frame/wgsl/lighting.js.map +1 -0
  90. package/dist/core/frame/wgsl/occluders.d.ts +20 -0
  91. package/dist/core/frame/wgsl/occluders.js +95 -0
  92. package/dist/core/frame/wgsl/occluders.js.map +1 -0
  93. package/dist/core/frame/wgsl/resolve.d.ts +19 -0
  94. package/dist/core/frame/wgsl/resolve.js +205 -0
  95. package/dist/core/frame/wgsl/resolve.js.map +1 -0
  96. package/dist/core/frame/wgsl/shadows.d.ts +35 -0
  97. package/dist/core/frame/wgsl/shadows.js +328 -0
  98. package/dist/core/frame/wgsl/shadows.js.map +1 -0
  99. package/dist/core/half.d.ts +11 -0
  100. package/dist/core/half.js +22 -0
  101. package/dist/core/half.js.map +1 -0
  102. package/dist/core/index.d.ts +25 -3
  103. package/dist/core/index.js +23 -4
  104. package/dist/core/index.js.map +1 -1
  105. package/dist/core/internal.d.ts +17 -1
  106. package/dist/core/internal.js +18 -1
  107. package/dist/core/internal.js.map +1 -1
  108. package/dist/core/pool/image-header.d.ts +13 -2
  109. package/dist/core/pool/image-header.js +24 -5
  110. package/dist/core/pool/image-header.js.map +1 -1
  111. package/dist/core/pool/layout.d.ts +35 -1
  112. package/dist/core/pool/layout.js +51 -2
  113. package/dist/core/pool/layout.js.map +1 -1
  114. package/dist/core/pool/limits.d.ts +1 -0
  115. package/dist/core/pool/limits.js +1 -0
  116. package/dist/core/pool/limits.js.map +1 -1
  117. package/dist/core/pool/pool.d.ts +120 -15
  118. package/dist/core/pool/pool.js +255 -24
  119. package/dist/core/pool/pool.js.map +1 -1
  120. package/dist/core/reference/index.d.ts +6 -0
  121. package/dist/core/reference/index.js +7 -0
  122. package/dist/core/reference/index.js.map +1 -0
  123. package/dist/core/reference/renderer.d.ts +105 -0
  124. package/dist/core/reference/renderer.js +474 -0
  125. package/dist/core/reference/renderer.js.map +1 -0
  126. package/dist/core/reference/wgsl.d.ts +65 -0
  127. package/dist/core/reference/wgsl.js +803 -0
  128. package/dist/core/reference/wgsl.js.map +1 -0
  129. package/dist/{three → core}/sequence.d.ts +32 -2
  130. package/dist/{three → core}/sequence.js +24 -2
  131. package/dist/core/sequence.js.map +1 -0
  132. package/dist/core/source/brick-cache.d.ts +165 -0
  133. package/dist/core/source/brick-cache.js +627 -0
  134. package/dist/core/source/brick-cache.js.map +1 -0
  135. package/dist/core/source/dense-fill.d.ts +53 -0
  136. package/dist/core/source/dense-fill.js +377 -0
  137. package/dist/core/source/dense-fill.js.map +1 -0
  138. package/dist/core/source/dense.d.ts +33 -2
  139. package/dist/core/source/dense.js +121 -24
  140. package/dist/core/source/dense.js.map +1 -1
  141. package/dist/core/source/sparse-wgsl.d.ts +92 -0
  142. package/dist/core/source/sparse-wgsl.js +481 -0
  143. package/dist/core/source/sparse-wgsl.js.map +1 -0
  144. package/dist/core/source/sparse.d.ts +192 -0
  145. package/dist/core/source/sparse.js +762 -0
  146. package/dist/core/source/sparse.js.map +1 -0
  147. package/dist/core/source/types.d.ts +59 -2
  148. package/dist/core/source/types.js.map +1 -1
  149. package/dist/core/surface/index.d.ts +10 -0
  150. package/dist/core/surface/index.js +9 -0
  151. package/dist/core/surface/index.js.map +1 -0
  152. package/dist/core/surface/level-set-pass.d.ts +140 -0
  153. package/dist/core/surface/level-set-pass.js +291 -0
  154. package/dist/core/surface/level-set-pass.js.map +1 -0
  155. package/dist/core/surface/level-set-wgsl.d.ts +46 -0
  156. package/dist/core/surface/level-set-wgsl.js +99 -0
  157. package/dist/core/surface/level-set-wgsl.js.map +1 -0
  158. package/dist/core/surface/points.d.ts +109 -0
  159. package/dist/core/surface/points.js +226 -0
  160. package/dist/core/surface/points.js.map +1 -0
  161. package/dist/core/types.d.ts +12 -3
  162. package/dist/core/types.js +6 -2
  163. package/dist/core/types.js.map +1 -1
  164. package/dist/core/wgsl/api.d.ts +29 -5
  165. package/dist/core/wgsl/api.js +110 -27
  166. package/dist/core/wgsl/api.js.map +1 -1
  167. package/dist/core/wgsl/generate.d.ts +8 -0
  168. package/dist/core/wgsl/generate.js +195 -22
  169. package/dist/core/wgsl/generate.js.map +1 -1
  170. package/dist/core/wgsl/lean.d.ts +50 -0
  171. package/dist/core/wgsl/lean.js +327 -0
  172. package/dist/core/wgsl/lean.js.map +1 -0
  173. package/dist/core/wgsl/level-set.d.ts +5 -1
  174. package/dist/core/wgsl/level-set.js +11 -5
  175. package/dist/core/wgsl/level-set.js.map +1 -1
  176. package/dist/core/wgsl/majorant.d.ts +62 -0
  177. package/dist/core/wgsl/majorant.js +381 -0
  178. package/dist/core/wgsl/majorant.js.map +1 -0
  179. package/dist/core/wgsl/pnanovdb.chunks.generated.d.ts +2 -2
  180. package/dist/core/wgsl/pnanovdb.chunks.generated.js +15 -12
  181. package/dist/core/wgsl/pnanovdb.chunks.generated.js.map +1 -1
  182. package/dist/core/wgsl/types.d.ts +97 -3
  183. package/dist/core/wgsl/types.js.map +1 -1
  184. package/dist/three/coarse-first.d.ts +53 -8
  185. package/dist/three/coarse-first.js +24 -6
  186. package/dist/three/coarse-first.js.map +1 -1
  187. package/dist/three/compute.d.ts +12 -2
  188. package/dist/three/compute.js +16 -6
  189. package/dist/three/compute.js.map +1 -1
  190. package/dist/three/device.d.ts +7 -0
  191. package/dist/three/device.js +3 -0
  192. package/dist/three/device.js.map +1 -1
  193. package/dist/three/frame/core-environment.d.ts +38 -0
  194. package/dist/three/frame/core-environment.js +154 -0
  195. package/dist/three/frame/core-environment.js.map +1 -0
  196. package/dist/three/frame/core-integrate-material.d.ts +34 -0
  197. package/dist/three/frame/core-integrate-material.js +162 -0
  198. package/dist/three/frame/core-integrate-material.js.map +1 -0
  199. package/dist/three/frame/core-occluders.d.ts +53 -0
  200. package/dist/three/frame/core-occluders.js +193 -0
  201. package/dist/three/frame/core-occluders.js.map +1 -0
  202. package/dist/three/frame/core-structs.d.ts +34 -0
  203. package/dist/three/frame/core-structs.js +61 -0
  204. package/dist/three/frame/core-structs.js.map +1 -0
  205. package/dist/three/frame/core-textures.d.ts +41 -0
  206. package/dist/three/frame/core-textures.js +114 -0
  207. package/dist/three/frame/core-textures.js.map +1 -0
  208. package/dist/three/frame/emission-light.d.ts +64 -114
  209. package/dist/three/frame/emission-light.js +188 -567
  210. package/dist/three/frame/emission-light.js.map +1 -1
  211. package/dist/three/frame/index.d.ts +11 -31
  212. package/dist/three/frame/index.js +9 -29
  213. package/dist/three/frame/index.js.map +1 -1
  214. package/dist/three/frame/medium.d.ts +12 -0
  215. package/dist/three/frame/medium.js.map +1 -1
  216. package/dist/three/frame/renderer.d.ts +58 -454
  217. package/dist/three/frame/renderer.js +409 -1427
  218. package/dist/three/frame/renderer.js.map +1 -1
  219. package/dist/three/frame/spectrum.d.ts +0 -14
  220. package/dist/three/frame/spectrum.js +2 -23
  221. package/dist/three/frame/spectrum.js.map +1 -1
  222. package/dist/three/frame/three-internals.d.ts +3 -8
  223. package/dist/three/frame/three-internals.js +13 -11
  224. package/dist/three/frame/three-internals.js.map +1 -1
  225. package/dist/three/frame/volume-shadows.d.ts +93 -107
  226. package/dist/three/frame/volume-shadows.js +278 -631
  227. package/dist/three/frame/volume-shadows.js.map +1 -1
  228. package/dist/three/frame/volume.d.ts +91 -33
  229. package/dist/three/frame/volume.js +63 -51
  230. package/dist/three/frame/volume.js.map +1 -1
  231. package/dist/three/grid-node.d.ts +34 -1
  232. package/dist/three/grid-node.js +36 -1
  233. package/dist/three/grid-node.js.map +1 -1
  234. package/dist/three/index.d.ts +20 -11
  235. package/dist/three/index.js +21 -12
  236. package/dist/three/index.js.map +1 -1
  237. package/dist/three/internal.d.ts +14 -8
  238. package/dist/three/internal.js +11 -7
  239. package/dist/three/internal.js.map +1 -1
  240. package/dist/three/level-set-material.d.ts +81 -8
  241. package/dist/three/level-set-material.js +162 -125
  242. package/dist/three/level-set-material.js.map +1 -1
  243. package/dist/three/level-set-physical-material.d.ts +154 -0
  244. package/dist/three/level-set-physical-material.js +253 -0
  245. package/dist/three/level-set-physical-material.js.map +1 -0
  246. package/dist/three/level-set-velocity.d.ts +94 -0
  247. package/dist/three/level-set-velocity.js +208 -0
  248. package/dist/three/level-set-velocity.js.map +1 -0
  249. package/dist/three/material.d.ts +141 -11
  250. package/dist/three/material.js +161 -18
  251. package/dist/three/material.js.map +1 -1
  252. package/dist/three/points.d.ts +60 -4
  253. package/dist/three/points.js +140 -9
  254. package/dist/three/points.js.map +1 -1
  255. package/dist/three/sparse-source.d.ts +49 -117
  256. package/dist/three/sparse-source.js +109 -580
  257. package/dist/three/sparse-source.js.map +1 -1
  258. package/dist/three/volume-source.d.ts +11 -156
  259. package/dist/three/volume-source.js +29 -272
  260. package/dist/three/volume-source.js.map +1 -1
  261. package/dist/tools/cpu/brick-atlas.d.ts +36 -0
  262. package/dist/tools/cpu/brick-atlas.js +129 -0
  263. package/dist/tools/cpu/brick-atlas.js.map +1 -0
  264. package/dist/tools/cpu/compute.d.ts +23 -4
  265. package/dist/tools/cpu/compute.js +35 -14
  266. package/dist/tools/cpu/compute.js.map +1 -1
  267. package/dist/tools/cpu/lean-reads.d.ts +81 -0
  268. package/dist/tools/cpu/lean-reads.js +262 -0
  269. package/dist/tools/cpu/lean-reads.js.map +1 -0
  270. package/dist/tools/cpu/level-set.d.ts +42 -3
  271. package/dist/tools/cpu/level-set.js +59 -7
  272. package/dist/tools/cpu/level-set.js.map +1 -1
  273. package/dist/tools/cpu/majorant.d.ts +265 -0
  274. package/dist/tools/cpu/majorant.js +541 -0
  275. package/dist/tools/cpu/majorant.js.map +1 -0
  276. package/dist/tools/cpu/march.d.ts +93 -2
  277. package/dist/tools/cpu/march.js +165 -14
  278. package/dist/tools/cpu/march.js.map +1 -1
  279. package/dist/tools/cpu/mesh-decimate.d.ts +124 -0
  280. package/dist/tools/cpu/mesh-decimate.js +1225 -0
  281. package/dist/tools/cpu/mesh-decimate.js.map +1 -0
  282. package/dist/tools/cpu/points.d.ts +29 -0
  283. package/dist/tools/cpu/points.js +38 -0
  284. package/dist/tools/cpu/points.js.map +1 -0
  285. package/dist/tools/cpu/read-value.d.ts +19 -6
  286. package/dist/tools/cpu/read-value.js +32 -17
  287. package/dist/tools/cpu/read-value.js.map +1 -1
  288. package/dist/tools/cpu/sample-trilinear.d.ts +17 -4
  289. package/dist/tools/cpu/sample-trilinear.js +19 -7
  290. package/dist/tools/cpu/sample-trilinear.js.map +1 -1
  291. package/dist/tools/cpu/stride-tables.d.ts +2 -2
  292. package/dist/tools/cpu/stride-tables.generated.d.ts +6 -5
  293. package/dist/tools/cpu/stride-tables.generated.js +7 -6
  294. package/dist/tools/cpu/stride-tables.generated.js.map +1 -1
  295. package/dist/tools/cpu/stride-tables.js +1 -1
  296. package/dist/tools/cpu/stride-tables.js.map +1 -1
  297. package/dist/tools/cpu/surface-nets.d.ts +90 -0
  298. package/dist/tools/cpu/surface-nets.js +597 -0
  299. package/dist/tools/cpu/surface-nets.js.map +1 -0
  300. package/dist/tools/errors.d.ts +9 -0
  301. package/dist/tools/errors.js +9 -0
  302. package/dist/tools/errors.js.map +1 -1
  303. package/dist/tools/frame/ambient.d.ts +98 -0
  304. package/dist/tools/frame/ambient.js +274 -0
  305. package/dist/tools/frame/ambient.js.map +1 -0
  306. package/dist/tools/frame/blackbody.d.ts +15 -0
  307. package/dist/tools/frame/blackbody.js +35 -0
  308. package/dist/tools/frame/blackbody.js.map +1 -1
  309. package/dist/tools/frame/brick-cache.d.ts +165 -0
  310. package/dist/tools/frame/brick-cache.js +326 -0
  311. package/dist/tools/frame/brick-cache.js.map +1 -0
  312. package/dist/tools/frame/emission.d.ts +9 -0
  313. package/dist/tools/frame/emission.js +9 -1
  314. package/dist/tools/frame/emission.js.map +1 -1
  315. package/dist/tools/frame/environment-gpu.d.ts +111 -0
  316. package/dist/tools/frame/environment-gpu.js +280 -0
  317. package/dist/tools/frame/environment-gpu.js.map +1 -0
  318. package/dist/tools/frame/environment.d.ts +3 -2
  319. package/dist/tools/frame/environment.js +8 -4
  320. package/dist/tools/frame/environment.js.map +1 -1
  321. package/dist/tools/frame/froxel.d.ts +58 -0
  322. package/dist/tools/frame/froxel.js +115 -0
  323. package/dist/tools/frame/froxel.js.map +1 -0
  324. package/dist/tools/frame/grid.d.ts +90 -0
  325. package/dist/tools/frame/grid.js +112 -13
  326. package/dist/tools/frame/grid.js.map +1 -1
  327. package/dist/tools/frame/index.d.ts +14 -0
  328. package/dist/tools/frame/index.js +45 -4
  329. package/dist/tools/frame/index.js.map +1 -1
  330. package/dist/tools/frame/medium.d.ts +16 -0
  331. package/dist/tools/frame/medium.js +3 -1
  332. package/dist/tools/frame/medium.js.map +1 -1
  333. package/dist/tools/frame/mie.d.ts +9 -0
  334. package/dist/tools/frame/mie.js +18 -0
  335. package/dist/tools/frame/mie.js.map +1 -1
  336. package/dist/tools/frame/mlp-nn.d.ts +36 -0
  337. package/dist/tools/frame/mlp-nn.js +159 -0
  338. package/dist/tools/frame/mlp-nn.js.map +1 -0
  339. package/dist/tools/frame/mlp-tza.d.ts +29 -0
  340. package/dist/tools/frame/mlp-tza.js +186 -0
  341. package/dist/tools/frame/mlp-tza.js.map +1 -0
  342. package/dist/tools/frame/mlp.d.ts +183 -0
  343. package/dist/tools/frame/mlp.js +434 -0
  344. package/dist/tools/frame/mlp.js.map +1 -0
  345. package/dist/tools/frame/ms-exit.d.ts +42 -0
  346. package/dist/tools/frame/ms-exit.js +90 -0
  347. package/dist/tools/frame/ms-exit.js.map +1 -0
  348. package/dist/tools/frame/multi-scale.d.ts +152 -0
  349. package/dist/tools/frame/multi-scale.js +302 -0
  350. package/dist/tools/frame/multi-scale.js.map +1 -0
  351. package/dist/tools/frame/neural-weights.d.ts +6 -5
  352. package/dist/tools/frame/neural-weights.js +234 -235
  353. package/dist/tools/frame/neural-weights.js.map +1 -1
  354. package/dist/tools/frame/neural.js +1 -1
  355. package/dist/tools/frame/neural.js.map +1 -1
  356. package/dist/tools/frame/occluders.d.ts +51 -0
  357. package/dist/tools/frame/occluders.js +72 -0
  358. package/dist/tools/frame/occluders.js.map +1 -0
  359. package/dist/tools/frame/pyramid-layout.d.ts +17 -0
  360. package/dist/tools/frame/pyramid-layout.js +47 -0
  361. package/dist/tools/frame/pyramid-layout.js.map +1 -1
  362. package/dist/tools/frame/shadows.d.ts +110 -0
  363. package/dist/tools/frame/shadows.js +286 -0
  364. package/dist/tools/frame/shadows.js.map +1 -1
  365. package/dist/tools/frame/sparse.d.ts +82 -0
  366. package/dist/tools/frame/sparse.js +242 -1
  367. package/dist/tools/frame/sparse.js.map +1 -1
  368. package/dist/tools/frame/spectral-stack.d.ts +159 -0
  369. package/dist/tools/frame/spectral-stack.js +391 -0
  370. package/dist/tools/frame/spectral-stack.js.map +1 -0
  371. package/dist/tools/frame/spectral.d.ts +21 -2
  372. package/dist/tools/frame/spectral.js +30 -8
  373. package/dist/tools/frame/spectral.js.map +1 -1
  374. package/dist/tools/frame/stack.d.ts +115 -0
  375. package/dist/tools/frame/stack.js +290 -0
  376. package/dist/tools/frame/stack.js.map +1 -0
  377. package/dist/tools/frame/view.d.ts +131 -0
  378. package/dist/tools/frame/view.js +337 -0
  379. package/dist/tools/frame/view.js.map +1 -0
  380. package/dist/tools/index.d.ts +66 -15
  381. package/dist/tools/index.js +55 -11
  382. package/dist/tools/index.js.map +1 -1
  383. package/dist/tools/internal.d.ts +58 -17
  384. package/dist/tools/internal.js +65 -11
  385. package/dist/tools/internal.js.map +1 -1
  386. package/dist/tools/nanovdb/build-from-vdb.d.ts +11 -2
  387. package/dist/tools/nanovdb/build-from-vdb.js +10 -2
  388. package/dist/tools/nanovdb/build-from-vdb.js.map +1 -1
  389. package/dist/tools/nanovdb/bytes.d.ts +17 -4
  390. package/dist/tools/nanovdb/bytes.js +46 -3
  391. package/dist/tools/nanovdb/bytes.js.map +1 -1
  392. package/dist/tools/nanovdb/coarse-first.d.ts +19 -3
  393. package/dist/tools/nanovdb/coarse-first.js +7 -1
  394. package/dist/tools/nanovdb/coarse-first.js.map +1 -1
  395. package/dist/tools/nanovdb/half.d.ts +22 -0
  396. package/dist/tools/nanovdb/half.js +73 -0
  397. package/dist/tools/nanovdb/half.js.map +1 -0
  398. package/dist/tools/nanovdb/index.d.ts +3 -1
  399. package/dist/tools/nanovdb/index.js +2 -1
  400. package/dist/tools/nanovdb/index.js.map +1 -1
  401. package/dist/tools/nanovdb/inspect.d.ts +10 -1
  402. package/dist/tools/nanovdb/inspect.js +8 -1
  403. package/dist/tools/nanovdb/inspect.js.map +1 -1
  404. package/dist/tools/nanovdb/leaf-codec.d.ts +35 -1
  405. package/dist/tools/nanovdb/leaf-codec.js +40 -4
  406. package/dist/tools/nanovdb/leaf-codec.js.map +1 -1
  407. package/dist/tools/nanovdb/quantize.d.ts +39 -10
  408. package/dist/tools/nanovdb/quantize.js +96 -44
  409. package/dist/tools/nanovdb/quantize.js.map +1 -1
  410. package/dist/tools/nanovdb/resample.d.ts +20 -3
  411. package/dist/tools/nanovdb/resample.js +20 -7
  412. package/dist/tools/nanovdb/resample.js.map +1 -1
  413. package/dist/tools/nanovdb/serialize.d.ts +34 -3
  414. package/dist/tools/nanovdb/serialize.js +51 -7
  415. package/dist/tools/nanovdb/serialize.js.map +1 -1
  416. package/dist/tools/nanovdb/stats.d.ts +34 -5
  417. package/dist/tools/nanovdb/stats.js +87 -11
  418. package/dist/tools/nanovdb/stats.js.map +1 -1
  419. package/dist/tools/nanovdb/transform.d.ts +4 -0
  420. package/dist/tools/nanovdb/transform.js +3 -0
  421. package/dist/tools/nanovdb/transform.js.map +1 -1
  422. package/dist/tools/nanovdb/tree.d.ts +14 -3
  423. package/dist/tools/nanovdb/tree.js +25 -13
  424. package/dist/tools/nanovdb/tree.js.map +1 -1
  425. package/dist/tools/nanovdb/write-nvdb.d.ts +47 -12
  426. package/dist/tools/nanovdb/write-nvdb.js +108 -28
  427. package/dist/tools/nanovdb/write-nvdb.js.map +1 -1
  428. package/dist/tools/nvdb-file.d.ts +77 -7
  429. package/dist/tools/nvdb-file.js +177 -20
  430. package/dist/tools/nvdb-file.js.map +1 -1
  431. package/dist/tools/nvdb-stream.d.ts +23 -7
  432. package/dist/tools/nvdb-stream.js +78 -34
  433. package/dist/tools/nvdb-stream.js.map +1 -1
  434. package/dist/tools/reference/analytic.d.ts +41 -0
  435. package/dist/tools/reference/analytic.js +95 -0
  436. package/dist/tools/reference/analytic.js.map +1 -0
  437. package/dist/tools/reference/environment.d.ts +62 -0
  438. package/dist/tools/reference/environment.js +154 -0
  439. package/dist/tools/reference/environment.js.map +1 -0
  440. package/dist/tools/reference/index.d.ts +12 -0
  441. package/dist/tools/reference/index.js +13 -0
  442. package/dist/tools/reference/index.js.map +1 -0
  443. package/dist/tools/reference/media.d.ts +14 -0
  444. package/dist/tools/reference/media.js +30 -0
  445. package/dist/tools/reference/media.js.map +1 -0
  446. package/dist/tools/reference/rng.d.ts +20 -0
  447. package/dist/tools/reference/rng.js +30 -0
  448. package/dist/tools/reference/rng.js.map +1 -0
  449. package/dist/tools/reference/scene.d.ts +312 -0
  450. package/dist/tools/reference/scene.js +169 -0
  451. package/dist/tools/reference/scene.js.map +1 -0
  452. package/dist/tools/reference/tables.d.ts +98 -0
  453. package/dist/tools/reference/tables.js +264 -0
  454. package/dist/tools/reference/tables.js.map +1 -0
  455. package/dist/tools/reference/trace.d.ts +160 -0
  456. package/dist/tools/reference/trace.js +497 -0
  457. package/dist/tools/reference/trace.js.map +1 -0
  458. package/dist/tools/vdb/blosc-write.d.ts +43 -0
  459. package/dist/tools/vdb/blosc-write.js +197 -0
  460. package/dist/tools/vdb/blosc-write.js.map +1 -0
  461. package/dist/tools/vdb/blosc.d.ts +35 -5
  462. package/dist/tools/vdb/blosc.js +82 -26
  463. package/dist/tools/vdb/blosc.js.map +1 -1
  464. package/dist/tools/vdb/blosclz.d.ts +33 -0
  465. package/dist/tools/vdb/blosclz.js +112 -0
  466. package/dist/tools/vdb/blosclz.js.map +1 -0
  467. package/dist/tools/vdb/byte-reader.d.ts +13 -3
  468. package/dist/tools/vdb/byte-reader.js +26 -4
  469. package/dist/tools/vdb/byte-reader.js.map +1 -1
  470. package/dist/tools/vdb/compression.d.ts +13 -5
  471. package/dist/tools/vdb/compression.js +13 -2
  472. package/dist/tools/vdb/compression.js.map +1 -1
  473. package/dist/tools/vdb/grid.js +8 -2
  474. package/dist/tools/vdb/grid.js.map +1 -1
  475. package/dist/tools/vdb/index.d.ts +2 -1
  476. package/dist/tools/vdb/index.js.map +1 -1
  477. package/dist/tools/vdb/lz4.d.ts +30 -0
  478. package/dist/tools/vdb/lz4.js +228 -0
  479. package/dist/tools/vdb/lz4.js.map +1 -0
  480. package/dist/tools/vdb/metadata.js +1 -1
  481. package/dist/tools/vdb/metadata.js.map +1 -1
  482. package/dist/tools/vdb/parse.d.ts +24 -2
  483. package/dist/tools/vdb/parse.js +102 -32
  484. package/dist/tools/vdb/parse.js.map +1 -1
  485. package/dist/tools/vdb/point-render-data.d.ts +49 -1
  486. package/dist/tools/vdb/point-render-data.js +91 -11
  487. package/dist/tools/vdb/point-render-data.js.map +1 -1
  488. package/dist/tools/vdb/points.d.ts +26 -0
  489. package/dist/tools/vdb/points.js +46 -5
  490. package/dist/tools/vdb/points.js.map +1 -1
  491. package/dist/tools/vdb/types.d.ts +59 -2
  492. package/dist/tools/vdb/types.js.map +1 -1
  493. package/dist/tools/wvdb/bake.d.ts +38 -9
  494. package/dist/tools/wvdb/bake.js +63 -13
  495. package/dist/tools/wvdb/bake.js.map +1 -1
  496. package/dist/tools/wvdb/dense.d.ts +80 -1
  497. package/dist/tools/wvdb/dense.js +67 -8
  498. package/dist/tools/wvdb/dense.js.map +1 -1
  499. package/dist/tools/wvdb/format.d.ts +59 -0
  500. package/dist/tools/wvdb/format.js +3 -0
  501. package/dist/tools/wvdb/format.js.map +1 -1
  502. package/dist/tools/wvdb/index.d.ts +1 -0
  503. package/dist/tools/wvdb/index.js +1 -0
  504. package/dist/tools/wvdb/index.js.map +1 -1
  505. package/dist/tools/wvdb/level-set.d.ts +10 -2
  506. package/dist/tools/wvdb/level-set.js.map +1 -1
  507. package/dist/tools/wvdb/nanovdb.d.ts +6 -1
  508. package/dist/tools/wvdb/nanovdb.js +5 -1
  509. package/dist/tools/wvdb/nanovdb.js.map +1 -1
  510. package/dist/tools/wvdb/partial.d.ts +74 -0
  511. package/dist/tools/wvdb/partial.js +233 -0
  512. package/dist/tools/wvdb/partial.js.map +1 -0
  513. package/dist/tools/wvdb/read.d.ts +77 -1
  514. package/dist/tools/wvdb/read.js +30 -7
  515. package/dist/tools/wvdb/read.js.map +1 -1
  516. package/dist/tools/wvdb/write.d.ts +23 -1
  517. package/dist/tools/wvdb/write.js +8 -1
  518. package/dist/tools/wvdb/write.js.map +1 -1
  519. package/package.json +2 -1
  520. package/vendor/VENDOR.md +21 -6
  521. package/vendor/pnanovdb.wgsl +52 -14
  522. package/dist/three/frame/blackbody.d.ts +0 -42
  523. package/dist/three/frame/blackbody.js +0 -74
  524. package/dist/three/frame/blackbody.js.map +0 -1
  525. package/dist/three/frame/chunks.d.ts +0 -157
  526. package/dist/three/frame/chunks.js +0 -559
  527. package/dist/three/frame/chunks.js.map +0 -1
  528. package/dist/three/frame/density-material.d.ts +0 -53
  529. package/dist/three/frame/density-material.js +0 -353
  530. package/dist/three/frame/density-material.js.map +0 -1
  531. package/dist/three/frame/environment-grid-material.d.ts +0 -21
  532. package/dist/three/frame/environment-grid-material.js +0 -184
  533. package/dist/three/frame/environment-grid-material.js.map +0 -1
  534. package/dist/three/frame/environment-material.d.ts +0 -22
  535. package/dist/three/frame/environment-material.js +0 -87
  536. package/dist/three/frame/environment-material.js.map +0 -1
  537. package/dist/three/frame/grid-mip-material.d.ts +0 -12
  538. package/dist/three/frame/grid-mip-material.js +0 -61
  539. package/dist/three/frame/grid-mip-material.js.map +0 -1
  540. package/dist/three/frame/inject-material.d.ts +0 -56
  541. package/dist/three/frame/inject-material.js +0 -424
  542. package/dist/three/frame/inject-material.js.map +0 -1
  543. package/dist/three/frame/integrate-material.d.ts +0 -26
  544. package/dist/three/frame/integrate-material.js +0 -198
  545. package/dist/three/frame/integrate-material.js.map +0 -1
  546. package/dist/three/frame/layout.d.ts +0 -34
  547. package/dist/three/frame/layout.js +0 -48
  548. package/dist/three/frame/layout.js.map +0 -1
  549. package/dist/three/frame/lighting-material.d.ts +0 -41
  550. package/dist/three/frame/lighting-material.js +0 -257
  551. package/dist/three/frame/lighting-material.js.map +0 -1
  552. package/dist/three/frame/lights.d.ts +0 -11
  553. package/dist/three/frame/lights.js +0 -16
  554. package/dist/three/frame/lights.js.map +0 -1
  555. package/dist/three/frame/neural.d.ts +0 -14
  556. package/dist/three/frame/neural.js +0 -105
  557. package/dist/three/frame/neural.js.map +0 -1
  558. package/dist/three/frame/phase.d.ts +0 -44
  559. package/dist/three/frame/phase.js +0 -80
  560. package/dist/three/frame/phase.js.map +0 -1
  561. package/dist/three/frame/shadow-density-material.d.ts +0 -30
  562. package/dist/three/frame/shadow-density-material.js +0 -123
  563. package/dist/three/frame/shadow-density-material.js.map +0 -1
  564. package/dist/three/frame/temporal-material.d.ts +0 -29
  565. package/dist/three/frame/temporal-material.js +0 -152
  566. package/dist/three/frame/temporal-material.js.map +0 -1
  567. package/dist/three/frame/transmittance-material.d.ts +0 -31
  568. package/dist/three/frame/transmittance-material.js +0 -315
  569. package/dist/three/frame/transmittance-material.js.map +0 -1
  570. package/dist/three/frame/view.d.ts +0 -103
  571. package/dist/three/frame/view.js +0 -296
  572. package/dist/three/frame/view.js.map +0 -1
  573. package/dist/three/frame/volume-shadow-material.d.ts +0 -36
  574. package/dist/three/frame/volume-shadow-material.js +0 -128
  575. package/dist/three/frame/volume-shadow-material.js.map +0 -1
  576. package/dist/three/sequence.js.map +0 -1
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mlp.js","sourceRoot":"","sources":["../../../src/tools/frame/mlp.ts"],"names":[],"mappings":"AAAA,0EAA0E;AAC1E,gHAAgH;AAChH,wHAAwH;AACxH,4GAA4G;AAC5G,gHAAgH;AAChH,qHAAqH;AACrH,wCAAwC;AAaxC,OAAO,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;AAElD,OAAO,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAC/C,OAAO,EAAE,eAAe,EAA2B,MAAM,WAAW,CAAC;AAErE,mFAAmF;AACnF,MAAM,CAAC,MAAM,wBAAwB,GAAG,CAAC,CAAC;AAC1C,MAAM,CAAC,MAAM,uBAAuB,GAAG,EAAE,CAAC;AAC1C,sFAAsF;AACtF,MAAM,CAAC,MAAM,wBAAwB,GAAG,CAAC,CAAC;AAC1C;;;GAGG;AACH,MAAM,CAAC,MAAM,sBAAsB,GAAG,CAAC,CAAC;AACxC,gHAAgH;AAChH,MAAM,CAAC,MAAM,kCAAkC,GAAG,EAAE,CAAC;AAerD,qHAAqH;AACrH,MAAM,WAAW,GAAG,CAAC,MAAyB,EAAE,UAAkB,EAAU,EAAE,CAC5E,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,CAAE,EAAE,IAAI,CAAC,GAAG,CAAC,UAAU,GAAG,CAAC,CAAC,CAAC,CAAC,CAA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AAE,GAAG,CAAC,CAAC,GAAG,GAAG,GAAG,CAAC,CAAC,GAAG,EAAE,CAAC;oBACpC,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE;wBAAE,CAAC,IAAI,MAAM,CAAC,GAAG,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,CAAE,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC;gBAClF,CAAC;gBACD,IAAI,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;YAC9C,CAAC;QACH,CAAC;QACD,CAAC,GAAG,IAAI,CAAC;IACX,CAAC;IACD,OAAO,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAE,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAE,CAAC;AAC/D,CAAC","sourcesContent":["// Portions derived from mjurczyk/openvdb (MIT), commit 75e7345 (v0.26.0):\n// src/three-openvdb/frame/webgpu/frameNeuralChunks.js L14–129 (dense layers, getLocalInputs, neuralLight: the\n// inputs of his 'neural' network), src/three-openvdb/frame/webgpu/FrameGridMipMaterial.js L10–66 (the 2x2x2 box mip).\n// Copyright (c) mjurczyk/openvdb contributors. Licensed under the MIT License (see THIRD_PARTY_NOTICES.md).\n// Changes: a generic small-MLP description (layer shapes as data, any activation sequence) instead of his fixed\n// 20 → 32 → 32 → 1 vec4 layout; the mips are levels of one 3D texture. CPU twins of the core's 'mlp' kernels (K6.3).\n// Divergences: DIVERGES.md (K6.3 rows).\n\n/**\n * K6.3, design §3.6 (Q5): the core's `multipleScattering: 'mlp'` is an EXPERIMENTAL generic small-MLP evaluator. A\n * network is data: its layer shapes become a uniform and its weights a storage buffer, so a new network needs no shader\n * change. The inputs are his `'neural'` features at 3·L + 2 values (L feature levels): log(1 + σ h 2^k) at the voxel,\n * h 2^k toward the light and h 2^k away from it for k < L, then log(1 + direct optical depth) and √(absorption /\n * extinction) of level 1. The output is the scattered light (total − direct) of a light slot. Our trained network (K6.N, D36)\n * ({@link vdbFrameMlpFromNeural} of `vdbFrameNeuralWeights`) is the first network, not the definition.\n */\n\nimport type { Vec2, Vec3 } from \"./index.js\";\nimport type { VDBFrameNeuralNetwork } from \"./neural.js\";\nimport { vdbFramePhaseLobes } from \"./ambient.js\";\nimport type { VDBFrameTexture3d } from \"./stack.js\";\nimport { vdbFrameTrilinear } from \"./stack.js\";\nimport { vdbFrameGridUvw, type VDBFrameGridLayout } from \"./grid.js\";\n\n/** Most layers and the widest layer of the core evaluator (two 64-wide locals). */\nexport const VDB_FRAME_MLP_MAX_LAYERS = 8;\nexport const VDB_FRAME_MLP_MAX_WIDTH = 64;\n/** Feature levels L of a network (level 0 the grid, mips 1–5 at the K6.N reaches). */\nexport const VDB_FRAME_MLP_MAX_LEVELS = 6;\n/**\n * K6.Nb: mips of the core's feature chain (to one voxel, at most this many). 'world' reaches on a grid finer than\n * {@link VDB_FRAME_MLP_REFERENCE_RESOLUTION} read levels past 5 (level k + shift); levels 0–5 are the K6.N chain.\n */\nexport const VDB_FRAME_MLP_MAX_MIPS = 8;\n/** K6.Nb: the grid side the networks are trained at (`scripts/k6/neural`): the reference of 'world' reaches. */\nexport const VDB_FRAME_MLP_REFERENCE_RESOLUTION = 64;\n\n/**\n * K6.Nb `mlpReach`: the feature reaches of a network. `'grid'` (K6.N, his): h 2^k with h the last cascade's largest voxel\n * side, level k (the features move with the grid side). `'world'`: unit 2^k with `unit` the voxel the last cascade would\n * have at {@link VDB_FRAME_MLP_REFERENCE_RESOLUTION} (64) over the same casters, read at mip level k + `shift`\n * (shift = log2(unit / h), an integer: both voxels are powers of two). At side 64 both are the same numbers.\n */\nexport interface VDBFrameMlpReach {\n /** The world length of feature level 0. */\n unit: number;\n /** The mip level of feature level k is max(k + shift, 0) (clamped to the chain by the sampler). */\n shift: number;\n}\n\n/** The largest power-of-two voxel side {@link vdbFrameGridCascades} gives a box of `extent` at side `resolution`. */\nconst cascadeUnit = (extent: readonly number[], resolution: number): number =>\n Math.max(...[0, 1, 2].map((a) => Math.pow(2, Math.ceil(Math.log2(Math.max(extent[a]!, 1e-6) / (resolution - 1))))));\n\n/**\n * K6.Nb: the reach of a network on the last cascade. `extent`: the world size of the casters' box (the union of the\n * caster boxes, the last cascade's box); `voxel`: the last cascade's voxel. `'grid'` gives (max voxel side, 0).\n */\nexport function vdbFrameMlpReach(mode: \"grid\" | \"world\", extent: readonly number[], voxel: readonly number[]): VDBFrameMlpReach {\n const h = Math.max(voxel[0]!, voxel[1]!, voxel[2]!);\n if (mode !== \"world\" || !(h > 0)) return { unit: h, shift: 0 };\n const unit = cascadeUnit(extent, VDB_FRAME_MLP_REFERENCE_RESOLUTION);\n return { unit, shift: Math.round(Math.log2(unit / h)) };\n}\n\n/**\n * K7.4d-a `mlpFeatures: 'cubic'`: the per-axis reduction of the cubic feature chain. The cascade fitter snaps each axis\n * of the last cascade to its own power-of-two voxel, but a feature level is one length (h 2^k, h the largest voxel\n * side). Axis a has voxels of h / 2^e[a]: level 0 of the cubic chain is the box mean of 2^e[0] × 2^e[1] × 2^e[2] voxels\n * (a cube of side h), every level after it a 2 × 2 × 2 box of the one before (a cube of side h 2^k). (0, 0, 0): the\n * voxels are cubes already, and the chain is the K6.3 one.\n */\nexport function vdbFrameMlpCubicReduce(voxel: readonly number[]): Vec3 {\n const h = Math.max(voxel[0]!, voxel[1]!, voxel[2]!);\n const e = (v: number): number => (h > 0 && v > 0 ? Math.max(0, Math.round(Math.log2(h / v))) : 0);\n return [e(voxel[0]!), e(voxel[1]!), e(voxel[2]!)];\n}\n\n/**\n * K7.4d-a: texels per axis of the cubic feature chain's mips: mip j IS feature level j (mip 0 the level-0 boxes of\n * {@link vdbFrameMlpCubicReduce}), max(1, (R >> e[a]) >> j) on axis a, down to one texel and at most\n * {@link VDB_FRAME_MLP_MAX_MIPS} + 1 mips (levels 0 to 8, as the K6.Nb chain plus the grid).\n */\nexport function vdbFrameMlpCubicSizes(resolution: number, reduce: readonly number[]): Vec3[] {\n const at = (j: number): Vec3 => [0, 1, 2].map((a) => Math.max(1, (resolution >> reduce[a]!) >> j)) as Vec3;\n const sizes = [at(0)];\n while (sizes.length < VDB_FRAME_MLP_MAX_MIPS + 1 && sizes[sizes.length - 1]!.some((n) => n > 1)) sizes.push(at(sizes.length));\n return sizes;\n}\n\n/**\n * K7.4d-a: the cubic chain's first kernel (`vdbFrameGridMipReduceCs`) at texel `p` of level 0: the mean of the\n * 2^e[0] × 2^e[1] × 2^e[2] voxels (p << e) + i of the last cascade (each axis clamped to `resolution` − 1) read at\n * `origin` in the stack. `channels` values (2: extinction, absorption; 3: a spectral stack's rgb).\n */\nexport function vdbFrameMlpCubicTexel(source: VDBFrameTexture3d, origin: readonly number[], resolution: number, reduce: readonly number[], p: Vec3, channels = 2): number[] {\n const sum = new Array<number>(channels).fill(0);\n const n = [1 << reduce[0]!, 1 << reduce[1]!, 1 << reduce[2]!];\n for (let k = 0; k < n[2]!; k++)\n for (let j = 0; j < n[1]!; j++)\n for (let i = 0; i < n[0]!; i++) {\n const q = [p[0] * n[0]! + i, p[1] * n[1]! + j, p[2] * n[2]! + k].map((v, a) => Math.min(v, resolution - 1) + origin[a]!);\n const at = (q[0]! + (q[1]! + q[2]! * source.size[1]) * source.size[0]) * source.channels;\n for (let c = 0; c < channels; c++) sum[c] = sum[c]! + source.data[at + c]!;\n }\n return sum.map((v) => v / (n[0]! * n[1]! * n[2]!));\n}\n\n/** K6.Nb: the extra inputs of a network after its 3 L + 2 features (1 for `extra: 'g'`, K6.Nb2: 3 for `'phase'`). */\nexport function vdbFrameMlpExtraInputs(mlp: { extra?: VDBFrameMlp[\"extra\"] | undefined }): number {\n return mlp.extra === \"g\" ? 1 : mlp.extra === \"phase\" ? 3 : 0;\n}\n\n/** K6.Nb2: most extra inputs a network may take (the shape uniform's `extra: vec4f`). */\nexport const VDB_FRAME_MLP_MAX_EXTRA = 4;\n\n/**\n * K6.Nb: the anisotropy input of `extra: 'g'` networks: the phase's mean cosine, (1 − w) g₁ + w g₂ of its two lobes\n * (`vdbFramePhaseLobes`: the Lorenz-Mie modes at the table's asymmetry; spectral: the green channel).\n */\nexport function vdbFrameMlpPhaseG(phase: readonly [number, number, number, number], phaseSpectrum: readonly [number, number, number]): number {\n const lobes = vdbFramePhaseLobes([...phase], [...phaseSpectrum]);\n return lobes.g[0][1] + (lobes.g[1][1] - lobes.g[0][1]) * lobes.weight;\n}\n\n/**\n * K6.Nb2: the anisotropy inputs of `extra: 'phase'` networks: the phase's two lobes (g₁, g₂, w), the phase being\n * (1 − w) HG(g₁) + w HG(g₂) (`vdbFramePhaseLobes`: the Lorenz-Mie modes at the table's asymmetry; spectral: the green\n * channel). Canonical, so one phase has one input: the lobe of weight ≥ ½ first (w ≤ ½), and one lobe (w = 0, or both\n * lobes equal) is (g, g, 0). The trainer's `canonicalPhase` (scripts/k6/neural/inputs.mjs) is the same rule.\n */\nexport function vdbFrameMlpPhaseInputs(phase: readonly [number, number, number, number], phaseSpectrum: readonly [number, number, number]): [number, number, number] {\n const lobes = vdbFramePhaseLobes([...phase], [...phaseSpectrum]);\n let g1 = lobes.g[0][1];\n let g2 = lobes.g[1][1];\n let w = lobes.weight;\n if (w > 0.5) [g1, g2, w] = [g2, g1, 1 - w];\n return !(w > 0) || g1 === g2 ? [g1, g1, 0] : [g1, g2, w];\n}\n\n/** K6.Nb2: the values of a network's extra inputs for a phase (none, the mean cosine, or the lobes). */\nexport function vdbFrameMlpExtraValues(mlp: Pick<VDBFrameMlp, \"extra\">, phase: readonly [number, number, number, number], phaseSpectrum: readonly [number, number, number]): number[] {\n if (mlp.extra === \"g\") return [vdbFrameMlpPhaseG(phase, phaseSpectrum)];\n if (mlp.extra === \"phase\") return vdbFrameMlpPhaseInputs(phase, phaseSpectrum);\n return [];\n}\n\n/** K6.Nb: the byte offset of `VdbFrameMlp.reach` (after `info` and the layer table); K6.Nb2: `extra` follows it. */\nexport const VDB_FRAME_MLP_REACH_OFFSET = 16 + 16 * VDB_FRAME_MLP_MAX_LAYERS;\n\n/**\n * K6.Nb: the `reach` and (K6.Nb2) `extra` fields of the shape uniform at {@link VDB_FRAME_MLP_REACH_OFFSET}: `reach` =\n * (unit, shift, extra input count, chain base), `extra` = the extra inputs' values (at most\n * {@link VDB_FRAME_MLP_MAX_EXTRA}, f32). K7.4d-a `base`: 0 = level 0 is the grid and level k ≥ 1 mip k − 1 (K6.3); 1 =\n * the cubic chain on a non-cubic cascade, level k is mip k.\n */\nexport function vdbFrameMlpReachUniform(reach: VDBFrameMlpReach, extra: readonly number[] = [], base: 0 | 1 = 0): Float32Array {\n const u = new Float32Array(8);\n u[0] = reach.unit;\n u[1] = reach.shift;\n u[2] = Math.min(extra.length, VDB_FRAME_MLP_MAX_EXTRA);\n u[3] = base;\n extra.slice(0, VDB_FRAME_MLP_MAX_EXTRA).forEach((v, i) => (u[4 + i] = v));\n return u;\n}\n\n/** One dense layer: `outputs` = activation(W · x + b), W row-major (row j = output j). */\nexport interface VDBFrameMlpLayer {\n inputs: number;\n outputs: number;\n activation: \"relu\" | \"linear\";\n}\n\n/** A network for the core's experimental `'mlp'` multiple scattering. */\nexport interface VDBFrameMlp {\n /** A label for warnings and signatures. */\n name?: string;\n /** Feature levels L (2–6): the first layer takes 3 L + 2 inputs. */\n levels: number;\n layers: readonly VDBFrameMlpLayer[];\n /** The output transform of the last layer's first output: `'exp'` = exp(min(o, 4)) (his), `'linear'` = o. */\n output: \"exp\" | \"linear\";\n /**\n * K6.Nb: extra inputs after the 3 L + 2 features. `'g'`: the phase's mean cosine (an anisotropy input: one network\n * for every phase; {@link vdbFrameMlpPhaseG}). K6.Nb2 `'phase'`: the phase's lobes g₁, g₂, w (three inputs,\n * {@link vdbFrameMlpPhaseInputs}). Default none (his layout).\n */\n extra?: \"g\" | \"phase\";\n /** Per layer, in order: outputs × inputs weights (row-major), then the outputs biases. */\n weights: Float32Array;\n}\n\n/** The weight offset of each layer (its row-major W; the biases follow at offset + outputs × inputs). */\nexport function vdbFrameMlpOffsets(mlp: Pick<VDBFrameMlp, \"layers\">): number[] {\n const offsets: number[] = [];\n let at = 0;\n for (const l of mlp.layers) {\n offsets.push(at);\n at += l.outputs * (l.inputs + 1);\n }\n return offsets;\n}\n\n/** Checks a network the core evaluator runs; returns a reason, or null when it fits. */\nexport function vdbFrameMlpCheck(mlp: VDBFrameMlp): string | null {\n if (!Number.isInteger(mlp.levels) || mlp.levels < 2 || mlp.levels > VDB_FRAME_MLP_MAX_LEVELS) return `levels must be 2 to ${VDB_FRAME_MLP_MAX_LEVELS} (got ${mlp.levels})`;\n if (mlp.layers.length < 1 || mlp.layers.length > VDB_FRAME_MLP_MAX_LAYERS) return `1 to ${VDB_FRAME_MLP_MAX_LAYERS} layers (got ${mlp.layers.length})`;\n if (mlp.extra !== undefined && mlp.extra !== \"g\" && mlp.extra !== \"phase\") return \"extra must be 'g', 'phase' or absent\";\n const inputs = 3 * mlp.levels + 2 + vdbFrameMlpExtraInputs(mlp);\n if (mlp.layers[0]!.inputs !== inputs) return `the first layer takes 3 × levels + 2${mlp.extra ? ` + ${vdbFrameMlpExtraInputs(mlp)} (extra '${mlp.extra}')` : \"\"} = ${inputs} inputs (got ${mlp.layers[0]!.inputs})`;\n for (let i = 0; i < mlp.layers.length; i++) {\n const l = mlp.layers[i]!;\n if (!(l.inputs >= 1 && l.inputs <= VDB_FRAME_MLP_MAX_WIDTH && l.outputs >= 1 && l.outputs <= VDB_FRAME_MLP_MAX_WIDTH)) return `layer ${i}: widths must be 1 to ${VDB_FRAME_MLP_MAX_WIDTH}`;\n if (i > 0 && l.inputs !== mlp.layers[i - 1]!.outputs) return `layer ${i} takes ${l.inputs} inputs, the layer before gives ${mlp.layers[i - 1]!.outputs}`;\n if (l.activation !== \"relu\" && l.activation !== \"linear\") return `layer ${i}: activation must be 'relu' or 'linear'`;\n }\n if (mlp.output !== \"exp\" && mlp.output !== \"linear\") return \"output must be 'exp' or 'linear'\";\n const total = mlp.layers.reduce((s, l) => s + l.outputs * (l.inputs + 1), 0);\n if (mlp.weights.length !== total) return `expected ${total} weights, got ${mlp.weights.length}`;\n return null;\n}\n\n/**\n * His `'neural'` network (vec4 layout: w1 rows, b1, w2 rows, b2, w3, b3.x) as a generic MLP: the same numbers\n * (his layout is row-major with the biases after each W; the 3 pad floats after b3 are dropped).\n */\nexport function vdbFrameMlpFromNeural(network: VDBFrameNeuralNetwork): VDBFrameMlp {\n const n = network.inputs;\n const h = network.hidden;\n const total = h * (n + 1) + h * (h + 1) + (h + 1);\n return {\n name: network.name ?? \"neural\",\n levels: network.levels,\n layers: [\n { inputs: n, outputs: h, activation: \"relu\" },\n { inputs: h, outputs: h, activation: \"relu\" },\n { inputs: h, outputs: 1, activation: \"linear\" },\n ],\n output: \"exp\",\n weights: network.weights.slice(0, total),\n };\n}\n\n/** The shape uniform of the core kernel (`VdbFrameMlp`: info, then (inputs, outputs, activation, offset) per layer). */\nexport function vdbFrameMlpShape(mlp: VDBFrameMlp): Uint32Array {\n const u = new Uint32Array(4 + 4 * VDB_FRAME_MLP_MAX_LAYERS);\n u[0] = mlp.layers.length;\n u[1] = mlp.levels;\n u[2] = mlp.output === \"exp\" ? 1 : 0;\n u[3] = 3 * mlp.levels + 2 + vdbFrameMlpExtraInputs(mlp);\n const offsets = vdbFrameMlpOffsets(mlp);\n mlp.layers.forEach((l, i) => {\n u[4 + 4 * i] = l.inputs;\n u[5 + 4 * i] = l.outputs;\n u[6 + 4 * i] = l.activation === \"relu\" ? 1 : 0;\n u[7 + 4 * i] = offsets[i]!;\n });\n return u;\n}\n\n/** The forward pass (f64): the last layer's first output through the output transform. */\nexport function vdbFrameMlpForward(mlp: VDBFrameMlp, inputs: ArrayLike<number>): number {\n const offsets = vdbFrameMlpOffsets(mlp);\n const w = mlp.weights;\n let x = Array.from(inputs);\n mlp.layers.forEach((l, li) => {\n const at = offsets[li]!;\n const bias = at + l.outputs * l.inputs;\n const out: number[] = [];\n for (let j = 0; j < l.outputs; j++) {\n let s = w[bias + j]!;\n for (let i = 0; i < l.inputs; i++) s += w[at + j * l.inputs + i]! * (x[i] ?? 0);\n out.push(l.activation === \"relu\" ? Math.max(s, 0) : s);\n }\n x = out;\n });\n return mlp.output === \"exp\" ? Math.exp(Math.min(x[0]!, 4)) : x[0]!;\n}\n\n/**\n * Voxels per side of the core's feature mip chain: mip j has max(1, (R >> 1) >> j), down to one voxel and at most\n * {@link VDB_FRAME_MLP_MAX_MIPS} mips (K6.N had at most 5, levels 1–5; K6.Nb runs on to 1 voxel for 'world' reaches:\n * mips 0–4 and so levels 0–5 are unchanged).\n */\nexport function vdbFrameMlpMipSizes(resolution: number): number[] {\n const base = Math.max(1, resolution >> 1);\n const sizes = [base];\n while (sizes.length < VDB_FRAME_MLP_MAX_MIPS && sizes[sizes.length - 1]! > 1) sizes.push(Math.max(1, sizes[sizes.length - 1]! >> 1));\n return sizes;\n}\n\n/**\n * The `gridMips` kernel (his FrameGridMipMaterial box) at texel `p` of a mip of side `size`: the mean of the 2 × 2 × 2\n * source texels 2p + i (each axis clamped to `sourceSize` − 1) of `source` read at `origin` (.xy: extinction, absorption).\n */\nexport function vdbFrameMlpMipTexel(source: VDBFrameTexture3d, origin: readonly number[], sourceSize: readonly number[], p: Vec3): Vec2 {\n let a = 0;\n let b = 0;\n for (let i = 0; i < 8; i++) {\n const q = [p[0] * 2 + (i & 1), p[1] * 2 + ((i >> 1) & 1), p[2] * 2 + ((i >> 2) & 1)].map((v, k) => Math.min(v, sourceSize[k]! - 1) + origin[k]!);\n const at = (q[0]! + (q[1]! + q[2]! * source.size[1]) * source.size[0]) * source.channels;\n a += source.data[at]!;\n b += source.data[at + 1]!;\n }\n return [a / 8, b / 8];\n}\n\n/**\n * sampleLevel on the core's textures: level 0 the last cascade in the shadow stack (`grid`, its origin), level k ≥ 1\n * mip min(k − 1, mips − 1) (`mips[j]`, its own texture), hardware trilinear clamped to the half-texel box; 0 outside.\n * K7.4d-a `base` 1 (the cubic chain on a non-cubic cascade): level k is mip min(k, mips − 1), the grid is not read.\n */\nexport function vdbFrameMlpSampleLevel(layout: VDBFrameGridLayout, grid: VDBFrameTexture3d, gridOrigin: readonly number[], mips: readonly VDBFrameTexture3d[], level: number, world: Vec3, base: 0 | 1 = 0): Vec2 {\n const cascade = layout.count - 1;\n const uvw = vdbFrameGridUvw(layout, cascade, world);\n if (uvw.some((v) => v < 0 || v > 1)) return [0, 0];\n if (level === 0 && base === 0) {\n const r = layout.resolution;\n const s = vdbFrameTrilinear(grid, uvw.map((v, k) => gridOrigin[k]! + Math.min(Math.max(v * r, 0.5), r - 0.5)));\n return [s[0]!, s[1]!];\n }\n const t = mips[Math.min(level + base - 1, mips.length - 1)]!;\n const s = vdbFrameTrilinear(t, uvw.map((v, k) => Math.min(Math.max(v * t.size[k]!, 0.5), t.size[k]! - 0.5)));\n return [s[0]!, s[1]!];\n}\n\n/**\n * The 3 L + 2 inputs at a world position for a unit direction to the light (his getLocalInputs + neuralLight). `h` is\n * the reach unit; K6.Nb `shift` reads feature level k at mip level max(k + shift, 0) ('world' reaches,\n * {@link vdbFrameMlpReach}; 0: his).\n */\nexport function vdbFrameMlpInputs(sample: (level: number, world: Vec3) => Vec2, levels: number, h: number, world: Vec3, direction: Vec3, opticalDepth: number, shift = 0, extra: readonly number[] = []): number[] {\n const input = new Array<number>(3 * levels + 2 + extra.length).fill(0);\n extra.forEach((v, i) => (input[3 * levels + 2 + i] = v));\n for (let k = 0; k < levels; k++) {\n const reach = h * 2 ** k;\n const level = Math.max(k + shift, 0);\n const s = sample(level, world);\n input[k] = Math.log(s[0] * reach + 1);\n if (k === 1 && s[0] > 0) input[3 * levels + 1] = Math.sqrt(Math.min(1, Math.max(0, s[1] / Math.max(s[0], 1e-20))));\n input[levels + k] = Math.log(sample(level, [world[0] + direction[0] * reach, world[1] + direction[1] * reach, world[2] + direction[2] * reach])[0] * reach + 1);\n input[2 * levels + k] = Math.log(sample(level, [world[0] - direction[0] * reach, world[1] - direction[1] * reach, world[2] - direction[2] * reach])[0] * reach + 1);\n }\n input[3 * levels] = Math.log(opticalDepth + 1);\n return input;\n}\n\n// --- K7.4a: spectral media (the network once per channel) ------------------------------------------------------------\n\n/**\n * K7.4a: the spectral `gridMips` kernel at texel `p` (as {@link vdbFrameMlpMipTexel}): the box mean of channels .xyz\n * (extinction rgb of the extinction stack, or absorption rgb of the absorption stack).\n */\nexport function vdbFrameMlpMipTexelRgb(source: VDBFrameTexture3d, origin: readonly number[], sourceSize: readonly number[], p: Vec3): Vec3 {\n const sum: Vec3 = [0, 0, 0];\n for (let i = 0; i < 8; i++) {\n const q = [p[0] * 2 + (i & 1), p[1] * 2 + ((i >> 1) & 1), p[2] * 2 + ((i >> 2) & 1)].map((v, k) => Math.min(v, sourceSize[k]! - 1) + origin[k]!);\n const at = (q[0]! + (q[1]! + q[2]! * source.size[1]) * source.size[0]) * source.channels;\n for (let c = 0; c < 3; c++) sum[c] = sum[c]! + source.data[at + c]!;\n }\n return [sum[0] / 8, sum[1] / 8, sum[2] / 8];\n}\n\n/** K7.4a: {@link vdbFrameMlpSampleLevel} of channels .xyz (a spectral stack and its mips; K7.4d-a `base`); 0 outside. */\nexport function vdbFrameMlpSampleLevelRgb(layout: VDBFrameGridLayout, grid: VDBFrameTexture3d, gridOrigin: readonly number[], mips: readonly VDBFrameTexture3d[], level: number, world: Vec3, base: 0 | 1 = 0): Vec3 {\n const cascade = layout.count - 1;\n const uvw = vdbFrameGridUvw(layout, cascade, world);\n if (uvw.some((v) => v < 0 || v > 1)) return [0, 0, 0];\n if (level === 0 && base === 0) {\n const r = layout.resolution;\n const s = vdbFrameTrilinear(grid, uvw.map((v, k) => gridOrigin[k]! + Math.min(Math.max(v * r, 0.5), r - 0.5)));\n return [s[0]!, s[1]!, s[2]!];\n }\n const t = mips[Math.min(level + base - 1, mips.length - 1)]!;\n const s = vdbFrameTrilinear(t, uvw.map((v, k) => Math.min(Math.max(v * t.size[k]!, 0.5), t.size[k]! - 0.5)));\n return [s[0]!, s[1]!, s[2]!];\n}\n\n/**\n * K7.4a: the network's scattered light of each channel of a spectral medium (the spectral transmittance kernel's\n * `vdbFrameMlpLight3`): one forward pass per channel c on that channel's inputs ({@link vdbFrameMlpInputs} with\n * extinction c, absorption c and the direct optical depth c). `extinction` / `absorption` sample a feature level of the\n * extinction and absorption stacks (rgb). On a grey medium the three channels are the grey network's value.\n */\nexport function vdbFrameSpectralMlpLight(\n mlp: VDBFrameMlp,\n extinction: (level: number, world: Vec3) => Vec3,\n absorption: (level: number, world: Vec3) => Vec3,\n h: number,\n world: Vec3,\n direction: Vec3,\n opticalDepth: Vec3,\n shift = 0,\n extra: readonly number[] = [],\n): Vec3 {\n const out: Vec3 = [0, 0, 0];\n for (let c = 0; c < 3; c++) {\n const sample = (level: number, p: Vec3): Vec2 => [extinction(level, p)[c]!, absorption(level, p)[c]!];\n out[c] = vdbFrameMlpForward(mlp, vdbFrameMlpInputs(sample, mlp.levels, h, world, direction, opticalDepth[c]!, shift, extra));\n }\n return out;\n}\n\n// --- K6.Na: the packed layout (pmndrs/denoiser `denoiser-wgsl` conv.ts `packWeights` / `packBias`, one tap) -------------\n// Portions derived from pmndrs/denoiser (MIT, Copyright (c) 2024 Dennis Smolek), commit 3ad5e98:\n// packages/denoiser-wgsl/src/conv.ts `packWeights` (mat4x4 per (output group, input chunk, tap), column j = input\n// channel j of the chunk, row i = output channel 4 × group + i; padded channels zero) and `packBias` (vec4 groups).\n// Changes: a dense layer is its 1 × 1 case (one tap, no second source); every layer of the network goes into one\n// `array<vec4f>` (each mat4x4 as its 4 columns, then the layer's bias groups), so the kernel keeps one storage buffer (D10).\n\n/** vec4s of one packed layer: ⌈outputs / 4⌉ × ⌈inputs / 4⌉ mat4x4 (4 vec4 each), then ⌈outputs / 4⌉ bias vec4s. */\nexport function vdbFrameMlpPackedLayerVectors(l: Pick<VDBFrameMlpLayer, \"inputs\" | \"outputs\">): number {\n const out4 = Math.ceil(l.outputs / 4);\n return out4 * Math.ceil(l.inputs / 4) * 4 + out4;\n}\n\n/** The vec4 offset of each packed layer (its matrices; the bias groups follow at offset + 4 ⌈out/4⌉ ⌈in/4⌉). */\nexport function vdbFrameMlpPackedOffsets(mlp: Pick<VDBFrameMlp, \"layers\">): number[] {\n const offsets: number[] = [];\n let at = 0;\n for (const l of mlp.layers) {\n offsets.push(at);\n at += vdbFrameMlpPackedLayerVectors(l);\n }\n return offsets;\n}\n\n/**\n * K6.Na: the weights in the packed layout the core's `mlpRuntime: 'packed'` evaluator reads (`array<vec4f>`): per layer,\n * for each output group o and input chunk k the mat4x4 M[o, k] (column j = input 4k + j, row i = output 4o + i,\n * column-major: element (i, j) at 4j + i), then the biases padded to vec4. Padded inputs and outputs are zero, so a\n * padded output is 0 through ReLU or linear and the next layer's padded inputs read 0.\n */\nexport function vdbFrameMlpPack(mlp: VDBFrameMlp): Float32Array {\n const offsets = vdbFrameMlpOffsets(mlp);\n const packed = vdbFrameMlpPackedOffsets(mlp);\n const last = mlp.layers[mlp.layers.length - 1]!;\n const out = new Float32Array((packed[packed.length - 1]! + vdbFrameMlpPackedLayerVectors(last)) * 4);\n mlp.layers.forEach((l, li) => {\n const w = offsets[li]!;\n const in4 = Math.ceil(l.inputs / 4);\n const out4 = Math.ceil(l.outputs / 4);\n const base = packed[li]! * 4;\n for (let o = 0; o < out4; o++) {\n for (let k = 0; k < in4; k++) {\n const m = base + (o * in4 + k) * 16;\n for (let j = 0; j < 4; j++) {\n const input = 4 * k + j;\n if (input >= l.inputs) continue;\n for (let i = 0; i < 4; i++) {\n const output = 4 * o + i;\n if (output >= l.outputs) continue;\n out[m + 4 * j + i] = mlp.weights[w + output * l.inputs + input]!;\n }\n }\n }\n }\n const bias = base + out4 * in4 * 16;\n for (let j = 0; j < l.outputs; j++) out[bias + j] = mlp.weights[w + l.outputs * l.inputs + j]!;\n });\n return out;\n}\n\n/** The shape uniform of the packed evaluator: as {@link vdbFrameMlpShape}, with each layer's offset in vec4s. */\nexport function vdbFrameMlpPackedShape(mlp: VDBFrameMlp): Uint32Array {\n const u = vdbFrameMlpShape(mlp);\n vdbFrameMlpPackedOffsets(mlp).forEach((offset, i) => {\n u[7 + 4 * i] = offset;\n });\n return u;\n}\n\n/**\n * The packed evaluator's forward pass (f64) on {@link vdbFrameMlpPack} data and the shape: per output group the bias\n * plus M[o, k] · x[k] over the input chunks, then the activation. A check that the packing loses nothing: it equals\n * {@link vdbFrameMlpForward} on the unpacked network (the oracle of both evaluators).\n */\nexport function vdbFrameMlpForwardPacked(packed: ArrayLike<number>, shape: ArrayLike<number>, inputs: ArrayLike<number>): number {\n const count = shape[0]!;\n let x = Array.from({ length: Math.ceil(inputs.length / 4) * 4 }, (_, i) => inputs[i] ?? 0);\n for (let l = 0; l < count; l++) {\n const n = shape[4 + 4 * l]!;\n const m = shape[5 + 4 * l]!;\n const relu = shape[6 + 4 * l] === 1;\n const at = shape[7 + 4 * l]! * 4;\n const in4 = Math.ceil(n / 4);\n const out4 = Math.ceil(m / 4);\n const next = new Array<number>(out4 * 4).fill(0);\n for (let o = 0; o < out4; o++) {\n const bias = at + (out4 * in4 * 4 + o) * 4;\n for (let i = 0; i < 4; i++) {\n let s = packed[bias + i]!;\n for (let k = 0; k < in4; k++) {\n const mat = at + (o * in4 + k) * 16;\n for (let j = 0; j < 4; j++) s += packed[mat + 4 * j + i]! * (x[4 * k + j] ?? 0);\n }\n next[4 * o + i] = relu ? Math.max(s, 0) : s;\n }\n }\n x = next;\n }\n return shape[2] === 1 ? Math.exp(Math.min(x[0]!, 4)) : x[0]!;\n}\n"]}
@@ -0,0 +1,42 @@
1
+ /**
2
+ * K7.4c (internal `msExit`, DIVERGES V229): the exit of the scattered light of a scene light. His frame renderer adds the
3
+ * scattered part of a light (total − direct, from any multiple-scattering mode: diffusion, 'two-sided', the network,
4
+ * 'multi-scale') with an isotropic phase. With a forward-peaked phase (Henyey-Greenstein g 0.8) the scattered light near
5
+ * the lit side still travels away from the light, so a view into the back lobe sees too much of it (K7.4 §1.1: +168 % /
6
+ * +194 % on the absorbing and thin bunnies).
7
+ *
8
+ * The model (small-angle transport, Poisson scattering orders): light that reached optical depth τ toward the light has
9
+ * been scattered n ~ Poisson(α τ) times (α the albedo), and the n-th order's mean cosine about the light's travel is ḡⁿ
10
+ * (ḡ the phase's mean cosine; Legendre coefficients multiply under convolution). The scattered light's first moment
11
+ * (flux along the light) is then F = Σ_{n≥1} P(n) ḡⁿ e^{−(1−α)τ} = D^{1 − α ḡ} − D with D = e^{−τ} the direct
12
+ * transmittance. Divided by the scattered total S of the mode it is the scattered radiance's mean cosine μ = F / S,
13
+ * clamped between 0 and ḡ (the first order's; a thick medium's diffuse reservoir makes S ≫ F and μ → 0, isotropic).
14
+ * The exit then weights the scattered light by its phase-weighted angular distribution, relative to isotropic:
15
+ * - `'dipole'`: the K6.Q1c dipole form per lobe, mix_i max(1 + 3 g_i μ cos θ, 0) (the radiance's first Legendre moment);
16
+ * - `'hg'`: the radiance as an HG lobe of mean cosine μ, convolved with each lobe: mix_i HG(g_i μ, cos θ) (exact for HG
17
+ * under convolution; averages to 1 over the sphere, so it moves no energy on average).
18
+ * `'isotropic'` (default) is his: factor 1. cos θ is the direct term's (view ray · direction to the light).
19
+ * K7.4a-2 `'hg-chroma'`: the `'hg'` factor of each channel divided by the green channel's: only the chromatic part of the
20
+ * exit (a medium whose g differs per channel, `phaseGExponent`, otherwise overshoots most in its most forward-scattering
21
+ * channel); the green channel, and every channel of a grey medium, exit as `'isotropic'`.
22
+ */
23
+ import { type Vec3, type Vec4 } from "./index.js";
24
+ /** The exit of the scattered light: his isotropic exit, the dipole form or the HG form (module doc). */
25
+ export type VDBFrameMsExit = "isotropic" | "dipole" | "hg" | "hg-chroma";
26
+ /** The uniform code of an exit mode (0 isotropic, 1 dipole, 2 hg, 3 hg-chroma). */
27
+ export declare function vdbFrameMsExitCode(mode: VDBFrameMsExit | undefined): number;
28
+ /** K7.4a-2: whether the grey slots apply an exit code (`'hg-chroma'`'s green factor is 1: the grey gathers skip it). */
29
+ export declare function vdbFrameMsExitGrey(mode: number): boolean;
30
+ /**
31
+ * The scattered radiance's mean cosine along the light's travel: (D^{1 − α ḡ} − D) / S clamped between 0 and ḡ; 0 when
32
+ * the scattered total S ≤ 1e-6 or D ≤ 0. `direct` D, `scattered` S, `albedo` α (clamped to [0, 1]), `g` ḡ.
33
+ */
34
+ export declare function vdbFrameMsExitMean(direct: number, scattered: number, albedo: number, g: number): number;
35
+ /**
36
+ * The factor of each channel on the scattered light (module doc). `mode` the uniform code (0: [1, 1, 1]); `phase`,
37
+ * `phaseSpectrum` the renderer's or volume's packing (each lobe's g of each channel as `vdbFramePhaseLobes`);
38
+ * `cosTheta` view ray · direction to the light; `direct`, `scattered`, `albedo` of each channel.
39
+ */
40
+ export declare function vdbFrameMsExitFactor(mode: number, phase: Vec4, phaseSpectrum: Vec3, cosTheta: number, direct: Vec3, scattered: Vec3, albedo: Vec3): Vec3;
41
+ /** The grey slots' factor: the green channel's, with the albedo's Rec. 709 luminance (the shadow absorption's). */
42
+ export declare function vdbFrameMsExitFactorGrey(mode: number, phase: Vec4, phaseSpectrum: Vec3, cosTheta: number, direct: number, scattered: number, albedo: Vec3): number;
@@ -0,0 +1,90 @@
1
+ /**
2
+ * K7.4c (internal `msExit`, DIVERGES V229): the exit of the scattered light of a scene light. His frame renderer adds the
3
+ * scattered part of a light (total − direct, from any multiple-scattering mode: diffusion, 'two-sided', the network,
4
+ * 'multi-scale') with an isotropic phase. With a forward-peaked phase (Henyey-Greenstein g 0.8) the scattered light near
5
+ * the lit side still travels away from the light, so a view into the back lobe sees too much of it (K7.4 §1.1: +168 % /
6
+ * +194 % on the absorbing and thin bunnies).
7
+ *
8
+ * The model (small-angle transport, Poisson scattering orders): light that reached optical depth τ toward the light has
9
+ * been scattered n ~ Poisson(α τ) times (α the albedo), and the n-th order's mean cosine about the light's travel is ḡⁿ
10
+ * (ḡ the phase's mean cosine; Legendre coefficients multiply under convolution). The scattered light's first moment
11
+ * (flux along the light) is then F = Σ_{n≥1} P(n) ḡⁿ e^{−(1−α)τ} = D^{1 − α ḡ} − D with D = e^{−τ} the direct
12
+ * transmittance. Divided by the scattered total S of the mode it is the scattered radiance's mean cosine μ = F / S,
13
+ * clamped between 0 and ḡ (the first order's; a thick medium's diffuse reservoir makes S ≫ F and μ → 0, isotropic).
14
+ * The exit then weights the scattered light by its phase-weighted angular distribution, relative to isotropic:
15
+ * - `'dipole'`: the K6.Q1c dipole form per lobe, mix_i max(1 + 3 g_i μ cos θ, 0) (the radiance's first Legendre moment);
16
+ * - `'hg'`: the radiance as an HG lobe of mean cosine μ, convolved with each lobe: mix_i HG(g_i μ, cos θ) (exact for HG
17
+ * under convolution; averages to 1 over the sphere, so it moves no energy on average).
18
+ * `'isotropic'` (default) is his: factor 1. cos θ is the direct term's (view ray · direction to the light).
19
+ * K7.4a-2 `'hg-chroma'`: the `'hg'` factor of each channel divided by the green channel's: only the chromatic part of the
20
+ * exit (a medium whose g differs per channel, `phaseGExponent`, otherwise overshoots most in its most forward-scattering
21
+ * channel); the green channel, and every channel of a grey medium, exit as `'isotropic'`.
22
+ */
23
+ import { vdbFrameHenyeyGreenstein } from "./index.js";
24
+ import { vdbFrameMieAsymmetry, vdbFrameMieRgbMode } from "./mie.js";
25
+ /** The uniform code of an exit mode (0 isotropic, 1 dipole, 2 hg, 3 hg-chroma). */
26
+ export function vdbFrameMsExitCode(mode) {
27
+ return mode === "dipole" ? 1 : mode === "hg" ? 2 : mode === "hg-chroma" ? 3 : 0;
28
+ }
29
+ /** K7.4a-2: whether the grey slots apply an exit code (`'hg-chroma'`'s green factor is 1: the grey gathers skip it). */
30
+ export function vdbFrameMsExitGrey(mode) {
31
+ return mode > 0.5 && mode < 2.5;
32
+ }
33
+ /**
34
+ * The scattered radiance's mean cosine along the light's travel: (D^{1 − α ḡ} − D) / S clamped between 0 and ḡ; 0 when
35
+ * the scattered total S ≤ 1e-6 or D ≤ 0. `direct` D, `scattered` S, `albedo` α (clamped to [0, 1]), `g` ḡ.
36
+ */
37
+ export function vdbFrameMsExitMean(direct, scattered, albedo, g) {
38
+ if (!(scattered > 1e-6) || !(direct > 0))
39
+ return 0;
40
+ const a = Math.min(1, Math.max(0, albedo));
41
+ const flux = Math.exp(Math.log(direct) * (1 - a * g)) - direct;
42
+ return Math.min(Math.max(flux / scattered, Math.min(g, 0)), Math.max(g, 0));
43
+ }
44
+ /** Each lobe's g of each channel (as `vdbFramePhaseLobes`, tools/frame/ambient.ts; not imported: grid.ts imports this file). */
45
+ function msExitLobes(phase, phaseSpectrum) {
46
+ const mieG = [vdbFrameMieAsymmetry, vdbFrameMieAsymmetry, vdbFrameMieAsymmetry];
47
+ if (phase[3] > vdbFrameMieRgbMode - 0.5)
48
+ return [mieG, mieG];
49
+ const scale = phaseSpectrum[2] > 0.5 ? [phaseSpectrum[0], 1, phaseSpectrum[1]] : [1, 1, 1];
50
+ const clampG = (g) => Math.min(0.99, Math.max(-0.99, g));
51
+ const mie = Math.min(phase[3], 1);
52
+ const lobe = (g) => scale.map((s) => clampG(s * g) + (vdbFrameMieAsymmetry - clampG(s * g)) * mie);
53
+ return [lobe(phase[0]), lobe(phase[1])];
54
+ }
55
+ /**
56
+ * The factor of each channel on the scattered light (module doc). `mode` the uniform code (0: [1, 1, 1]); `phase`,
57
+ * `phaseSpectrum` the renderer's or volume's packing (each lobe's g of each channel as `vdbFramePhaseLobes`);
58
+ * `cosTheta` view ray · direction to the light; `direct`, `scattered`, `albedo` of each channel.
59
+ */
60
+ export function vdbFrameMsExitFactor(mode, phase, phaseSpectrum, cosTheta, direct, scattered, albedo) {
61
+ if (mode < 0.5)
62
+ return [1, 1, 1];
63
+ const [g0, g1] = msExitLobes(phase, phaseSpectrum);
64
+ const w = phase[2];
65
+ const factor = [0, 1, 2].map((c) => {
66
+ const gMean = g0[c] + (g1[c] - g0[c]) * w;
67
+ const m = vdbFrameMsExitMean(direct[c], scattered[c], albedo[c], gMean);
68
+ if (mode < 1.5) {
69
+ const k = 3 * m * cosTheta;
70
+ const a = Math.max(1 + g0[c] * k, 0);
71
+ const b = Math.max(1 + g1[c] * k, 0);
72
+ return a + (b - a) * w;
73
+ }
74
+ const a = vdbFrameHenyeyGreenstein(cosTheta, g0[c] * m);
75
+ const b = vdbFrameHenyeyGreenstein(cosTheta, g1[c] * m);
76
+ return a + (b - a) * w;
77
+ });
78
+ // K7.4a-2 'hg-chroma': the chromatic part only
79
+ if (mode > 2.5) {
80
+ const green = Math.max(factor[1], 1e-6);
81
+ return [factor[0] / green, factor[1] / green, factor[2] / green];
82
+ }
83
+ return factor;
84
+ }
85
+ /** The grey slots' factor: the green channel's, with the albedo's Rec. 709 luminance (the shadow absorption's). */
86
+ export function vdbFrameMsExitFactorGrey(mode, phase, phaseSpectrum, cosTheta, direct, scattered, albedo) {
87
+ const lum = Math.min(1, Math.max(0, albedo[0] * 0.2126 + albedo[1] * 0.7152 + albedo[2] * 0.0722));
88
+ return vdbFrameMsExitFactor(mode, phase, phaseSpectrum, cosTheta, [direct, direct, direct], [scattered, scattered, scattered], [lum, lum, lum])[1];
89
+ }
90
+ //# sourceMappingURL=ms-exit.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ms-exit.js","sourceRoot":"","sources":["../../../src/tools/frame/ms-exit.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAEH,OAAO,EAAE,wBAAwB,EAAwB,MAAM,YAAY,CAAC;AAC5E,OAAO,EAAE,oBAAoB,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAC;AAKpE,mFAAmF;AACnF,MAAM,UAAU,kBAAkB,CAAC,IAAgC;IAC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AAI,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC;QACxC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,GAAG,KAAK,EAAE,MAAM,CAAC,CAAC,CAAC,GAAG,KAAK,EAAE,MAAM,CAAC,CAAC,CAAC,GAAG,KAAK,CAAC,CAAC;IACnE,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC;AAED,mHAAmH;AACnH,MAAM,UAAU,wBAAwB,CAAC,IAAY,EAAE,KAAW,EAAE,aAAmB,EAAE,QAAgB,EAAE,MAAc,EAAE,SAAiB,EAAE,MAAY;IACxJ,MAAM,GAAG,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC,CAAC,GAAG,MAAM,GAAG,MAAM,CAAC,CAAC,CAAC,GAAG,MAAM,GAAG,MAAM,CAAC,CAAC,CAAC,GAAG,MAAM,CAAC,CAAC,CAAC;IACnG,OAAO,oBAAoB,CAAC,IAAI,EAAE,KAAK,EAAE,aAAa,EAAE,QAAQ,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,CAAC,SAAS,EAAE,SAAS,EAAE,SAAS,CAAC,EAAE,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AACrJ,CAAC","sourcesContent":["/**\n * K7.4c (internal `msExit`, DIVERGES V229): the exit of the scattered light of a scene light. His frame renderer adds the\n * scattered part of a light (total − direct, from any multiple-scattering mode: diffusion, 'two-sided', the network,\n * 'multi-scale') with an isotropic phase. With a forward-peaked phase (Henyey-Greenstein g 0.8) the scattered light near\n * the lit side still travels away from the light, so a view into the back lobe sees too much of it (K7.4 §1.1: +168 % /\n * +194 % on the absorbing and thin bunnies).\n *\n * The model (small-angle transport, Poisson scattering orders): light that reached optical depth τ toward the light has\n * been scattered n ~ Poisson(α τ) times (α the albedo), and the n-th order's mean cosine about the light's travel is ḡⁿ\n * (ḡ the phase's mean cosine; Legendre coefficients multiply under convolution). The scattered light's first moment\n * (flux along the light) is then F = Σ_{n≥1} P(n) ḡⁿ e^{−(1−α)τ} = D^{1 − α ḡ} − D with D = e^{−τ} the direct\n * transmittance. Divided by the scattered total S of the mode it is the scattered radiance's mean cosine μ = F / S,\n * clamped between 0 and ḡ (the first order's; a thick medium's diffuse reservoir makes S ≫ F and μ → 0, isotropic).\n * The exit then weights the scattered light by its phase-weighted angular distribution, relative to isotropic:\n * - `'dipole'`: the K6.Q1c dipole form per lobe, mix_i max(1 + 3 g_i μ cos θ, 0) (the radiance's first Legendre moment);\n * - `'hg'`: the radiance as an HG lobe of mean cosine μ, convolved with each lobe: mix_i HG(g_i μ, cos θ) (exact for HG\n * under convolution; averages to 1 over the sphere, so it moves no energy on average).\n * `'isotropic'` (default) is his: factor 1. cos θ is the direct term's (view ray · direction to the light).\n * K7.4a-2 `'hg-chroma'`: the `'hg'` factor of each channel divided by the green channel's: only the chromatic part of the\n * exit (a medium whose g differs per channel, `phaseGExponent`, otherwise overshoots most in its most forward-scattering\n * channel); the green channel, and every channel of a grey medium, exit as `'isotropic'`.\n */\n\nimport { vdbFrameHenyeyGreenstein, type Vec3, type Vec4 } from \"./index.js\";\nimport { vdbFrameMieAsymmetry, vdbFrameMieRgbMode } from \"./mie.js\";\n\n/** The exit of the scattered light: his isotropic exit, the dipole form or the HG form (module doc). */\nexport type VDBFrameMsExit = \"isotropic\" | \"dipole\" | \"hg\" | \"hg-chroma\";\n\n/** The uniform code of an exit mode (0 isotropic, 1 dipole, 2 hg, 3 hg-chroma). */\nexport function vdbFrameMsExitCode(mode: VDBFrameMsExit | undefined): number {\n return mode === \"dipole\" ? 1 : mode === \"hg\" ? 2 : mode === \"hg-chroma\" ? 3 : 0;\n}\n\n/** K7.4a-2: whether the grey slots apply an exit code (`'hg-chroma'`'s green factor is 1: the grey gathers skip it). */\nexport function vdbFrameMsExitGrey(mode: number): boolean {\n return mode > 0.5 && mode < 2.5;\n}\n\n/**\n * The scattered radiance's mean cosine along the light's travel: (D^{1 − α ḡ} − D) / S clamped between 0 and ḡ; 0 when\n * the scattered total S ≤ 1e-6 or D ≤ 0. `direct` D, `scattered` S, `albedo` α (clamped to [0, 1]), `g` ḡ.\n */\nexport function vdbFrameMsExitMean(direct: number, scattered: number, albedo: number, g: number): number {\n if (!(scattered > 1e-6) || !(direct > 0)) return 0;\n const a = Math.min(1, Math.max(0, albedo));\n const flux = Math.exp(Math.log(direct) * (1 - a * g)) - direct;\n return Math.min(Math.max(flux / scattered, Math.min(g, 0)), Math.max(g, 0));\n}\n\n/** Each lobe's g of each channel (as `vdbFramePhaseLobes`, tools/frame/ambient.ts; not imported: grid.ts imports this file). */\nfunction msExitLobes(phase: Vec4, phaseSpectrum: Vec3): [Vec3, Vec3] {\n const mieG: Vec3 = [vdbFrameMieAsymmetry, vdbFrameMieAsymmetry, vdbFrameMieAsymmetry];\n if (phase[3] > vdbFrameMieRgbMode - 0.5) return [mieG, mieG];\n const scale: Vec3 = phaseSpectrum[2] > 0.5 ? [phaseSpectrum[0], 1, phaseSpectrum[1]] : [1, 1, 1];\n const clampG = (g: number) => Math.min(0.99, Math.max(-0.99, g));\n const mie = Math.min(phase[3], 1);\n const lobe = (g: number) => scale.map((s) => clampG(s * g) + (vdbFrameMieAsymmetry - clampG(s * g)) * mie) as Vec3;\n return [lobe(phase[0]), lobe(phase[1])];\n}\n\n/**\n * The factor of each channel on the scattered light (module doc). `mode` the uniform code (0: [1, 1, 1]); `phase`,\n * `phaseSpectrum` the renderer's or volume's packing (each lobe's g of each channel as `vdbFramePhaseLobes`);\n * `cosTheta` view ray · direction to the light; `direct`, `scattered`, `albedo` of each channel.\n */\nexport function vdbFrameMsExitFactor(mode: number, phase: Vec4, phaseSpectrum: Vec3, cosTheta: number, direct: Vec3, scattered: Vec3, albedo: Vec3): Vec3 {\n if (mode < 0.5) return [1, 1, 1];\n const [g0, g1] = msExitLobes(phase, phaseSpectrum);\n const w = phase[2];\n const factor = [0, 1, 2].map((c) => {\n const gMean = g0[c]! + (g1[c]! - g0[c]!) * w;\n const m = vdbFrameMsExitMean(direct[c]!, scattered[c]!, albedo[c]!, gMean);\n if (mode < 1.5) {\n const k = 3 * m * cosTheta;\n const a = Math.max(1 + g0[c]! * k, 0);\n const b = Math.max(1 + g1[c]! * k, 0);\n return a + (b - a) * w;\n }\n const a = vdbFrameHenyeyGreenstein(cosTheta, g0[c]! * m);\n const b = vdbFrameHenyeyGreenstein(cosTheta, g1[c]! * m);\n return a + (b - a) * w;\n }) as Vec3;\n // K7.4a-2 'hg-chroma': the chromatic part only\n if (mode > 2.5) {\n const green = Math.max(factor[1], 1e-6);\n return [factor[0] / green, factor[1] / green, factor[2] / green];\n }\n return factor;\n}\n\n/** The grey slots' factor: the green channel's, with the albedo's Rec. 709 luminance (the shadow absorption's). */\nexport function vdbFrameMsExitFactorGrey(mode: number, phase: Vec4, phaseSpectrum: Vec3, cosTheta: number, direct: number, scattered: number, albedo: Vec3): number {\n const lum = Math.min(1, Math.max(0, albedo[0] * 0.2126 + albedo[1] * 0.7152 + albedo[2] * 0.0722));\n return vdbFrameMsExitFactor(mode, phase, phaseSpectrum, cosTheta, [direct, direct, direct], [scattered, scattered, scattered], [lum, lum, lum])[1];\n}\n"]}
@@ -0,0 +1,152 @@
1
+ import type { Vec2, Vec3 } from "./index.js";
2
+ /** Most levels (base included) the layout takes: level 7 is 128 voxels. */
3
+ export declare const VDB_FRAME_MULTI_SCALE_MAX_LEVELS = 8;
4
+ /** His default `multiScaleLevels` (base included). */
5
+ export declare const VDB_FRAME_MULTI_SCALE_DEFAULT_LEVELS = 6;
6
+ /** Edge rule of the mip build: zero outside the grid (default), or his clamp-to-edge. */
7
+ export type VDBFrameMultiScaleEdge = "zero" | "clamp";
8
+ /**
9
+ * K6.3a: the blur of each lookup level (V75 item 5). `'his'` (default): level k reads mip k, the binomial chain's
10
+ * σ ≈ 2^(k−1) voxels (σ_k² = (4^k − 1) / 4; his 4e2d46f). `'paper'`: level k reads mip k + 1, σ ≈ 2^k voxels, the
11
+ * Gaussian width of Disney "Deep Scattering" §4.2 (its stencil spacing at level k is 2^k voxels); the chain holds one
12
+ * more mip (at most {@link VDB_FRAME_MULTI_SCALE_MAX_LEVELS} levels: past it the last level reads the last mip).
13
+ */
14
+ export type VDBFrameMultiScaleSigma = "his" | "paper";
15
+ /** The mip a lookup level reads past its own index (0 for `'his'`, 1 for `'paper'`). */
16
+ export declare function vdbFrameMultiScaleLevelOffset(sigma: VDBFrameMultiScaleSigma | undefined): number;
17
+ /** One mip level (1 to levels − 1). */
18
+ export interface VDBFrameMultiScaleMipLevel {
19
+ /** The level k (1 = first mip). */
20
+ level: number;
21
+ /** Texels per axis of the level (exactly halving; mip level k − 1 of the mip texture). */
22
+ dimensions: Vec3;
23
+ /** Texels that cover the base (⌈size / 2^k⌉); the rest is padding. */
24
+ extent: Vec3;
25
+ }
26
+ /** The sizes of the mip chain of a base grid. */
27
+ export interface VDBFrameMultiScaleLayout {
28
+ /** Base texels per axis (the grid region the levels filter). */
29
+ size: Vec3;
30
+ /** Levels including the base (2 to {@link VDB_FRAME_MULTI_SCALE_MAX_LEVELS}). */
31
+ levels: number;
32
+ /** Levels 1 to levels − 1. */
33
+ mips: VDBFrameMultiScaleMipLevel[];
34
+ }
35
+ /**
36
+ * The mip chain sizes of a base grid of `size` texels: D_k = ⌈size / 2^(levels−1)⌉ · 2^(levels−1−k) per axis,
37
+ * extent ⌈size / 2^k⌉.
38
+ *
39
+ * @param size Base texels per axis (positive integers).
40
+ * @param levels Levels including the base (default 6, his `multiScaleLevels`).
41
+ */
42
+ export declare function vdbFrameMultiScaleLayout(size: readonly number[], levels?: number): VDBFrameMultiScaleLayout;
43
+ /** A grid on the CPU in texture order: x fastest, then y, then z; `channels` components per texel, interleaved. */
44
+ export interface VDBFrameTexture3D {
45
+ data: ArrayLike<number>;
46
+ dimensions: Vec3;
47
+ channels: number;
48
+ }
49
+ /** Options of {@link vdbFrameMultiScaleMips}. */
50
+ export interface VDBFrameMultiScaleMipOptions {
51
+ /** Levels including the base (default 6). */
52
+ levels?: number;
53
+ /** Base texels per axis to filter (default: the source's dimensions minus `origin`). */
54
+ size?: Vec3;
55
+ /** First texel of the region in the source (default 0, 0, 0): one cascade of a stacked grid. */
56
+ origin?: Vec3;
57
+ /** Source components that become the level channels, in order (default [0, 1]: extinction, absorption). */
58
+ channels?: readonly number[];
59
+ /** Edge rule (default `'zero'`). */
60
+ edge?: VDBFrameMultiScaleEdge;
61
+ }
62
+ /** The f64 mip chain: `levels[k − 1]` is level k (`dimensions` texels × `channels`, interleaved). */
63
+ export interface VDBFrameMultiScaleMips {
64
+ layout: VDBFrameMultiScaleLayout;
65
+ channels: number;
66
+ levels: Float64Array[];
67
+ }
68
+ /**
69
+ * The binomial mip chain of a base grid (CPU twin of the core `csMsLevel` kernel): level 1 from the source region,
70
+ * 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.
71
+ *
72
+ * @param source The base grid (texture order).
73
+ * @param options Levels, region, channels and edge rule.
74
+ */
75
+ export declare function vdbFrameMultiScaleMips(source: VDBFrameTexture3D, options?: VDBFrameMultiScaleMipOptions): VDBFrameMultiScaleMips;
76
+ /**
77
+ * The f16 texels of a level as the GPU writes them (twin of `csMsPack`): `texelChannels` components per texel
78
+ * (1, 2 or 4: r16float, rg16float, rgba16float), the level's `channels` first and 0 after, each f32-rounded then
79
+ * rounded to the nearest half, ties to even (`vdbFloatToHalf`).
80
+ */
81
+ export declare function vdbFrameMultiScaleToHalf(level: ArrayLike<number>, channels: number, texelChannels: number): Uint16Array;
82
+ /**
83
+ * The GPU's linear filter with clamp-to-edge at a texel-space coordinate (texel centres at i + ½): the trilinear
84
+ * blend of the 8 texels around it, f64 weights (SwiftShader filters in full precision; hardware may quantize the
85
+ * weights to 8 bits). Writes `out` (one entry per channel) and returns it.
86
+ */
87
+ export declare function vdbFrameTexture3DLinear(t: VDBFrameTexture3D, coord: Vec3, out?: number[]): number[];
88
+ /** The lookup's grid: the WGSL `VdbFrameMultiScale` struct (core `vdbFrameMultiScaleParams`). */
89
+ export interface VDBFrameMultiScaleGrid {
90
+ /** World box of the base region: `boxMin` to `boxMin + boxSize` (his last cascade: gridMin, gridSize). */
91
+ boxMin: Vec3;
92
+ boxSize: Vec3;
93
+ /** h: the largest voxel side of the grid, world units (his `unit`). */
94
+ unit: number;
95
+ /** Levels read, base included (his `multiScaleLevels`; at most the chain's levels). */
96
+ levels: number;
97
+ /** 1 − g of the phase function (his `frameMultipleScattering`); 0 is single scattering (no scattered light). */
98
+ multipleScattering: number;
99
+ /**
100
+ * K6.3a: level k reads mip level min(k + levelOffset, mipLevels) (default 0; 1 is `multiScaleSigma: 'paper'`,
101
+ * {@link vdbFrameMultiScaleLevelOffset}).
102
+ */
103
+ levelOffset?: number;
104
+ /** K6.3a: the chain's mip count (levels − 1 of its layout): the highest level a lookup reads (default: no clamp). */
105
+ mipLevels?: number;
106
+ }
107
+ /** The textures the lookup reads: the base region and the mip levels. */
108
+ export interface VDBFrameMultiScaleTextures {
109
+ /** The host's grid texture (level 0). */
110
+ base: VDBFrameTexture3D;
111
+ /** First texel of the base region in `base` (default 0, 0, 0). */
112
+ baseOrigin?: Vec3;
113
+ /** Base region texels per axis (the layout's `size`). */
114
+ baseSize: Vec3;
115
+ /** Base components of extinction and absorption (default [0, 1]; one entry: no absorption). */
116
+ baseChannels?: readonly number[];
117
+ /** Levels 1 to levels − 1 (channel 0 extinction, channel 1 absorption when present). */
118
+ mips: readonly VDBFrameTexture3D[];
119
+ }
120
+ /**
121
+ * (extinction, absorption) of `level` at a world position (WGSL `vdbFrameMultiScaleSample`, his `sampleLevel`):
122
+ * 0 outside the box; level 0 is the base region with its edges clamped (no bleed into a neighbouring cascade);
123
+ * level k is the mip at base texel coordinate / 2^k, clamp-to-edge.
124
+ */
125
+ export declare function vdbFrameMultiScaleSample(textures: VDBFrameMultiScaleTextures, grid: Pick<VDBFrameMultiScaleGrid, "boxMin" | "boxSize">, level: number, world: Vec3): Vec2;
126
+ /**
127
+ * The scattered light (total − direct) of a light slot at a world position (WGSL `vdbFrameMultiScaleLight`, his
128
+ * `frameMultiScaleLight`). `direction` is the unit direction to the light, `maxDistance` the distance to it
129
+ * (1e20 for a directional light). The consumer adds it to the direct transmittance of its shadow march and
130
+ * clamps the total to 1 (his transmittance pass).
131
+ *
132
+ * @param sampleLevel (extinction, absorption) of level k at a world position ({@link vdbFrameMultiScaleSample}).
133
+ */
134
+ export declare function vdbFrameMultiScaleLight(sampleLevel: (level: number, world: Vec3) => Vec2, grid: Pick<VDBFrameMultiScaleGrid, "unit" | "levels" | "multipleScattering" | "levelOffset" | "mipLevels">, world: Vec3, direction: Vec3, maxDistance: number): number;
135
+ /**
136
+ * K7.4a-3: channels 0–2 of `level` at a world position (one texture of WGSL `vdbFrameMultiScaleSample3`): the same
137
+ * addressing as {@link vdbFrameMultiScaleSample}, the base region's components 0–2 at level 0 and the mip's 0–2 above
138
+ * (spectral chains are made with `channels: [0, 1, 2]`). `baseChannels` is ignored.
139
+ */
140
+ export declare function vdbFrameMultiScaleSampleRgb(textures: VDBFrameMultiScaleTextures, grid: Pick<VDBFrameMultiScaleGrid, "boxMin" | "boxSize">, level: number, world: Vec3): Vec3;
141
+ /**
142
+ * K7.4a-3: the scattered light (total − direct) of each colour channel (WGSL `vdbFrameMultiScaleLight3`): channel c is
143
+ * {@link vdbFrameMultiScaleLight} on channel c's (extinction, absorption) levels, with the one `multipleScattering`
144
+ * (1 − g) of the spectral march. A grey medium gives the grey lookup in every channel.
145
+ *
146
+ * @param sampleLevel Extinction rgb and absorption rgb of level k at a world position (e.g. two
147
+ * {@link vdbFrameMultiScaleSampleRgb}, one per stack and chain).
148
+ */
149
+ export declare function vdbFrameSpectralMultiScaleLight(sampleLevel: (level: number, world: Vec3) => {
150
+ extinction: Vec3;
151
+ absorption: Vec3;
152
+ }, grid: Pick<VDBFrameMultiScaleGrid, "unit" | "levels" | "multipleScattering" | "levelOffset" | "mipLevels">, world: Vec3, direction: Vec3, maxDistance: number): Vec3;