@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,290 @@
1
+ // Portions derived from mjurczyk/openvdb (MIT), commit 75e7345 (v0.26.0):
2
+ // src/three-openvdb/frame/webgpu/frameShaderChunks.js L1061–1194 (createGridNodes: sampleTiles, sampleShadows),
3
+ // FrameShadowDensityMaterial.js L111–155 (the shadow density pass at one voxel).
4
+ // Copyright (c) mjurczyk/openvdb contributors. Licensed under the MIT License (see THIRD_PARTY_NOTICES.md).
5
+ // Changes: stacked 3D textures instead of his 2D slice atlases (K6.2, design §3.2): the layout of the sub-volumes
6
+ // and the hardware trilinear sample of one, as f64 CPU twins of the core kernels. Divergences: DIVERGES.md.
7
+ /**
8
+ * Stacked 3D textures of the core frame renderer (K6.2, design §3.2): several logical R³ grids (cascades × targets)
9
+ * are sub-volumes of one 3D texture, tiled along z, then x, then y within the device's `maxTextureDimension3D`. A
10
+ * read clamps the coordinate to the sub-volume's half-texel box, which equals clamp-to-edge per sub-volume and is his
11
+ * `sampleTiles` (bilinear in a slice, linear between slices, both clamped). The core imports the layout; the
12
+ * `k6-core` harness compares the kernels against these twins.
13
+ */
14
+ import { vdbFrameFindCascade, vdbFrameGridMarch, vdbFrameGridUvw, vdbFrameIsotropicDiffusion } from "./grid.js";
15
+ import { vdbFrameNoise, vdbFrameOctavesOff, vdbFrameShadowAbsorption, vdbFrameShadowDepth, vdbFrameShadowMarchDepth, vdbFrameShadowStep, vdbFrameShadowTotal, vdbFrameShadowTransmittance, vdbFrameTwoSidedDiffusion, } from "./index.js";
16
+ import { vdbFrameOccludedTotal } from "./occluders.js";
17
+ import { vdbFrameAmbientDipole, vdbFrameAmbientPairTotals, vdbFrameAmbientVisibility } from "./ambient.js";
18
+ /**
19
+ * The layout of `count` cubes of `side` texels in one 3D texture: along z first (as many as fit in
20
+ * `maxDimension`), then further columns along x, then rows along y. Throws when they do not fit.
21
+ */
22
+ export function vdbFrameStackLayout(side, count, maxDimension = 2048) {
23
+ const perAxis = Math.floor(maxDimension / side);
24
+ if (perAxis < 1 || count > perAxis * perAxis * perAxis)
25
+ throw new RangeError(`vdbFrameStackLayout: ${count} sub-volumes of ${side}³ do not fit ${maxDimension}³`);
26
+ const alongZ = Math.min(count, perAxis);
27
+ const columns = Math.min(Math.ceil(count / alongZ), perAxis);
28
+ const rows = Math.ceil(count / (alongZ * columns));
29
+ const origins = [];
30
+ for (let i = 0; i < count; i++) {
31
+ const z = i % alongZ;
32
+ const x = Math.floor(i / alongZ) % columns;
33
+ const y = Math.floor(i / (alongZ * columns));
34
+ origins.push([x * side, y * side, z * side]);
35
+ }
36
+ return { size: [columns * side, rows * side, alongZ * side], origins };
37
+ }
38
+ /** Hardware trilinear filtering (texel centres at i + ½, clamp to edge) of a 3D texture at texel coordinates `p`. */
39
+ export function vdbFrameTrilinear(t, p) {
40
+ const [W, H, D] = t.size;
41
+ const f = [p[0] - 0.5, p[1] - 0.5, p[2] - 0.5];
42
+ const i0 = f.map(Math.floor);
43
+ const w = f.map((v, a) => v - i0[a]);
44
+ const cl = (i, n) => Math.min(Math.max(i, 0), n - 1);
45
+ const out = new Array(t.channels).fill(0);
46
+ for (let k = 0; k < 8; k++) {
47
+ const dx = k & 1;
48
+ const dy = (k >> 1) & 1;
49
+ const dz = (k >> 2) & 1;
50
+ const weight = (dx ? w[0] : 1 - w[0]) * (dy ? w[1] : 1 - w[1]) * (dz ? w[2] : 1 - w[2]);
51
+ if (weight === 0)
52
+ continue;
53
+ const at = (cl(i0[0] + dx, W) + (cl(i0[1] + dy, H) + cl(i0[2] + dz, D) * H) * W) * t.channels;
54
+ for (let c = 0; c < t.channels; c++)
55
+ out[c] += t.data[at + c] * weight;
56
+ }
57
+ return out;
58
+ }
59
+ /** `vdbFrameStackSample`: the sub-volume at `origin` (side `side`) at `uvw`, clamped to its half-texel box. */
60
+ export function vdbFrameStackSample(t, origin, side, uvw) {
61
+ return vdbFrameTrilinear(t, [0, 1, 2].map((a) => origin[a] + Math.min(Math.max(uvw[a] * side, 0.5), side - 0.5)));
62
+ }
63
+ /** His grid atlas pixel of a voxel (the jitter noise coordinate): tile `cascade · R + z` of `columns` columns. */
64
+ export function vdbFrameGridFragCoord(resolution, columns, cascade, cell) {
65
+ const tile = cascade * resolution + cell[2];
66
+ return [(tile % columns) * resolution + cell[0] + 0.5, Math.floor(tile / columns) * resolution + cell[1] + 0.5];
67
+ }
68
+ /** The world position of grid voxel `cell` of `cascade` (his getGridCell + gridMin + uvw · gridSize). */
69
+ export function vdbFrameGridVoxelWorld(grid, cascade, cell) {
70
+ const m = grid.gridMin[cascade];
71
+ const s = grid.gridSize[cascade];
72
+ const r = grid.resolution;
73
+ return [m[0] + ((cell[0] + 0.5) / r) * s[0], m[1] + ((cell[1] + 0.5) / r) * s[1], m[2] + ((cell[2] + 0.5) / r) * s[2]];
74
+ }
75
+ /**
76
+ * The shadow density pass at one voxel (`vdbFrameGridDensityCs`): the summed (extinction, absorption) of the casters
77
+ * whose unit box holds the voxel centre, each read at the voxel's lod (`voxelSize` = the cascade's largest voxel side).
78
+ */
79
+ export function vdbFrameGridDensityVoxel(world, voxelSize, casters) {
80
+ let extinction = 0;
81
+ let absorption = 0;
82
+ for (const c of casters) {
83
+ const m = c.worldToLocal;
84
+ const local = [0, 1, 2].map((r) => m[r] * world[0] + m[4 + r] * world[1] + m[8 + r] * world[2] + m[12 + r]);
85
+ if (Math.max(Math.abs(local[0]), Math.abs(local[1]), Math.abs(local[2])) > 0.5)
86
+ continue;
87
+ const lod = Math.max(0, Math.log2((voxelSize / c.worldScale) * c.maxTexels));
88
+ const readLod = c.mipmaps ? lod : 0;
89
+ const e = c.extinctionAt(local, readLod) * c.absorbance;
90
+ if (!(e > 0))
91
+ continue;
92
+ extinction += e;
93
+ absorption += vdbFrameShadowAbsorption(e, c.albedoAt(local, readLod));
94
+ }
95
+ return [extinction, absorption];
96
+ }
97
+ /**
98
+ * The transmittance pass (grey) at voxel `cell` of `cascade`, through a grid sampled by `gridAt(cascade, uvw)`
99
+ * ((extinction, absorption) of that cascade): the 4 targets of `vdbFrameTransmittanceCs`. `lights` are the slots
100
+ * (≤ 6), `jitter` the frame's (< 0: off); the noise reads his grid atlas pixel. K6.3 `modes`: octaves, two-sided and
101
+ * the slot total of 'mlp' / 'multi-scale'.
102
+ */
103
+ export function vdbFrameTransmittanceVoxel3d(gridAt, grid, cascade, cell, lights, skyDirection, multipleScattering, jitter, visibility = null, modes = {}) {
104
+ const out = [
105
+ [1, 1, 1, 1],
106
+ [1, 1, 1, 1],
107
+ [1, 1, 1, 1],
108
+ [1, 1, 1, 1],
109
+ ];
110
+ const dipoleOn = !!modes.ambientDipole && !!modes.ambientDirections && modes.ambientDirections.length > 0;
111
+ if (dipoleOn)
112
+ out.dipole = [0, 0, 0, 0];
113
+ const world = vdbFrameGridVoxelWorld(grid, cascade, cell);
114
+ const voxel = grid.gridVoxel[cascade];
115
+ const extinctionAt = (p) => {
116
+ const c = vdbFrameFindCascade(grid, p, 0);
117
+ return c < 0 ? [0, 0] : gridAt(c, vdbFrameGridUvw(grid, c, p));
118
+ };
119
+ let near = 0;
120
+ for (let i = 0; i < 8; i++) {
121
+ const c = [(i & 1) - 0.5, ((i >> 1) & 1) - 0.5, ((i >> 2) & 1) - 0.5];
122
+ near += extinctionAt([world[0] + c[0] * voxel[0], world[1] + c[1] * voxel[1], world[2] + c[2] * voxel[2]])[0];
123
+ }
124
+ if (!(near > 0))
125
+ return out;
126
+ const noise = vdbFrameNoise(jitter, vdbFrameGridFragCoord(grid.resolution, grid.columns, cascade, cell));
127
+ const n = (v) => {
128
+ const l = Math.hypot(v[0], v[1], v[2]);
129
+ return l > 0 ? [v[0] / l, v[1] / l, v[2] / l] : [0, 0, 0];
130
+ };
131
+ const sky = n(skyDirection);
132
+ const octaves = modes.octaves ?? vdbFrameOctavesOff;
133
+ const slot = (i) => {
134
+ if (i >= lights.length)
135
+ return [1, 1, 0, 0];
136
+ const l = lights[i];
137
+ const isDirection = l[3] < 1.5;
138
+ const toLight = [l[0] - world[0], l[1] - world[1], l[2] - world[2]];
139
+ const dir = isDirection ? n([l[0], l[1], l[2]]) : n(toLight);
140
+ const maxDistance = isDirection ? 1e20 : Math.hypot(...toLight);
141
+ const optical = { opticalDepth: 0 };
142
+ const r = vdbFrameGridMarch(extinctionAt, grid, world, dir, maxDistance, noise, multipleScattering, octaves, optical);
143
+ // K6.3 'two-sided': the slab between the light side and the far side
144
+ if (modes.twoSided)
145
+ r[1] = vdbFrameTwoSidedDiffusion(r[0], r[2], r[3], vdbFrameGridMarch(extinctionAt, grid, world, [-dir[0], -dir[1], -dir[2]], 1e20, noise, multipleScattering, octaves)[2]);
146
+ // K6.3 'mlp' / 'multi-scale': the total from the direct transmittance
147
+ if (modes.slotTotal)
148
+ r[1] = modes.slotTotal(r[0], world, dir, optical.opticalDepth, maxDistance);
149
+ return r;
150
+ };
151
+ const ls = [0, 1, 2, 3, 4, 5].map(slot);
152
+ // K6.5b: a host occluder map scales the slot's scattered part by the voxel's visibility (the direct stays unoccluded),
153
+ // after the K6.3 mode's own total; octaves keep 1 / (1 + depth) (the gather occludes their light)
154
+ if (visibility && !(octaves[0] > 0)) {
155
+ for (let i = 0; i < Math.min(lights.length, 6); i++) {
156
+ const s = ls[i];
157
+ s[1] = vdbFrameOccludedTotal(s[0], s[1], visibility(i, world));
158
+ }
159
+ }
160
+ // K7.15: the sky marches only when something reads them (the AO pairs read pair 0 from them)
161
+ const dirs = modes.ambientDirections;
162
+ const skyMarch = modes.skyMarch !== false || (!!dirs && dirs.length > 0);
163
+ const unmarched = [1, 1, 0, 0];
164
+ const up = skyMarch ? vdbFrameGridMarch(extinctionAt, grid, world, sky, 1e20, noise, multipleScattering, octaves) : unmarched;
165
+ const down = skyMarch ? vdbFrameGridMarch(extinctionAt, grid, world, [-sky[0], -sky[1], -sky[2]], 1e20, noise, multipleScattering, octaves) : unmarched;
166
+ const skyTotal = (f, b) => (multipleScattering > 0 && skyMarch ? vdbFrameIsotropicDiffusion(f[2], b[2], f[3]) : f[1]);
167
+ out[0] = [skyTotal(up, down), skyTotal(down, up), ls[0][1], ls[1][1]];
168
+ out[1] = [ls[2][1], ls[3][1], ls[4][1], ls[5][1]];
169
+ out[2] = [ls[0][0], ls[1][0], ls[2][0], ls[3][0]];
170
+ out[3] = [ls[4][0], ls[5][0], 1, 1];
171
+ // K6.Q1: each pair's isotropic-light totals (pair 0: the sky up / down marches), averaged per side
172
+ if (dirs && dirs.length > 0) {
173
+ const totals = dirs.map((d, k) => {
174
+ const front = k === 0 ? up : vdbFrameGridMarch(extinctionAt, grid, world, d, 1e20, noise, multipleScattering, octaves);
175
+ const back = k === 0 ? down : vdbFrameGridMarch(extinctionAt, grid, world, [-d[0], -d[1], -d[2]], 1e20, noise, multipleScattering, octaves);
176
+ return vdbFrameAmbientPairTotals(front, back, multipleScattering > 0, octaves);
177
+ });
178
+ const v = vdbFrameAmbientVisibility(totals);
179
+ out[3][2] = v[0];
180
+ out[3][3] = v[1];
181
+ // K6.Q1d: the pairs' dipole b
182
+ if (dipoleOn)
183
+ out.dipole = [...vdbFrameAmbientDipole(totals, dirs, modes.ambientDipole), 0];
184
+ }
185
+ return out;
186
+ }
187
+ const smoothstep = (e0, e1, x) => {
188
+ const t = Math.min(Math.max((x - e0) / (e1 - e0), 0), 1);
189
+ return t * t * (3 - 2 * t);
190
+ };
191
+ /**
192
+ * K6.Q1d: one stacked target at a world position (`targetAt(cascade, uvw)`; the dipole: `vdbFrameStackDipole`), blended
193
+ * toward the next cascade as {@link vdbFrameStackShadows}; `outside` outside the grid.
194
+ */
195
+ export function vdbFrameStackTarget(targetAt, grid, world, outside) {
196
+ const cascade = vdbFrameFindCascade(grid, world, 0);
197
+ if (cascade < 0)
198
+ return [...outside];
199
+ const uvw = vdbFrameGridUvw(grid, cascade, world);
200
+ let out = targetAt(cascade, uvw);
201
+ const side = Math.min(uvw[0], uvw[1], uvw[2], 1 - uvw[0], 1 - uvw[1], 1 - uvw[2]);
202
+ const blend = 1 - smoothstep(0, 0.1, side);
203
+ if (blend > 0) {
204
+ const next = vdbFrameFindCascade(grid, world, cascade + 1);
205
+ if (next >= 0) {
206
+ const v = targetAt(next, vdbFrameGridUvw(grid, next, world));
207
+ out = out.map((x, c) => x + (v[c] - x) * blend);
208
+ }
209
+ }
210
+ return out;
211
+ }
212
+ /**
213
+ * sampleShadows on a stacked transmittance texture: the 4 targets at a world position (`targetAt(cascade, k, uvw)`),
214
+ * 1 outside the grid, blended toward the next cascade within 10% of a cascade's sides.
215
+ */
216
+ export function vdbFrameStackShadows(targetAt, grid, world) {
217
+ const out = [0, 1, 2, 3].map(() => [1, 1, 1, 1]);
218
+ const cascade = vdbFrameFindCascade(grid, world, 0);
219
+ if (cascade < 0)
220
+ return out;
221
+ const uvw = vdbFrameGridUvw(grid, cascade, world);
222
+ for (let k = 0; k < 4; k++)
223
+ out[k] = targetAt(cascade, k, uvw);
224
+ const side = Math.min(uvw[0], uvw[1], uvw[2], 1 - uvw[0], 1 - uvw[1], 1 - uvw[2]);
225
+ const blend = 1 - smoothstep(0, 0.1, side);
226
+ if (blend > 0) {
227
+ const next = vdbFrameFindCascade(grid, world, cascade + 1);
228
+ if (next >= 0) {
229
+ const nextUvw = vdbFrameGridUvw(grid, next, world);
230
+ for (let k = 0; k < 4; k++) {
231
+ const v = targetAt(next, k, nextUvw);
232
+ out[k] = out[k].map((x, c) => x + (v[c] - x) * blend);
233
+ }
234
+ }
235
+ }
236
+ return out;
237
+ }
238
+ /**
239
+ * The environment grid pass (grey; K6.2b) at voxel `cell` of the last cascade, through a grid sampled by
240
+ * `gridAt(cascade, uvw)`: `unshadowed` (the colour sum of `lights`, ≥ 0) where no extinction is within half a voxel,
241
+ * else Σ colour × total of one-voxel-step marches that stay in the last cascade (with diffusion the two-sided total of
242
+ * the march and the opposite one), ≥ 0. His FrameEnvironmentGridMaterial on a 3D grid. K6.3 `octaves`: the march
243
+ * stops at the last octave's depth, totals are octave sums, and the unshadowed light gets the octave total of 1.
244
+ */
245
+ export function vdbFrameEnvironmentGridVoxel3d(gridAt, grid, cell, lights, multipleScattering, octaves = vdbFrameOctavesOff) {
246
+ const cascade = grid.count - 1;
247
+ const world = vdbFrameGridVoxelWorld(grid, cascade, cell);
248
+ const voxel = grid.gridVoxel[cascade];
249
+ const uvwOf = (p) => vdbFrameGridUvw(grid, cascade, p);
250
+ const unshadowed = [0, 0, 0];
251
+ for (const l of lights)
252
+ for (let c = 0; c < 3; c++)
253
+ unshadowed[c] = unshadowed[c] + l.color[c];
254
+ let near = 0;
255
+ for (let i = 0; i < 8; i++) {
256
+ const c = [(i & 1) - 0.5, ((i >> 1) & 1) - 0.5, ((i >> 2) & 1) - 0.5];
257
+ near += gridAt(cascade, uvwOf([world[0] + c[0] * voxel[0], world[1] + c[1] * voxel[1], world[2] + c[2] * voxel[2]]))[0];
258
+ }
259
+ const outside = vdbFrameShadowTotal(1, octaves);
260
+ if (!(near > 0))
261
+ return [Math.max(unshadowed[0], 0) * outside, Math.max(unshadowed[1], 0) * outside, Math.max(unshadowed[2], 0) * outside, 1];
262
+ const marchDepths = (dir) => {
263
+ const step = 1 / Math.max(Math.abs(dir[0]) / voxel[0], Math.abs(dir[1]) / voxel[1], Math.abs(dir[2]) / voxel[2]);
264
+ const probe = [world[0] + dir[0] * step * 0.5, world[1] + dir[1] * step * 0.5, world[2] + dir[2] * step * 0.5];
265
+ const depths = [0, 0, 0];
266
+ for (let i = 0; i < 1024; i++) {
267
+ const uvw = uvwOf(probe);
268
+ if (uvw.some((v) => v < 0 || v > 1) || vdbFrameShadowMarchDepth(depths, multipleScattering, octaves) > 6)
269
+ break;
270
+ const s = gridAt(cascade, uvw);
271
+ const d = vdbFrameShadowStep(s[0], s[1], multipleScattering);
272
+ for (let c = 0; c < 3; c++) {
273
+ depths[c] = depths[c] + d[c] * step;
274
+ probe[c] = probe[c] + dir[c] * step;
275
+ }
276
+ }
277
+ return depths;
278
+ };
279
+ const irradiance = [0, 0, 0];
280
+ for (const l of lights) {
281
+ const depths = marchDepths(l.direction);
282
+ const total = multipleScattering > 0
283
+ ? vdbFrameIsotropicDiffusion(depths[2], marchDepths([-l.direction[0], -l.direction[1], -l.direction[2]])[2], depths[1])
284
+ : vdbFrameShadowTotal(vdbFrameShadowTransmittance(depths, multipleScattering, octaves)[1], octaves);
285
+ for (let c = 0; c < 3; c++)
286
+ irradiance[c] = irradiance[c] + l.color[c] * total;
287
+ }
288
+ return [Math.max(irradiance[0], 0), Math.max(irradiance[1], 0), Math.max(irradiance[2], 0), 1];
289
+ }
290
+ //# sourceMappingURL=stack.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"stack.js","sourceRoot":"","sources":["../../../src/tools/frame/stack.ts"],"names":[],"mappings":"AAAA,0EAA0E;AAC1E,kHAAkH;AAClH,mFAAmF;AACnF,4GAA4G;AAC5G,kHAAkH;AAClH,4GAA4G;AAE5G;;;;;;GAMG;AAEH,OAAO,EAAE,mBAAmB,EAAE,iBAAiB,EAAE,eAAe,EAAE,0BAA0B,EAAqD,MAAM,WAAW,CAAC;AACnK,OAAO,EACL,aAAa,EACb,kBAAkB,EAClB,wBAAwB,EACxB,mBAAmB,EACnB,wBAAwB,EACxB,kBAAkB,EAClB,mBAAmB,EACnB,2BAA2B,EAC3B,yBAAyB,GAI1B,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,qBAAqB,EAAE,MAAM,gBAAgB,CAAC;AACvD,OAAO,EAAE,qBAAqB,EAAE,yBAAyB,EAAE,yBAAyB,EAAE,MAAM,cAAc,CAAC;AAU3G;;;GAGG;AACH,MAAM,UAAU,mBAAmB,CAAC,IAAY,EAAE,KAAa,EAAE,YAAY,GAAG,IAAI;IAClF,MAAM,OAAO,GAAG,IAAI,CAAC,KAAK,CAAC,YAAY,GAAG,IAAI,CAAC,CAAC;IAChD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nF,CAAC;IACD,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,IAAI,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,IAAI,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;AACjG,CAAC","sourcesContent":["// Portions derived from mjurczyk/openvdb (MIT), commit 75e7345 (v0.26.0):\n// src/three-openvdb/frame/webgpu/frameShaderChunks.js L1061–1194 (createGridNodes: sampleTiles, sampleShadows),\n// FrameShadowDensityMaterial.js L111–155 (the shadow density pass at one voxel).\n// Copyright (c) mjurczyk/openvdb contributors. Licensed under the MIT License (see THIRD_PARTY_NOTICES.md).\n// Changes: stacked 3D textures instead of his 2D slice atlases (K6.2, design §3.2): the layout of the sub-volumes\n// and the hardware trilinear sample of one, as f64 CPU twins of the core kernels. Divergences: DIVERGES.md.\n\n/**\n * Stacked 3D textures of the core frame renderer (K6.2, design §3.2): several logical R³ grids (cascades × targets)\n * are sub-volumes of one 3D texture, tiled along z, then x, then y within the device's `maxTextureDimension3D`. A\n * read clamps the coordinate to the sub-volume's half-texel box, which equals clamp-to-edge per sub-volume and is his\n * `sampleTiles` (bilinear in a slice, linear between slices, both clamped). The core imports the layout; the\n * `k6-core` harness compares the kernels against these twins.\n */\n\nimport { vdbFrameFindCascade, vdbFrameGridMarch, vdbFrameGridUvw, vdbFrameIsotropicDiffusion, type VDBFrameGridLayout, type VDBFrameShadowLight } from \"./grid.js\";\nimport {\n vdbFrameNoise,\n vdbFrameOctavesOff,\n vdbFrameShadowAbsorption,\n vdbFrameShadowDepth,\n vdbFrameShadowMarchDepth,\n vdbFrameShadowStep,\n vdbFrameShadowTotal,\n vdbFrameShadowTransmittance,\n vdbFrameTwoSidedDiffusion,\n type Vec2,\n type Vec3,\n type Vec4,\n} from \"./index.js\";\nimport { vdbFrameOccludedTotal } from \"./occluders.js\";\nimport { vdbFrameAmbientDipole, vdbFrameAmbientPairTotals, vdbFrameAmbientVisibility } from \"./ambient.js\";\n\n/** Where the sub-volumes of a stack sit. */\nexport interface VDBFrameStackLayout {\n /** The 3D texture's size in texels. */\n readonly size: [number, number, number];\n /** Texel origin of each sub-volume, in order. */\n readonly origins: [number, number, number][];\n}\n\n/**\n * The layout of `count` cubes of `side` texels in one 3D texture: along z first (as many as fit in\n * `maxDimension`), then further columns along x, then rows along y. Throws when they do not fit.\n */\nexport function vdbFrameStackLayout(side: number, count: number, maxDimension = 2048): VDBFrameStackLayout {\n const perAxis = Math.floor(maxDimension / side);\n if (perAxis < 1 || count > perAxis * perAxis * perAxis) throw new RangeError(`vdbFrameStackLayout: ${count} sub-volumes of ${side}³ do not fit ${maxDimension}³`);\n const alongZ = Math.min(count, perAxis);\n const columns = Math.min(Math.ceil(count / alongZ), perAxis);\n const rows = Math.ceil(count / (alongZ * columns));\n const origins: [number, number, number][] = [];\n for (let i = 0; i < count; i++) {\n const z = i % alongZ;\n const x = Math.floor(i / alongZ) % columns;\n const y = Math.floor(i / (alongZ * columns));\n origins.push([x * side, y * side, z * side]);\n }\n return { size: [columns * side, rows * side, alongZ * side], origins };\n}\n\n/** A read-back 3D texture: `data` is `channels` values per texel, x fastest, then y, then z. */\nexport interface VDBFrameTexture3d {\n readonly data: ArrayLike<number>;\n readonly size: readonly [number, number, number];\n readonly channels: number;\n}\n\n/** Hardware trilinear filtering (texel centres at i + ½, clamp to edge) of a 3D texture at texel coordinates `p`. */\nexport function vdbFrameTrilinear(t: VDBFrameTexture3d, p: readonly number[]): number[] {\n const [W, H, D] = t.size;\n const f = [p[0]! - 0.5, p[1]! - 0.5, p[2]! - 0.5];\n const i0 = f.map(Math.floor);\n const w = f.map((v, a) => v - i0[a]!);\n const cl = (i: number, n: number) => Math.min(Math.max(i, 0), n - 1);\n const out = new Array<number>(t.channels).fill(0);\n for (let k = 0; k < 8; k++) {\n const dx = k & 1;\n const dy = (k >> 1) & 1;\n const dz = (k >> 2) & 1;\n const weight = (dx ? w[0]! : 1 - w[0]!) * (dy ? w[1]! : 1 - w[1]!) * (dz ? w[2]! : 1 - w[2]!);\n if (weight === 0) continue;\n const at = (cl(i0[0]! + dx, W) + (cl(i0[1]! + dy, H) + cl(i0[2]! + dz, D) * H) * W) * t.channels;\n for (let c = 0; c < t.channels; c++) out[c]! += t.data[at + c]! * weight;\n }\n return out;\n}\n\n/** `vdbFrameStackSample`: the sub-volume at `origin` (side `side`) at `uvw`, clamped to its half-texel box. */\nexport function vdbFrameStackSample(t: VDBFrameTexture3d, origin: readonly number[], side: number, uvw: readonly number[]): number[] {\n return vdbFrameTrilinear(\n t,\n [0, 1, 2].map((a) => origin[a]! + Math.min(Math.max(uvw[a]! * side, 0.5), side - 0.5)),\n );\n}\n\n/** His grid atlas pixel of a voxel (the jitter noise coordinate): tile `cascade · R + z` of `columns` columns. */\nexport function vdbFrameGridFragCoord(resolution: number, columns: number, cascade: number, cell: Vec3): Vec2 {\n const tile = cascade * resolution + cell[2];\n return [(tile % columns) * resolution + cell[0] + 0.5, Math.floor(tile / columns) * resolution + cell[1] + 0.5];\n}\n\n/** The world position of grid voxel `cell` of `cascade` (his getGridCell + gridMin + uvw · gridSize). */\nexport function vdbFrameGridVoxelWorld(grid: VDBFrameGridLayout, cascade: number, cell: Vec3): Vec3 {\n const m = grid.gridMin[cascade]!;\n const s = grid.gridSize[cascade]!;\n const r = grid.resolution;\n return [m[0] + ((cell[0] + 0.5) / r) * s[0], m[1] + ((cell[1] + 0.5) / r) * s[1], m[2] + ((cell[2] + 0.5) / r) * s[2]];\n}\n\n/** One shadow caster as the shadow density pass reads it. */\nexport interface VDBFrameGridCaster {\n /** World → the local unit box (column-major). */\n readonly worldToLocal: ArrayLike<number>;\n /** The source's largest texel count (getLod) and the volume's max world scale. */\n readonly maxTexels: number;\n readonly worldScale: number;\n /** The volume reads mip levels (else level 0). */\n readonly mipmaps: boolean;\n readonly absorbance: number;\n /** sampleExtinction (extinction per world unit) and sampleAlbedo at a local position and lod. */\n extinctionAt(local: Vec3, lod: number): number;\n albedoAt(local: Vec3, lod: number): Vec3;\n}\n\n/**\n * The shadow density pass at one voxel (`vdbFrameGridDensityCs`): the summed (extinction, absorption) of the casters\n * whose unit box holds the voxel centre, each read at the voxel's lod (`voxelSize` = the cascade's largest voxel side).\n */\nexport function vdbFrameGridDensityVoxel(world: Vec3, voxelSize: number, casters: readonly VDBFrameGridCaster[]): Vec2 {\n let extinction = 0;\n let absorption = 0;\n for (const c of casters) {\n const m = c.worldToLocal;\n const local = [0, 1, 2].map((r) => m[r]! * world[0] + m[4 + r]! * world[1] + m[8 + r]! * world[2] + m[12 + r]!) as Vec3;\n if (Math.max(Math.abs(local[0]), Math.abs(local[1]), Math.abs(local[2])) > 0.5) continue;\n const lod = Math.max(0, Math.log2((voxelSize / c.worldScale) * c.maxTexels));\n const readLod = c.mipmaps ? lod : 0;\n const e = c.extinctionAt(local, readLod) * c.absorbance;\n if (!(e > 0)) continue;\n extinction += e;\n absorption += vdbFrameShadowAbsorption(e, c.albedoAt(local, readLod));\n }\n return [extinction, absorption];\n}\n\n/** K6.3: the multiple scattering terms of {@link vdbFrameTransmittanceVoxel3d} beyond the diffusion value. */\nexport interface VDBFrameTransmittanceModes3d {\n /** `getFrameScatteringOctaves` (count 0: off). */\n octaves?: Vec4;\n /** 'two-sided': each slot also marches away from the light (frameTwoSidedDiffusion). */\n twoSided?: boolean;\n /**\n * 'mlp' / 'multi-scale': a slot's total from its direct transmittance, the voxel's world position, the unit direction\n * to the light, the direct optical depth and the march length (e.g. direct + `vdbFrameMlpForward(...)`).\n */\n slotTotal?: ((direct: number, world: Vec3, direction: Vec3, opticalDepth: number, maxDistance: number) => number) | null;\n /**\n * K6.Q1 shadowed ambient: the pairs' upper directions (`vdbFrameAmbientDirections`; [0] the sky direction): the\n * fourth target's z, w become the hemispherical visibilities (V up, V down). Default none (1, 1).\n */\n ambientDirections?: readonly Vec3[] | null;\n /**\n * K6.Q1d ('frame' lighting's `ambientPhase: 'dipole'`, while read): M⁺ / 2 of the directions (`vdbFrameAmbientDipoleMatrix`, row-major): the\n * result's `dipole` is the fifth target, the pairs' dipole b (xyz, w 0; 0 where no extinction is near). Needs\n * `ambientDirections`. Default none.\n */\n ambientDipole?: readonly number[] | null;\n /**\n * K7.15 (his VDB-167): false when nothing reads the sky up / down totals (no probe, hemisphere light or 'outward'\n * environment, no AO pairs): the first target's x, y stay 1, unmarched. Default true. Ignored with\n * `ambientDirections` (pair 0 is the sky marches), as the kernel.\n */\n skyMarch?: boolean;\n}\n\n/** The grey transmittance targets of one voxel; K6.Q1d: `dipole`, the fifth target, with `modes.ambientDipole`. */\nexport type VDBFrameTransmittanceTargets3d = [Vec4, Vec4, Vec4, Vec4] & { dipole?: Vec4 };\n\n/**\n * The transmittance pass (grey) at voxel `cell` of `cascade`, through a grid sampled by `gridAt(cascade, uvw)`\n * ((extinction, absorption) of that cascade): the 4 targets of `vdbFrameTransmittanceCs`. `lights` are the slots\n * (≤ 6), `jitter` the frame's (< 0: off); the noise reads his grid atlas pixel. K6.3 `modes`: octaves, two-sided and\n * the slot total of 'mlp' / 'multi-scale'.\n */\nexport function vdbFrameTransmittanceVoxel3d(\n gridAt: (cascade: number, uvw: Vec3) => Vec2,\n grid: VDBFrameGridLayout,\n cascade: number,\n cell: Vec3,\n lights: readonly VDBFrameShadowLight[],\n skyDirection: Vec3,\n multipleScattering: number,\n jitter: number,\n visibility: ((slot: number, world: Vec3) => number) | null = null,\n modes: VDBFrameTransmittanceModes3d = {},\n): VDBFrameTransmittanceTargets3d {\n const out: VDBFrameTransmittanceTargets3d = [\n [1, 1, 1, 1],\n [1, 1, 1, 1],\n [1, 1, 1, 1],\n [1, 1, 1, 1],\n ];\n const dipoleOn = !!modes.ambientDipole && !!modes.ambientDirections && modes.ambientDirections.length > 0;\n if (dipoleOn) out.dipole = [0, 0, 0, 0];\n const world = vdbFrameGridVoxelWorld(grid, cascade, cell);\n const voxel = grid.gridVoxel[cascade]!;\n const extinctionAt = (p: Vec3): Vec2 => {\n const c = vdbFrameFindCascade(grid, p, 0);\n return c < 0 ? [0, 0] : gridAt(c, vdbFrameGridUvw(grid, c, p));\n };\n let near = 0;\n for (let i = 0; i < 8; i++) {\n const c: Vec3 = [(i & 1) - 0.5, ((i >> 1) & 1) - 0.5, ((i >> 2) & 1) - 0.5];\n near += extinctionAt([world[0] + c[0] * voxel[0], world[1] + c[1] * voxel[1], world[2] + c[2] * voxel[2]])[0];\n }\n if (!(near > 0)) return out;\n const noise = vdbFrameNoise(jitter, vdbFrameGridFragCoord(grid.resolution, grid.columns, cascade, cell));\n const n = (v: Vec3): Vec3 => {\n const l = Math.hypot(v[0], v[1], v[2]);\n return l > 0 ? [v[0] / l, v[1] / l, v[2] / l] : [0, 0, 0];\n };\n const sky = n(skyDirection);\n const octaves = modes.octaves ?? vdbFrameOctavesOff;\n const slot = (i: number): Vec4 => {\n if (i >= lights.length) return [1, 1, 0, 0];\n const l = lights[i]!;\n const isDirection = l[3] < 1.5;\n const toLight: Vec3 = [l[0] - world[0], l[1] - world[1], l[2] - world[2]];\n const dir = isDirection ? n([l[0], l[1], l[2]]) : n(toLight);\n const maxDistance = isDirection ? 1e20 : Math.hypot(...toLight);\n const optical = { opticalDepth: 0 };\n const r = vdbFrameGridMarch(extinctionAt, grid, world, dir, maxDistance, noise, multipleScattering, octaves, optical);\n // K6.3 'two-sided': the slab between the light side and the far side\n if (modes.twoSided) r[1] = vdbFrameTwoSidedDiffusion(r[0], r[2], r[3], vdbFrameGridMarch(extinctionAt, grid, world, [-dir[0], -dir[1], -dir[2]], 1e20, noise, multipleScattering, octaves)[2]);\n // K6.3 'mlp' / 'multi-scale': the total from the direct transmittance\n if (modes.slotTotal) r[1] = modes.slotTotal(r[0], world, dir, optical.opticalDepth, maxDistance);\n return r;\n };\n const ls = [0, 1, 2, 3, 4, 5].map(slot);\n // K6.5b: a host occluder map scales the slot's scattered part by the voxel's visibility (the direct stays unoccluded),\n // after the K6.3 mode's own total; octaves keep 1 / (1 + depth) (the gather occludes their light)\n if (visibility && !(octaves[0] > 0)) {\n for (let i = 0; i < Math.min(lights.length, 6); i++) {\n const s = ls[i]!;\n s[1] = vdbFrameOccludedTotal(s[0], s[1], visibility(i, world));\n }\n }\n // K7.15: the sky marches only when something reads them (the AO pairs read pair 0 from them)\n const dirs = modes.ambientDirections;\n const skyMarch = modes.skyMarch !== false || (!!dirs && dirs.length > 0);\n const unmarched: Vec4 = [1, 1, 0, 0];\n const up = skyMarch ? vdbFrameGridMarch(extinctionAt, grid, world, sky, 1e20, noise, multipleScattering, octaves) : unmarched;\n const down = skyMarch ? vdbFrameGridMarch(extinctionAt, grid, world, [-sky[0], -sky[1], -sky[2]], 1e20, noise, multipleScattering, octaves) : unmarched;\n const skyTotal = (f: Vec4, b: Vec4) => (multipleScattering > 0 && skyMarch ? vdbFrameIsotropicDiffusion(f[2], b[2], f[3]) : f[1]);\n out[0] = [skyTotal(up, down), skyTotal(down, up), ls[0]![1], ls[1]![1]];\n out[1] = [ls[2]![1], ls[3]![1], ls[4]![1], ls[5]![1]];\n out[2] = [ls[0]![0], ls[1]![0], ls[2]![0], ls[3]![0]];\n out[3] = [ls[4]![0], ls[5]![0], 1, 1];\n // K6.Q1: each pair's isotropic-light totals (pair 0: the sky up / down marches), averaged per side\n if (dirs && dirs.length > 0) {\n const totals = dirs.map((d, k) => {\n const front = k === 0 ? up : vdbFrameGridMarch(extinctionAt, grid, world, d, 1e20, noise, multipleScattering, octaves);\n const back = k === 0 ? down : vdbFrameGridMarch(extinctionAt, grid, world, [-d[0], -d[1], -d[2]], 1e20, noise, multipleScattering, octaves);\n return vdbFrameAmbientPairTotals(front, back, multipleScattering > 0, octaves);\n });\n const v = vdbFrameAmbientVisibility(totals);\n out[3][2] = v[0];\n out[3][3] = v[1];\n // K6.Q1d: the pairs' dipole b\n if (dipoleOn) out.dipole = [...vdbFrameAmbientDipole(totals, dirs, modes.ambientDipole!), 0];\n }\n return out;\n}\n\n\n\nconst smoothstep = (e0: number, e1: number, x: number) => {\n const t = Math.min(Math.max((x - e0) / (e1 - e0), 0), 1);\n return t * t * (3 - 2 * t);\n};\n\n/**\n * K6.Q1d: one stacked target at a world position (`targetAt(cascade, uvw)`; the dipole: `vdbFrameStackDipole`), blended\n * toward the next cascade as {@link vdbFrameStackShadows}; `outside` outside the grid.\n */\nexport function vdbFrameStackTarget(targetAt: (cascade: number, uvw: Vec3) => number[], grid: VDBFrameGridLayout, world: Vec3, outside: readonly number[]): number[] {\n const cascade = vdbFrameFindCascade(grid, world, 0);\n if (cascade < 0) return [...outside];\n const uvw = vdbFrameGridUvw(grid, cascade, world);\n let out = targetAt(cascade, uvw);\n const side = Math.min(uvw[0], uvw[1], uvw[2], 1 - uvw[0], 1 - uvw[1], 1 - uvw[2]);\n const blend = 1 - smoothstep(0, 0.1, side);\n if (blend > 0) {\n const next = vdbFrameFindCascade(grid, world, cascade + 1);\n if (next >= 0) {\n const v = targetAt(next, vdbFrameGridUvw(grid, next, world));\n out = out.map((x, c) => x + (v[c]! - x) * blend);\n }\n }\n return out;\n}\n/**\n * sampleShadows on a stacked transmittance texture: the 4 targets at a world position (`targetAt(cascade, k, uvw)`),\n * 1 outside the grid, blended toward the next cascade within 10% of a cascade's sides.\n */\nexport function vdbFrameStackShadows(targetAt: (cascade: number, k: number, uvw: Vec3) => number[], grid: VDBFrameGridLayout, world: Vec3): number[][] {\n const out = [0, 1, 2, 3].map(() => [1, 1, 1, 1]);\n const cascade = vdbFrameFindCascade(grid, world, 0);\n if (cascade < 0) return out;\n const uvw = vdbFrameGridUvw(grid, cascade, world);\n for (let k = 0; k < 4; k++) out[k] = targetAt(cascade, k, uvw);\n const side = Math.min(uvw[0], uvw[1], uvw[2], 1 - uvw[0], 1 - uvw[1], 1 - uvw[2]);\n const blend = 1 - smoothstep(0, 0.1, side);\n if (blend > 0) {\n const next = vdbFrameFindCascade(grid, world, cascade + 1);\n if (next >= 0) {\n const nextUvw = vdbFrameGridUvw(grid, next, world);\n for (let k = 0; k < 4; k++) {\n const v = targetAt(next, k, nextUvw);\n out[k] = out[k]!.map((x, c) => x + (v[c]! - x) * blend);\n }\n }\n }\n return out;\n}\n\n/**\n * The environment grid pass (grey; K6.2b) at voxel `cell` of the last cascade, through a grid sampled by\n * `gridAt(cascade, uvw)`: `unshadowed` (the colour sum of `lights`, ≥ 0) where no extinction is within half a voxel,\n * else Σ colour × total of one-voxel-step marches that stay in the last cascade (with diffusion the two-sided total of\n * the march and the opposite one), ≥ 0. His FrameEnvironmentGridMaterial on a 3D grid. K6.3 `octaves`: the march\n * stops at the last octave's depth, totals are octave sums, and the unshadowed light gets the octave total of 1.\n */\nexport function vdbFrameEnvironmentGridVoxel3d(\n gridAt: (cascade: number, uvw: Vec3) => Vec2,\n grid: VDBFrameGridLayout,\n cell: Vec3,\n lights: readonly { direction: Vec3; color: Vec3 }[],\n multipleScattering: number,\n octaves: Vec4 = vdbFrameOctavesOff,\n): Vec4 {\n const cascade = grid.count - 1;\n const world = vdbFrameGridVoxelWorld(grid, cascade, cell);\n const voxel = grid.gridVoxel[cascade]!;\n const uvwOf = (p: Vec3) => vdbFrameGridUvw(grid, cascade, p);\n const unshadowed: Vec3 = [0, 0, 0];\n for (const l of lights) for (let c = 0; c < 3; c++) unshadowed[c] = unshadowed[c]! + l.color[c]!;\n let near = 0;\n for (let i = 0; i < 8; i++) {\n const c: Vec3 = [(i & 1) - 0.5, ((i >> 1) & 1) - 0.5, ((i >> 2) & 1) - 0.5];\n near += gridAt(cascade, uvwOf([world[0] + c[0] * voxel[0], world[1] + c[1] * voxel[1], world[2] + c[2] * voxel[2]]))[0];\n }\n const outside = vdbFrameShadowTotal(1, octaves);\n if (!(near > 0)) return [Math.max(unshadowed[0], 0) * outside, Math.max(unshadowed[1], 0) * outside, Math.max(unshadowed[2], 0) * outside, 1];\n const marchDepths = (dir: Vec3): Vec3 => {\n const step = 1 / Math.max(Math.abs(dir[0]) / voxel[0], Math.abs(dir[1]) / voxel[1], Math.abs(dir[2]) / voxel[2]);\n const probe: Vec3 = [world[0] + dir[0] * step * 0.5, world[1] + dir[1] * step * 0.5, world[2] + dir[2] * step * 0.5];\n const depths: Vec3 = [0, 0, 0];\n for (let i = 0; i < 1024; i++) {\n const uvw = uvwOf(probe);\n if (uvw.some((v) => v < 0 || v > 1) || vdbFrameShadowMarchDepth(depths, multipleScattering, octaves) > 6) break;\n const s = gridAt(cascade, uvw);\n const d = vdbFrameShadowStep(s[0], s[1], multipleScattering);\n for (let c = 0; c < 3; c++) {\n depths[c] = depths[c]! + d[c]! * step;\n probe[c] = probe[c]! + dir[c]! * step;\n }\n }\n return depths;\n };\n const irradiance: Vec3 = [0, 0, 0];\n for (const l of lights) {\n const depths = marchDepths(l.direction);\n const total =\n multipleScattering > 0\n ? vdbFrameIsotropicDiffusion(depths[2], marchDepths([-l.direction[0], -l.direction[1], -l.direction[2]])[2], depths[1])\n : vdbFrameShadowTotal(vdbFrameShadowTransmittance(depths, multipleScattering, octaves)[1], octaves);\n for (let c = 0; c < 3; c++) irradiance[c] = irradiance[c]! + l.color[c]! * total;\n }\n return [Math.max(irradiance[0], 0), Math.max(irradiance[1], 0), Math.max(irradiance[2], 0), 1];\n}\n"]}
@@ -0,0 +1,131 @@
1
+ /** Column-major 4x4. */
2
+ export type VDBMat4 = ArrayLike<number>;
3
+ type V3 = [number, number, number];
4
+ /** A plane `normal · p + constant = 0` (normalized). */
5
+ interface Plane {
6
+ n: V3;
7
+ c: number;
8
+ }
9
+ /** `a × b`, column-major 4x4. */
10
+ export declare function vdbMat4Multiply(a: VDBMat4, b: VDBMat4, out?: Float64Array): Float64Array;
11
+ /** The inverse of a column-major 4x4 (three's `Matrix4.invert`; the zero matrix when singular). */
12
+ export declare function vdbMat4Invert(m: VDBMat4, out?: Float64Array): Float64Array;
13
+ /** `m · (x, y, z, 1)` divided by its w (three's `Vector3.applyMatrix4`). */
14
+ export declare function vdbMat4Point(m: VDBMat4, p: readonly number[]): V3;
15
+ /** `m · (x, y, z, w)`. */
16
+ export declare function vdbMat4Vec4(m: VDBMat4, v: readonly number[]): [number, number, number, number];
17
+ /** The largest axis scale of a column-major 4x4 (three's `Matrix4.getMaxScaleOnAxis`). */
18
+ export declare function vdbMat4MaxScale(m: VDBMat4): number;
19
+ /** The frustum of a projection (or view-projection), three's `Frustum.setFromProjectionMatrix` (planes 0–5). */
20
+ export declare function vdbFrustumPlanes(m: VDBMat4, coordinateSystem?: "webgl" | "webgpu", reversedDepth?: boolean): Plane[];
21
+ /** The world box of the unit box [-0.5, 0.5]³ under `m` (three's `Box3.applyMatrix4`). */
22
+ export declare function vdbUnitBoxBounds(m: VDBMat4): {
23
+ min: V3;
24
+ max: V3;
25
+ };
26
+ /**
27
+ * The per-camera state of the volume clip (his `FrameVolumeCollector.collect` set-up): the world frustum
28
+ * (WebGL convention, as his `frustum.setFromProjectionMatrix(projectionScreenMatrix)`), the view frustum
29
+ * (the camera's coordinate system and depth direction) and its 8 corners.
30
+ */
31
+ export interface VDBFrameClipCamera {
32
+ readonly world: Plane[];
33
+ readonly view: Plane[];
34
+ readonly corners: V3[];
35
+ readonly viewMatrix: VDBMat4;
36
+ readonly projection: VDBMat4;
37
+ }
38
+ /**
39
+ * @param view World → view (three's `camera.matrixWorldInverse`), column-major.
40
+ * @param projection The projection (three's `camera.projectionMatrix`), column-major.
41
+ * @param o The projection's coordinate system (default `'webgpu'`, NDC z in [0, 1]) and depth direction.
42
+ */
43
+ export declare function vdbFrameClipCamera(view: VDBMat4, projection: VDBMat4, o?: {
44
+ coordinateSystem?: "webgl" | "webgpu";
45
+ reversedDepth?: boolean;
46
+ }): VDBFrameClipCamera;
47
+ /** One volume after the clip: its matrices and the view depth range of its part inside the view frustum. */
48
+ export interface VDBFrameClippedVolume {
49
+ readonly localToView: Float64Array;
50
+ readonly viewToLocal: Float64Array;
51
+ readonly worldToLocal: Float64Array;
52
+ readonly viewNear: number;
53
+ readonly viewFar: number;
54
+ }
55
+ /**
56
+ * His `FrameVolumeCollector.addVolume` for one volume box (`matrixWorld`: the local unit box → world):
57
+ * world-frustum culling, then the view depth range of the part of the box inside the view frustum
58
+ * (faces clipped to the planes, plus the frustum corners inside the box). Null when no part is in view.
59
+ */
60
+ export declare function vdbFrameClipVolume(cam: VDBFrameClipCamera, matrixWorld: VDBMat4): VDBFrameClippedVolume | null;
61
+ /** A froxel rectangle in cells: `[x0, y0, x1, y1)`, bottom-left origin. */
62
+ export type VDBFroxelRect = [number, number, number, number];
63
+ /**
64
+ * His `getFroxelRect`: the screen rectangle of the volume box in froxel cells, one cell of padding for
65
+ * the linear filter; the whole grid when a corner is behind the camera. Null when it covers no cell.
66
+ */
67
+ export declare function vdbFrameFroxelRect(localToView: VDBMat4, projection: VDBMat4, width: number, height: number): VDBFroxelRect | null;
68
+ /** His froxel area: the rectangle and slices of all volumes, one cell and one slice larger on each side. */
69
+ export interface VDBFroxelArea {
70
+ rect: VDBFroxelRect;
71
+ first: number;
72
+ count: number;
73
+ }
74
+ /** The empty area (count 0). */
75
+ export declare const vdbFroxelAreaEmpty: () => VDBFroxelArea;
76
+ /**
77
+ * His `getFroxelArea` over volumes that each already have a rect (`vdbFrameFroxelRect`) and a slice range
78
+ * (`vdbFrameSliceRange`); volumes without a rect are skipped. Count 0 when none covers a cell.
79
+ */
80
+ export declare function vdbFrameFroxelArea(volumes: readonly {
81
+ rect: VDBFroxelRect | null;
82
+ first: number;
83
+ count: number;
84
+ }[], width: number, height: number, depth: number): VDBFroxelArea;
85
+ /** The slices of a volume (his `getFroxelSliceRange`): `{ first, count }`. */
86
+ export declare function vdbFrameVolumeSlices(viewNear: number, viewFar: number, range: readonly [number, number], depth: number): {
87
+ first: number;
88
+ count: number;
89
+ };
90
+ /**
91
+ * The bounding box of two areas (rect union, slice union), for a dispatch that must also clear what the
92
+ * last dispatch wrote. An empty area does not widen it.
93
+ */
94
+ export declare function vdbFroxelAreaUnion(a: VDBFroxelArea, b: VDBFroxelArea): VDBFroxelArea;
95
+ /** His `getAtlasLayout`: tiles of tileWidth × tileHeight in an atlas that is about square. */
96
+ export declare function vdbFrameAtlasLayout(tileWidth: number, tileHeight: number, tileCount: number): {
97
+ columns: number;
98
+ width: number;
99
+ height: number;
100
+ };
101
+ /** Held sizes of {@link vdbFrameFroxelSize} (his frameLayout.js state). */
102
+ export interface VDBFroxelHeldSize {
103
+ canvasX: number;
104
+ canvasY: number;
105
+ bufferX: number;
106
+ bufferY: number;
107
+ }
108
+ /** A fresh held size (nothing held). */
109
+ export declare const vdbFroxelHeldSize: () => VDBFroxelHeldSize;
110
+ /**
111
+ * His `getFroxelSize`: the settings' width and height, at most the drawing-buffer pixels and, with
112
+ * `pixelsPerFroxel` N > 0, at most one froxel per N × N canvas pixels; `state` holds sizes through
113
+ * small changes.
114
+ */
115
+ export declare function vdbFrameFroxelSize(settings: {
116
+ width: number;
117
+ height: number;
118
+ pixelsPerFroxel: number;
119
+ }, viewport: {
120
+ drawingBuffer: readonly [number, number];
121
+ canvas: readonly [number, number];
122
+ }, state?: VDBFroxelHeldSize | null): {
123
+ width: number;
124
+ height: number;
125
+ };
126
+ /**
127
+ * The clip rectangle of a froxel cell rectangle (his `getClipRect`), `padding` cells larger on each side:
128
+ * (x0, y0, x1, y1) in clip space; all 0 for an empty rectangle.
129
+ */
130
+ export declare function vdbFrameClipRect(rect: VDBFroxelRect, width: number, height: number, padding: number): [number, number, number, number];
131
+ export {};