@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,100 @@
1
+ /**
2
+ * Resources of the core frame renderer (K6.1, design §4.1–§4.2): the retire queue and the froxel texture
3
+ * allocation. The renderer owns every texture and buffer it makes; a replaced one is retired and destroyed
4
+ * two updates later, in a later task (K6.10a, see {@link VDBRetireQueue}). `dispose()` drains the queue.
5
+ */
6
+ /**
7
+ * Destroys retired objects two updates after they were retired, and never in the task that made them due (K6.10a).
8
+ *
9
+ * WebGPU accepts `destroy()` on an object that a SUBMITTED command buffer uses (the free waits for the GPU), but a
10
+ * submit that names an object destroyed before it fails. The queue cannot see the host's submit, so it waits for two
11
+ * things, either of which makes the destroy safe:
12
+ * - two updates (the K6.1 contract: one update per submit, so the encoders that used the object were submitted), and
13
+ * - a task boundary after the update that made it due (`setTimeout(0)`): a host that records several updates (or
14
+ * pass records) into one encoder and submits it in the same task has submitted it by then.
15
+ *
16
+ * Before K6.10a the destroy ran inside the update, so three updates recorded into one encoder before one submit
17
+ * destroyed a texture the first update's passes still used. The remaining unsafe pattern is three or more updates
18
+ * recorded without a submit AND across tasks (an `await` between record and submit); the renderer's docs say to submit
19
+ * each update's encoder in the task that recorded it.
20
+ */
21
+ export class VDBRetireQueue {
22
+ #items = [];
23
+ /** Due objects whose destroy waits for the next task (removed when destroyed, by the timer or by `drain`). */
24
+ #scheduled = new Set();
25
+ #tick = 0;
26
+ /** Objects waiting to be destroyed (retired, or due and waiting for the next task). */
27
+ get pending() {
28
+ return this.#items.length + this.#scheduled.size;
29
+ }
30
+ /** Keeps `object` until two more {@link advance} calls, then destroys it in a later task. */
31
+ retire(object) {
32
+ if (object)
33
+ this.#items.push({ tick: this.#tick, object });
34
+ }
35
+ /**
36
+ * Destroys `object` in a later task, without waiting for updates: for an owner that has no update of its own (a
37
+ * source replaced between the host's record and submit, K6.10a). Safe when the host submits in the task that
38
+ * recorded; the owner's users rebind at their next update.
39
+ */
40
+ retireAfterTask(object) {
41
+ if (object)
42
+ this.#schedule([object]);
43
+ }
44
+ /** One update: what was retired two or more updates ago is destroyed in a later task. */
45
+ advance() {
46
+ this.#tick++;
47
+ const keep = [];
48
+ const due = [];
49
+ for (const item of this.#items) {
50
+ if (this.#tick - item.tick >= 2)
51
+ due.push(item.object);
52
+ else
53
+ keep.push(item);
54
+ }
55
+ this.#items = keep;
56
+ if (due.length > 0)
57
+ this.#schedule(due);
58
+ }
59
+ #schedule(objects) {
60
+ for (const o of objects)
61
+ this.#scheduled.add(o);
62
+ setTimeout(() => {
63
+ for (const o of objects)
64
+ if (this.#scheduled.delete(o))
65
+ o.destroy();
66
+ }, 0);
67
+ }
68
+ /** Destroys everything now (`dispose()`: the host has no more work naming these objects). */
69
+ drain() {
70
+ for (const item of this.#items)
71
+ item.object.destroy();
72
+ this.#items = [];
73
+ for (const o of this.#scheduled)
74
+ o.destroy();
75
+ this.#scheduled.clear();
76
+ }
77
+ }
78
+ /**
79
+ * K7.16 (his VDB-168 `spectralReleaseRenders`): updates in a row that need less (fewer spectral slot groups, one source
80
+ * group; K7.16a no froxel work at all) before the frame renderer frees what the scene no longer uses. Settings-driven
81
+ * releases (temporal off, 'volume' lighting) happen at the next update.
82
+ */
83
+ export const VDB_FRAME_RELEASE_UPDATES = 120;
84
+ /** `GPUTextureUsage` values, restated (the globals do not exist in Node). */
85
+ export const TEXTURE_USAGE = { COPY_SRC: 0x01, COPY_DST: 0x02, TEXTURE_BINDING: 0x04, STORAGE_BINDING: 0x08, RENDER_ATTACHMENT: 0x10 };
86
+ /** `GPUBufferUsage` values. */
87
+ export const BUFFER_USAGE = { MAP_READ: 0x1, COPY_SRC: 0x4, COPY_DST: 0x8, UNIFORM: 0x40, STORAGE: 0x80 };
88
+ /** `GPUShaderStage` values. */
89
+ export const STAGE = { VERTEX: 0x1, FRAGMENT: 0x2, COMPUTE: 0x4 };
90
+ /** A froxel-sized 3D storage texture (write by compute, read by sampling or `textureLoad`, copy for readbacks). */
91
+ export function createFroxelTexture(device, label, size, format, sampled = true) {
92
+ return device.createTexture({
93
+ label,
94
+ size: [size[0], size[1], size[2]],
95
+ dimension: "3d",
96
+ format,
97
+ usage: TEXTURE_USAGE.STORAGE_BINDING | TEXTURE_USAGE.COPY_SRC | (sampled ? TEXTURE_USAGE.TEXTURE_BINDING : 0),
98
+ });
99
+ }
100
+ //# sourceMappingURL=resources.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"resources.js","sourceRoot":"","sources":["../../../src/core/frame/resources.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAOH;;;;;;;;;;;;;;GAcG;AACH,MAAM,OAAO,cAAc;IACzB,MAAM,GAA+C,EAAE,CAAC;IACxD,8GAA8G;IACrG,UAAU,GAAG,IAAI,GAAG,EAAkB,CAAC;IAChD,KAAK,GAAG,CAAC,CAAC;IAEV,uFAAuF;IACvF,IAAI,OAAO;QACT,OAAO,IAAI,CAAC,MAAM,CAAC,MAAM,GAAG,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC;IACnD,CAAC;IAED,6FAA6F;IAC7F,MAAM,CAAC,MAAyC;QAC9C,IAAI,MAAM;YAAE,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,IAAI,CAAC,KAAK,EAAE,MAAM,EAAE,CAAC,CAAC;IAC7D,CAAC;IAED;;;;OAIG;IACH,eAAe,CAAC,MAAyC;QACvD,IAAI,MAAM;YAAE,IAAI,CAAC,SAAS,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC;IACvC,CAAC;IAED,yFAAyF;IACzF,OAAO;QACL,IAAI,CAAC,KAAK,EAAE,CAAC;QACb,MAAM,IAAI,GAA+C,EAAE,CAAC;QAC5D,MAAM,GAAG,GAAqB,EAAE,CAAC;QACjC,KAAK,MAAM,IAAI,IAAI,IAAI,CAAC,MAAM,EAAE,CAAC;YAC/B,IAAI,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,IAAI,IAAI,CAAC;gBAAE,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;;gBAClD,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACvB,CAAC;QACD,IAAI,CA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B;AAC/B,MAAM,CAAC,MAAM,KAAK,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,QAAQ,EAAE,GAAG,EAAE,OAAO,EAAE,GAAG,EAAW,CAAC;AAE3E,mHAAmH;AACnH,MAAM,UAAU,mBAAmB,CAAC,MAAiB,EAAE,KAAa,EAAE,IAAuC,EAAE,MAAwB,EAAE,OAAO,GAAG,IAAI;IACrJ,OAAO,MAAM,CAAC,aAAa,CAAC;QAC1B,KAAK;QACL,IAAI,EAAE,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC;QACjC,SAAS,EAAE,IAAI;QACf,MAAM;QACN,KAAK,EAAE,aAAa,CAAC,eAAe,GAAG,aAAa,CAAC,QAAQ,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,aAAa,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC,CAAC;KAC9G,CAAC,CAAC;AACL,CAAC","sourcesContent":["/**\n * Resources of the core frame renderer (K6.1, design §4.1–§4.2): the retire queue and the froxel texture\n * allocation. The renderer owns every texture and buffer it makes; a replaced one is retired and destroyed\n * two updates later, in a later task (K6.10a, see {@link VDBRetireQueue}). `dispose()` drains the queue.\n */\n\n/** Something with a `destroy()` (a GPUTexture, GPUBuffer or GPUQuerySet). */\nexport interface VDBDestroyable {\n destroy(): void;\n}\n\n/**\n * Destroys retired objects two updates after they were retired, and never in the task that made them due (K6.10a).\n *\n * WebGPU accepts `destroy()` on an object that a SUBMITTED command buffer uses (the free waits for the GPU), but a\n * submit that names an object destroyed before it fails. The queue cannot see the host's submit, so it waits for two\n * things, either of which makes the destroy safe:\n * - two updates (the K6.1 contract: one update per submit, so the encoders that used the object were submitted), and\n * - a task boundary after the update that made it due (`setTimeout(0)`): a host that records several updates (or\n * pass records) into one encoder and submits it in the same task has submitted it by then.\n *\n * Before K6.10a the destroy ran inside the update, so three updates recorded into one encoder before one submit\n * destroyed a texture the first update's passes still used. The remaining unsafe pattern is three or more updates\n * recorded without a submit AND across tasks (an `await` between record and submit); the renderer's docs say to submit\n * each update's encoder in the task that recorded it.\n */\nexport class VDBRetireQueue {\n #items: { tick: number; object: VDBDestroyable }[] = [];\n /** Due objects whose destroy waits for the next task (removed when destroyed, by the timer or by `drain`). */\n readonly #scheduled = new Set<VDBDestroyable>();\n #tick = 0;\n\n /** Objects waiting to be destroyed (retired, or due and waiting for the next task). */\n get pending(): number {\n return this.#items.length + this.#scheduled.size;\n }\n\n /** Keeps `object` until two more {@link advance} calls, then destroys it in a later task. */\n retire(object: VDBDestroyable | null | undefined): void {\n if (object) this.#items.push({ tick: this.#tick, object });\n }\n\n /**\n * Destroys `object` in a later task, without waiting for updates: for an owner that has no update of its own (a\n * source replaced between the host's record and submit, K6.10a). Safe when the host submits in the task that\n * recorded; the owner's users rebind at their next update.\n */\n retireAfterTask(object: VDBDestroyable | null | undefined): void {\n if (object) this.#schedule([object]);\n }\n\n /** One update: what was retired two or more updates ago is destroyed in a later task. */\n advance(): void {\n this.#tick++;\n const keep: { tick: number; object: VDBDestroyable }[] = [];\n const due: VDBDestroyable[] = [];\n for (const item of this.#items) {\n if (this.#tick - item.tick >= 2) due.push(item.object);\n else keep.push(item);\n }\n this.#items = keep;\n if (due.length > 0) this.#schedule(due);\n }\n\n #schedule(objects: VDBDestroyable[]): void {\n for (const o of objects) this.#scheduled.add(o);\n setTimeout(() => {\n for (const o of objects) if (this.#scheduled.delete(o)) o.destroy();\n }, 0);\n }\n\n /** Destroys everything now (`dispose()`: the host has no more work naming these objects). */\n drain(): void {\n for (const item of this.#items) item.object.destroy();\n this.#items = [];\n for (const o of this.#scheduled) o.destroy();\n this.#scheduled.clear();\n }\n}\n\n/**\n * K7.16 (his VDB-168 `spectralReleaseRenders`): updates in a row that need less (fewer spectral slot groups, one source\n * group; K7.16a no froxel work at all) before the frame renderer frees what the scene no longer uses. Settings-driven\n * releases (temporal off, 'volume' lighting) happen at the next update.\n */\nexport const VDB_FRAME_RELEASE_UPDATES = 120;\n\n/** `GPUTextureUsage` values, restated (the globals do not exist in Node). */\nexport const TEXTURE_USAGE = { COPY_SRC: 0x01, COPY_DST: 0x02, TEXTURE_BINDING: 0x04, STORAGE_BINDING: 0x08, RENDER_ATTACHMENT: 0x10 } as const;\n/** `GPUBufferUsage` values. */\nexport const BUFFER_USAGE = { MAP_READ: 0x1, COPY_SRC: 0x4, COPY_DST: 0x8, UNIFORM: 0x40, STORAGE: 0x80 } as const;\n/** `GPUShaderStage` values. */\nexport const STAGE = { VERTEX: 0x1, FRAGMENT: 0x2, COMPUTE: 0x4 } as const;\n\n/** A froxel-sized 3D storage texture (write by compute, read by sampling or `textureLoad`, copy for readbacks). */\nexport function createFroxelTexture(device: GPUDevice, label: string, size: readonly [number, number, number], format: GPUTextureFormat, sampled = true): GPUTexture {\n return device.createTexture({\n label,\n size: [size[0], size[1], size[2]],\n dimension: \"3d\",\n format,\n usage: TEXTURE_USAGE.STORAGE_BINDING | TEXTURE_USAGE.COPY_SRC | (sampled ? TEXTURE_USAGE.TEXTURE_BINDING : 0),\n });\n}\n"]}
@@ -0,0 +1,97 @@
1
+ /**
2
+ * K6.3 (design §3.6): the resources of the transmittance kernel's pluggable scattered-light term.
3
+ *
4
+ * - `'mlp'` (EXPERIMENTAL, Q5; his `'neural'` maps to it): the network as data (`VDBFrameMlp`: a shape uniform and a
5
+ * weight storage buffer, the source-free kernel's one storage buffer, D10) and the box mips of its feature levels
6
+ * (`gridMips`: one rgba16float 3D texture of side R/2 with mips to one voxel (≤ 8; K6.N: ≤ 5), redrawn with the shadow
7
+ * grid) and (K6.Nb) the feature reach in the shape uniform (`mlpReach`). K7.4d-a `mlpFeatures: 'cubic'` on a last
8
+ * cascade with non-cubic voxels: the texture holds the cubic chain instead (mip 0 = level 0, boxes of the largest
9
+ * voxel side: R >> e texels per axis; `vdbFrameMlpCubicReduce`), and the kernel reads level k at mip k.
10
+ * - `'multi-scale'` (K7.3): `vdbCreateMultiScaleMips` on the last shadow grid cascade (rg16float, edge `'zero'` or his
11
+ * `'clamp'`, `multiScaleLevels`; K6.3a `multiScaleSigma: 'paper'` adds one level and the lookup's `levelOffset`),
12
+ * recorded in its own compute pass after the grid, and the `VdbFrameMultiScale` uniform.
13
+ *
14
+ * 'frame' lighting only; elsewhere these modes run as 1D diffusion (his `isNeural`). K7.4a: spectral 'frame' lighting runs
15
+ * `'mlp'` per channel (a second mip chain of the absorption stack beside the extinction one). K7.4a-3: spectral
16
+ * `'multi-scale'` runs K7.3's lookup per channel the same way: two rgba16float chains (channels 0–2: the extinction rgb
17
+ * stack's, the absorption rgb stack's) in place of the grey rg16float (extinction, absorption) chain.
18
+ */
19
+ import { type VDBMultiScaleMips } from "../compute/multi-scale.js";
20
+ import { type VDBFrameMlp, type VDBFrameMlpReach } from "../../tools/frame/mlp.js";
21
+ import { type VDBFrameScatteringKernel } from "./wgsl/lighting.js";
22
+ import { VDBRetireQueue } from "./resources.js";
23
+ import type { VDBFrameSettings } from "./settings.js";
24
+ /** K6.Nb2: the phase an `extra` network's anisotropy inputs describe (`vdbFramePhaseVector`, `vdbFramePhaseSpectrum`). */
25
+ export interface VDBFrameMlpPhase {
26
+ phase: readonly [number, number, number, number];
27
+ spectrum: readonly [number, number, number];
28
+ }
29
+ /** The last cascade of the shadow grid, as the scattered-light terms read it. */
30
+ export interface VDBFrameScatteringGrid {
31
+ resolution: number;
32
+ /** World box and voxel of the last cascade. */
33
+ min: readonly number[];
34
+ size: readonly number[];
35
+ voxel: readonly number[];
36
+ /** Its texel origin in the shadow grid stack. */
37
+ origin: readonly number[];
38
+ /** K6.Nb: the world size of the casters' box (the last cascade's box before the voxel snap; 'world' MLP reaches). */
39
+ extent: readonly number[];
40
+ }
41
+ /** The scattered-light term of an update: the kernel family and the uniform values. */
42
+ export interface VDBFrameScatteringPlan {
43
+ kind: VDBFrameScatteringKernel;
44
+ /** The transmittance redraw signature's part (network identity, levels, edge, mip versions). */
45
+ signature: unknown[];
46
+ }
47
+ /** The `'mlp'` and `'multi-scale'` resources of one renderer (see the file comment). */
48
+ export declare class VDBFrameScattering {
49
+ #private;
50
+ constructor(device: GPUDevice, label: string, retire: VDBRetireQueue, warn: (key: string, message: string) => void);
51
+ /**
52
+ * The kernel family of this update ('frame' lighting): `'neural'` / `'mlp'` with a valid network → `'mlp'`,
53
+ * `'multi-scale'` → `'multi-scale'`, else `'none'` (a bad or missing network warns once and runs as 1D diffusion).
54
+ * K7.4a / K7.4a-3: spectral runs the network and the multi-scale lookup per channel.
55
+ */
56
+ kind(settings: VDBFrameSettings, mlp: VDBFrameMlp | null): VDBFrameScatteringKernel;
57
+ /**
58
+ * Prepares the resources of `kind` for the last cascade `grid` (drawn at `gridVersion`): uploads a new network,
59
+ * (re)allocates the mips, writes the multi-scale uniform. Returns the plan; `recordPass` / `recordEncoder` draw the
60
+ * mips when the grid moved.
61
+ */
62
+ plan(kind: VDBFrameScatteringKernel, settings: VDBFrameSettings, grid: VDBFrameScatteringGrid, multipleScattering: number, phase?: VDBFrameMlpPhase): VDBFrameScatteringPlan;
63
+ /** `'mlp'`: whether the feature mips must be drawn for the grid at `gridVersion`. */
64
+ mipsStale(kind: VDBFrameScatteringKernel, gridVersion: number): boolean;
65
+ /**
66
+ * `'mlp'`: records the feature mip chain (one dispatch per mip) into `pass` from the shadow grid `stack`; K7.4a
67
+ * spectral: also the absorption chain from the `absorption` stack.
68
+ */
69
+ recordMips(pass: GPUComputePassEncoder, group0: GPUBindGroup, stack: GPUTexture, gridVersion: number, absorption?: GPUTexture | null): void;
70
+ /**
71
+ * `'multi-scale'`: records K7.3's mip build (its own compute pass) into `encoder` from the last cascade; K7.4a-3
72
+ * spectral: also the absorption chain from the `absorption` stack (a second pass).
73
+ */
74
+ recordMultiScale(encoder: GPUCommandEncoder, stack: GPUTexture, origin: readonly number[], gridVersion: number, absorption?: GPUTexture | null): void;
75
+ /** The transmittance kernel's group 2 for `kind` (null for `'none'`). */
76
+ group2(kind: VDBFrameScatteringKernel, layout: GPUBindGroupLayout | undefined): GPUBindGroup | null;
77
+ /**
78
+ * K7.16 (his VDB-168 `releaseGridMipTargets`): retires the 'mlp' feature mips and the 'multi-scale' chain when the
79
+ * settings no longer run them (`keep` false); the next plan of that mode makes them again and draws them (a new mips
80
+ * texture and a new chain version are in the transmittance signature).
81
+ */
82
+ release(keep: {
83
+ mlp: boolean;
84
+ multiScale: boolean;
85
+ }): void;
86
+ /** @internal (harness probes) the feature mips texture and the multi-scale chain (K7.4a-3 spectral: and its absorption chain). */
87
+ get debug(): {
88
+ mips: GPUTexture | null;
89
+ absorptionMips: GPUTexture | null;
90
+ multiScale: VDBMultiScaleMips | null;
91
+ multiScaleAbsorption: VDBMultiScaleMips | null;
92
+ mlp: VDBFrameMlp | null;
93
+ reach: VDBFrameMlpReach | null;
94
+ reduce: readonly number[];
95
+ };
96
+ dispose(): void;
97
+ }
@@ -0,0 +1,332 @@
1
+ // Portions derived from mjurczyk/openvdb (MIT), commit 75e7345 (v0.26.0):
2
+ // src/three-openvdb/frame/webgpu/FrameRenderer.js L291–296 and L642–699 (isNeural, the grid mip targets and their
3
+ // redraw, renderGridMips); commit 4e2d46f (the 'multi-scale' mips and levels); commit 92421cc (v0.31.0, VDB-168:
4
+ // releaseGridMipTargets).
5
+ // Copyright (c) mjurczyk/openvdb contributors. Licensed under the MIT License (see THIRD_PARTY_NOTICES.md).
6
+ // Changes: the network is data for a generic MLP evaluator (shape uniform + weight storage buffer) and its feature
7
+ // levels are mips of one 3D texture; 'multi-scale' uses K7.3's core mips. Divergences: DIVERGES.md (K6.3 rows).
8
+ /**
9
+ * K6.3 (design §3.6): the resources of the transmittance kernel's pluggable scattered-light term.
10
+ *
11
+ * - `'mlp'` (EXPERIMENTAL, Q5; his `'neural'` maps to it): the network as data (`VDBFrameMlp`: a shape uniform and a
12
+ * weight storage buffer, the source-free kernel's one storage buffer, D10) and the box mips of its feature levels
13
+ * (`gridMips`: one rgba16float 3D texture of side R/2 with mips to one voxel (≤ 8; K6.N: ≤ 5), redrawn with the shadow
14
+ * grid) and (K6.Nb) the feature reach in the shape uniform (`mlpReach`). K7.4d-a `mlpFeatures: 'cubic'` on a last
15
+ * cascade with non-cubic voxels: the texture holds the cubic chain instead (mip 0 = level 0, boxes of the largest
16
+ * voxel side: R >> e texels per axis; `vdbFrameMlpCubicReduce`), and the kernel reads level k at mip k.
17
+ * - `'multi-scale'` (K7.3): `vdbCreateMultiScaleMips` on the last shadow grid cascade (rg16float, edge `'zero'` or his
18
+ * `'clamp'`, `multiScaleLevels`; K6.3a `multiScaleSigma: 'paper'` adds one level and the lookup's `levelOffset`),
19
+ * recorded in its own compute pass after the grid, and the `VdbFrameMultiScale` uniform.
20
+ *
21
+ * 'frame' lighting only; elsewhere these modes run as 1D diffusion (his `isNeural`). K7.4a: spectral 'frame' lighting runs
22
+ * `'mlp'` per channel (a second mip chain of the absorption stack beside the extinction one). K7.4a-3: spectral
23
+ * `'multi-scale'` runs K7.3's lookup per channel the same way: two rgba16float chains (channels 0–2: the extinction rgb
24
+ * stack's, the absorption rgb stack's) in place of the grey rg16float (extinction, absorption) chain.
25
+ */
26
+ import { vdbCreateMultiScaleMips, vdbFrameMultiScaleParams, VDB_FRAME_MULTI_SCALE_PARAMS_BYTES } from "../compute/multi-scale.js";
27
+ import { vdbFrameMlpCheck, vdbFrameMlpCubicReduce, vdbFrameMlpCubicSizes, vdbFrameMlpExtraValues, vdbFrameMlpMipSizes, vdbFrameMlpPack, vdbFrameMlpPackedShape, vdbFrameMlpReach, vdbFrameMlpReachUniform, vdbFrameMlpShape, VDB_FRAME_MLP_REACH_OFFSET, } from "../../tools/frame/mlp.js";
28
+ import { vdbFrameMultiScaleLevelOffset } from "../../tools/frame/multi-scale.js";
29
+ import { GRID_MIP_BINDINGS, TRANSMITTANCE_MLP_BINDINGS, TRANSMITTANCE_MULTI_SCALE_BINDINGS, vdbFrameScatteringIsMlp } from "./wgsl/lighting.js";
30
+ import { vdbFrameGridMipSpec } from "./kernels.js";
31
+ import { computePipeline } from "./pipelines.js";
32
+ import { BUFFER_USAGE, TEXTURE_USAGE, VDBRetireQueue } from "./resources.js";
33
+ const DEFAULT_PHASE = { phase: [0, 0, 0, 0], spectrum: [1, 1, 0] };
34
+ // info, the layer table, then (K6.Nb) the reach and (K6.Nb2) the extra inputs
35
+ const MLP_SHAPE_BYTES = VDB_FRAME_MLP_REACH_OFFSET + 32;
36
+ /** The `'mlp'` and `'multi-scale'` resources of one renderer (see the file comment). */
37
+ export class VDBFrameScattering {
38
+ #device;
39
+ #label;
40
+ #retire;
41
+ #warn;
42
+ // 'mlp'
43
+ #mlp = null;
44
+ #mlpValid = false;
45
+ #mlpVersion = 0;
46
+ /** K6.Na: the evaluator the uploaded weights are laid out for (`mlpRuntime`). */
47
+ #mlpPacked = false;
48
+ #weights = null;
49
+ #shape = null;
50
+ #mips = null;
51
+ /** K7.4a spectral: the absorption rgb box mips (null when grey). */
52
+ #absorptionMips = null;
53
+ #mipsResolution = 0;
54
+ /** K7.4d-a: the cubic chain's per-axis reduction the mips were made for ("0,0,0": the K6.3 chain). */
55
+ #mipsReduce = "0,0,0";
56
+ #reduce = [0, 0, 0];
57
+ #reachBase = 0;
58
+ /** The grid version the feature mips hold (−1: none). */
59
+ #mipsDrawn = -1;
60
+ /** K6.Nb: the reach and extra input in the shape uniform (null: not written since the buffer was made). */
61
+ #reach = null;
62
+ #reachExtra = [];
63
+ // 'multi-scale'
64
+ #ms = null;
65
+ /** K7.4a-3 spectral: the absorption rgb chain (`#ms` holds the extinction rgb; null when grey). */
66
+ #msAbsorption = null;
67
+ #msKey = "";
68
+ #msParams = null;
69
+ #msDrawn = -1;
70
+ #msVersion = 0;
71
+ constructor(device, label, retire, warn) {
72
+ this.#device = device;
73
+ this.#label = label;
74
+ this.#retire = retire;
75
+ this.#warn = warn;
76
+ }
77
+ /**
78
+ * The kernel family of this update ('frame' lighting): `'neural'` / `'mlp'` with a valid network → `'mlp'`,
79
+ * `'multi-scale'` → `'multi-scale'`, else `'none'` (a bad or missing network warns once and runs as 1D diffusion).
80
+ * K7.4a / K7.4a-3: spectral runs the network and the multi-scale lookup per channel.
81
+ */
82
+ kind(settings, mlp) {
83
+ const mode = settings.multipleScattering;
84
+ if (mode === "multi-scale")
85
+ return "multi-scale";
86
+ if (mode !== "neural" && mode !== "mlp")
87
+ return "none";
88
+ // K6.Na: `mlpRuntime: 'packed'` runs the same network on the packed evaluator (its own weight layout)
89
+ const packed = settings.mlpRuntime === "packed";
90
+ if (mlp !== this.#mlp || packed !== this.#mlpPacked) {
91
+ this.#mlp = mlp;
92
+ this.#mlpPacked = packed;
93
+ const problem = mlp ? vdbFrameMlpCheck(mlp) : null;
94
+ this.#mlpValid = !!mlp && !problem;
95
+ this.#mlpVersion++;
96
+ if (this.#weights)
97
+ this.#retire.retire(this.#weights);
98
+ this.#weights = null;
99
+ if (!mlp)
100
+ this.#warn("mlp-none", `multipleScattering '${mode}' has no network (mlp is null); the light slots use 1D diffusion (true).`);
101
+ else if (problem)
102
+ this.#warn(`mlp-shape-${this.#mlpVersion}`, `the mlp ${mlp.name ?? ""} does not fit the evaluator (${problem}); using 1D diffusion.`);
103
+ }
104
+ return this.#mlpValid ? (packed ? "mlp-packed" : "mlp") : "none";
105
+ }
106
+ /**
107
+ * Prepares the resources of `kind` for the last cascade `grid` (drawn at `gridVersion`): uploads a new network,
108
+ * (re)allocates the mips, writes the multi-scale uniform. Returns the plan; `recordPass` / `recordEncoder` draw the
109
+ * mips when the grid moved.
110
+ */
111
+ plan(kind, settings, grid, multipleScattering, phase = DEFAULT_PHASE) {
112
+ if (vdbFrameScatteringIsMlp(kind)) {
113
+ const spectral = !!settings.spectral;
114
+ const mlp = this.#mlp;
115
+ if (!this.#weights) {
116
+ // K6.Na: 'mlp-packed' uploads the packed layout (and vec4 offsets in the shape); 'mlp' the flat weights
117
+ const weights = kind === "mlp-packed" ? vdbFrameMlpPack(mlp) : mlp.weights;
118
+ this.#weights = this.#device.createBuffer({ label: `${this.#label} mlp weights`, size: Math.max(16, weights.byteLength), usage: BUFFER_USAGE.STORAGE | BUFFER_USAGE.COPY_DST });
119
+ this.#device.queue.writeBuffer(this.#weights, 0, weights.buffer, weights.byteOffset, weights.byteLength);
120
+ this.#shape ??= this.#device.createBuffer({ label: `${this.#label} mlp shape`, size: MLP_SHAPE_BYTES, usage: BUFFER_USAGE.UNIFORM | BUFFER_USAGE.COPY_DST });
121
+ this.#device.queue.writeBuffer(this.#shape, 0, (kind === "mlp-packed" ? vdbFrameMlpPackedShape(mlp) : vdbFrameMlpShape(mlp)).buffer);
122
+ }
123
+ // K6.Nb: the feature reach of this grid (`mlpReach`), written when it moves
124
+ const reach = vdbFrameMlpReach(settings.mlpReach === "world" ? "world" : "grid", grid.extent, grid.voxel);
125
+ // K6.Nb / K6.Nb2: an `extra` network's anisotropy inputs ('g': the mean cosine; 'phase': the lobes; f32 as the kernel reads them)
126
+ const extra = vdbFrameMlpExtraValues(mlp, phase.phase, phase.spectrum).map(Math.fround);
127
+ // K7.4d-a `mlpFeatures: 'cubic'`: on non-cubic voxels the chain starts with an anisotropic step and holds level 0
128
+ const reduce = settings.mlpFeatures === "cubic" ? vdbFrameMlpCubicReduce(grid.voxel) : [0, 0, 0];
129
+ const base = reduce.some((e) => e > 0) ? 1 : 0;
130
+ const reduceKey = reduce.join(",");
131
+ if (!this.#reach || this.#reach.unit !== reach.unit || this.#reach.shift !== reach.shift || this.#reachBase !== base || this.#reachExtra.length !== extra.length || extra.some((v, i) => this.#reachExtra[i] !== v)) {
132
+ this.#device.queue.writeBuffer(this.#shape, VDB_FRAME_MLP_REACH_OFFSET, vdbFrameMlpReachUniform(reach, extra, base).buffer);
133
+ this.#reach = reach;
134
+ this.#reachExtra = extra;
135
+ this.#reachBase = base;
136
+ }
137
+ if (!this.#mips || this.#mipsResolution !== grid.resolution || this.#mipsReduce !== reduceKey || spectral !== !!this.#absorptionMips) {
138
+ this.#retire.retire(this.#mips);
139
+ this.#retire.retire(this.#absorptionMips);
140
+ const cubes = base ? vdbFrameMlpCubicSizes(grid.resolution, reduce) : null;
141
+ const sizes = cubes ? cubes.map((s) => s[0]) : vdbFrameMlpMipSizes(grid.resolution);
142
+ const mips = (label) => this.#device.createTexture({
143
+ label: `${this.#label} ${label}`,
144
+ size: cubes ? [...cubes[0]] : [sizes[0], sizes[0], sizes[0]],
145
+ dimension: "3d",
146
+ format: "rgba16float",
147
+ mipLevelCount: sizes.length,
148
+ usage: TEXTURE_USAGE.STORAGE_BINDING | TEXTURE_USAGE.TEXTURE_BINDING | TEXTURE_USAGE.COPY_SRC,
149
+ });
150
+ this.#mips = mips("mlp feature mips");
151
+ // K7.4a spectral: the absorption rgb chain (the extinction chain holds the extinction rgb)
152
+ this.#absorptionMips = spectral ? mips("mlp absorption feature mips") : null;
153
+ this.#mipsResolution = grid.resolution;
154
+ this.#mipsReduce = reduceKey;
155
+ this.#reduce = reduce;
156
+ this.#mipsDrawn = -1;
157
+ }
158
+ return { kind, signature: [kind, this.#mlpVersion, this.#mips, this.#absorptionMips, reach.unit, reach.shift, ...extra] };
159
+ }
160
+ if (kind === "multi-scale") {
161
+ const levels = Math.min(8, Math.max(2, Math.round(settings.multiScaleLevels)));
162
+ const internal = settings;
163
+ const edge = internal.multiScaleEdge === "clamp" ? "clamp" : "zero";
164
+ // K6.3a: the paper's σ = 2^k reads mip k + 1 for level k, so the chain holds one more level (at most 8)
165
+ const levelOffset = vdbFrameMultiScaleLevelOffset(internal.multiScaleSigma);
166
+ const chainLevels = Math.min(8, levels + levelOffset);
167
+ // K7.4a-3 spectral: two rgb chains (extinction stack, absorption stack) instead of the grey (extinction, absorption)
168
+ const spectral = !!settings.spectral;
169
+ const key = `${grid.resolution}:${levels}:${edge}:${levelOffset}:${spectral}`;
170
+ if (!this.#ms || this.#msKey !== key) {
171
+ if (this.#ms)
172
+ this.#retire.retire(this.#ms);
173
+ if (this.#msAbsorption)
174
+ this.#retire.retire(this.#msAbsorption);
175
+ const size = [grid.resolution, grid.resolution, grid.resolution];
176
+ const chain = (label) => vdbCreateMultiScaleMips(this.#device, { size, levels: chainLevels, edge, channels: spectral ? [0, 1, 2] : [0, 1], label: `${this.#label} ${label}` });
177
+ this.#ms = chain("multi-scale");
178
+ this.#msAbsorption = spectral ? chain("multi-scale absorption") : null;
179
+ this.#msKey = key;
180
+ this.#msDrawn = -1;
181
+ this.#msVersion++;
182
+ }
183
+ this.#msParams ??= this.#device.createBuffer({ label: `${this.#label} multi-scale params`, size: VDB_FRAME_MULTI_SCALE_PARAMS_BYTES, usage: BUFFER_USAGE.UNIFORM | BUFFER_USAGE.COPY_DST });
184
+ const r = grid.resolution;
185
+ this.#device.queue.writeBuffer(this.#msParams, 0, vdbFrameMultiScaleParams({
186
+ boxMin: [grid.min[0], grid.min[1], grid.min[2]],
187
+ boxSize: [grid.size[0], grid.size[1], grid.size[2]],
188
+ unit: Math.max(grid.voxel[0], grid.voxel[1], grid.voxel[2]),
189
+ levels,
190
+ multipleScattering,
191
+ baseOrigin: [grid.origin[0], grid.origin[1], grid.origin[2]],
192
+ baseSize: [r, r, r],
193
+ levelOffset,
194
+ }));
195
+ return { kind, signature: ["multi-scale", key, this.#msVersion] };
196
+ }
197
+ return { kind, signature: ["none"] };
198
+ }
199
+ /** `'mlp'`: whether the feature mips must be drawn for the grid at `gridVersion`. */
200
+ mipsStale(kind, gridVersion) {
201
+ if (vdbFrameScatteringIsMlp(kind))
202
+ return this.#mipsDrawn !== gridVersion;
203
+ if (kind === "multi-scale")
204
+ return this.#msDrawn !== gridVersion;
205
+ return false;
206
+ }
207
+ /**
208
+ * `'mlp'`: records the feature mip chain (one dispatch per mip) into `pass` from the shadow grid `stack`; K7.4a
209
+ * spectral: also the absorption chain from the `absorption` stack.
210
+ */
211
+ recordMips(pass, group0, stack, gridVersion, absorption = null) {
212
+ this.#recordChain(pass, group0, stack, this.#mips, "feature");
213
+ if (this.#absorptionMips && absorption)
214
+ this.#recordChain(pass, group0, absorption, this.#absorptionMips, "absorption");
215
+ this.#mipsDrawn = gridVersion;
216
+ }
217
+ #recordChain(pass, group0, stack, mips, name) {
218
+ const b = GRID_MIP_BINDINGS;
219
+ for (let level = 0; level < mips.mipLevelCount; level++) {
220
+ // K7.4d-a: the cubic chain's level 0 is the anisotropic box of the last cascade (its own module per reduction)
221
+ const built = computePipeline(this.#device, vdbFrameGridMipSpec({ first: level === 0, reduce: this.#reduce }));
222
+ const source = level === 0 ? stack.createView({ dimension: "3d" }) : mips.createView({ dimension: "3d", baseMipLevel: level - 1, mipLevelCount: 1 });
223
+ const out = mips.createView({ dimension: "3d", baseMipLevel: level, mipLevelCount: 1 });
224
+ pass.setPipeline(built.pipeline);
225
+ pass.setBindGroup(0, group0);
226
+ pass.setBindGroup(1, this.#device.createBindGroup({
227
+ label: `${this.#label} grid ${name} mip ${level + 1} group 1`,
228
+ layout: built.layouts[1],
229
+ entries: [
230
+ { binding: b.source, resource: source },
231
+ { binding: b.out, resource: out },
232
+ ],
233
+ }));
234
+ const groups = (n) => Math.ceil(Math.max(1, n >> level) / 4);
235
+ pass.dispatchWorkgroups(groups(mips.width), groups(mips.height), groups(mips.depthOrArrayLayers));
236
+ }
237
+ }
238
+ /**
239
+ * `'multi-scale'`: records K7.3's mip build (its own compute pass) into `encoder` from the last cascade; K7.4a-3
240
+ * spectral: also the absorption chain from the `absorption` stack (a second pass).
241
+ */
242
+ recordMultiScale(encoder, stack, origin, gridVersion, absorption = null) {
243
+ const at = [origin[0], origin[1], origin[2]];
244
+ this.#ms.record(encoder, stack, { origin: at });
245
+ if (this.#msAbsorption && absorption)
246
+ this.#msAbsorption.record(encoder, absorption, { origin: at });
247
+ this.#msDrawn = gridVersion;
248
+ }
249
+ /** The transmittance kernel's group 2 for `kind` (null for `'none'`). */
250
+ group2(kind, layout) {
251
+ if (!layout)
252
+ return null;
253
+ if (vdbFrameScatteringIsMlp(kind)) {
254
+ const m = TRANSMITTANCE_MLP_BINDINGS;
255
+ return this.#device.createBindGroup({
256
+ label: `${this.#label} transmittance mlp group 2`,
257
+ layout,
258
+ entries: [
259
+ { binding: m.weights, resource: { buffer: this.#weights } },
260
+ { binding: m.shape, resource: { buffer: this.#shape } },
261
+ { binding: m.mips, resource: this.#mips.createView({ dimension: "3d" }) },
262
+ // K7.4a spectral: the absorption rgb chain
263
+ ...(this.#absorptionMips ? [{ binding: m.absorptionMips, resource: this.#absorptionMips.createView({ dimension: "3d" }) }] : []),
264
+ ],
265
+ });
266
+ }
267
+ if (kind === "multi-scale") {
268
+ const m = TRANSMITTANCE_MULTI_SCALE_BINDINGS;
269
+ return this.#device.createBindGroup({
270
+ label: `${this.#label} transmittance multi-scale group 2`,
271
+ layout,
272
+ entries: [
273
+ { binding: m.params, resource: { buffer: this.#msParams } },
274
+ { binding: m.mips, resource: this.#ms.view },
275
+ // K7.4a-3 spectral: the absorption rgb chain
276
+ ...(this.#msAbsorption ? [{ binding: m.absorptionMips, resource: this.#msAbsorption.view }] : []),
277
+ ],
278
+ });
279
+ }
280
+ return null;
281
+ }
282
+ /**
283
+ * K7.16 (his VDB-168 `releaseGridMipTargets`): retires the 'mlp' feature mips and the 'multi-scale' chain when the
284
+ * settings no longer run them (`keep` false); the next plan of that mode makes them again and draws them (a new mips
285
+ * texture and a new chain version are in the transmittance signature).
286
+ */
287
+ release(keep) {
288
+ if (!keep.mlp && this.#mips) {
289
+ this.#retire.retire(this.#mips);
290
+ this.#retire.retire(this.#absorptionMips);
291
+ this.#mips = null;
292
+ this.#absorptionMips = null;
293
+ this.#mipsResolution = 0;
294
+ this.#mipsReduce = "0,0,0";
295
+ this.#reduce = [0, 0, 0];
296
+ this.#mipsDrawn = -1;
297
+ }
298
+ if (!keep.multiScale && this.#ms) {
299
+ this.#retire.retire(this.#ms);
300
+ if (this.#msAbsorption)
301
+ this.#retire.retire(this.#msAbsorption);
302
+ this.#ms = null;
303
+ this.#msAbsorption = null;
304
+ this.#msKey = "";
305
+ this.#msDrawn = -1;
306
+ }
307
+ }
308
+ /** @internal (harness probes) the feature mips texture and the multi-scale chain (K7.4a-3 spectral: and its absorption chain). */
309
+ get debug() {
310
+ return { mips: this.#mips, absorptionMips: this.#absorptionMips, multiScale: this.#ms, multiScaleAbsorption: this.#msAbsorption, mlp: this.#mlpValid ? this.#mlp : null, reach: this.#reach, reduce: this.#mips ? this.#reduce : [0, 0, 0] };
311
+ }
312
+ dispose() {
313
+ this.#weights?.destroy();
314
+ this.#shape?.destroy();
315
+ this.#mips?.destroy();
316
+ this.#absorptionMips?.destroy();
317
+ this.#ms?.destroy();
318
+ this.#msAbsorption?.destroy();
319
+ this.#msParams?.destroy();
320
+ this.#weights = this.#shape = this.#msParams = null;
321
+ this.#reach = null;
322
+ this.#reachExtra = [];
323
+ this.#reachBase = 0;
324
+ this.#mipsReduce = "0,0,0";
325
+ this.#reduce = [0, 0, 0];
326
+ this.#mips = null;
327
+ this.#absorptionMips = null;
328
+ this.#ms = null;
329
+ this.#msAbsorption = null;
330
+ }
331
+ }
332
+ //# sourceMappingURL=scattering.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"scattering.js","sourceRoot":"","sources":["../../../src/core/frame/scattering.ts"],"names":[],"mappings":"AAAA,0EAA0E;AAC1E,oHAAoH;AACpH,mHAAmH;AACnH,4BAA4B;AAC5B,4GAA4G;AAC5G,mHAAmH;AACnH,gHAAgH;AAEhH;;;;;;;;;;;;;;;;;GAiBG;AAEH,OAAO,EAAE,uBAAuB,EAAE,wBAAwB,EAAE,kCAAkC,EAA0B,MAAM,2BAA2B,CAAC;AAC1J,OAAO,EACL,gBAAgB,EAChB,sBAAsB,EACtB,qBAAqB,EACrB,sBAAsB,EACtB,mBAAmB,EACnB,eAAe,EACf,sBAAsB,EACtB,gBAAgB,EAChB,uBAAuB,EACvB,gBAAgB,EAChB,0BAA0B,GAG3B,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,6BAA6B,EAA+B,MAAM,kCAAkC,CAAC;AAC9G,OAAO,EAAE,iBAAiB,EAAE,0BAA0B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,CAAC,MAAM,GAAG,IAAI,CAAC;QACnB,IAAI,CAAC,WAAW,GAAG,EAAE,CAAC;QACtB,IAAI,CAAC,UAAU,GAAG,CAAC,CAAC;QACpB,IAAI,CAAC,WAAW,GAAG,OAAO,CAAC;QAC3B,IAAI,CAAC,OAAO,GAAG,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;QACzB,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC;QAClB,IAAI,CAAC,eAAe,GAAG,IAAI,CAAC;QAC5B,IAAI,CAAC,GAAG,GAAG,IAAI,CAAC;QAChB,IAAI,CAAC,aAAa,GAAG,IAAI,CAAC;IAC5B,CAAC;CACF","sourcesContent":["// Portions derived from mjurczyk/openvdb (MIT), commit 75e7345 (v0.26.0):\n// src/three-openvdb/frame/webgpu/FrameRenderer.js L291–296 and L642–699 (isNeural, the grid mip targets and their\n// redraw, renderGridMips); commit 4e2d46f (the 'multi-scale' mips and levels); commit 92421cc (v0.31.0, VDB-168:\n// releaseGridMipTargets).\n// Copyright (c) mjurczyk/openvdb contributors. Licensed under the MIT License (see THIRD_PARTY_NOTICES.md).\n// Changes: the network is data for a generic MLP evaluator (shape uniform + weight storage buffer) and its feature\n// levels are mips of one 3D texture; 'multi-scale' uses K7.3's core mips. Divergences: DIVERGES.md (K6.3 rows).\n\n/**\n * K6.3 (design §3.6): the resources of the transmittance kernel's pluggable scattered-light term.\n *\n * - `'mlp'` (EXPERIMENTAL, Q5; his `'neural'` maps to it): the network as data (`VDBFrameMlp`: a shape uniform and a\n * weight storage buffer, the source-free kernel's one storage buffer, D10) and the box mips of its feature levels\n * (`gridMips`: one rgba16float 3D texture of side R/2 with mips to one voxel (≤ 8; K6.N: ≤ 5), redrawn with the shadow\n * grid) and (K6.Nb) the feature reach in the shape uniform (`mlpReach`). K7.4d-a `mlpFeatures: 'cubic'` on a last\n * cascade with non-cubic voxels: the texture holds the cubic chain instead (mip 0 = level 0, boxes of the largest\n * voxel side: R >> e texels per axis; `vdbFrameMlpCubicReduce`), and the kernel reads level k at mip k.\n * - `'multi-scale'` (K7.3): `vdbCreateMultiScaleMips` on the last shadow grid cascade (rg16float, edge `'zero'` or his\n * `'clamp'`, `multiScaleLevels`; K6.3a `multiScaleSigma: 'paper'` adds one level and the lookup's `levelOffset`),\n * recorded in its own compute pass after the grid, and the `VdbFrameMultiScale` uniform.\n *\n * 'frame' lighting only; elsewhere these modes run as 1D diffusion (his `isNeural`). K7.4a: spectral 'frame' lighting runs\n * `'mlp'` per channel (a second mip chain of the absorption stack beside the extinction one). K7.4a-3: spectral\n * `'multi-scale'` runs K7.3's lookup per channel the same way: two rgba16float chains (channels 0–2: the extinction rgb\n * stack's, the absorption rgb stack's) in place of the grey rg16float (extinction, absorption) chain.\n */\n\nimport { vdbCreateMultiScaleMips, vdbFrameMultiScaleParams, VDB_FRAME_MULTI_SCALE_PARAMS_BYTES, type VDBMultiScaleMips } from \"../compute/multi-scale.js\";\nimport {\n vdbFrameMlpCheck,\n vdbFrameMlpCubicReduce,\n vdbFrameMlpCubicSizes,\n vdbFrameMlpExtraValues,\n vdbFrameMlpMipSizes,\n vdbFrameMlpPack,\n vdbFrameMlpPackedShape,\n vdbFrameMlpReach,\n vdbFrameMlpReachUniform,\n vdbFrameMlpShape,\n VDB_FRAME_MLP_REACH_OFFSET,\n type VDBFrameMlp,\n type VDBFrameMlpReach,\n} from \"../../tools/frame/mlp.js\";\nimport { vdbFrameMultiScaleLevelOffset, type VDBFrameMultiScaleEdge } from \"../../tools/frame/multi-scale.js\";\nimport { GRID_MIP_BINDINGS, TRANSMITTANCE_MLP_BINDINGS, TRANSMITTANCE_MULTI_SCALE_BINDINGS, vdbFrameScatteringIsMlp, type VDBFrameScatteringKernel } from \"./wgsl/lighting.js\";\nimport { vdbFrameGridMipSpec } from \"./kernels.js\";\nimport { computePipeline } from \"./pipelines.js\";\nimport { BUFFER_USAGE, TEXTURE_USAGE, VDBRetireQueue } from \"./resources.js\";\nimport type { VDBFrameInternalSettings, VDBFrameSettings } from \"./settings.js\";\n\n/** K6.Nb2: the phase an `extra` network's anisotropy inputs describe (`vdbFramePhaseVector`, `vdbFramePhaseSpectrum`). */\nexport interface VDBFrameMlpPhase {\n phase: readonly [number, number, number, number];\n spectrum: readonly [number, number, number];\n}\nconst DEFAULT_PHASE: VDBFrameMlpPhase = { phase: [0, 0, 0, 0], spectrum: [1, 1, 0] };\n\n/** The last cascade of the shadow grid, as the scattered-light terms read it. */\nexport interface VDBFrameScatteringGrid {\n resolution: number;\n /** World box and voxel of the last cascade. */\n min: readonly number[];\n size: readonly number[];\n voxel: readonly number[];\n /** Its texel origin in the shadow grid stack. */\n origin: readonly number[];\n /** K6.Nb: the world size of the casters' box (the last cascade's box before the voxel snap; 'world' MLP reaches). */\n extent: readonly number[];\n}\n\n/** The scattered-light term of an update: the kernel family and the uniform values. */\nexport interface VDBFrameScatteringPlan {\n kind: VDBFrameScatteringKernel;\n /** The transmittance redraw signature's part (network identity, levels, edge, mip versions). */\n signature: unknown[];\n}\n\n// info, the layer table, then (K6.Nb) the reach and (K6.Nb2) the extra inputs\nconst MLP_SHAPE_BYTES = VDB_FRAME_MLP_REACH_OFFSET + 32;\n\n/** The `'mlp'` and `'multi-scale'` resources of one renderer (see the file comment). */\nexport class VDBFrameScattering {\n readonly #device: GPUDevice;\n readonly #label: string;\n readonly #retire: VDBRetireQueue;\n readonly #warn: (key: string, message: string) => void;\n // 'mlp'\n #mlp: VDBFrameMlp | null = null;\n #mlpValid = false;\n #mlpVersion = 0;\n /** K6.Na: the evaluator the uploaded weights are laid out for (`mlpRuntime`). */\n #mlpPacked = false;\n #weights: GPUBuffer | null = null;\n #shape: GPUBuffer | null = null;\n #mips: GPUTexture | null = null;\n /** K7.4a spectral: the absorption rgb box mips (null when grey). */\n #absorptionMips: GPUTexture | null = null;\n #mipsResolution = 0;\n /** K7.4d-a: the cubic chain's per-axis reduction the mips were made for (\"0,0,0\": the K6.3 chain). */\n #mipsReduce = \"0,0,0\";\n #reduce: readonly number[] = [0, 0, 0];\n #reachBase: 0 | 1 = 0;\n /** The grid version the feature mips hold (−1: none). */\n #mipsDrawn = -1;\n /** K6.Nb: the reach and extra input in the shape uniform (null: not written since the buffer was made). */\n #reach: VDBFrameMlpReach | null = null;\n #reachExtra: readonly number[] = [];\n // 'multi-scale'\n #ms: VDBMultiScaleMips | null = null;\n /** K7.4a-3 spectral: the absorption rgb chain (`#ms` holds the extinction rgb; null when grey). */\n #msAbsorption: VDBMultiScaleMips | null = null;\n #msKey = \"\";\n #msParams: GPUBuffer | null = null;\n #msDrawn = -1;\n #msVersion = 0;\n\n constructor(device: GPUDevice, label: string, retire: VDBRetireQueue, warn: (key: string, message: string) => void) {\n this.#device = device;\n this.#label = label;\n this.#retire = retire;\n this.#warn = warn;\n }\n\n /**\n * The kernel family of this update ('frame' lighting): `'neural'` / `'mlp'` with a valid network → `'mlp'`,\n * `'multi-scale'` → `'multi-scale'`, else `'none'` (a bad or missing network warns once and runs as 1D diffusion).\n * K7.4a / K7.4a-3: spectral runs the network and the multi-scale lookup per channel.\n */\n kind(settings: VDBFrameSettings, mlp: VDBFrameMlp | null): VDBFrameScatteringKernel {\n const mode = settings.multipleScattering;\n if (mode === \"multi-scale\") return \"multi-scale\";\n if (mode !== \"neural\" && mode !== \"mlp\") return \"none\";\n // K6.Na: `mlpRuntime: 'packed'` runs the same network on the packed evaluator (its own weight layout)\n const packed = (settings as VDBFrameInternalSettings).mlpRuntime === \"packed\";\n if (mlp !== this.#mlp || packed !== this.#mlpPacked) {\n this.#mlp = mlp;\n this.#mlpPacked = packed;\n const problem = mlp ? vdbFrameMlpCheck(mlp) : null;\n this.#mlpValid = !!mlp && !problem;\n this.#mlpVersion++;\n if (this.#weights) this.#retire.retire(this.#weights);\n this.#weights = null;\n if (!mlp) this.#warn(\"mlp-none\", `multipleScattering '${mode}' has no network (mlp is null); the light slots use 1D diffusion (true).`);\n else if (problem) this.#warn(`mlp-shape-${this.#mlpVersion}`, `the mlp ${mlp.name ?? \"\"} does not fit the evaluator (${problem}); using 1D diffusion.`);\n }\n return this.#mlpValid ? (packed ? \"mlp-packed\" : \"mlp\") : \"none\";\n }\n\n /**\n * Prepares the resources of `kind` for the last cascade `grid` (drawn at `gridVersion`): uploads a new network,\n * (re)allocates the mips, writes the multi-scale uniform. Returns the plan; `recordPass` / `recordEncoder` draw the\n * mips when the grid moved.\n */\n plan(kind: VDBFrameScatteringKernel, settings: VDBFrameSettings, grid: VDBFrameScatteringGrid, multipleScattering: number, phase: VDBFrameMlpPhase = DEFAULT_PHASE): VDBFrameScatteringPlan {\n if (vdbFrameScatteringIsMlp(kind)) {\n const spectral = !!settings.spectral;\n const mlp = this.#mlp!;\n if (!this.#weights) {\n // K6.Na: 'mlp-packed' uploads the packed layout (and vec4 offsets in the shape); 'mlp' the flat weights\n const weights = kind === \"mlp-packed\" ? vdbFrameMlpPack(mlp) : mlp.weights;\n this.#weights = this.#device.createBuffer({ label: `${this.#label} mlp weights`, size: Math.max(16, weights.byteLength), usage: BUFFER_USAGE.STORAGE | BUFFER_USAGE.COPY_DST });\n this.#device.queue.writeBuffer(this.#weights, 0, weights.buffer as ArrayBuffer, weights.byteOffset, weights.byteLength);\n this.#shape ??= this.#device.createBuffer({ label: `${this.#label} mlp shape`, size: MLP_SHAPE_BYTES, usage: BUFFER_USAGE.UNIFORM | BUFFER_USAGE.COPY_DST });\n this.#device.queue.writeBuffer(this.#shape, 0, (kind === \"mlp-packed\" ? vdbFrameMlpPackedShape(mlp) : vdbFrameMlpShape(mlp)).buffer as ArrayBuffer);\n }\n // K6.Nb: the feature reach of this grid (`mlpReach`), written when it moves\n const reach = vdbFrameMlpReach((settings as VDBFrameInternalSettings).mlpReach === \"world\" ? \"world\" : \"grid\", grid.extent, grid.voxel);\n // K6.Nb / K6.Nb2: an `extra` network's anisotropy inputs ('g': the mean cosine; 'phase': the lobes; f32 as the kernel reads them)\n const extra = vdbFrameMlpExtraValues(mlp, phase.phase, phase.spectrum).map(Math.fround);\n // K7.4d-a `mlpFeatures: 'cubic'`: on non-cubic voxels the chain starts with an anisotropic step and holds level 0\n const reduce = (settings as VDBFrameInternalSettings).mlpFeatures === \"cubic\" ? vdbFrameMlpCubicReduce(grid.voxel) : [0, 0, 0];\n const base: 0 | 1 = reduce.some((e) => e > 0) ? 1 : 0;\n const reduceKey = reduce.join(\",\");\n if (!this.#reach || this.#reach.unit !== reach.unit || this.#reach.shift !== reach.shift || this.#reachBase !== base || this.#reachExtra.length !== extra.length || extra.some((v, i) => this.#reachExtra[i] !== v)) {\n this.#device.queue.writeBuffer(this.#shape!, VDB_FRAME_MLP_REACH_OFFSET, vdbFrameMlpReachUniform(reach, extra, base).buffer as ArrayBuffer);\n this.#reach = reach;\n this.#reachExtra = extra;\n this.#reachBase = base;\n }\n if (!this.#mips || this.#mipsResolution !== grid.resolution || this.#mipsReduce !== reduceKey || spectral !== !!this.#absorptionMips) {\n this.#retire.retire(this.#mips);\n this.#retire.retire(this.#absorptionMips);\n const cubes = base ? vdbFrameMlpCubicSizes(grid.resolution, reduce) : null;\n const sizes = cubes ? cubes.map((s) => s[0]) : vdbFrameMlpMipSizes(grid.resolution);\n const mips = (label: string) =>\n this.#device.createTexture({\n label: `${this.#label} ${label}`,\n size: cubes ? [...cubes[0]!] : [sizes[0]!, sizes[0]!, sizes[0]!],\n dimension: \"3d\",\n format: \"rgba16float\",\n mipLevelCount: sizes.length,\n usage: TEXTURE_USAGE.STORAGE_BINDING | TEXTURE_USAGE.TEXTURE_BINDING | TEXTURE_USAGE.COPY_SRC,\n });\n this.#mips = mips(\"mlp feature mips\");\n // K7.4a spectral: the absorption rgb chain (the extinction chain holds the extinction rgb)\n this.#absorptionMips = spectral ? mips(\"mlp absorption feature mips\") : null;\n this.#mipsResolution = grid.resolution;\n this.#mipsReduce = reduceKey;\n this.#reduce = reduce;\n this.#mipsDrawn = -1;\n }\n return { kind, signature: [kind, this.#mlpVersion, this.#mips, this.#absorptionMips, reach.unit, reach.shift, ...extra] };\n }\n if (kind === \"multi-scale\") {\n const levels = Math.min(8, Math.max(2, Math.round(settings.multiScaleLevels)));\n const internal = settings as VDBFrameInternalSettings;\n const edge: VDBFrameMultiScaleEdge = internal.multiScaleEdge === \"clamp\" ? \"clamp\" : \"zero\";\n // K6.3a: the paper's σ = 2^k reads mip k + 1 for level k, so the chain holds one more level (at most 8)\n const levelOffset = vdbFrameMultiScaleLevelOffset(internal.multiScaleSigma);\n const chainLevels = Math.min(8, levels + levelOffset);\n // K7.4a-3 spectral: two rgb chains (extinction stack, absorption stack) instead of the grey (extinction, absorption)\n const spectral = !!settings.spectral;\n const key = `${grid.resolution}:${levels}:${edge}:${levelOffset}:${spectral}`;\n if (!this.#ms || this.#msKey !== key) {\n if (this.#ms) this.#retire.retire(this.#ms);\n if (this.#msAbsorption) this.#retire.retire(this.#msAbsorption);\n const size: [number, number, number] = [grid.resolution, grid.resolution, grid.resolution];\n const chain = (label: string) => vdbCreateMultiScaleMips(this.#device, { size, levels: chainLevels, edge, channels: spectral ? [0, 1, 2] : [0, 1], label: `${this.#label} ${label}` });\n this.#ms = chain(\"multi-scale\");\n this.#msAbsorption = spectral ? chain(\"multi-scale absorption\") : null;\n this.#msKey = key;\n this.#msDrawn = -1;\n this.#msVersion++;\n }\n this.#msParams ??= this.#device.createBuffer({ label: `${this.#label} multi-scale params`, size: VDB_FRAME_MULTI_SCALE_PARAMS_BYTES, usage: BUFFER_USAGE.UNIFORM | BUFFER_USAGE.COPY_DST });\n const r = grid.resolution;\n this.#device.queue.writeBuffer(\n this.#msParams,\n 0,\n vdbFrameMultiScaleParams({\n boxMin: [grid.min[0]!, grid.min[1]!, grid.min[2]!],\n boxSize: [grid.size[0]!, grid.size[1]!, grid.size[2]!],\n unit: Math.max(grid.voxel[0]!, grid.voxel[1]!, grid.voxel[2]!),\n levels,\n multipleScattering,\n baseOrigin: [grid.origin[0]!, grid.origin[1]!, grid.origin[2]!],\n baseSize: [r, r, r],\n levelOffset,\n }),\n );\n return { kind, signature: [\"multi-scale\", key, this.#msVersion] };\n }\n return { kind, signature: [\"none\"] };\n }\n\n /** `'mlp'`: whether the feature mips must be drawn for the grid at `gridVersion`. */\n mipsStale(kind: VDBFrameScatteringKernel, gridVersion: number): boolean {\n if (vdbFrameScatteringIsMlp(kind)) return this.#mipsDrawn !== gridVersion;\n if (kind === \"multi-scale\") return this.#msDrawn !== gridVersion;\n return false;\n }\n\n /**\n * `'mlp'`: records the feature mip chain (one dispatch per mip) into `pass` from the shadow grid `stack`; K7.4a\n * spectral: also the absorption chain from the `absorption` stack.\n */\n recordMips(pass: GPUComputePassEncoder, group0: GPUBindGroup, stack: GPUTexture, gridVersion: number, absorption: GPUTexture | null = null): void {\n this.#recordChain(pass, group0, stack, this.#mips!, \"feature\");\n if (this.#absorptionMips && absorption) this.#recordChain(pass, group0, absorption, this.#absorptionMips, \"absorption\");\n this.#mipsDrawn = gridVersion;\n }\n\n #recordChain(pass: GPUComputePassEncoder, group0: GPUBindGroup, stack: GPUTexture, mips: GPUTexture, name: string): void {\n const b = GRID_MIP_BINDINGS;\n for (let level = 0; level < mips.mipLevelCount; level++) {\n // K7.4d-a: the cubic chain's level 0 is the anisotropic box of the last cascade (its own module per reduction)\n const built = computePipeline(this.#device, vdbFrameGridMipSpec({ first: level === 0, reduce: this.#reduce }));\n const source = level === 0 ? stack.createView({ dimension: \"3d\" }) : mips.createView({ dimension: \"3d\", baseMipLevel: level - 1, mipLevelCount: 1 });\n const out = mips.createView({ dimension: \"3d\", baseMipLevel: level, mipLevelCount: 1 });\n pass.setPipeline(built.pipeline);\n pass.setBindGroup(0, group0);\n pass.setBindGroup(\n 1,\n this.#device.createBindGroup({\n label: `${this.#label} grid ${name} mip ${level + 1} group 1`,\n layout: built.layouts[1]!,\n entries: [\n { binding: b.source, resource: source },\n { binding: b.out, resource: out },\n ],\n }),\n );\n const groups = (n: number): number => Math.ceil(Math.max(1, n >> level) / 4);\n pass.dispatchWorkgroups(groups(mips.width), groups(mips.height), groups(mips.depthOrArrayLayers));\n }\n }\n\n /**\n * `'multi-scale'`: records K7.3's mip build (its own compute pass) into `encoder` from the last cascade; K7.4a-3\n * spectral: also the absorption chain from the `absorption` stack (a second pass).\n */\n recordMultiScale(encoder: GPUCommandEncoder, stack: GPUTexture, origin: readonly number[], gridVersion: number, absorption: GPUTexture | null = null): void {\n const at: [number, number, number] = [origin[0]!, origin[1]!, origin[2]!];\n this.#ms!.record(encoder, stack, { origin: at });\n if (this.#msAbsorption && absorption) this.#msAbsorption.record(encoder, absorption, { origin: at });\n this.#msDrawn = gridVersion;\n }\n\n /** The transmittance kernel's group 2 for `kind` (null for `'none'`). */\n group2(kind: VDBFrameScatteringKernel, layout: GPUBindGroupLayout | undefined): GPUBindGroup | null {\n if (!layout) return null;\n if (vdbFrameScatteringIsMlp(kind)) {\n const m = TRANSMITTANCE_MLP_BINDINGS;\n return this.#device.createBindGroup({\n label: `${this.#label} transmittance mlp group 2`,\n layout,\n entries: [\n { binding: m.weights, resource: { buffer: this.#weights! } },\n { binding: m.shape, resource: { buffer: this.#shape! } },\n { binding: m.mips, resource: this.#mips!.createView({ dimension: \"3d\" }) },\n // K7.4a spectral: the absorption rgb chain\n ...(this.#absorptionMips ? [{ binding: m.absorptionMips, resource: this.#absorptionMips.createView({ dimension: \"3d\" }) }] : []),\n ],\n });\n }\n if (kind === \"multi-scale\") {\n const m = TRANSMITTANCE_MULTI_SCALE_BINDINGS;\n return this.#device.createBindGroup({\n label: `${this.#label} transmittance multi-scale group 2`,\n layout,\n entries: [\n { binding: m.params, resource: { buffer: this.#msParams! } },\n { binding: m.mips, resource: this.#ms!.view },\n // K7.4a-3 spectral: the absorption rgb chain\n ...(this.#msAbsorption ? [{ binding: m.absorptionMips, resource: this.#msAbsorption.view }] : []),\n ],\n });\n }\n return null;\n }\n\n /**\n * K7.16 (his VDB-168 `releaseGridMipTargets`): retires the 'mlp' feature mips and the 'multi-scale' chain when the\n * settings no longer run them (`keep` false); the next plan of that mode makes them again and draws them (a new mips\n * texture and a new chain version are in the transmittance signature).\n */\n release(keep: { mlp: boolean; multiScale: boolean }): void {\n if (!keep.mlp && this.#mips) {\n this.#retire.retire(this.#mips);\n this.#retire.retire(this.#absorptionMips);\n this.#mips = null;\n this.#absorptionMips = null;\n this.#mipsResolution = 0;\n this.#mipsReduce = \"0,0,0\";\n this.#reduce = [0, 0, 0];\n this.#mipsDrawn = -1;\n }\n if (!keep.multiScale && this.#ms) {\n this.#retire.retire(this.#ms);\n if (this.#msAbsorption) this.#retire.retire(this.#msAbsorption);\n this.#ms = null;\n this.#msAbsorption = null;\n this.#msKey = \"\";\n this.#msDrawn = -1;\n }\n }\n\n /** @internal (harness probes) the feature mips texture and the multi-scale chain (K7.4a-3 spectral: and its absorption chain). */\n get debug(): { mips: GPUTexture | null; absorptionMips: GPUTexture | null; multiScale: VDBMultiScaleMips | null; multiScaleAbsorption: VDBMultiScaleMips | null; mlp: VDBFrameMlp | null; reach: VDBFrameMlpReach | null; reduce: readonly number[] } {\n return { mips: this.#mips, absorptionMips: this.#absorptionMips, multiScale: this.#ms, multiScaleAbsorption: this.#msAbsorption, mlp: this.#mlpValid ? this.#mlp : null, reach: this.#reach, reduce: this.#mips ? this.#reduce : [0, 0, 0] };\n }\n\n dispose(): void {\n this.#weights?.destroy();\n this.#shape?.destroy();\n this.#mips?.destroy();\n this.#absorptionMips?.destroy();\n this.#ms?.destroy();\n this.#msAbsorption?.destroy();\n this.#msParams?.destroy();\n this.#weights = this.#shape = this.#msParams = null;\n this.#reach = null;\n this.#reachExtra = [];\n this.#reachBase = 0;\n this.#mipsReduce = \"0,0,0\";\n this.#reduce = [0, 0, 0];\n this.#mips = null;\n this.#absorptionMips = null;\n this.#ms = null;\n this.#msAbsorption = null;\n }\n}\n"]}