@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,274 @@
1
+ /**
2
+ * K6.Q1 shadowed ambient (V85; DIVERGES V125–V128): the CPU twins of the core renderer's ambient occlusion. Ambient,
3
+ * hemisphere and light-probe light (distant light with no shadow slot) is attenuated by the medium: transmittance is
4
+ * marched along `pairs` opposite direction pairs, (ω_k, −ω_k) with ω_k in the hemisphere around the sky direction, and
5
+ * averaged into two hemispherical visibilities (V_up over the ω_k, V_down over the −ω_k). Each direction's value is the
6
+ * lighting mode's isotropic-light total (as his sky up / down slots): the direct transmittance without multiple
7
+ * scattering, the octave total over an open direction's with octaves, the two-sided isotropic diffusion of the pair (white furnace: V_up + V_down
8
+ * = 2 at albedo 1) with any other mode. The distant light then reads the visibilities as his sky up / down totals:
9
+ * ambient × (V_up + V_down) / 2, hemisphere sky × V_up / 2 + ground × V_down / 2, the probe's SH irradiance along ± the
10
+ * sky × V / 2. Pairs are an equal-area quadrature of each hemisphere: the sky direction, then a ring at the centroid
11
+ * of the rest. 'frame' lighting marches the pairs in the transmittance pass (two spare channels of the fourth target);
12
+ * 'volume' lighting marches them per froxel through the volume's own shadow march (fewer steps).
13
+ */
14
+ import { vdbFrameIsotropicDiffusion } from "./grid.js";
15
+ import { vdbFrameOctavesOff, vdbFrameShadowTotal } from "./index.js";
16
+ import { vdbFrameMieAsymmetry, vdbFrameMieRgbMode } from "./mie.js";
17
+ import { vdbFrameSpectralShadowTotal } from "./spectral.js";
18
+ /** Most direction pairs (the uniform table's length). */
19
+ export const VDB_FRAME_AMBIENT_MAX_PAIRS = 8;
20
+ const normalize = (v) => {
21
+ const l = Math.hypot(v[0], v[1], v[2]);
22
+ return l > 0 ? [v[0] / l, v[1] / l, v[2] / l] : [0, 1, 0];
23
+ };
24
+ const cross = (a, b) => [a[1] * b[2] - a[2] * b[1], a[2] * b[0] - a[0] * b[2], a[0] * b[1] - a[1] * b[0]];
25
+ /**
26
+ * The upper direction of each pair (world, unit): [0] the sky direction, then `pairs − 1` at cos θ = (1 − 1/pairs) / 2
27
+ * from it (the ring's area centroid when the sky direction's cap holds 1/pairs of the hemisphere), evenly in azimuth
28
+ * from a tangent of the sky direction. The lower directions are their negatives. The ring is fixed (K6.Q1c, D37 (5):
29
+ * K6.Q1a turned it per frame with `jitter` and `temporal`).
30
+ */
31
+ export function vdbFrameAmbientDirections(sky, pairs) {
32
+ const n = Math.min(VDB_FRAME_AMBIENT_MAX_PAIRS, Math.max(1, Math.round(pairs)));
33
+ const s = normalize(sky);
34
+ const out = [s];
35
+ if (n === 1)
36
+ return out;
37
+ const helper = Math.abs(s[1]) < 0.9 ? [0, 1, 0] : [1, 0, 0];
38
+ const t = normalize(cross(helper, s));
39
+ const b = cross(s, t);
40
+ const cosTheta = (1 - 1 / n) / 2;
41
+ const sinTheta = Math.sqrt(1 - cosTheta * cosTheta);
42
+ for (let k = 0; k < n - 1; k++) {
43
+ const phi = (2 * Math.PI * k) / (n - 1);
44
+ const c = Math.cos(phi) * sinTheta;
45
+ const d = Math.sin(phi) * sinTheta;
46
+ out.push(normalize([s[0] * cosTheta + t[0] * c + b[0] * d, s[1] * cosTheta + t[1] * c + b[1] * d, s[2] * cosTheta + t[2] * c + b[2] * d]));
47
+ }
48
+ return out;
49
+ }
50
+ /**
51
+ * One pair's isotropic-light totals (up, down) from its two marches (direct, total, reduced depth, effective depth):
52
+ * the two-sided isotropic diffusion with `diffusion`, else each march's total through the octave sum (octaves off:
53
+ * the total as given) divided by the octave total of an open direction (a visibility, 1 unoccluded). The 'frame'
54
+ * transmittance's sky up / down rule, but normalised.
55
+ */
56
+ export function vdbFrameAmbientPairTotals(front, back, diffusion, octaves = vdbFrameOctavesOff) {
57
+ if (diffusion)
58
+ return [vdbFrameIsotropicDiffusion(front[2], back[2], front[3]), vdbFrameIsotropicDiffusion(back[2], front[2], back[3])];
59
+ // octaves: normalised by the octave total of no medium (1 + Σ bⁿ), so an open direction is 1 as without octaves
60
+ const open = vdbFrameShadowTotal(1, octaves);
61
+ return [vdbFrameShadowTotal(front[1], octaves) / open, vdbFrameShadowTotal(back[1], octaves) / open];
62
+ }
63
+ /**
64
+ * K6.Q1a: one pair's isotropic-light totals of each channel (up, down) from its two spectral marches (direct, total,
65
+ * reduced depth, effective depth of each channel): the two-sided isotropic diffusion of each channel with `diffusion`,
66
+ * else each march's spectral total (octaves: at `albedo`, the spectral octave light) over an open direction's. A grey
67
+ * medium (equal channels; octaves: albedo 1) gives {@link vdbFrameAmbientPairTotals} in every channel.
68
+ */
69
+ export function vdbFrameSpectralAmbientPairTotals(front, back, diffusion, octaves = vdbFrameOctavesOff, albedo = [1, 1, 1]) {
70
+ const map3 = (f) => [f(0), f(1), f(2)];
71
+ if (diffusion)
72
+ return [map3((c) => vdbFrameIsotropicDiffusion(front.z[c], back.z[c], front.w[c])), map3((c) => vdbFrameIsotropicDiffusion(back.z[c], front.z[c], back.w[c]))];
73
+ const open = vdbFrameSpectralShadowTotal([1, 1, 1], octaves, albedo);
74
+ const up = vdbFrameSpectralShadowTotal(front.y, octaves, albedo);
75
+ const down = vdbFrameSpectralShadowTotal(back.y, octaves, albedo);
76
+ return [map3((c) => up[c] / open[c]), map3((c) => down[c] / open[c])];
77
+ }
78
+ /** K6.Q1a: the hemispherical visibilities of each channel (V_up, V_down): the mean of each side's pair totals. */
79
+ export function vdbFrameSpectralAmbientVisibility(totals) {
80
+ if (totals.length === 0)
81
+ return [[1, 1, 1], [1, 1, 1]];
82
+ const up = [0, 0, 0];
83
+ const down = [0, 0, 0];
84
+ for (const t of totals)
85
+ for (let c = 0; c < 3; c++) {
86
+ up[c] = up[c] + t[0][c] / totals.length;
87
+ down[c] = down[c] + t[1][c] / totals.length;
88
+ }
89
+ return [up, down];
90
+ }
91
+ /** The hemispherical visibilities (V_up, V_down): the mean of each side's pair totals. */
92
+ export function vdbFrameAmbientVisibility(totals) {
93
+ if (totals.length === 0)
94
+ return [1, 1];
95
+ let up = 0;
96
+ let down = 0;
97
+ for (const t of totals) {
98
+ up += t[0];
99
+ down += t[1];
100
+ }
101
+ return [up / totals.length, down / totals.length];
102
+ }
103
+ /**
104
+ * K6.Q1c (V128): the phase weight of the distant light. The pair totals are fitted with a dipole, T(ω) ≈ a + b·ω (least
105
+ * squares over the 2N sides ±ω_k: a their mean, b = M⁺ Σ_k (T(ω_k) − T(−ω_k)) ω_k / 2 with M = Σ_k ω_k ω_kᵀ). Under an HG
106
+ * lobe of mean cosine g, ∫ p T dω = a − g b·ω_cam (ω_cam toward the camera) = a + g b·r (r the view ray's direction),
107
+ * clamped to [0, 1] per lobe and mixed by the lobe weight (a dual lobe's mean cosine in one clamp darkens a backlit
108
+ * position too much: the back lobe's share is lost to the clamp at 0). The renderer packs M⁺ / 2 (`ambientDipole`); with
109
+ * 1–3 pairs M is singular and the pseudo-inverse fits b in the pairs' span.
110
+ */
111
+ /** Eigen-decomposition of a symmetric 3×3 (row-major) by Jacobi rotations: eigenvalues and eigenvector columns. */
112
+ function symmetricEigen3(m) {
113
+ const a = [...m];
114
+ const v = [1, 0, 0, 0, 1, 0, 0, 0, 1];
115
+ for (let sweep = 0; sweep < 32; sweep++) {
116
+ const off = Math.abs(a[1]) + Math.abs(a[2]) + Math.abs(a[5]);
117
+ if (off < 1e-15)
118
+ break;
119
+ for (const [p, q] of [[0, 1], [0, 2], [1, 2]]) {
120
+ const apq = a[p * 3 + q];
121
+ if (Math.abs(apq) < 1e-300)
122
+ continue;
123
+ const theta = (a[q * 3 + q] - a[p * 3 + p]) / (2 * apq);
124
+ const t = Math.sign(theta || 1) / (Math.abs(theta) + Math.sqrt(theta * theta + 1));
125
+ const c = 1 / Math.sqrt(t * t + 1);
126
+ const s = t * c;
127
+ for (let k = 0; k < 3; k++) {
128
+ const akp = a[k * 3 + p];
129
+ const akq = a[k * 3 + q];
130
+ a[k * 3 + p] = c * akp - s * akq;
131
+ a[k * 3 + q] = s * akp + c * akq;
132
+ }
133
+ for (let k = 0; k < 3; k++) {
134
+ const apk = a[p * 3 + k];
135
+ const aqk = a[q * 3 + k];
136
+ a[p * 3 + k] = c * apk - s * aqk;
137
+ a[q * 3 + k] = s * apk + c * aqk;
138
+ }
139
+ for (let k = 0; k < 3; k++) {
140
+ const vkp = v[k * 3 + p];
141
+ const vkq = v[k * 3 + q];
142
+ v[k * 3 + p] = c * vkp - s * vkq;
143
+ v[k * 3 + q] = s * vkp + c * vkq;
144
+ }
145
+ }
146
+ }
147
+ return { values: [a[0], a[4], a[8]], vectors: v };
148
+ }
149
+ /**
150
+ * K6.Q1c: M⁺ / 2 of the pairs' upper directions (row-major 3×3, symmetric; M = Σ_k ω_k ω_kᵀ, eigenvalues below 1e-6 of
151
+ * the largest dropped). `b · r = Σ_k (T(ω_k) − T(−ω_k)) ω_k · (M⁺/2 · r)`.
152
+ */
153
+ export function vdbFrameAmbientDipoleMatrix(directions) {
154
+ const m = [0, 0, 0, 0, 0, 0, 0, 0, 0];
155
+ for (const w of directions)
156
+ for (let i = 0; i < 3; i++)
157
+ for (let j = 0; j < 3; j++)
158
+ m[i * 3 + j] = m[i * 3 + j] + w[i] * w[j];
159
+ const { values, vectors } = symmetricEigen3(m);
160
+ const top = Math.max(...values.map(Math.abs));
161
+ const out = [0, 0, 0, 0, 0, 0, 0, 0, 0];
162
+ for (let e = 0; e < 3; e++) {
163
+ if (!(top > 0) || Math.abs(values[e]) <= 1e-6 * top)
164
+ continue;
165
+ const inv = 0.5 / values[e];
166
+ for (let i = 0; i < 3; i++)
167
+ for (let j = 0; j < 3; j++)
168
+ out[i * 3 + j] = out[i * 3 + j] + vectors[i * 3 + e] * vectors[j * 3 + e] * inv;
169
+ }
170
+ return out;
171
+ }
172
+ /**
173
+ * K6.Q1c: the phase's lobes (the WGSL `vdbFrameAmbientPhaseFactor` reads the same): forward g and back g (spectral: each
174
+ * scaled per channel and clamped ±0.99, as `vdbFramePhaseColor`) with the back weight; both lobes at the Lorenz-Mie table's
175
+ * asymmetry for 'lorenz-mie' and 'lorenz-mie-rgb'.
176
+ */
177
+ export function vdbFramePhaseLobes(phase, phaseSpectrum) {
178
+ const mieG = [vdbFrameMieAsymmetry, vdbFrameMieAsymmetry, vdbFrameMieAsymmetry];
179
+ if (phase[3] > vdbFrameMieRgbMode - 0.5)
180
+ return { g: [mieG, mieG], weight: phase[2] };
181
+ const scale = phaseSpectrum[2] > 0.5 ? [phaseSpectrum[0], 1, phaseSpectrum[1]] : [1, 1, 1];
182
+ const clampG = (g) => Math.min(0.99, Math.max(-0.99, g));
183
+ const mie = Math.min(phase[3], 1);
184
+ const lobe = (g) => scale.map((s) => clampG(s * g) + (vdbFrameMieAsymmetry - clampG(s * g)) * mie);
185
+ return { g: [lobe(phase[0]), lobe(phase[1])], weight: phase[2] };
186
+ }
187
+ /**
188
+ * K6.Q1c: the scale of the distant light at one position (both visibilities × it): the dipole's phase-weighted visibility
189
+ * mix(clamp(a + g₁ b·r, 0, 1), clamp(a + g₂ b·r, 0, 1), weight) over the isotropic one a (1 where a ≤ 1e-6). `totals` are
190
+ * the pairs' (up, down) totals in `directions` order (grey: numbers; spectral: per channel), `matrix`
191
+ * {@link vdbFrameAmbientDipoleMatrix} of the directions the renderer packed, `ray` the unit view ray (camera → position),
192
+ * `lobes` {@link vdbFramePhaseLobes}.
193
+ */
194
+ export function vdbFrameAmbientPhaseFactor(totals, directions, matrix, ray, lobes) {
195
+ if (totals.length === 0)
196
+ return [1, 1, 1];
197
+ const u = [0, 1, 2].map((i) => matrix[i * 3] * ray[0] + matrix[i * 3 + 1] * ray[1] + matrix[i * 3 + 2] * ray[2]);
198
+ const ch = (v, c) => (typeof v === "number" ? v : v[c]);
199
+ return [0, 1, 2].map((c) => {
200
+ let sum = 0;
201
+ let dipole = 0;
202
+ totals.forEach((t, k) => {
203
+ const w = directions[k];
204
+ sum += ch(t[0], c) + ch(t[1], c);
205
+ dipole += (ch(t[0], c) - ch(t[1], c)) * (w[0] * u[0] + w[1] * u[1] + w[2] * u[2]);
206
+ });
207
+ const a = sum / (2 * totals.length);
208
+ const lobe = (g) => Math.min(Math.max(a + g[c] * dipole, 0), 1);
209
+ const v = lobe(lobes.g[0]) + (lobe(lobes.g[1]) - lobe(lobes.g[0])) * lobes.weight;
210
+ return a > 1e-6 ? v / a : 1;
211
+ });
212
+ }
213
+ /**
214
+ * K6.Q1d: the pairs' dipole b = M⁺/2 Σ_k (T(ω_k) − T(−ω_k)) ω_k of grey totals (`matrix` {@link vdbFrameAmbientDipoleMatrix}
215
+ * of `directions`): what 'frame' lighting's transmittance pass stores per grid voxel (view-independent; b · r is
216
+ * {@link vdbFrameAmbientPhaseFactor}'s dipole sum for a ray r).
217
+ */
218
+ export function vdbFrameAmbientDipole(totals, directions, matrix) {
219
+ const sum = [0, 0, 0];
220
+ totals.forEach((t, k) => {
221
+ const w = directions[k];
222
+ for (let i = 0; i < 3; i++)
223
+ sum[i] = sum[i] + (t[0] - t[1]) * w[i];
224
+ });
225
+ return [0, 1, 2].map((i) => matrix[i * 3] * sum[0] + matrix[i * 3 + 1] * sum[1] + matrix[i * 3 + 2] * sum[2]);
226
+ }
227
+ /** K6.Q1d: {@link vdbFrameAmbientDipole} of each channel of spectral totals (b of red, green, blue). */
228
+ export function vdbFrameSpectralAmbientDipole(totals, directions, matrix) {
229
+ const channel = (c) => vdbFrameAmbientDipole(totals.map((t) => [t[0][c], t[1][c]]), directions, matrix);
230
+ return [channel(0), channel(1), channel(2)];
231
+ }
232
+ /**
233
+ * K6.Q1d: the phase weight of the distant light from the hemispherical visibilities (up, down) and the dipole's b · r
234
+ * at one position (the WGSL `vdbFrameAmbientPhaseFactor` with one pair): a = (up + down) / 2,
235
+ * mix(clamp(a + g₁ b·r, 0, 1), clamp(a + g₂ b·r, 0, 1), weight) / a (1 where a ≤ 1e-6); per channel.
236
+ */
237
+ export function vdbFrameAmbientPhaseWeight(up, down, dipoleDotRay, lobes) {
238
+ const ch = (v, c) => (typeof v === "number" ? v : v[c]);
239
+ return [0, 1, 2].map((c) => {
240
+ const a = (ch(up, c) + ch(down, c)) / 2;
241
+ const d = ch(dipoleDotRay, c);
242
+ const lobe = (g) => Math.min(Math.max(a + g[c] * d, 0), 1);
243
+ const v = lobe(lobes.g[0]) + (lobe(lobes.g[1]) - lobe(lobes.g[0])) * lobes.weight;
244
+ return a > 1e-6 ? v / a : 1;
245
+ });
246
+ }
247
+ /** three's getShIrradianceAt. */
248
+ function shIrradiance(n, sh) {
249
+ const [x, y, z] = n;
250
+ const k = [0.886227, 2 * 0.511664 * y, 2 * 0.511664 * z, 2 * 0.511664 * x, 2 * 0.429043 * x * y, 2 * 0.429043 * y * z, z * z * 0.743125 - 0.247708, 2 * 0.429043 * x * z, 0.429043 * (x * x - y * y)];
251
+ const out = [0, 0, 0];
252
+ for (let i = 0; i < 9; i++)
253
+ for (let c = 0; c < 3; c++)
254
+ out[c] = out[c] + (sh[i]?.[c] ?? 0) * k[i];
255
+ return out;
256
+ }
257
+ /**
258
+ * The shadowed distant-light irradiance at visibilities (V_up, V_down) (both lightings): ambient × (V_up + V_down) / 2
259
+ * + hemisphere sky × V_up / 2 + ground × V_down / 2 + the probe's irradiance along ± the sky direction × V / 2.
260
+ * Unoccluded (1, 1) gives the ambient and hemisphere light of the unshadowed renderer. K6.Q1a: a visibility may be per
261
+ * channel (spectral).
262
+ */
263
+ export function vdbFrameAmbientIrradiance(light, visibility) {
264
+ const ch = (v, c) => (typeof v === "number" ? v : v[c]) * 0.5;
265
+ const out = [0, 1, 2].map((c) => light.ambient[c] * (ch(visibility[0], c) + ch(visibility[1], c)) + light.hemiSky[c] * ch(visibility[0], c) + light.hemiGround[c] * ch(visibility[1], c));
266
+ if (light.probe) {
267
+ const a = shIrradiance(light.sky, light.probe);
268
+ const b = shIrradiance([-light.sky[0], -light.sky[1], -light.sky[2]], light.probe);
269
+ for (let c = 0; c < 3; c++)
270
+ out[c] = out[c] + a[c] * ch(visibility[0], c) + b[c] * ch(visibility[1], c);
271
+ }
272
+ return out;
273
+ }
274
+ //# sourceMappingURL=ambient.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ambient.js","sourceRoot":"","sources":["../../../src/tools/frame/ambient.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,EAAE,0BAA0B,EAAE,MAAM,WAAW,CAAC;AACvD,OAAO,EAAE,kBAAkB,EAAE,mBAAmB,EAAwB,MAAM,YAAY,CAAC;AAC3F,OAAO,EAAE,oBAAoB,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAC;AACpE,OAAO,EAAE,2BAA2B,EAA8B,MAAM,eAAe,CAAC;AAExF,yDAAyD;AACzD,MAAM,CAAC,MAAM,2BAA2B,GAAG,CAAC,CAAC;AAE7C,MAAM,SAAS,GAAG,CAAC,CAAoB,EAAQ,EAAE;IAC/C,MAAM,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAE,EAAE,CAAC,CAAC,CAAC,CAAE,EAAE,CAAC,CAAC,CAAC,CAAE,CAAC,CAAC;IAC1C,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAE,GAAG,CAAC,EAAE,CAAC,CAAC,CAAC,CAAE,GAAG,CAAC,EAAE,CAAC,CAAC,CAAC,CAAE,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;AAC/D,CAAC,CAAC;AACF,MAAM,KAAK,GAAG,CAAC,CAAoB,EAAE,CAAoB,EAAQ,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAE,GAAG,CAAC,CAAC,CAAC,CAAE,GAAG,CAAC,CAAC,CAAC,CAAE,GAAG,CAAC,CAAC,CAAC,CAAE,EAAE,CAAC,CAAC,CAAC,CAAE,GAAG,CAAC,CAAC,CAA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GES V125–V128): the CPU twins of the core renderer's ambient occlusion. Ambient,\n * hemisphere and light-probe light (distant light with no shadow slot) is attenuated by the medium: transmittance is\n * marched along `pairs` opposite direction pairs, (ω_k, −ω_k) with ω_k in the hemisphere around the sky direction, and\n * averaged into two hemispherical visibilities (V_up over the ω_k, V_down over the −ω_k). Each direction's value is the\n * lighting mode's isotropic-light total (as his sky up / down slots): the direct transmittance without multiple\n * scattering, the octave total over an open direction's with octaves, the two-sided isotropic diffusion of the pair (white furnace: V_up + V_down\n * = 2 at albedo 1) with any other mode. The distant light then reads the visibilities as his sky up / down totals:\n * ambient × (V_up + V_down) / 2, hemisphere sky × V_up / 2 + ground × V_down / 2, the probe's SH irradiance along ± the\n * sky × V / 2. Pairs are an equal-area quadrature of each hemisphere: the sky direction, then a ring at the centroid\n * of the rest. 'frame' lighting marches the pairs in the transmittance pass (two spare channels of the fourth target);\n * 'volume' lighting marches them per froxel through the volume's own shadow march (fewer steps).\n */\n\nimport { vdbFrameIsotropicDiffusion } from \"./grid.js\";\nimport { vdbFrameOctavesOff, vdbFrameShadowTotal, type Vec3, type Vec4 } from \"./index.js\";\nimport { vdbFrameMieAsymmetry, vdbFrameMieRgbMode } from \"./mie.js\";\nimport { vdbFrameSpectralShadowTotal, type VDBFrameSpectralMarch } from \"./spectral.js\";\n\n/** Most direction pairs (the uniform table's length). */\nexport const VDB_FRAME_AMBIENT_MAX_PAIRS = 8;\n\nconst normalize = (v: readonly number[]): 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, 1, 0];\n};\nconst cross = (a: readonly number[], b: readonly number[]): Vec3 => [a[1]! * b[2]! - a[2]! * b[1]!, a[2]! * b[0]! - a[0]! * b[2]!, a[0]! * b[1]! - a[1]! * b[0]!];\n\n/**\n * The upper direction of each pair (world, unit): [0] the sky direction, then `pairs − 1` at cos θ = (1 − 1/pairs) / 2\n * from it (the ring's area centroid when the sky direction's cap holds 1/pairs of the hemisphere), evenly in azimuth\n * from a tangent of the sky direction. The lower directions are their negatives. The ring is fixed (K6.Q1c, D37 (5):\n * K6.Q1a turned it per frame with `jitter` and `temporal`).\n */\nexport function vdbFrameAmbientDirections(sky: readonly number[], pairs: number): Vec3[] {\n const n = Math.min(VDB_FRAME_AMBIENT_MAX_PAIRS, Math.max(1, Math.round(pairs)));\n const s = normalize(sky);\n const out: Vec3[] = [s];\n if (n === 1) return out;\n const helper: Vec3 = Math.abs(s[1]) < 0.9 ? [0, 1, 0] : [1, 0, 0];\n const t = normalize(cross(helper, s));\n const b = cross(s, t);\n const cosTheta = (1 - 1 / n) / 2;\n const sinTheta = Math.sqrt(1 - cosTheta * cosTheta);\n for (let k = 0; k < n - 1; k++) {\n const phi = (2 * Math.PI * k) / (n - 1);\n const c = Math.cos(phi) * sinTheta;\n const d = Math.sin(phi) * sinTheta;\n out.push(normalize([s[0] * cosTheta + t[0] * c + b[0] * d, s[1] * cosTheta + t[1] * c + b[1] * d, s[2] * cosTheta + t[2] * c + b[2] * d]));\n }\n return out;\n}\n\n/**\n * One pair's isotropic-light totals (up, down) from its two marches (direct, total, reduced depth, effective depth):\n * the two-sided isotropic diffusion with `diffusion`, else each march's total through the octave sum (octaves off:\n * the total as given) divided by the octave total of an open direction (a visibility, 1 unoccluded). The 'frame'\n * transmittance's sky up / down rule, but normalised.\n */\nexport function vdbFrameAmbientPairTotals(front: Vec4, back: Vec4, diffusion: boolean, octaves: Vec4 = vdbFrameOctavesOff): [number, number] {\n if (diffusion) return [vdbFrameIsotropicDiffusion(front[2], back[2], front[3]), vdbFrameIsotropicDiffusion(back[2], front[2], back[3])];\n // octaves: normalised by the octave total of no medium (1 + Σ bⁿ), so an open direction is 1 as without octaves\n const open = vdbFrameShadowTotal(1, octaves);\n return [vdbFrameShadowTotal(front[1], octaves) / open, vdbFrameShadowTotal(back[1], octaves) / open];\n}\n\n/**\n * K6.Q1a: one pair's isotropic-light totals of each channel (up, down) from its two spectral marches (direct, total,\n * reduced depth, effective depth of each channel): the two-sided isotropic diffusion of each channel with `diffusion`,\n * else each march's spectral total (octaves: at `albedo`, the spectral octave light) over an open direction's. A grey\n * medium (equal channels; octaves: albedo 1) gives {@link vdbFrameAmbientPairTotals} in every channel.\n */\nexport function vdbFrameSpectralAmbientPairTotals(front: VDBFrameSpectralMarch, back: VDBFrameSpectralMarch, diffusion: boolean, octaves: Vec4 = vdbFrameOctavesOff, albedo: Vec3 = [1, 1, 1]): [Vec3, Vec3] {\n const map3 = (f: (c: number) => number): Vec3 => [f(0), f(1), f(2)];\n if (diffusion) return [map3((c) => vdbFrameIsotropicDiffusion(front.z[c]!, back.z[c]!, front.w[c]!)), map3((c) => vdbFrameIsotropicDiffusion(back.z[c]!, front.z[c]!, back.w[c]!))];\n const open = vdbFrameSpectralShadowTotal([1, 1, 1], octaves, albedo);\n const up = vdbFrameSpectralShadowTotal(front.y, octaves, albedo);\n const down = vdbFrameSpectralShadowTotal(back.y, octaves, albedo);\n return [map3((c) => up[c]! / open[c]!), map3((c) => down[c]! / open[c]!)];\n}\n\n/** K6.Q1a: the hemispherical visibilities of each channel (V_up, V_down): the mean of each side's pair totals. */\nexport function vdbFrameSpectralAmbientVisibility(totals: readonly (readonly [Vec3, Vec3])[]): [Vec3, Vec3] {\n if (totals.length === 0) return [[1, 1, 1], [1, 1, 1]];\n const up: Vec3 = [0, 0, 0];\n const down: Vec3 = [0, 0, 0];\n for (const t of totals) for (let c = 0; c < 3; c++) {\n up[c] = up[c]! + t[0][c]! / totals.length;\n down[c] = down[c]! + t[1][c]! / totals.length;\n }\n return [up, down];\n}\n\n/** The hemispherical visibilities (V_up, V_down): the mean of each side's pair totals. */\nexport function vdbFrameAmbientVisibility(totals: readonly (readonly [number, number])[]): [number, number] {\n if (totals.length === 0) return [1, 1];\n let up = 0;\n let down = 0;\n for (const t of totals) {\n up += t[0];\n down += t[1];\n }\n return [up / totals.length, down / totals.length];\n}\n\n/**\n * K6.Q1c (V128): the phase weight of the distant light. The pair totals are fitted with a dipole, T(ω) ≈ a + b·ω (least\n * squares over the 2N sides ±ω_k: a their mean, b = M⁺ Σ_k (T(ω_k) − T(−ω_k)) ω_k / 2 with M = Σ_k ω_k ω_kᵀ). Under an HG\n * lobe of mean cosine g, ∫ p T dω = a − g b·ω_cam (ω_cam toward the camera) = a + g b·r (r the view ray's direction),\n * clamped to [0, 1] per lobe and mixed by the lobe weight (a dual lobe's mean cosine in one clamp darkens a backlit\n * position too much: the back lobe's share is lost to the clamp at 0). The renderer packs M⁺ / 2 (`ambientDipole`); with\n * 1–3 pairs M is singular and the pseudo-inverse fits b in the pairs' span.\n */\n\n/** Eigen-decomposition of a symmetric 3×3 (row-major) by Jacobi rotations: eigenvalues and eigenvector columns. */\nfunction symmetricEigen3(m: readonly number[]): { values: Vec3; vectors: number[] } {\n const a = [...m];\n const v = [1, 0, 0, 0, 1, 0, 0, 0, 1];\n for (let sweep = 0; sweep < 32; sweep++) {\n const off = Math.abs(a[1]!) + Math.abs(a[2]!) + Math.abs(a[5]!);\n if (off < 1e-15) break;\n for (const [p, q] of [[0, 1], [0, 2], [1, 2]] as const) {\n const apq = a[p * 3 + q]!;\n if (Math.abs(apq) < 1e-300) continue;\n const theta = (a[q * 3 + q]! - a[p * 3 + p]!) / (2 * apq);\n const t = Math.sign(theta || 1) / (Math.abs(theta) + Math.sqrt(theta * theta + 1));\n const c = 1 / Math.sqrt(t * t + 1);\n const s = t * c;\n for (let k = 0; k < 3; k++) {\n const akp = a[k * 3 + p]!;\n const akq = a[k * 3 + q]!;\n a[k * 3 + p] = c * akp - s * akq;\n a[k * 3 + q] = s * akp + c * akq;\n }\n for (let k = 0; k < 3; k++) {\n const apk = a[p * 3 + k]!;\n const aqk = a[q * 3 + k]!;\n a[p * 3 + k] = c * apk - s * aqk;\n a[q * 3 + k] = s * apk + c * aqk;\n }\n for (let k = 0; k < 3; k++) {\n const vkp = v[k * 3 + p]!;\n const vkq = v[k * 3 + q]!;\n v[k * 3 + p] = c * vkp - s * vkq;\n v[k * 3 + q] = s * vkp + c * vkq;\n }\n }\n }\n return { values: [a[0]!, a[4]!, a[8]!], vectors: v };\n}\n\n/**\n * K6.Q1c: M⁺ / 2 of the pairs' upper directions (row-major 3×3, symmetric; M = Σ_k ω_k ω_kᵀ, eigenvalues below 1e-6 of\n * the largest dropped). `b · r = Σ_k (T(ω_k) − T(−ω_k)) ω_k · (M⁺/2 · r)`.\n */\nexport function vdbFrameAmbientDipoleMatrix(directions: readonly (readonly number[])[]): number[] {\n const m = [0, 0, 0, 0, 0, 0, 0, 0, 0];\n for (const w of directions) for (let i = 0; i < 3; i++) for (let j = 0; j < 3; j++) m[i * 3 + j] = m[i * 3 + j]! + w[i]! * w[j]!;\n const { values, vectors } = symmetricEigen3(m);\n const top = Math.max(...values.map(Math.abs));\n const out = [0, 0, 0, 0, 0, 0, 0, 0, 0];\n for (let e = 0; e < 3; e++) {\n if (!(top > 0) || Math.abs(values[e]!) <= 1e-6 * top) continue;\n const inv = 0.5 / values[e]!;\n for (let i = 0; i < 3; i++) for (let j = 0; j < 3; j++) out[i * 3 + j] = out[i * 3 + j]! + vectors[i * 3 + e]! * vectors[j * 3 + e]! * inv;\n }\n return out;\n}\n\n/** K6.Q1c: a phase's two HG lobes, each one's mean cosine per channel, and the second lobe's weight. */\nexport interface VDBFramePhaseLobes {\n g: [Vec3, Vec3];\n weight: number;\n}\n\n/**\n * K6.Q1c: the phase's lobes (the WGSL `vdbFrameAmbientPhaseFactor` reads the same): forward g and back g (spectral: each\n * scaled per channel and clamped ±0.99, as `vdbFramePhaseColor`) with the back weight; both lobes at the Lorenz-Mie table's\n * asymmetry for 'lorenz-mie' and 'lorenz-mie-rgb'.\n */\nexport function vdbFramePhaseLobes(phase: Vec4, phaseSpectrum: Vec3): VDBFramePhaseLobes {\n const mieG: Vec3 = [vdbFrameMieAsymmetry, vdbFrameMieAsymmetry, vdbFrameMieAsymmetry];\n if (phase[3] > vdbFrameMieRgbMode - 0.5) return { g: [mieG, mieG], weight: phase[2] };\n const scale: Vec3 = phaseSpectrum[2] > 0.5 ? [phaseSpectrum[0], 1, phaseSpectrum[1]] : [1, 1, 1];\n const clampG = (g: number) => Math.min(0.99, Math.max(-0.99, g));\n const mie = Math.min(phase[3], 1);\n const lobe = (g: number) => scale.map((s) => clampG(s * g) + (vdbFrameMieAsymmetry - clampG(s * g)) * mie) as Vec3;\n return { g: [lobe(phase[0]), lobe(phase[1])], weight: phase[2] };\n}\n\n/**\n * K6.Q1c: the scale of the distant light at one position (both visibilities × it): the dipole's phase-weighted visibility\n * mix(clamp(a + g₁ b·r, 0, 1), clamp(a + g₂ b·r, 0, 1), weight) over the isotropic one a (1 where a ≤ 1e-6). `totals` are\n * the pairs' (up, down) totals in `directions` order (grey: numbers; spectral: per channel), `matrix`\n * {@link vdbFrameAmbientDipoleMatrix} of the directions the renderer packed, `ray` the unit view ray (camera → position),\n * `lobes` {@link vdbFramePhaseLobes}.\n */\nexport function vdbFrameAmbientPhaseFactor(\n totals: readonly (readonly [number | Vec3, number | Vec3])[],\n directions: readonly (readonly number[])[],\n matrix: readonly number[],\n ray: readonly number[],\n lobes: VDBFramePhaseLobes,\n): Vec3 {\n if (totals.length === 0) return [1, 1, 1];\n const u = [0, 1, 2].map((i) => matrix[i * 3]! * ray[0]! + matrix[i * 3 + 1]! * ray[1]! + matrix[i * 3 + 2]! * ray[2]!);\n const ch = (v: number | Vec3, c: number) => (typeof v === \"number\" ? v : v[c]!);\n return [0, 1, 2].map((c) => {\n let sum = 0;\n let dipole = 0;\n totals.forEach((t, k) => {\n const w = directions[k]!;\n sum += ch(t[0], c) + ch(t[1], c);\n dipole += (ch(t[0], c) - ch(t[1], c)) * (w[0]! * u[0]! + w[1]! * u[1]! + w[2]! * u[2]!);\n });\n const a = sum / (2 * totals.length);\n const lobe = (g: Vec3) => Math.min(Math.max(a + g[c]! * dipole, 0), 1);\n const v = lobe(lobes.g[0]) + (lobe(lobes.g[1]) - lobe(lobes.g[0])) * lobes.weight;\n return a > 1e-6 ? v / a : 1;\n }) as Vec3;\n}\n\n/**\n * K6.Q1d: the pairs' dipole b = M⁺/2 Σ_k (T(ω_k) − T(−ω_k)) ω_k of grey totals (`matrix` {@link vdbFrameAmbientDipoleMatrix}\n * of `directions`): what 'frame' lighting's transmittance pass stores per grid voxel (view-independent; b · r is\n * {@link vdbFrameAmbientPhaseFactor}'s dipole sum for a ray r).\n */\nexport function vdbFrameAmbientDipole(totals: readonly (readonly [number, number])[], directions: readonly (readonly number[])[], matrix: readonly number[]): Vec3 {\n const sum: Vec3 = [0, 0, 0];\n totals.forEach((t, k) => {\n const w = directions[k]!;\n for (let i = 0; i < 3; i++) sum[i] = sum[i]! + (t[0] - t[1]) * w[i]!;\n });\n return [0, 1, 2].map((i) => matrix[i * 3]! * sum[0] + matrix[i * 3 + 1]! * sum[1] + matrix[i * 3 + 2]! * sum[2]) as Vec3;\n}\n\n/** K6.Q1d: {@link vdbFrameAmbientDipole} of each channel of spectral totals (b of red, green, blue). */\nexport function vdbFrameSpectralAmbientDipole(totals: readonly (readonly [Vec3, Vec3])[], directions: readonly (readonly number[])[], matrix: readonly number[]): [Vec3, Vec3, Vec3] {\n const channel = (c: number) => vdbFrameAmbientDipole(totals.map((t) => [t[0][c]!, t[1][c]!] as [number, number]), directions, matrix);\n return [channel(0), channel(1), channel(2)];\n}\n\n/**\n * K6.Q1d: the phase weight of the distant light from the hemispherical visibilities (up, down) and the dipole's b · r\n * at one position (the WGSL `vdbFrameAmbientPhaseFactor` with one pair): a = (up + down) / 2,\n * mix(clamp(a + g₁ b·r, 0, 1), clamp(a + g₂ b·r, 0, 1), weight) / a (1 where a ≤ 1e-6); per channel.\n */\nexport function vdbFrameAmbientPhaseWeight(up: number | Vec3, down: number | Vec3, dipoleDotRay: number | Vec3, lobes: VDBFramePhaseLobes): Vec3 {\n const ch = (v: number | Vec3, c: number) => (typeof v === \"number\" ? v : v[c]!);\n return [0, 1, 2].map((c) => {\n const a = (ch(up, c) + ch(down, c)) / 2;\n const d = ch(dipoleDotRay, c);\n const lobe = (g: Vec3) => Math.min(Math.max(a + g[c]! * d, 0), 1);\n const v = lobe(lobes.g[0]) + (lobe(lobes.g[1]) - lobe(lobes.g[0])) * lobes.weight;\n return a > 1e-6 ? v / a : 1;\n }) as Vec3;\n}\n\n/** The distant light of a frame (renderer units: irradiance on a surface facing it, three colour × intensity). */\nexport interface VDBFrameDistantLight {\n ambient: Vec3;\n /** Sums of the hemisphere lights' sky and ground colours (they share the first one's up: the sky direction). */\n hemiSky: Vec3;\n hemiGround: Vec3;\n /** Light probe SH9 (three's order, RGB), or none. */\n probe?: readonly Vec3[] | null;\n /** Unit sky direction (the first hemisphere light's up, else +y). */\n sky: Vec3;\n}\n\n/** three's getShIrradianceAt. */\nfunction shIrradiance(n: Vec3, sh: readonly Vec3[]): Vec3 {\n const [x, y, z] = n;\n const k = [0.886227, 2 * 0.511664 * y, 2 * 0.511664 * z, 2 * 0.511664 * x, 2 * 0.429043 * x * y, 2 * 0.429043 * y * z, z * z * 0.743125 - 0.247708, 2 * 0.429043 * x * z, 0.429043 * (x * x - y * y)];\n const out: Vec3 = [0, 0, 0];\n for (let i = 0; i < 9; i++) for (let c = 0; c < 3; c++) out[c] = out[c]! + (sh[i]?.[c] ?? 0) * k[i]!;\n return out;\n}\n\n/**\n * The shadowed distant-light irradiance at visibilities (V_up, V_down) (both lightings): ambient × (V_up + V_down) / 2\n * + hemisphere sky × V_up / 2 + ground × V_down / 2 + the probe's irradiance along ± the sky direction × V / 2.\n * Unoccluded (1, 1) gives the ambient and hemisphere light of the unshadowed renderer. K6.Q1a: a visibility may be per\n * channel (spectral).\n */\nexport function vdbFrameAmbientIrradiance(light: VDBFrameDistantLight, visibility: readonly [number | Vec3, number | Vec3]): Vec3 {\n const ch = (v: number | Vec3, c: number) => (typeof v === \"number\" ? v : v[c]!) * 0.5;\n const out: Vec3 = [0, 1, 2].map((c) => light.ambient[c]! * (ch(visibility[0], c) + ch(visibility[1], c)) + light.hemiSky[c]! * ch(visibility[0], c) + light.hemiGround[c]! * ch(visibility[1], c)) as Vec3;\n if (light.probe) {\n const a = shIrradiance(light.sky, light.probe);\n const b = shIrradiance([-light.sky[0], -light.sky[1], -light.sky[2]], light.probe);\n for (let c = 0; c < 3; c++) out[c] = out[c]! + a[c]! * ch(visibility[0], c) + b[c]! * ch(visibility[1], c);\n }\n return out;\n}\n"]}
@@ -36,7 +36,22 @@ export declare function vdbFrameBlackbodyTable(cmf?: VDBColorMatchingFunctions):
36
36
  /**
37
37
  * frameBlackbodyColor (CPU twin): the table read with linear blending in log temperature and exponent between the
38
38
  * texels (`load`, no sampler), on the f32 table values (of the `cmf` table; default: the analytic fit, D33).
39
+ * @param temperature Kelvin; clamped to the table's range.
40
+ * @param exponent The soot exponent, clamped to `0..frameMaxSootExponent`.
41
+ * @param cmf The colour matching functions the table integrates. Default {@link vdbCie1931Fit}.
39
42
  */
40
43
  export declare function vdbFrameBlackbodyColor(temperature: number, exponent: number, cmf?: VDBColorMatchingFunctions): Vec3;
44
+ /**
45
+ * K6.5: one emission colour LUT row of the core renderer (`emissionColor: { spectrum }`): the table's two exponent
46
+ * rows around `exponent` blended into 256 rgb texels over log temperature (500–40,000 K). Bilinear filtering is
47
+ * separable, so {@link vdbFrameEmissionLutColor} on this row equals {@link vdbFrameBlackbodyColor} (up to rounding).
48
+ * `table`: a {@link vdbFrameBlackbodyTable} (256 × 16 rgba; default the analytic CMF fit, D33).
49
+ */
50
+ export declare function vdbFrameEmissionLutRow(exponent: number, table?: ArrayLike<number>): Float32Array;
51
+ /**
52
+ * K6.5: the core emission LUT read (CPU twin of `vdbFrameEmissionLutColor` in core/frame/wgsl/emission.ts): a
53
+ * 256-texel rgb row over log temperature (500–40,000 K), linear between texels, clamped at the ends.
54
+ */
55
+ export declare function vdbFrameEmissionLutColor(row: ArrayLike<number>, temperature: number): Vec3;
41
56
  /** His `getFrameEmissionSpectrum` for the ported spectra: (table weight 1, soot exponent); 'planck' is exponent 0. An invalid soot exponent gives his 1.39. */
42
57
  export declare function vdbFrameEmissionSpectrum(spectrum: "planck" | "soot", sootExponent?: number): Vec2;
@@ -88,6 +88,9 @@ export function vdbFrameBlackbodyTable(cmf = vdbCie1931Fit) {
88
88
  /**
89
89
  * frameBlackbodyColor (CPU twin): the table read with linear blending in log temperature and exponent between the
90
90
  * texels (`load`, no sampler), on the f32 table values (of the `cmf` table; default: the analytic fit, D33).
91
+ * @param temperature Kelvin; clamped to the table's range.
92
+ * @param exponent The soot exponent, clamped to `0..frameMaxSootExponent`.
93
+ * @param cmf The colour matching functions the table integrates. Default {@link vdbCie1931Fit}.
91
94
  */
92
95
  export function vdbFrameBlackbodyColor(temperature, exponent, cmf = vdbCie1931Fit) {
93
96
  const t = vdbFrameBlackbodyTable(cmf);
@@ -105,6 +108,38 @@ export function vdbFrameBlackbodyColor(temperature, exponent, cmf = vdbCie1931Fi
105
108
  const mixv = (a, b, w) => [a[0] + (b[0] - a[0]) * w, a[1] + (b[1] - a[1]) * w, a[2] + (b[2] - a[2]) * w];
106
109
  return mixv(mixv(texel(0, 0), texel(1, 0), bx), mixv(texel(0, 1), texel(1, 1), bx), by);
107
110
  }
111
+ /**
112
+ * K6.5: one emission colour LUT row of the core renderer (`emissionColor: { spectrum }`): the table's two exponent
113
+ * rows around `exponent` blended into 256 rgb texels over log temperature (500–40,000 K). Bilinear filtering is
114
+ * separable, so {@link vdbFrameEmissionLutColor} on this row equals {@link vdbFrameBlackbodyColor} (up to rounding).
115
+ * `table`: a {@link vdbFrameBlackbodyTable} (256 × 16 rgba; default the analytic CMF fit, D33).
116
+ */
117
+ export function vdbFrameEmissionLutRow(exponent, table = vdbFrameBlackbodyTable()) {
118
+ const y = Math.min(1, Math.max(0, exponent / frameMaxSootExponent)) * (frameBlackbodyTableRows - 1);
119
+ const row = Math.min(Math.trunc(y), frameBlackbodyTableRows - 2);
120
+ const by = y - row;
121
+ const out = new Float32Array(frameBlackbodyTableSize * 3);
122
+ for (let x = 0; x < frameBlackbodyTableSize; x++) {
123
+ for (let c = 0; c < 3; c++) {
124
+ const a = table[(row * frameBlackbodyTableSize + x) * 4 + c];
125
+ const b = table[((row + 1) * frameBlackbodyTableSize + x) * 4 + c];
126
+ out[x * 3 + c] = a + (b - a) * by;
127
+ }
128
+ }
129
+ return out;
130
+ }
131
+ /**
132
+ * K6.5: the core emission LUT read (CPU twin of `vdbFrameEmissionLutColor` in core/frame/wgsl/emission.ts): a
133
+ * 256-texel rgb row over log temperature (500–40,000 K), linear between texels, clamped at the ends.
134
+ */
135
+ export function vdbFrameEmissionLutColor(row, temperature) {
136
+ const scale = Math.log(frameBlackbodyMaxTemperature / frameBlackbodyMinTemperature);
137
+ const x = Math.min(1, Math.max(0, Math.log(Math.max(temperature, 1e-3) / frameBlackbodyMinTemperature) / scale)) * (frameBlackbodyTableSize - 1);
138
+ const column = Math.min(Math.trunc(x), frameBlackbodyTableSize - 2);
139
+ const bx = x - column;
140
+ const at = (i, c) => row[i * 3 + c];
141
+ return [0, 1, 2].map((c) => at(column, c) + (at(column + 1, c) - at(column, c)) * bx);
142
+ }
108
143
  /** His `getFrameEmissionSpectrum` for the ported spectra: (table weight 1, soot exponent); 'planck' is exponent 0. An invalid soot exponent gives his 1.39. */
109
144
  export function vdbFrameEmissionSpectrum(spectrum, sootExponent = 1.39) {
110
145
  if (spectrum === "planck")
@@ -1 +1 @@
1
- {"version":3,"file":"blackbody.js","sourceRoot":"","sources":["../../../src/tools/frame/blackbody.ts"],"names":[],"mappings":"AAAA,0EAA0E;AAC1E,qHAAqH;AACrH,0FAA0F;AAC1F,wGAAwG;AACxG,4GAA4G;AAC5G,kHAAkH;AAClH,gHAAgH;AAChH,qFAAqF;AACrF,iHAAiH;AACjH,qHAAqH;AACrH,wCAAwC;AACxC,iHAAiH;AACjH,qGAAqG;AACrG,oHAAoH;AACpH,6EAA6E;AAe7E,6GAA6G;AAC7G,MAAM,IAAI,GAAG,CAAC,UAAkB,EAAE,KAAa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C;AAC1F,CAAC;AAED,+JAA+J;AAC/J,MAAM,UAAU,wBAAwB,CAAC,QAA2B,EAAE,YAAY,GAAG,IAAI;IACvF,IAAI,QAAQ,KAAK,QAAQ;QAAE,OAAO,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;IACzC,MAAM,QAAQ,GAAG,MAAM,CAAC,YAAY,CAAC,CAAC;IACtC,MAAM,KAAK,GAAG,MAAM,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC;IAC1D,OAAO,CAAC,CAAC,EAAE,IAAI,CAAC,GAAG,CAAC,oBAAoB,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC;AACjE,CAAC","sourcesContent":["// Portions derived from mjurczyk/openvdb (MIT), commit 75e7345 (v0.26.0):\n// src/three-openvdb/frame/core/frameBlackbody.js L1–172 (the 'planck' / 'soot' emission colour table: its Planck ×\n// soot integration, XYZ → linear sRGB and normalization, and getFrameEmissionSpectrum);\n// src/three-openvdb/frame/webgpu/frameShaderChunks.js L236–256 (frameBlackbodyColor, the table read).\n// Copyright (c) mjurczyk/openvdb contributors. Licensed under the MIT License (see THIRD_PARTY_NOTICES.md).\n// Changes: TypeScript, engine-free; the table read is a CPU twin of the shader's. His 'approximate' spectrum (the\n// Shadertoy blackBody(), CC BY-NC-SA unless stated) is not ported (R1 §7): emission colour stays a caller hook,\n// and this table is the hook the three adapter offers (`vdbFrameBlackbodyEmission`).\n// D33: his table integrates the tabulated CIE 1931 2° colour matching functions (a CC BY-SA 4.0 dataset, CIE DOI\n// 10.25039/CIE.DS.xvudnb9b). No CIE data is shipped here: the colour matching functions are the multi-lobe piecewise\n// Gaussian fit (Equation 4, Table 1) of\n// C. Wyman, P.-P. Sloan, P. Shirley, \"Simple Analytic Approximations to the CIE XYZ Color Matching Functions\",\n// Journal of Computer Graphics Techniques 2(2), 1–11, 2013. https://jcgt.org/published/0002/02/01/\n// written from the paper's published formula and coefficients. Callers may pass their own colour matching functions\n// (e.g. the exact CIE table, under its own licence) to every function below.\n\n/**\n * K3.6: the physical emission spectra of his `FrameVolume.emissionSpectrum`: Planck radiance × the soot emissivity\n * λ^−exponent, integrated with the CIE 1931 2° colour matching functions (by default the analytic fit\n * {@link vdbCie1931Fit}, D33) at 380–780 nm in 5 nm steps, CIE XYZ → linear sRGB (IEC 61966-2-1), negatives to 0,\n * largest channel 1. A 256 × 16 RGBA table over log temperature (500–40,000 K) and soot exponent (0–3); `'planck'` is\n * the exponent-0 row.\n */\n\nimport type { Vec2, Vec3 } from \"./index.js\";\n\n/** CIE 1931 2° colour matching functions (x̄, ȳ, z̄) at a wavelength in nm. */\nexport type VDBColorMatchingFunctions = (wavelength: number) => Vec3;\n\n/** One piecewise Gaussian lobe: α · exp(−½ ((λ − β) · (λ < β ? γ : δ))²) (Wyman et al. 2013, Equation 4). */\nconst lobe = (wavelength: number, alpha: number, beta: number, gamma: number, delta: number): number => {\n const t = (wavelength - beta) * (wavelength < beta ? gamma : delta);\n return alpha * Math.exp(-0.5 * t * t);\n};\n\n/**\n * The CIE 1931 2° standard observer as the analytic multi-lobe fit of Wyman, Sloan & Shirley (JCGT 2(2), 2013,\n * Equation 4 with Table 1: three lobes for x̄, two each for ȳ and z̄). The paper's stated accuracy against the 1 nm\n * CIE curves: max squared error 2.0e-4 / 6.4e-5 / 4.9e-4, mean squared error 3.1e-5 / 7.1e-6 / 1.6e-5 (x̄ / ȳ / z̄).\n */\nexport function vdbCie1931Fit(wavelength: number): Vec3 {\n return [\n lobe(wavelength, 0.362, 442.0, 0.0624, 0.0374) + lobe(wavelength, 1.056, 599.8, 0.0264, 0.0323) + lobe(wavelength, -0.065, 501.1, 0.049, 0.0382),\n lobe(wavelength, 0.821, 568.8, 0.0213, 0.0247) + lobe(wavelength, 0.286, 530.9, 0.0613, 0.0322),\n lobe(wavelength, 1.217, 437.0, 0.0845, 0.0278) + lobe(wavelength, 0.681, 459.0, 0.0385, 0.0725),\n ];\n}\n\n/** His integration grid: 380–780 nm in 5 nm steps (81 samples). */\nexport const frameBlackbodyWavelengthStart = 380.0;\nexport const frameBlackbodyWavelengthStep = 5.0;\nexport const frameBlackbodyWavelengthCount = 81;\n\n/** Second radiation constant h·c/k in nm·K. */\nconst c2 = 1.4388e7;\n\nexport const frameBlackbodyTableSize = 256;\nexport const frameBlackbodyTableRows = 16;\nexport const frameBlackbodyMinTemperature = 500.0;\nexport const frameBlackbodyMaxTemperature = 40000.0;\nexport const frameMaxSootExponent = 3.0;\n\n/**\n * The table's colour of one temperature (K) and soot exponent: linear sRGB, largest channel 1 (0 when black).\n * `cmf`: the colour matching functions, sampled at his 81 wavelengths (default: the analytic fit, D33).\n */\nexport function vdbFrameBlackbodyRgb(temperature: number, exponent: number, cmf: VDBColorMatchingFunctions = vdbCie1931Fit): Vec3 {\n let x = 0;\n let y = 0;\n let z = 0;\n for (let i = 0; i < frameBlackbodyWavelengthCount; i++) {\n const wavelength = frameBlackbodyWavelengthStart + i * frameBlackbodyWavelengthStep;\n // Planck radiance without constant factors (the scale is removed at the end)\n const radiance = ((wavelength / 550.0) ** -exponent * (550.0 / wavelength) ** 5) / Math.expm1(c2 / (wavelength * temperature));\n const [xBar, yBar, zBar] = cmf(wavelength);\n x += radiance * xBar;\n y += radiance * yBar;\n z += radiance * zBar;\n }\n const r = Math.max(0, 3.2406 * x - 1.5372 * y - 0.4986 * z);\n const g = Math.max(0, -0.9689 * x + 1.8758 * y + 0.0415 * z);\n const b = Math.max(0, 0.0557 * x - 0.204 * y + 1.057 * z);\n const peak = Math.max(r, g, b);\n return peak > 0 ? [r / peak, g / peak, b / peak] : [0, 0, 0];\n}\n\nconst tables = new WeakMap<VDBColorMatchingFunctions, Float32Array>();\n\n/**\n * RGBA float texels, {@link frameBlackbodyTableSize} × {@link frameBlackbodyTableRows}, row = soot exponent (made once\n * per `cmf` function; default: the analytic fit, D33).\n */\nexport function vdbFrameBlackbodyTable(cmf: VDBColorMatchingFunctions = vdbCie1931Fit): Float32Array {\n const cached = tables.get(cmf);\n if (cached) return cached;\n const t = new Float32Array(frameBlackbodyTableSize * frameBlackbodyTableRows * 4);\n for (let row = 0; row < frameBlackbodyTableRows; row++) {\n const exponent = (frameMaxSootExponent * row) / (frameBlackbodyTableRows - 1);\n for (let column = 0; column < frameBlackbodyTableSize; column++) {\n const temperature = frameBlackbodyMinTemperature * (frameBlackbodyMaxTemperature / frameBlackbodyMinTemperature) ** (column / (frameBlackbodyTableSize - 1));\n const rgb = vdbFrameBlackbodyRgb(temperature, exponent, cmf);\n t.set([rgb[0], rgb[1], rgb[2], 1.0], (row * frameBlackbodyTableSize + column) * 4);\n }\n }\n tables.set(cmf, t);\n return t;\n}\n\n/**\n * frameBlackbodyColor (CPU twin): the table read with linear blending in log temperature and exponent between the\n * texels (`load`, no sampler), on the f32 table values (of the `cmf` table; default: the analytic fit, D33).\n */\nexport function vdbFrameBlackbodyColor(temperature: number, exponent: number, cmf: VDBColorMatchingFunctions = vdbCie1931Fit): Vec3 {\n const t = vdbFrameBlackbodyTable(cmf);\n const scale = Math.log(frameBlackbodyMaxTemperature / frameBlackbodyMinTemperature);\n const x = Math.min(1, Math.max(0, Math.log(Math.max(temperature, 1e-3) / frameBlackbodyMinTemperature) / scale)) * (frameBlackbodyTableSize - 1);\n const y = Math.min(1, Math.max(0, exponent / frameMaxSootExponent)) * (frameBlackbodyTableRows - 1);\n const column = Math.min(Math.trunc(x), frameBlackbodyTableSize - 2);\n const row = Math.min(Math.trunc(y), frameBlackbodyTableRows - 2);\n const bx = x - column;\n const by = y - row;\n const texel = (dx: number, dy: number): Vec3 => {\n const i = ((row + dy) * frameBlackbodyTableSize + column + dx) * 4;\n return [t[i]!, t[i + 1]!, t[i + 2]!];\n };\n const mixv = (a: Vec3, b: Vec3, w: number): Vec3 => [a[0] + (b[0] - a[0]) * w, a[1] + (b[1] - a[1]) * w, a[2] + (b[2] - a[2]) * w];\n return mixv(mixv(texel(0, 0), texel(1, 0), bx), mixv(texel(0, 1), texel(1, 1), bx), by);\n}\n\n/** His `getFrameEmissionSpectrum` for the ported spectra: (table weight 1, soot exponent); 'planck' is exponent 0. An invalid soot exponent gives his 1.39. */\nexport function vdbFrameEmissionSpectrum(spectrum: \"planck\" | \"soot\", sootExponent = 1.39): Vec2 {\n if (spectrum === \"planck\") return [1, 0];\n const exponent = Number(sootExponent);\n const valid = Number.isFinite(exponent) ? exponent : 1.39;\n return [1, Math.min(frameMaxSootExponent, Math.max(0, valid))];\n}\n"]}
1
+ {"version":3,"file":"blackbody.js","sourceRoot":"","sources":["../../../src/tools/frame/blackbody.ts"],"names":[],"mappings":"AAAA,0EAA0E;AAC1E,qHAAqH;AACrH,0FAA0F;AAC1F,wGAAwG;AACxG,4GAA4G;AAC5G,kHAAkH;AAClH,gHAAgH;AAChH,qFAAqF;AACrF,iHAAiH;AACjH,qHAAqH;AACrH,wCAAwC;AACxC,iHAAiH;AACjH,qGAAqG;AACrG,oHAAoH;AACpH,6EAA6E;AAe7E,6GAA6G;AAC7G,MAAM,IAAI,GAAG,CAAC,UAAkB,EAAE,KAAa,EAAE,IAAY,EAAE,KAAa,EAAE,KAAa,EAAU,EAAE;IACrG,MAAM,CAAC,GAAG,CAAC,UAAU,GAAG,IAAI,CAAC,GAAG,CAAC,UAAU,GAAG,IAAI,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC;IACpE,OAAO,KAAK,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,GAAG,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC;AACxC,CAAC,CAAC;AAEF;;;;GAIG;AACH,MAAM,UAAU,aAAa,CAAC,UAAkB;IAC9C,OAAO;QACL,IAAI,CAAC,UAAU,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,CAAC,GAAG,IAAI,CAAC,UAAU,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,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C,CAAS,EAAE,CAAS,EAAE,EAAE,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,CAAE,CAAC;IACrD,OAAO,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,EAAE,CAAC,MAAM,EAAE,CAAC,CAAC,GAAG,CAAC,EAAE,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC,CAAC,GAAG,EAAE,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC,GAAG,EAAE,CAAS,CAAC;AAChG,CAAC;AAED,+JAA+J;AAC/J,MAAM,UAAU,wBAAwB,CAAC,QAA2B,EAAE,YAAY,GAAG,IAAI;IACvF,IAAI,QAAQ,KAAK,QAAQ;QAAE,OAAO,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;IACzC,MAAM,QAAQ,GAAG,MAAM,CAAC,YAAY,CAAC,CAAC;IACtC,MAAM,KAAK,GAAG,MAAM,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC;IAC1D,OAAO,CAAC,CAAC,EAAE,IAAI,CAAC,GAAG,CAAC,oBAAoB,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC;AACjE,CAAC","sourcesContent":["// Portions derived from mjurczyk/openvdb (MIT), commit 75e7345 (v0.26.0):\n// src/three-openvdb/frame/core/frameBlackbody.js L1–172 (the 'planck' / 'soot' emission colour table: its Planck ×\n// soot integration, XYZ → linear sRGB and normalization, and getFrameEmissionSpectrum);\n// src/three-openvdb/frame/webgpu/frameShaderChunks.js L236–256 (frameBlackbodyColor, the table read).\n// Copyright (c) mjurczyk/openvdb contributors. Licensed under the MIT License (see THIRD_PARTY_NOTICES.md).\n// Changes: TypeScript, engine-free; the table read is a CPU twin of the shader's. His 'approximate' spectrum (the\n// Shadertoy blackBody(), CC BY-NC-SA unless stated) is not ported (R1 §7): emission colour stays a caller hook,\n// and this table is the hook the three adapter offers (`vdbFrameBlackbodyEmission`).\n// D33: his table integrates the tabulated CIE 1931 2° colour matching functions (a CC BY-SA 4.0 dataset, CIE DOI\n// 10.25039/CIE.DS.xvudnb9b). No CIE data is shipped here: the colour matching functions are the multi-lobe piecewise\n// Gaussian fit (Equation 4, Table 1) of\n// C. Wyman, P.-P. Sloan, P. Shirley, \"Simple Analytic Approximations to the CIE XYZ Color Matching Functions\",\n// Journal of Computer Graphics Techniques 2(2), 1–11, 2013. https://jcgt.org/published/0002/02/01/\n// written from the paper's published formula and coefficients. Callers may pass their own colour matching functions\n// (e.g. the exact CIE table, under its own licence) to every function below.\n\n/**\n * K3.6: the physical emission spectra of his `FrameVolume.emissionSpectrum`: Planck radiance × the soot emissivity\n * λ^−exponent, integrated with the CIE 1931 2° colour matching functions (by default the analytic fit\n * {@link vdbCie1931Fit}, D33) at 380–780 nm in 5 nm steps, CIE XYZ → linear sRGB (IEC 61966-2-1), negatives to 0,\n * largest channel 1. A 256 × 16 RGBA table over log temperature (500–40,000 K) and soot exponent (0–3); `'planck'` is\n * the exponent-0 row.\n */\n\nimport type { Vec2, Vec3 } from \"./index.js\";\n\n/** CIE 1931 2° colour matching functions (x̄, ȳ, z̄) at a wavelength in nm. */\nexport type VDBColorMatchingFunctions = (wavelength: number) => Vec3;\n\n/** One piecewise Gaussian lobe: α · exp(−½ ((λ − β) · (λ < β ? γ : δ))²) (Wyman et al. 2013, Equation 4). */\nconst lobe = (wavelength: number, alpha: number, beta: number, gamma: number, delta: number): number => {\n const t = (wavelength - beta) * (wavelength < beta ? gamma : delta);\n return alpha * Math.exp(-0.5 * t * t);\n};\n\n/**\n * The CIE 1931 2° standard observer as the analytic multi-lobe fit of Wyman, Sloan & Shirley (JCGT 2(2), 2013,\n * Equation 4 with Table 1: three lobes for x̄, two each for ȳ and z̄). The paper's stated accuracy against the 1 nm\n * CIE curves: max squared error 2.0e-4 / 6.4e-5 / 4.9e-4, mean squared error 3.1e-5 / 7.1e-6 / 1.6e-5 (x̄ / ȳ / z̄).\n */\nexport function vdbCie1931Fit(wavelength: number): Vec3 {\n return [\n lobe(wavelength, 0.362, 442.0, 0.0624, 0.0374) + lobe(wavelength, 1.056, 599.8, 0.0264, 0.0323) + lobe(wavelength, -0.065, 501.1, 0.049, 0.0382),\n lobe(wavelength, 0.821, 568.8, 0.0213, 0.0247) + lobe(wavelength, 0.286, 530.9, 0.0613, 0.0322),\n lobe(wavelength, 1.217, 437.0, 0.0845, 0.0278) + lobe(wavelength, 0.681, 459.0, 0.0385, 0.0725),\n ];\n}\n\n/** His integration grid: 380–780 nm in 5 nm steps (81 samples). */\nexport const frameBlackbodyWavelengthStart = 380.0;\nexport const frameBlackbodyWavelengthStep = 5.0;\nexport const frameBlackbodyWavelengthCount = 81;\n\n/** Second radiation constant h·c/k in nm·K. */\nconst c2 = 1.4388e7;\n\nexport const frameBlackbodyTableSize = 256;\nexport const frameBlackbodyTableRows = 16;\nexport const frameBlackbodyMinTemperature = 500.0;\nexport const frameBlackbodyMaxTemperature = 40000.0;\nexport const frameMaxSootExponent = 3.0;\n\n/**\n * The table's colour of one temperature (K) and soot exponent: linear sRGB, largest channel 1 (0 when black).\n * `cmf`: the colour matching functions, sampled at his 81 wavelengths (default: the analytic fit, D33).\n */\nexport function vdbFrameBlackbodyRgb(temperature: number, exponent: number, cmf: VDBColorMatchingFunctions = vdbCie1931Fit): Vec3 {\n let x = 0;\n let y = 0;\n let z = 0;\n for (let i = 0; i < frameBlackbodyWavelengthCount; i++) {\n const wavelength = frameBlackbodyWavelengthStart + i * frameBlackbodyWavelengthStep;\n // Planck radiance without constant factors (the scale is removed at the end)\n const radiance = ((wavelength / 550.0) ** -exponent * (550.0 / wavelength) ** 5) / Math.expm1(c2 / (wavelength * temperature));\n const [xBar, yBar, zBar] = cmf(wavelength);\n x += radiance * xBar;\n y += radiance * yBar;\n z += radiance * zBar;\n }\n const r = Math.max(0, 3.2406 * x - 1.5372 * y - 0.4986 * z);\n const g = Math.max(0, -0.9689 * x + 1.8758 * y + 0.0415 * z);\n const b = Math.max(0, 0.0557 * x - 0.204 * y + 1.057 * z);\n const peak = Math.max(r, g, b);\n return peak > 0 ? [r / peak, g / peak, b / peak] : [0, 0, 0];\n}\n\nconst tables = new WeakMap<VDBColorMatchingFunctions, Float32Array>();\n\n/**\n * RGBA float texels, {@link frameBlackbodyTableSize} × {@link frameBlackbodyTableRows}, row = soot exponent (made once\n * per `cmf` function; default: the analytic fit, D33).\n */\nexport function vdbFrameBlackbodyTable(cmf: VDBColorMatchingFunctions = vdbCie1931Fit): Float32Array {\n const cached = tables.get(cmf);\n if (cached) return cached;\n const t = new Float32Array(frameBlackbodyTableSize * frameBlackbodyTableRows * 4);\n for (let row = 0; row < frameBlackbodyTableRows; row++) {\n const exponent = (frameMaxSootExponent * row) / (frameBlackbodyTableRows - 1);\n for (let column = 0; column < frameBlackbodyTableSize; column++) {\n const temperature = frameBlackbodyMinTemperature * (frameBlackbodyMaxTemperature / frameBlackbodyMinTemperature) ** (column / (frameBlackbodyTableSize - 1));\n const rgb = vdbFrameBlackbodyRgb(temperature, exponent, cmf);\n t.set([rgb[0], rgb[1], rgb[2], 1.0], (row * frameBlackbodyTableSize + column) * 4);\n }\n }\n tables.set(cmf, t);\n return t;\n}\n\n/**\n * frameBlackbodyColor (CPU twin): the table read with linear blending in log temperature and exponent between the\n * texels (`load`, no sampler), on the f32 table values (of the `cmf` table; default: the analytic fit, D33).\n * @param temperature Kelvin; clamped to the table's range.\n * @param exponent The soot exponent, clamped to `0..frameMaxSootExponent`.\n * @param cmf The colour matching functions the table integrates. Default {@link vdbCie1931Fit}.\n */\nexport function vdbFrameBlackbodyColor(temperature: number, exponent: number, cmf: VDBColorMatchingFunctions = vdbCie1931Fit): Vec3 {\n const t = vdbFrameBlackbodyTable(cmf);\n const scale = Math.log(frameBlackbodyMaxTemperature / frameBlackbodyMinTemperature);\n const x = Math.min(1, Math.max(0, Math.log(Math.max(temperature, 1e-3) / frameBlackbodyMinTemperature) / scale)) * (frameBlackbodyTableSize - 1);\n const y = Math.min(1, Math.max(0, exponent / frameMaxSootExponent)) * (frameBlackbodyTableRows - 1);\n const column = Math.min(Math.trunc(x), frameBlackbodyTableSize - 2);\n const row = Math.min(Math.trunc(y), frameBlackbodyTableRows - 2);\n const bx = x - column;\n const by = y - row;\n const texel = (dx: number, dy: number): Vec3 => {\n const i = ((row + dy) * frameBlackbodyTableSize + column + dx) * 4;\n return [t[i]!, t[i + 1]!, t[i + 2]!];\n };\n const mixv = (a: Vec3, b: Vec3, w: number): Vec3 => [a[0] + (b[0] - a[0]) * w, a[1] + (b[1] - a[1]) * w, a[2] + (b[2] - a[2]) * w];\n return mixv(mixv(texel(0, 0), texel(1, 0), bx), mixv(texel(0, 1), texel(1, 1), bx), by);\n}\n\n/**\n * K6.5: one emission colour LUT row of the core renderer (`emissionColor: { spectrum }`): the table's two exponent\n * rows around `exponent` blended into 256 rgb texels over log temperature (500–40,000 K). Bilinear filtering is\n * separable, so {@link vdbFrameEmissionLutColor} on this row equals {@link vdbFrameBlackbodyColor} (up to rounding).\n * `table`: a {@link vdbFrameBlackbodyTable} (256 × 16 rgba; default the analytic CMF fit, D33).\n */\nexport function vdbFrameEmissionLutRow(exponent: number, table: ArrayLike<number> = vdbFrameBlackbodyTable()): Float32Array {\n const y = Math.min(1, Math.max(0, exponent / frameMaxSootExponent)) * (frameBlackbodyTableRows - 1);\n const row = Math.min(Math.trunc(y), frameBlackbodyTableRows - 2);\n const by = y - row;\n const out = new Float32Array(frameBlackbodyTableSize * 3);\n for (let x = 0; x < frameBlackbodyTableSize; x++) {\n for (let c = 0; c < 3; c++) {\n const a = table[(row * frameBlackbodyTableSize + x) * 4 + c]!;\n const b = table[((row + 1) * frameBlackbodyTableSize + x) * 4 + c]!;\n out[x * 3 + c] = a + (b - a) * by;\n }\n }\n return out;\n}\n\n/**\n * K6.5: the core emission LUT read (CPU twin of `vdbFrameEmissionLutColor` in core/frame/wgsl/emission.ts): a\n * 256-texel rgb row over log temperature (500–40,000 K), linear between texels, clamped at the ends.\n */\nexport function vdbFrameEmissionLutColor(row: ArrayLike<number>, temperature: number): Vec3 {\n const scale = Math.log(frameBlackbodyMaxTemperature / frameBlackbodyMinTemperature);\n const x = Math.min(1, Math.max(0, Math.log(Math.max(temperature, 1e-3) / frameBlackbodyMinTemperature) / scale)) * (frameBlackbodyTableSize - 1);\n const column = Math.min(Math.trunc(x), frameBlackbodyTableSize - 2);\n const bx = x - column;\n const at = (i: number, c: number) => row[i * 3 + c]!;\n return [0, 1, 2].map((c) => at(column, c) + (at(column + 1, c) - at(column, c)) * bx) as Vec3;\n}\n\n/** His `getFrameEmissionSpectrum` for the ported spectra: (table weight 1, soot exponent); 'planck' is exponent 0. An invalid soot exponent gives his 1.39. */\nexport function vdbFrameEmissionSpectrum(spectrum: \"planck\" | \"soot\", sootExponent = 1.39): Vec2 {\n if (spectrum === \"planck\") return [1, 0];\n const exponent = Number(sootExponent);\n const valid = Number.isFinite(exponent) ? exponent : 1.39;\n return [1, Math.min(frameMaxSootExponent, Math.max(0, valid))];\n}\n"]}