@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,159 @@
1
+ /**
2
+ * CPU twins (f64) of the core frame renderer's spectral kernels (K6.4): the oracles of `e2e/k6-core.spec.ts`'s
3
+ * spectral probes. The pass maths are tools/frame/spectral.ts (his K3.5 twins); these assemble them on the core's
4
+ * stacked textures, slot-group packing and combine rules.
5
+ */
6
+ import { type Vec2, type Vec3, type Vec4 } from "./index.js";
7
+ import { type VDBFrameDensityInputs, type VDBFrameGridLayout, type VDBFrameShadowLight } from "./grid.js";
8
+ import { vdbFrameUnpackSpectralGroup, type VDBFrameSpectralShadow } from "./spectral.js";
9
+ import { type VDBFrameEnvironmentFlags, type VDBFrameEnvironmentGpuResult } from "./environment-gpu.js";
10
+ /** One caster as the spectral shadow density pass reads it (`VDBFrameGridCaster` + the volume's extinction spectrum). */
11
+ export interface VDBFrameSpectralGridCaster {
12
+ readonly worldToLocal: ArrayLike<number>;
13
+ readonly maxTexels: number;
14
+ readonly worldScale: number;
15
+ readonly mipmaps: boolean;
16
+ readonly absorbance: number;
17
+ readonly extinctionSpectrum: Vec3;
18
+ extinctionAt(local: Vec3, lod: number): number;
19
+ albedoAt(local: Vec3, lod: number): Vec3;
20
+ }
21
+ /**
22
+ * The spectral shadow density pass at one voxel (`vdbFrameGridDensityCs`, spectral): the summed extinction
23
+ * (spectrum × extinction) and absorption (× (1 − albedo) of each channel) of the casters whose box holds the voxel.
24
+ */
25
+ export declare function vdbFrameSpectralGridDensityVoxel(world: Vec3, voxelSize: number, casters: readonly VDBFrameSpectralGridCaster[]): {
26
+ extinction: Vec3;
27
+ absorption: Vec3;
28
+ };
29
+ /** The spectral grid at a cascade's uvw: (extinction, absorption) of each channel (the two stacks). */
30
+ export type VDBFrameSpectralGridAt = (cascade: number, uvw: Vec3) => {
31
+ extinction: Vec3;
32
+ absorption: Vec3;
33
+ };
34
+ /** The spectral transmittance targets of one voxel and slot group; K6.Q1d: group 0's `dipole` targets with `ambientDipole`. */
35
+ export type VDBFrameSpectralTransmittanceTargets3d = [Vec4, Vec4, Vec4] & {
36
+ dipole?: [Vec4, Vec4, Vec4];
37
+ };
38
+ /**
39
+ * The spectral transmittance kernel at voxel `cell` of `cascade` for slot group `group` (his buildSpectralNodes on the
40
+ * core's stacks): the 3 packed targets. Group 0: (sky up, sky down) and slot 0; group g: slots 2g − 1 and 2g; a slot
41
+ * entry is (total, direct). `lights` are the slots (≤ 6, incl. the environment slot); `visibility(slot, world)` the K6.5b
42
+ * occluder of the scene slots (< `sceneSlots`). Voxels with no extinction within half a voxel keep 1.
43
+ */
44
+ export declare function vdbFrameSpectralTransmittanceVoxel3d(gridAt: VDBFrameSpectralGridAt, grid: VDBFrameGridLayout, cascade: number, cell: Vec3, lights: readonly VDBFrameShadowLight[], skyDirection: Vec3, multipleScattering: number, jitter: number, group: number, o?: {
45
+ octaves?: Vec4;
46
+ twoSided?: boolean;
47
+ visibility?: ((slot: number, world: Vec3) => number) | null;
48
+ sceneSlots?: number;
49
+ /**
50
+ * K6.Q1a shadowed ambient: the pairs' upper directions (`vdbFrameAmbientDirections`; [0] the sky direction): group
51
+ * 0's sky entry becomes the hemispherical visibilities of each channel (V up, V down). Default none (the sky totals).
52
+ */
53
+ ambientDirections?: readonly Vec3[] | null;
54
+ /**
55
+ * K6.Q1d ('frame' lighting's `ambientPhase: 'dipole'`, while read): M⁺ / 2 of the directions (`vdbFrameAmbientDipoleMatrix`): group 0's result
56
+ * carries `dipole`, its 3 dipole targets (b of each channel, xyz; 0 where no extinction is near). Default none.
57
+ */
58
+ ambientDipole?: readonly number[] | null;
59
+ /**
60
+ * K7.4a 'mlp' / 'neural': a slot's total of each channel from its direct transmittance, the voxel's world position,
61
+ * the unit direction to the light, the direct optical depth of each channel and the march length (e.g. direct +
62
+ * `vdbFrameSpectralMlpLight(...)`; K7.4a-3 'multi-scale': min(direct + `vdbFrameSpectralMultiScaleLight(...)`, 1)),
63
+ * after 'two-sided' and before the occluder visibility (the grey twin's order).
64
+ */
65
+ slotTotal?: ((direct: Vec3, world: Vec3, direction: Vec3, opticalDepth: Vec3, maxDistance: number) => Vec3) | null;
66
+ /**
67
+ * K7.15 (his VDB-167): false when nothing reads group 0's sky entry: it stays 1, unmarched (ignored with
68
+ * `ambientDirections`, as the kernel). Default true.
69
+ */
70
+ skyMarch?: boolean;
71
+ }): VDBFrameSpectralTransmittanceTargets3d;
72
+ /**
73
+ * The spectral environment grid kernel at voxel `cell` of the last cascade (his spectral branch on the core's stacks):
74
+ * one-voxel-step marches of each channel that stay in the last cascade, the voxel's albedo for the octaves; diffusion:
75
+ * the two-sided total of each channel. Outside the casters: the unshadowed light × the octave total of 1.
76
+ */
77
+ export declare function vdbFrameSpectralEnvironmentGridVoxel3d(gridAt: VDBFrameSpectralGridAt, grid: VDBFrameGridLayout, cell: Vec3, lights: readonly {
78
+ direction: Vec3;
79
+ color: Vec3;
80
+ }[], multipleScattering: number, octaves?: Vec4): Vec4;
81
+ /**
82
+ * sampleShadows of every slot group in use at a world position (the core's spectral stack: `targetAt(cascade, group, k,
83
+ * uvw)`), 1 outside the grid, blended toward the next cascade within 10% of a cascade's sides. Groups past `groups`: 1.
84
+ */
85
+ export declare function vdbFrameSpectralStackGroups(targetAt: (cascade: number, group: number, k: number, uvw: Vec3) => number[], grid: VDBFrameGridLayout, world: Vec3, groups: number): number[][][];
86
+ /** The spectral density sums of one volume in one froxel (the core's `vdbFrameDensitySums`, spectral). */
87
+ export interface VDBFrameSpectralSums {
88
+ /** (albedo · extinction rgb, weight = the channel mean of the extinction). */
89
+ a: Vec4;
90
+ /** (emission · weight, visible t · weight). */
91
+ e: Vec4;
92
+ /** (extinction rgb, 0). */
93
+ x: Vec4;
94
+ }
95
+ /** The inputs of {@link vdbFrameSpectralDensitySums}: the grey density inputs (hooks), the extinction spectrum, the environment term. */
96
+ export interface VDBFrameSpectralDensityInputs3d extends Pick<VDBFrameDensityInputs, "froxelGrid" | "columns" | "range" | "projectionInverse" | "cameraWorld" | "viewToLocal" | "maxTexels" | "mipLevels" | "worldScale" | "subSteps" | "jitter" | "fadeRadius" | "opacity" | "baseColor" | "scatterColor" | "extinctionAt" | "stochastic" | "albedoAt" | "emissionAt"> {
97
+ extinctionSpectrum: Vec3;
98
+ /**
99
+ * The environment irradiance added as albedo · E / π at the visible world and local position, given the albedo (and,
100
+ * K6.Q1d, the froxel's unit view ray: the 'outward' term's visibilities take the dipole's phase weight).
101
+ */
102
+ environmentAt?: ((world: Vec3, local: Vec3, albedo: Vec3, ray: Vec3) => Vec3) | null;
103
+ }
104
+ /**
105
+ * The core's spectral density sums of one volume in one froxel (his spectral density pass): the pre-integration with the
106
+ * transmittance of each channel (the visible position weighs the channel mean), the extinction-weighted sums; null when
107
+ * the weight is not > 0. `fragCoord` is his atlas pixel.
108
+ */
109
+ export declare function vdbFrameSpectralDensitySums(fragCoord: Vec2, p: VDBFrameSpectralDensityInputs3d): VDBFrameSpectralSums | null;
110
+ /**
111
+ * The core's spectral environment term of the density pass (`vdbFrameEnvironmentDensityTerm` of each channel): the
112
+ * environment grid at the visible position (outside: the unshadowed light × the spectral octave total of 1), nothing
113
+ * with the environment slot, else 'outward' SH irradiance shadowed between the sky down and up totals of each channel
114
+ * (`sky` (up, down) are group 0's entry a at the visible position, before the totals; K6.Q1a `ambientOcclusion`: the
115
+ * hemispherical visibilities, read as they are).
116
+ */
117
+ export declare function vdbFrameSpectralEnvironmentDensityTerm(env: VDBFrameEnvironmentGpuResult, flags: VDBFrameEnvironmentFlags, outward: Vec3, skyDirection: Vec3, sky: VDBFrameSpectralShadow, albedo: Vec3, gridAt: () => Vec3 | null, octaves?: Vec4, ambientOcclusion?: boolean): Vec3;
118
+ /** One volume's spectral froxel in the 'volume' gather: unpremultiplied radiance and the alpha of each channel. */
119
+ export interface VDBFrameSpectralVolumeFroxel {
120
+ radiance: Vec3;
121
+ alpha: Vec3;
122
+ }
123
+ /**
124
+ * The 'volume' gather's spectral combine of the volumes in one froxel: (L · α rgb, α rgb). Per channel
125
+ * (τ = −log(1 − α), α = 1 − exp(−Στ), L = ΣτL / Στ); one volume gives (Lα, α).
126
+ */
127
+ export declare function vdbFrameGatherFroxelSpectral(volumes: readonly VDBFrameSpectralVolumeFroxel[]): {
128
+ color: Vec3;
129
+ alpha: Vec3;
130
+ };
131
+ /**
132
+ * The spectral resolve scan of one column (his spectral integrate loop over whole slices): `froxels[z]` = (scatter
133
+ * (L·α rgb, α green), alpha (α red, α blue, 0, α green)). Boundary k holds (Σ radiance rgb, 1 − T green) and the alpha
134
+ * prefix (1 − T red, 1 − T blue); a slice adds nothing once every channel's T < 0.001 (his maxComponent break).
135
+ */
136
+ export declare function vdbFrameScanColumnSpectral(froxels: readonly {
137
+ scatter: Vec4;
138
+ alpha: Vec4;
139
+ }[], o?: {
140
+ stop?: number;
141
+ }): {
142
+ prefix: Vec4[];
143
+ alpha: Vec2[];
144
+ };
145
+ /**
146
+ * The spectral composite's two taps (`vdbFrameIntegrate` spectral): the grey two-tap formula for each channel, the red
147
+ * and blue opacity from the alpha prefix. Returns (radiance, transmittance of each channel).
148
+ */
149
+ export declare function vdbFrameIntegratePrefixSpectral(a: Vec4, aAlpha: Vec2, b: Vec4, bAlpha: Vec2, c: number): {
150
+ radiance: Vec3;
151
+ transmittance: Vec3;
152
+ };
153
+ /**
154
+ * His spectral composite (`vdbFrameCompositeSpectralColor`): the scene colour × the transmittance of each channel + the
155
+ * radiance, or (sRGB) the per-channel mix in sRGB (clamped to [0, 1] when `clampColors`); alpha from green.
156
+ */
157
+ export declare function vdbFrameCompositeSpectral(radiance: Vec3, transmittance: Vec3, scene: Vec4, srgb: boolean, clampColors?: boolean): Vec4;
158
+ /** Re-exported for the spectral 'frame' lighting twin: group entries of the core's 3 packed targets. */
159
+ export { vdbFrameUnpackSpectralGroup };
@@ -0,0 +1,391 @@
1
+ // Portions derived from mjurczyk/openvdb (MIT), commit 75e7345 (v0.26.0):
2
+ // src/three-openvdb/frame/webgpu/FrameShadowDensityMaterial.js L111–121 (the spectral shadow density),
3
+ // FrameTransmittanceMaterial.js L278–459 (buildSpectralNodes), FrameEnvironmentGridMaterial.js L104–197 (the spectral
4
+ // branch), FrameDensityMaterial.js L363–537 and FrameLightingMaterial.js L114–275 (the spectral density and lighting
5
+ // passes), FrameInjectMaterial.js L200–532 (the spectral inject pass), FrameTemporalMaterial.js and
6
+ // FrameIntegrateMaterial.js L140–217 (the spectral second target and composite).
7
+ // Copyright (c) mjurczyk/openvdb contributors. Licensed under the MIT License (see THIRD_PARTY_NOTICES.md).
8
+ // Changes: f64 CPU twins of the core's spectral kernels (K6.4) on stacked 3D textures (K6.2's layout): the spectral
9
+ // shadow grid (two stacks), the transmittance per slot group, the environment grid, the fused density + lighting
10
+ // gather, the 'volume' gather's combine, the resolve scan and the composite. Divergences: DIVERGES.md (K6.4 rows).
11
+ /**
12
+ * CPU twins (f64) of the core frame renderer's spectral kernels (K6.4): the oracles of `e2e/k6-core.spec.ts`'s
13
+ * spectral probes. The pass maths are tools/frame/spectral.ts (his K3.5 twins); these assemble them on the core's
14
+ * stacked textures, slot-group packing and combine rules.
15
+ */
16
+ import { vdbFrameDistanceFade, vdbFrameNoise, vdbFrameOctavesOff, vdbFrameTwoSidedDiffusion, vdbSrgbEotf, vdbSrgbOetf } from "./index.js";
17
+ import { vdbFrameIntegratePrefix, vdbFrameMaxOpticalDepth } from "./froxel.js";
18
+ import { vdbFrameFindCascade, vdbFrameGridUvw, vdbFrameInsideGrid, vdbFrameDensityFroxelSteps, vdbFrameSliceExtinction, vdbFrameIsotropicDiffusion } from "./grid.js";
19
+ import { vdbFrameGridFragCoord, vdbFrameGridVoxelWorld } from "./stack.js";
20
+ import { vdbFrameMeanComponent, vdbFrameSpectralGridAlbedo, vdbFrameSpectralGridMarch, vdbFrameSpectralShadowMarchDepth, vdbFrameSpectralShadowStep, vdbFrameSpectralShadowTotal, vdbFrameSpectralShadowTransmittance, vdbFrameUnpackSpectralGroup, vdbFramePackSpectralGroup, } from "./spectral.js";
21
+ import { vdbFrameOccludedTotal } from "./occluders.js";
22
+ import { vdbFrameSpectralAmbientDipole, vdbFrameSpectralAmbientPairTotals, vdbFrameSpectralAmbientVisibility } from "./ambient.js";
23
+ import { vdbFrameEnvironmentIrradiance } from "./environment-gpu.js";
24
+ const clamp01 = (x) => Math.min(1, Math.max(0, x));
25
+ const map3 = (f) => [f(0), f(1), f(2)];
26
+ const normalize3 = (v) => {
27
+ const l = Math.hypot(v[0], v[1], v[2]);
28
+ return l > 0 ? [v[0] / l, v[1] / l, v[2] / l] : [0, 0, 0];
29
+ };
30
+ const unmarched = () => ({ x: [1, 1, 1], y: [1, 1, 1], z: [0, 0, 0], w: [0, 0, 0] });
31
+ /**
32
+ * The spectral shadow density pass at one voxel (`vdbFrameGridDensityCs`, spectral): the summed extinction
33
+ * (spectrum × extinction) and absorption (× (1 − albedo) of each channel) of the casters whose box holds the voxel.
34
+ */
35
+ export function vdbFrameSpectralGridDensityVoxel(world, voxelSize, casters) {
36
+ const extinction = [0, 0, 0];
37
+ const absorption = [0, 0, 0];
38
+ for (const c of casters) {
39
+ const m = c.worldToLocal;
40
+ const local = [0, 1, 2].map((r) => m[r] * world[0] + m[4 + r] * world[1] + m[8 + r] * world[2] + m[12 + r]);
41
+ if (Math.max(Math.abs(local[0]), Math.abs(local[1]), Math.abs(local[2])) > 0.5)
42
+ continue;
43
+ const lod = Math.max(0, Math.log2((voxelSize / c.worldScale) * c.maxTexels));
44
+ const readLod = c.mipmaps ? lod : 0;
45
+ const e = c.extinctionAt(local, readLod) * c.absorbance;
46
+ if (!(e > 0))
47
+ continue;
48
+ const albedo = c.albedoAt(local, readLod);
49
+ for (let k = 0; k < 3; k++) {
50
+ const s = c.extinctionSpectrum[k] * e;
51
+ extinction[k] = extinction[k] + s;
52
+ absorption[k] = absorption[k] + s * (1 - clamp01(albedo[k]));
53
+ }
54
+ }
55
+ return { extinction, absorption };
56
+ }
57
+ /**
58
+ * The spectral transmittance kernel at voxel `cell` of `cascade` for slot group `group` (his buildSpectralNodes on the
59
+ * core's stacks): the 3 packed targets. Group 0: (sky up, sky down) and slot 0; group g: slots 2g − 1 and 2g; a slot
60
+ * entry is (total, direct). `lights` are the slots (≤ 6, incl. the environment slot); `visibility(slot, world)` the K6.5b
61
+ * occluder of the scene slots (< `sceneSlots`). Voxels with no extinction within half a voxel keep 1.
62
+ */
63
+ export function vdbFrameSpectralTransmittanceVoxel3d(gridAt, grid, cascade, cell, lights, skyDirection, multipleScattering, jitter, group, o = {}) {
64
+ const ones = [
65
+ [1, 1, 1, 1],
66
+ [1, 1, 1, 1],
67
+ [1, 1, 1, 1],
68
+ ];
69
+ const dipoleOn = group === 0 && !!o.ambientDipole && !!o.ambientDirections && o.ambientDirections.length > 0;
70
+ if (dipoleOn)
71
+ ones.dipole = [[0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0]];
72
+ const octaves = o.octaves ?? vdbFrameOctavesOff;
73
+ const world = vdbFrameGridVoxelWorld(grid, cascade, cell);
74
+ const voxel = grid.gridVoxel[cascade];
75
+ const sampleAt = (p) => {
76
+ const c = vdbFrameFindCascade(grid, p, 0);
77
+ return c < 0 ? { extinction: [0, 0, 0], absorption: [0, 0, 0] } : gridAt(c, vdbFrameGridUvw(grid, c, p));
78
+ };
79
+ let near = 0;
80
+ for (let i = 0; i < 8; i++) {
81
+ const c = [(i & 1) - 0.5, ((i >> 1) & 1) - 0.5, ((i >> 2) & 1) - 0.5];
82
+ const e = sampleAt([world[0] + c[0] * voxel[0], world[1] + c[1] * voxel[1], world[2] + c[2] * voxel[2]]).extinction;
83
+ near += e[0] + e[1] + e[2];
84
+ }
85
+ if (!(near > 0))
86
+ return ones;
87
+ const noise = vdbFrameNoise(jitter, vdbFrameGridFragCoord(grid.resolution, grid.columns, cascade, cell));
88
+ const march = (dir, maxDistance, out) => vdbFrameSpectralGridMarch(sampleAt, grid, world, dir, maxDistance, noise, multipleScattering, octaves, out);
89
+ const slot = (i) => {
90
+ if (i >= Math.min(lights.length, 6))
91
+ return unmarched();
92
+ const l = lights[i];
93
+ const isDirection = l[3] < 1.5;
94
+ const toLight = [l[0] - world[0], l[1] - world[1], l[2] - world[2]];
95
+ const dir = isDirection ? normalize3([l[0], l[1], l[2]]) : normalize3(toLight);
96
+ const maxDistance = isDirection ? 1e20 : Math.hypot(...toLight);
97
+ const optical = { opticalDepth: [0, 0, 0] };
98
+ const front = march(dir, maxDistance, optical);
99
+ if (o.twoSided) {
100
+ const back = march([-dir[0], -dir[1], -dir[2]], 1e20);
101
+ front.y = map3((c) => vdbFrameTwoSidedDiffusion(front.x[c], front.z[c], front.w[c], back.z[c]));
102
+ }
103
+ // K7.4a 'mlp' / 'neural': the network's total of each channel from the direct transmittance
104
+ if (o.slotTotal)
105
+ front.y = o.slotTotal(front.x, world, dir, optical.opticalDepth, maxDistance);
106
+ // K6.5b: the scene slot's scattered part × the voxel's occluder visibility (octaves: the gather occludes)
107
+ if (o.visibility && i < (o.sceneSlots ?? lights.length) && !(octaves[0] > 0)) {
108
+ const v = o.visibility(i, world);
109
+ front.y = map3((c) => vdbFrameOccludedTotal(front.x[c], front.y[c], v));
110
+ }
111
+ return front;
112
+ };
113
+ const entry = (m) => ({ x: m.y, y: m.x });
114
+ if (group === 0) {
115
+ const sky = normalize3(skyDirection);
116
+ const dirs = o.ambientDirections;
117
+ // K7.15: the sky marches only when something reads them (the AO pairs read pair 0 from them)
118
+ const skyMarch = o.skyMarch !== false || (!!dirs && dirs.length > 0);
119
+ const up = skyMarch ? march(sky, 1e20) : unmarched();
120
+ const down = skyMarch ? march([-sky[0], -sky[1], -sky[2]], 1e20) : unmarched();
121
+ const total = (f, b) => (multipleScattering > 0 && skyMarch ? map3((c) => vdbFrameIsotropicDiffusion(f.z[c], b.z[c], f.w[c])) : f.y);
122
+ if (dirs && dirs.length > 0) {
123
+ // K6.Q1a: each pair's isotropic-light totals of each channel (pair 0: the sky marches), averaged per side; octaves
124
+ // at the voxel's grid albedo (its own cascade's texel)
125
+ const centre = gridAt(cascade, vdbFrameGridUvw(grid, cascade, world));
126
+ const albedo = vdbFrameSpectralGridAlbedo(centre.extinction, centre.absorption);
127
+ const totals = dirs.map((d, k) => {
128
+ const front = k === 0 ? up : march(d, 1e20);
129
+ const back = k === 0 ? down : march([-d[0], -d[1], -d[2]], 1e20);
130
+ return vdbFrameSpectralAmbientPairTotals(front, back, multipleScattering > 0, octaves, albedo);
131
+ });
132
+ const v = vdbFrameSpectralAmbientVisibility(totals);
133
+ const packed = vdbFramePackSpectralGroup({ x: v[0], y: v[1] }, entry(slot(0)));
134
+ // K6.Q1d: the pairs' dipole of each channel
135
+ if (dipoleOn)
136
+ packed.dipole = vdbFrameSpectralAmbientDipole(totals, dirs, o.ambientDipole).map((b) => [...b, 0]);
137
+ return packed;
138
+ }
139
+ return vdbFramePackSpectralGroup({ x: total(up, down), y: total(down, up) }, entry(slot(0)));
140
+ }
141
+ return vdbFramePackSpectralGroup(entry(slot(2 * group - 1)), entry(slot(2 * group)));
142
+ }
143
+ /**
144
+ * The spectral environment grid kernel at voxel `cell` of the last cascade (his spectral branch on the core's stacks):
145
+ * one-voxel-step marches of each channel that stay in the last cascade, the voxel's albedo for the octaves; diffusion:
146
+ * the two-sided total of each channel. Outside the casters: the unshadowed light × the octave total of 1.
147
+ */
148
+ export function vdbFrameSpectralEnvironmentGridVoxel3d(gridAt, grid, cell, lights, multipleScattering, octaves = vdbFrameOctavesOff) {
149
+ const cascade = grid.count - 1;
150
+ const world = vdbFrameGridVoxelWorld(grid, cascade, cell);
151
+ const voxel = grid.gridVoxel[cascade];
152
+ const uvwOf = (p) => vdbFrameGridUvw(grid, cascade, p);
153
+ const unshadowed = [0, 0, 0];
154
+ for (const l of lights)
155
+ for (let c = 0; c < 3; c++)
156
+ unshadowed[c] = unshadowed[c] + l.color[c];
157
+ let near = 0;
158
+ for (let i = 0; i < 8; i++) {
159
+ const c = [(i & 1) - 0.5, ((i >> 1) & 1) - 0.5, ((i >> 2) & 1) - 0.5];
160
+ const e = gridAt(cascade, uvwOf([world[0] + c[0] * voxel[0], world[1] + c[1] * voxel[1], world[2] + c[2] * voxel[2]])).extinction;
161
+ near += e[0] + e[1] + e[2];
162
+ }
163
+ const outside = vdbFrameSpectralShadowTotal([1, 1, 1], octaves, [1, 1, 1]);
164
+ if (!(near > 0))
165
+ return [Math.max(unshadowed[0], 0) * outside[0], Math.max(unshadowed[1], 0) * outside[1], Math.max(unshadowed[2], 0) * outside[2], 1];
166
+ const centre = gridAt(cascade, uvwOf(world));
167
+ const albedo = vdbFrameSpectralGridAlbedo(centre.extinction, centre.absorption);
168
+ const marchDepths = (dir) => {
169
+ const step = 1 / Math.max(Math.abs(dir[0]) / voxel[0], Math.abs(dir[1]) / voxel[1], Math.abs(dir[2]) / voxel[2]);
170
+ const probe = [world[0] + dir[0] * step * 0.5, world[1] + dir[1] * step * 0.5, world[2] + dir[2] * step * 0.5];
171
+ const d = { x: [0, 0, 0], y: [0, 0, 0], z: [0, 0, 0] };
172
+ for (let i = 0; i < 1024; i++) {
173
+ const uvw = uvwOf(probe);
174
+ if (uvw.some((v) => v < 0 || v > 1) || Math.min(...vdbFrameSpectralShadowMarchDepth(d, multipleScattering, octaves)) > 6)
175
+ break;
176
+ const s = gridAt(cascade, uvw);
177
+ const st = vdbFrameSpectralShadowStep(s.extinction, s.absorption, multipleScattering);
178
+ for (let c = 0; c < 3; c++) {
179
+ d.x[c] = d.x[c] + st.x[c] * step;
180
+ d.y[c] = d.y[c] + st.y[c] * step;
181
+ d.z[c] = d.z[c] + st.z[c] * step;
182
+ probe[c] = probe[c] + dir[c] * step;
183
+ }
184
+ }
185
+ return d;
186
+ };
187
+ const irradiance = [0, 0, 0];
188
+ for (const l of lights) {
189
+ const d = marchDepths(l.direction);
190
+ const total = multipleScattering > 0
191
+ ? map3((c) => vdbFrameIsotropicDiffusion(d.z[c], marchDepths([-l.direction[0], -l.direction[1], -l.direction[2]]).z[c], d.y[c]))
192
+ : vdbFrameSpectralShadowTotal(vdbFrameSpectralShadowTransmittance(d, multipleScattering, octaves).y, octaves, albedo);
193
+ for (let c = 0; c < 3; c++)
194
+ irradiance[c] = irradiance[c] + l.color[c] * total[c];
195
+ }
196
+ return [Math.max(irradiance[0], 0), Math.max(irradiance[1], 0), Math.max(irradiance[2], 0), 1];
197
+ }
198
+ const smoothstep = (e0, e1, x) => {
199
+ const t = Math.min(Math.max((x - e0) / (e1 - e0), 0), 1);
200
+ return t * t * (3 - 2 * t);
201
+ };
202
+ /**
203
+ * sampleShadows of every slot group in use at a world position (the core's spectral stack: `targetAt(cascade, group, k,
204
+ * uvw)`), 1 outside the grid, blended toward the next cascade within 10% of a cascade's sides. Groups past `groups`: 1.
205
+ */
206
+ export function vdbFrameSpectralStackGroups(targetAt, grid, world, groups) {
207
+ const out = [0, 1, 2, 3].map(() => [0, 1, 2].map(() => [1, 1, 1, 1]));
208
+ const cascade = vdbFrameFindCascade(grid, world, 0);
209
+ if (cascade < 0)
210
+ return out;
211
+ const uvw = vdbFrameGridUvw(grid, cascade, world);
212
+ const side = Math.min(uvw[0], uvw[1], uvw[2], 1 - uvw[0], 1 - uvw[1], 1 - uvw[2]);
213
+ const blend = 1 - smoothstep(0, 0.1, side);
214
+ const next = blend > 0 ? vdbFrameFindCascade(grid, world, cascade + 1) : -1;
215
+ for (let g = 0; g < Math.min(groups, 4); g++) {
216
+ for (let k = 0; k < 3; k++) {
217
+ let v = targetAt(cascade, g, k, uvw);
218
+ if (next >= 0) {
219
+ const w = targetAt(next, g, k, vdbFrameGridUvw(grid, next, world));
220
+ v = v.map((x, c) => x + (w[c] - x) * blend);
221
+ }
222
+ out[g][k] = v;
223
+ }
224
+ }
225
+ return out;
226
+ }
227
+ /**
228
+ * The core's spectral density sums of one volume in one froxel (his spectral density pass): the pre-integration with the
229
+ * transmittance of each channel (the visible position weighs the channel mean), the extinction-weighted sums; null when
230
+ * the weight is not > 0. `fragCoord` is his atlas pixel.
231
+ */
232
+ export function vdbFrameSpectralDensitySums(fragCoord, p) {
233
+ const f = vdbFrameDensityFroxelSteps(fragCoord, p);
234
+ if (!f)
235
+ return null;
236
+ const { viewNear, viewFar, localNear, localFar, t0, segment, steps, subStepLength, lod, jitter, mul } = f;
237
+ const lerp3 = (x, y, t) => [x[0] + (y[0] - x[0]) * t, x[1] + (y[1] - x[1]) * t, x[2] + (y[2] - x[2]) * t];
238
+ const spectrum = p.extinctionSpectrum;
239
+ let extinctionSum = 0;
240
+ const transmittance = [1, 1, 1];
241
+ let visibleWeight = 0;
242
+ let visibleTSum = 0;
243
+ for (let i = 0; i < steps; i++) {
244
+ const t = t0 + segment * ((i + jitter) / steps);
245
+ const e = vdbFrameSliceExtinction(p, fragCoord, i, lerp3(localNear, localFar, t), lod) * p.opacity * vdbFrameDistanceFade(p.fadeRadius, lerp3(viewNear, viewFar, t));
246
+ const stepT = map3((c) => Math.exp(-spectrum[c] * e * subStepLength));
247
+ const w = vdbFrameMeanComponent(map3((c) => transmittance[c] * (1 - stepT[c])));
248
+ visibleWeight += w;
249
+ visibleTSum += w * t;
250
+ extinctionSum += e;
251
+ for (let c = 0; c < 3; c++)
252
+ transmittance[c] = transmittance[c] * stepT[c];
253
+ }
254
+ const extinction = map3((c) => spectrum[c] * ((extinctionSum / steps) * segment));
255
+ const weight = vdbFrameMeanComponent(extinction);
256
+ if (!(weight > 0))
257
+ return null;
258
+ const visibleT = visibleWeight > 0 ? visibleTSum / visibleWeight : 0.5;
259
+ const local = lerp3(localNear, localFar, visibleT);
260
+ const world = mul(p.cameraWorld, lerp3(viewNear, viewFar, visibleT));
261
+ const albedo = p.albedoAt ? p.albedoAt(local, lod) : [...p.baseColor];
262
+ const own = p.emissionAt ? p.emissionAt(local, lod) : [0, 0, 0];
263
+ const emission = map3((c) => own[c] + p.scatterColor[c]);
264
+ if (p.environmentAt) {
265
+ const m = p.cameraWorld;
266
+ const seg = [viewFar[0] - viewNear[0], viewFar[1] - viewNear[1], viewFar[2] - viewNear[2]];
267
+ const ray = normalize3(map3((r) => m[r] * seg[0] + m[4 + r] * seg[1] + m[8 + r] * seg[2]));
268
+ const env = p.environmentAt(world, local, albedo, ray);
269
+ for (let c = 0; c < 3; c++)
270
+ emission[c] = emission[c] + (albedo[c] * env[c]) / Math.PI;
271
+ }
272
+ return {
273
+ a: [albedo[0] * extinction[0], albedo[1] * extinction[1], albedo[2] * extinction[2], weight],
274
+ e: [emission[0] * weight, emission[1] * weight, emission[2] * weight, visibleT * weight],
275
+ x: [extinction[0], extinction[1], extinction[2], 0],
276
+ };
277
+ }
278
+ /**
279
+ * The core's spectral environment term of the density pass (`vdbFrameEnvironmentDensityTerm` of each channel): the
280
+ * environment grid at the visible position (outside: the unshadowed light × the spectral octave total of 1), nothing
281
+ * with the environment slot, else 'outward' SH irradiance shadowed between the sky down and up totals of each channel
282
+ * (`sky` (up, down) are group 0's entry a at the visible position, before the totals; K6.Q1a `ambientOcclusion`: the
283
+ * hemispherical visibilities, read as they are).
284
+ */
285
+ export function vdbFrameSpectralEnvironmentDensityTerm(env, flags, outward, skyDirection, sky, albedo, gridAt, octaves = vdbFrameOctavesOff, ambientOcclusion = false) {
286
+ if (!env.valid)
287
+ return [0, 0, 0];
288
+ const first = flags.slot ? 1 : 0;
289
+ if (flags.useShadows && flags.grid && env.count > first) {
290
+ const inside = gridAt();
291
+ if (inside)
292
+ return inside;
293
+ const sum = [0, 0, 0];
294
+ for (let i = first; i < env.count; i++)
295
+ for (let c = 0; c < 3; c++)
296
+ sum[c] = sum[c] + env.colors[i][c];
297
+ const total = vdbFrameSpectralShadowTotal([1, 1, 1], octaves, albedo);
298
+ return map3((c) => Math.max(sum[c], 0) * total[c]);
299
+ }
300
+ if (flags.useShadows && flags.slot && env.count > 0)
301
+ return [0, 0, 0];
302
+ const blend = (outward[0] * skyDirection[0] + outward[1] * skyDirection[1] + outward[2] * skyDirection[2]) * 0.5 + 0.5;
303
+ // K6.Q1a: with the shadowed ambient the entry holds the hemispherical visibilities (totals already)
304
+ const up = ambientOcclusion ? sky.x : vdbFrameSpectralShadowTotal(sky.x, octaves, albedo);
305
+ const down = ambientOcclusion ? sky.y : vdbFrameSpectralShadowTotal(sky.y, octaves, albedo);
306
+ const shadow = map3((c) => down[c] + (up[c] - down[c]) * blend);
307
+ const e = vdbFrameEnvironmentIrradiance(env.sh, outward);
308
+ if (!flags.diffusion)
309
+ return map3((c) => e[c] * shadow[c]);
310
+ const inward = map3((c) => up[c] + (down[c] - up[c]) * blend);
311
+ const back = vdbFrameEnvironmentIrradiance(env.sh, [-outward[0], -outward[1], -outward[2]]);
312
+ return map3((c) => (e[c] * shadow[c] + back[c] * inward[c]) * 0.5);
313
+ }
314
+ /**
315
+ * The 'volume' gather's spectral combine of the volumes in one froxel: (L · α rgb, α rgb). Per channel
316
+ * (τ = −log(1 − α), α = 1 − exp(−Στ), L = ΣτL / Στ); one volume gives (Lα, α).
317
+ */
318
+ export function vdbFrameGatherFroxelSpectral(volumes) {
319
+ const lit = volumes.filter((v) => Math.max(...v.alpha) > 0);
320
+ if (lit.length === 0)
321
+ return { color: [0, 0, 0], alpha: [0, 0, 0] };
322
+ if (lit.length === 1) {
323
+ const v = lit[0];
324
+ return { color: map3((c) => v.radiance[c] * v.alpha[c]), alpha: [...v.alpha] };
325
+ }
326
+ const tau = [0, 0, 0];
327
+ const tl = [0, 0, 0];
328
+ for (const v of lit) {
329
+ for (let c = 0; c < 3; c++) {
330
+ const t = Math.min(-Math.log(Math.max(1 - v.alpha[c], 0)), vdbFrameMaxOpticalDepth);
331
+ tau[c] = tau[c] + t;
332
+ tl[c] = tl[c] + t * v.radiance[c];
333
+ }
334
+ }
335
+ const alpha = map3((c) => 1 - Math.exp(-tau[c]));
336
+ return { color: map3((c) => (tau[c] > 0 ? (tl[c] / tau[c]) * alpha[c] : 0)), alpha };
337
+ }
338
+ /**
339
+ * The spectral resolve scan of one column (his spectral integrate loop over whole slices): `froxels[z]` = (scatter
340
+ * (L·α rgb, α green), alpha (α red, α blue, 0, α green)). Boundary k holds (Σ radiance rgb, 1 − T green) and the alpha
341
+ * prefix (1 − T red, 1 − T blue); a slice adds nothing once every channel's T < 0.001 (his maxComponent break).
342
+ */
343
+ export function vdbFrameScanColumnSpectral(froxels, o = {}) {
344
+ const stop = o.stop ?? 0.001;
345
+ const prefix = [[0, 0, 0, 0]];
346
+ const alpha = [[0, 0]];
347
+ const L = [0, 0, 0];
348
+ const T = [1, 1, 1];
349
+ for (const f of froxels) {
350
+ const a = [clamp01(f.alpha[0]), clamp01(f.scatter[3]), clamp01(f.alpha[1])];
351
+ if (Math.max(...T) >= stop && Math.max(...a) > 0) {
352
+ for (let c = 0; c < 3; c++) {
353
+ L[c] = L[c] + T[c] * f.scatter[c];
354
+ T[c] = T[c] * (1 - a[c]);
355
+ }
356
+ }
357
+ prefix.push([L[0], L[1], L[2], 1 - T[1]]);
358
+ alpha.push([1 - T[0], 1 - T[2]]);
359
+ }
360
+ return { prefix, alpha };
361
+ }
362
+ /**
363
+ * The spectral composite's two taps (`vdbFrameIntegrate` spectral): the grey two-tap formula for each channel, the red
364
+ * and blue opacity from the alpha prefix. Returns (radiance, transmittance of each channel).
365
+ */
366
+ export function vdbFrameIntegratePrefixSpectral(a, aAlpha, b, bAlpha, c) {
367
+ const r = vdbFrameIntegratePrefix([a[0], 0, 0, aAlpha[0]], [b[0], 0, 0, bAlpha[0]], c);
368
+ const g = vdbFrameIntegratePrefix([a[1], 0, 0, a[3]], [b[1], 0, 0, b[3]], c);
369
+ const bl = vdbFrameIntegratePrefix([a[2], 0, 0, aAlpha[1]], [b[2], 0, 0, bAlpha[1]], c);
370
+ return { radiance: [r.radiance[0], g.radiance[0], bl.radiance[0]], transmittance: [r.transmittance, g.transmittance, bl.transmittance] };
371
+ }
372
+ /**
373
+ * His spectral composite (`vdbFrameCompositeSpectralColor`): the scene colour × the transmittance of each channel + the
374
+ * radiance, or (sRGB) the per-channel mix in sRGB (clamped to [0, 1] when `clampColors`); alpha from green.
375
+ */
376
+ export function vdbFrameCompositeSpectral(radiance, transmittance, scene, srgb, clampColors = true) {
377
+ const alpha = map3((c) => 1 - transmittance[c]);
378
+ const outAlpha = alpha[1] + scene[3] * (1 - alpha[1]);
379
+ if (!srgb)
380
+ return [radiance[0] + scene[0] * transmittance[0], radiance[1] + scene[1] * transmittance[1], radiance[2] + scene[2] * transmittance[2], outAlpha];
381
+ const enc = (x) => (clampColors ? clamp01(vdbSrgbOetf(x)) : vdbSrgbOetf(x));
382
+ const out = map3((c) => {
383
+ const bg = enc(scene[c]);
384
+ const vol = enc(radiance[c] / Math.max(alpha[c], 1e-6));
385
+ return vdbSrgbEotf(bg + (vol - bg) * alpha[c]);
386
+ });
387
+ return [out[0], out[1], out[2], outAlpha];
388
+ }
389
+ /** Re-exported for the spectral 'frame' lighting twin: group entries of the core's 3 packed targets. */
390
+ export { vdbFrameUnpackSpectralGroup };
391
+ //# sourceMappingURL=spectral-stack.js.map