@pmndrs/vdb 0.0.0-stage → 0.1.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 (390) hide show
  1. package/CHANGELOG.md +137 -0
  2. package/LICENSE +21 -0
  3. package/README.md +448 -2
  4. package/THIRD_PARTY_NOTICES.md +147 -0
  5. package/dist/core/compute/atlas.d.ts +94 -0
  6. package/dist/core/compute/atlas.js +98 -0
  7. package/dist/core/compute/atlas.js.map +1 -0
  8. package/dist/core/compute/index.d.ts +13 -0
  9. package/dist/core/compute/index.js +9 -0
  10. package/dist/core/compute/index.js.map +1 -0
  11. package/dist/core/compute/pyramid.d.ts +105 -0
  12. package/dist/core/compute/pyramid.js +455 -0
  13. package/dist/core/compute/pyramid.js.map +1 -0
  14. package/dist/core/compute/shared.d.ts +115 -0
  15. package/dist/core/compute/shared.js +211 -0
  16. package/dist/core/compute/shared.js.map +1 -0
  17. package/dist/core/compute/stats.d.ts +71 -0
  18. package/dist/core/compute/stats.js +188 -0
  19. package/dist/core/compute/stats.js.map +1 -0
  20. package/dist/core/compute/value-transform.d.ts +23 -0
  21. package/dist/core/compute/value-transform.js +58 -0
  22. package/dist/core/compute/value-transform.js.map +1 -0
  23. package/dist/core/errors.d.ts +11 -0
  24. package/dist/core/errors.js +9 -0
  25. package/dist/core/errors.js.map +1 -0
  26. package/dist/core/index.d.ts +30 -0
  27. package/dist/core/index.js +27 -0
  28. package/dist/core/index.js.map +1 -0
  29. package/dist/core/internal.d.ts +15 -0
  30. package/dist/core/internal.js +15 -0
  31. package/dist/core/internal.js.map +1 -0
  32. package/dist/core/pool/affine.d.ts +34 -0
  33. package/dist/core/pool/affine.js +100 -0
  34. package/dist/core/pool/affine.js.map +1 -0
  35. package/dist/core/pool/allocator.d.ts +32 -0
  36. package/dist/core/pool/allocator.js +81 -0
  37. package/dist/core/pool/allocator.js.map +1 -0
  38. package/dist/core/pool/image-header.d.ts +82 -0
  39. package/dist/core/pool/image-header.js +175 -0
  40. package/dist/core/pool/image-header.js.map +1 -0
  41. package/dist/core/pool/layout.d.ts +164 -0
  42. package/dist/core/pool/layout.js +267 -0
  43. package/dist/core/pool/layout.js.map +1 -0
  44. package/dist/core/pool/limits.d.ts +40 -0
  45. package/dist/core/pool/limits.js +79 -0
  46. package/dist/core/pool/limits.js.map +1 -0
  47. package/dist/core/pool/pool.d.ts +279 -0
  48. package/dist/core/pool/pool.js +953 -0
  49. package/dist/core/pool/pool.js.map +1 -0
  50. package/dist/core/source/dense.d.ts +19 -0
  51. package/dist/core/source/dense.js +287 -0
  52. package/dist/core/source/dense.js.map +1 -0
  53. package/dist/core/source/types.d.ts +63 -0
  54. package/dist/core/source/types.js +9 -0
  55. package/dist/core/source/types.js.map +1 -0
  56. package/dist/core/types.d.ts +28 -0
  57. package/dist/core/types.js +28 -0
  58. package/dist/core/types.js.map +1 -0
  59. package/dist/core/wgsl/api.d.ts +41 -0
  60. package/dist/core/wgsl/api.js +463 -0
  61. package/dist/core/wgsl/api.js.map +1 -0
  62. package/dist/core/wgsl/generate.d.ts +82 -0
  63. package/dist/core/wgsl/generate.js +505 -0
  64. package/dist/core/wgsl/generate.js.map +1 -0
  65. package/dist/core/wgsl/level-set.d.ts +54 -0
  66. package/dist/core/wgsl/level-set.js +194 -0
  67. package/dist/core/wgsl/level-set.js.map +1 -0
  68. package/dist/core/wgsl/pnanovdb.chunks.generated.d.ts +14 -0
  69. package/dist/core/wgsl/pnanovdb.chunks.generated.js +330 -0
  70. package/dist/core/wgsl/pnanovdb.chunks.generated.js.map +1 -0
  71. package/dist/core/wgsl/reserved.d.ts +9 -0
  72. package/dist/core/wgsl/reserved.js +26 -0
  73. package/dist/core/wgsl/reserved.js.map +1 -0
  74. package/dist/core/wgsl/types.d.ts +104 -0
  75. package/dist/core/wgsl/types.js +2 -0
  76. package/dist/core/wgsl/types.js.map +1 -0
  77. package/dist/three/coarse-first.d.ts +162 -0
  78. package/dist/three/coarse-first.js +187 -0
  79. package/dist/three/coarse-first.js.map +1 -0
  80. package/dist/three/compute.d.ts +63 -0
  81. package/dist/three/compute.js +56 -0
  82. package/dist/three/compute.js.map +1 -0
  83. package/dist/three/device.d.ts +59 -0
  84. package/dist/three/device.js +59 -0
  85. package/dist/three/device.js.map +1 -0
  86. package/dist/three/frame/blackbody.d.ts +42 -0
  87. package/dist/three/frame/blackbody.js +74 -0
  88. package/dist/three/frame/blackbody.js.map +1 -0
  89. package/dist/three/frame/chunks.d.ts +157 -0
  90. package/dist/three/frame/chunks.js +559 -0
  91. package/dist/three/frame/chunks.js.map +1 -0
  92. package/dist/three/frame/density-material.d.ts +53 -0
  93. package/dist/three/frame/density-material.js +353 -0
  94. package/dist/three/frame/density-material.js.map +1 -0
  95. package/dist/three/frame/emission-light.d.ts +167 -0
  96. package/dist/three/frame/emission-light.js +655 -0
  97. package/dist/three/frame/emission-light.js.map +1 -0
  98. package/dist/three/frame/environment-grid-material.d.ts +21 -0
  99. package/dist/three/frame/environment-grid-material.js +184 -0
  100. package/dist/three/frame/environment-grid-material.js.map +1 -0
  101. package/dist/three/frame/environment-material.d.ts +22 -0
  102. package/dist/three/frame/environment-material.js +87 -0
  103. package/dist/three/frame/environment-material.js.map +1 -0
  104. package/dist/three/frame/grid-mip-material.d.ts +12 -0
  105. package/dist/three/frame/grid-mip-material.js +61 -0
  106. package/dist/three/frame/grid-mip-material.js.map +1 -0
  107. package/dist/three/frame/index.d.ts +39 -0
  108. package/dist/three/frame/index.js +35 -0
  109. package/dist/three/frame/index.js.map +1 -0
  110. package/dist/three/frame/inject-material.d.ts +56 -0
  111. package/dist/three/frame/inject-material.js +424 -0
  112. package/dist/three/frame/inject-material.js.map +1 -0
  113. package/dist/three/frame/integrate-material.d.ts +26 -0
  114. package/dist/three/frame/integrate-material.js +198 -0
  115. package/dist/three/frame/integrate-material.js.map +1 -0
  116. package/dist/three/frame/layout.d.ts +34 -0
  117. package/dist/three/frame/layout.js +48 -0
  118. package/dist/three/frame/layout.js.map +1 -0
  119. package/dist/three/frame/lighting-material.d.ts +41 -0
  120. package/dist/three/frame/lighting-material.js +257 -0
  121. package/dist/three/frame/lighting-material.js.map +1 -0
  122. package/dist/three/frame/lights.d.ts +11 -0
  123. package/dist/three/frame/lights.js +16 -0
  124. package/dist/three/frame/lights.js.map +1 -0
  125. package/dist/three/frame/medium.d.ts +21 -0
  126. package/dist/three/frame/medium.js +29 -0
  127. package/dist/three/frame/medium.js.map +1 -0
  128. package/dist/three/frame/neural.d.ts +14 -0
  129. package/dist/three/frame/neural.js +105 -0
  130. package/dist/three/frame/neural.js.map +1 -0
  131. package/dist/three/frame/phase.d.ts +44 -0
  132. package/dist/three/frame/phase.js +80 -0
  133. package/dist/three/frame/phase.js.map +1 -0
  134. package/dist/three/frame/renderer.d.ts +493 -0
  135. package/dist/three/frame/renderer.js +1498 -0
  136. package/dist/three/frame/renderer.js.map +1 -0
  137. package/dist/three/frame/shadow-density-material.d.ts +30 -0
  138. package/dist/three/frame/shadow-density-material.js +123 -0
  139. package/dist/three/frame/shadow-density-material.js.map +1 -0
  140. package/dist/three/frame/spectrum.d.ts +18 -0
  141. package/dist/three/frame/spectrum.js +36 -0
  142. package/dist/three/frame/spectrum.js.map +1 -0
  143. package/dist/three/frame/temporal-material.d.ts +29 -0
  144. package/dist/three/frame/temporal-material.js +152 -0
  145. package/dist/three/frame/temporal-material.js.map +1 -0
  146. package/dist/three/frame/three-internals.d.ts +65 -0
  147. package/dist/three/frame/three-internals.js +150 -0
  148. package/dist/three/frame/three-internals.js.map +1 -0
  149. package/dist/three/frame/transmittance-material.d.ts +31 -0
  150. package/dist/three/frame/transmittance-material.js +315 -0
  151. package/dist/three/frame/transmittance-material.js.map +1 -0
  152. package/dist/three/frame/view.d.ts +103 -0
  153. package/dist/three/frame/view.js +296 -0
  154. package/dist/three/frame/view.js.map +1 -0
  155. package/dist/three/frame/volume-shadow-material.d.ts +36 -0
  156. package/dist/three/frame/volume-shadow-material.js +128 -0
  157. package/dist/three/frame/volume-shadow-material.js.map +1 -0
  158. package/dist/three/frame/volume-shadows.d.ts +153 -0
  159. package/dist/three/frame/volume-shadows.js +756 -0
  160. package/dist/three/frame/volume-shadows.js.map +1 -0
  161. package/dist/three/frame/volume.d.ts +172 -0
  162. package/dist/three/frame/volume.js +256 -0
  163. package/dist/three/frame/volume.js.map +1 -0
  164. package/dist/three/grid-node.d.ts +196 -0
  165. package/dist/three/grid-node.js +510 -0
  166. package/dist/three/grid-node.js.map +1 -0
  167. package/dist/three/index.d.ts +43 -0
  168. package/dist/three/index.js +49 -0
  169. package/dist/three/index.js.map +1 -0
  170. package/dist/three/internal.d.ts +14 -0
  171. package/dist/three/internal.js +14 -0
  172. package/dist/three/internal.js.map +1 -0
  173. package/dist/three/level-set-material.d.ts +112 -0
  174. package/dist/three/level-set-material.js +204 -0
  175. package/dist/three/level-set-material.js.map +1 -0
  176. package/dist/three/material.d.ts +194 -0
  177. package/dist/three/material.js +359 -0
  178. package/dist/three/material.js.map +1 -0
  179. package/dist/three/points.d.ts +84 -0
  180. package/dist/three/points.js +130 -0
  181. package/dist/three/points.js.map +1 -0
  182. package/dist/three/sequence.d.ts +317 -0
  183. package/dist/three/sequence.js +526 -0
  184. package/dist/three/sequence.js.map +1 -0
  185. package/dist/three/sparse-source.d.ts +233 -0
  186. package/dist/three/sparse-source.js +876 -0
  187. package/dist/three/sparse-source.js.map +1 -0
  188. package/dist/three/volume-source.d.ts +167 -0
  189. package/dist/three/volume-source.js +353 -0
  190. package/dist/three/volume-source.js.map +1 -0
  191. package/dist/tools/cpu/compute.d.ts +97 -0
  192. package/dist/tools/cpu/compute.js +218 -0
  193. package/dist/tools/cpu/compute.js.map +1 -0
  194. package/dist/tools/cpu/level-set.d.ts +72 -0
  195. package/dist/tools/cpu/level-set.js +261 -0
  196. package/dist/tools/cpu/level-set.js.map +1 -0
  197. package/dist/tools/cpu/march.d.ts +206 -0
  198. package/dist/tools/cpu/march.js +575 -0
  199. package/dist/tools/cpu/march.js.map +1 -0
  200. package/dist/tools/cpu/probe-coords.d.ts +70 -0
  201. package/dist/tools/cpu/probe-coords.js +116 -0
  202. package/dist/tools/cpu/probe-coords.js.map +1 -0
  203. package/dist/tools/cpu/read-value.d.ts +31 -0
  204. package/dist/tools/cpu/read-value.js +336 -0
  205. package/dist/tools/cpu/read-value.js.map +1 -0
  206. package/dist/tools/cpu/sample-trilinear.d.ts +30 -0
  207. package/dist/tools/cpu/sample-trilinear.js +156 -0
  208. package/dist/tools/cpu/sample-trilinear.js.map +1 -0
  209. package/dist/tools/cpu/stride-tables.d.ts +56 -0
  210. package/dist/tools/cpu/stride-tables.generated.d.ts +1058 -0
  211. package/dist/tools/cpu/stride-tables.generated.js +1266 -0
  212. package/dist/tools/cpu/stride-tables.generated.js.map +1 -0
  213. package/dist/tools/cpu/stride-tables.js +78 -0
  214. package/dist/tools/cpu/stride-tables.js.map +1 -0
  215. package/dist/tools/errors.d.ts +57 -0
  216. package/dist/tools/errors.js +58 -0
  217. package/dist/tools/errors.js.map +1 -0
  218. package/dist/tools/frame/blackbody.d.ts +42 -0
  219. package/dist/tools/frame/blackbody.js +116 -0
  220. package/dist/tools/frame/blackbody.js.map +1 -0
  221. package/dist/tools/frame/emission.d.ts +128 -0
  222. package/dist/tools/frame/emission.js +282 -0
  223. package/dist/tools/frame/emission.js.map +1 -0
  224. package/dist/tools/frame/environment.d.ts +105 -0
  225. package/dist/tools/frame/environment.js +268 -0
  226. package/dist/tools/frame/environment.js.map +1 -0
  227. package/dist/tools/frame/grid.d.ts +302 -0
  228. package/dist/tools/frame/grid.js +703 -0
  229. package/dist/tools/frame/grid.js.map +1 -0
  230. package/dist/tools/frame/index.d.ts +136 -0
  231. package/dist/tools/frame/index.js +348 -0
  232. package/dist/tools/frame/index.js.map +1 -0
  233. package/dist/tools/frame/medium.d.ts +61 -0
  234. package/dist/tools/frame/medium.js +99 -0
  235. package/dist/tools/frame/medium.js.map +1 -0
  236. package/dist/tools/frame/mie-table.d.ts +6 -0
  237. package/dist/tools/frame/mie-table.js +16 -0
  238. package/dist/tools/frame/mie-table.js.map +1 -0
  239. package/dist/tools/frame/mie.d.ts +54 -0
  240. package/dist/tools/frame/mie.js +176 -0
  241. package/dist/tools/frame/mie.js.map +1 -0
  242. package/dist/tools/frame/neural-weights.d.ts +9 -0
  243. package/dist/tools/frame/neural-weights.js +245 -0
  244. package/dist/tools/frame/neural-weights.js.map +1 -0
  245. package/dist/tools/frame/neural.d.ts +80 -0
  246. package/dist/tools/frame/neural.js +150 -0
  247. package/dist/tools/frame/neural.js.map +1 -0
  248. package/dist/tools/frame/pyramid-layout.d.ts +38 -0
  249. package/dist/tools/frame/pyramid-layout.js +53 -0
  250. package/dist/tools/frame/pyramid-layout.js.map +1 -0
  251. package/dist/tools/frame/shadows.d.ts +80 -0
  252. package/dist/tools/frame/shadows.js +182 -0
  253. package/dist/tools/frame/shadows.js.map +1 -0
  254. package/dist/tools/frame/sparse.d.ts +65 -0
  255. package/dist/tools/frame/sparse.js +191 -0
  256. package/dist/tools/frame/sparse.js.map +1 -0
  257. package/dist/tools/frame/spectral.d.ts +203 -0
  258. package/dist/tools/frame/spectral.js +550 -0
  259. package/dist/tools/frame/spectral.js.map +1 -0
  260. package/dist/tools/index.d.ts +106 -0
  261. package/dist/tools/index.js +88 -0
  262. package/dist/tools/index.js.map +1 -0
  263. package/dist/tools/internal.d.ts +46 -0
  264. package/dist/tools/internal.js +31 -0
  265. package/dist/tools/internal.js.map +1 -0
  266. package/dist/tools/nanovdb/build-from-vdb.d.ts +50 -0
  267. package/dist/tools/nanovdb/build-from-vdb.js +92 -0
  268. package/dist/tools/nanovdb/build-from-vdb.js.map +1 -0
  269. package/dist/tools/nanovdb/bytes.d.ts +220 -0
  270. package/dist/tools/nanovdb/bytes.js +345 -0
  271. package/dist/tools/nanovdb/bytes.js.map +1 -0
  272. package/dist/tools/nanovdb/coarse-first.d.ts +62 -0
  273. package/dist/tools/nanovdb/coarse-first.js +86 -0
  274. package/dist/tools/nanovdb/coarse-first.js.map +1 -0
  275. package/dist/tools/nanovdb/index.d.ts +32 -0
  276. package/dist/tools/nanovdb/index.js +24 -0
  277. package/dist/tools/nanovdb/index.js.map +1 -0
  278. package/dist/tools/nanovdb/inspect.d.ts +24 -0
  279. package/dist/tools/nanovdb/inspect.js +63 -0
  280. package/dist/tools/nanovdb/inspect.js.map +1 -0
  281. package/dist/tools/nanovdb/leaf-codec.d.ts +85 -0
  282. package/dist/tools/nanovdb/leaf-codec.js +320 -0
  283. package/dist/tools/nanovdb/leaf-codec.js.map +1 -0
  284. package/dist/tools/nanovdb/quantize.d.ts +43 -0
  285. package/dist/tools/nanovdb/quantize.js +277 -0
  286. package/dist/tools/nanovdb/quantize.js.map +1 -0
  287. package/dist/tools/nanovdb/resample.d.ts +160 -0
  288. package/dist/tools/nanovdb/resample.js +679 -0
  289. package/dist/tools/nanovdb/resample.js.map +1 -0
  290. package/dist/tools/nanovdb/serialize.d.ts +145 -0
  291. package/dist/tools/nanovdb/serialize.js +395 -0
  292. package/dist/tools/nanovdb/serialize.js.map +1 -0
  293. package/dist/tools/nanovdb/stats.d.ts +58 -0
  294. package/dist/tools/nanovdb/stats.js +149 -0
  295. package/dist/tools/nanovdb/stats.js.map +1 -0
  296. package/dist/tools/nanovdb/transform.d.ts +26 -0
  297. package/dist/tools/nanovdb/transform.js +91 -0
  298. package/dist/tools/nanovdb/transform.js.map +1 -0
  299. package/dist/tools/nanovdb/tree.d.ts +175 -0
  300. package/dist/tools/nanovdb/tree.js +518 -0
  301. package/dist/tools/nanovdb/tree.js.map +1 -0
  302. package/dist/tools/nanovdb/write-nvdb.d.ts +39 -0
  303. package/dist/tools/nanovdb/write-nvdb.js +210 -0
  304. package/dist/tools/nanovdb/write-nvdb.js.map +1 -0
  305. package/dist/tools/nvdb-file.d.ts +195 -0
  306. package/dist/tools/nvdb-file.js +606 -0
  307. package/dist/tools/nvdb-file.js.map +1 -0
  308. package/dist/tools/nvdb-stream.d.ts +138 -0
  309. package/dist/tools/nvdb-stream.js +365 -0
  310. package/dist/tools/nvdb-stream.js.map +1 -0
  311. package/dist/tools/vdb/bit-utils.d.ts +20 -0
  312. package/dist/tools/vdb/bit-utils.js +42 -0
  313. package/dist/tools/vdb/bit-utils.js.map +1 -0
  314. package/dist/tools/vdb/blosc.d.ts +56 -0
  315. package/dist/tools/vdb/blosc.js +231 -0
  316. package/dist/tools/vdb/blosc.js.map +1 -0
  317. package/dist/tools/vdb/byte-reader.d.ts +40 -0
  318. package/dist/tools/vdb/byte-reader.js +139 -0
  319. package/dist/tools/vdb/byte-reader.js.map +1 -0
  320. package/dist/tools/vdb/compression.d.ts +73 -0
  321. package/dist/tools/vdb/compression.js +249 -0
  322. package/dist/tools/vdb/compression.js.map +1 -0
  323. package/dist/tools/vdb/errors.d.ts +10 -0
  324. package/dist/tools/vdb/errors.js +11 -0
  325. package/dist/tools/vdb/errors.js.map +1 -0
  326. package/dist/tools/vdb/grid.d.ts +37 -0
  327. package/dist/tools/vdb/grid.js +147 -0
  328. package/dist/tools/vdb/grid.js.map +1 -0
  329. package/dist/tools/vdb/half-float.d.ts +9 -0
  330. package/dist/tools/vdb/half-float.js +24 -0
  331. package/dist/tools/vdb/half-float.js.map +1 -0
  332. package/dist/tools/vdb/index.d.ts +3 -0
  333. package/dist/tools/vdb/index.js +3 -0
  334. package/dist/tools/vdb/index.js.map +1 -0
  335. package/dist/tools/vdb/inflate.d.ts +24 -0
  336. package/dist/tools/vdb/inflate.js +334 -0
  337. package/dist/tools/vdb/inflate.js.map +1 -0
  338. package/dist/tools/vdb/metadata.d.ts +17 -0
  339. package/dist/tools/vdb/metadata.js +72 -0
  340. package/dist/tools/vdb/metadata.js.map +1 -0
  341. package/dist/tools/vdb/parse.d.ts +25 -0
  342. package/dist/tools/vdb/parse.js +171 -0
  343. package/dist/tools/vdb/parse.js.map +1 -0
  344. package/dist/tools/vdb/point-render-data.d.ts +31 -0
  345. package/dist/tools/vdb/point-render-data.js +57 -0
  346. package/dist/tools/vdb/point-render-data.js.map +1 -0
  347. package/dist/tools/vdb/points.d.ts +160 -0
  348. package/dist/tools/vdb/points.js +794 -0
  349. package/dist/tools/vdb/points.js.map +1 -0
  350. package/dist/tools/vdb/transform.d.ts +23 -0
  351. package/dist/tools/vdb/transform.js +54 -0
  352. package/dist/tools/vdb/transform.js.map +1 -0
  353. package/dist/tools/vdb/tree.d.ts +111 -0
  354. package/dist/tools/vdb/tree.js +228 -0
  355. package/dist/tools/vdb/tree.js.map +1 -0
  356. package/dist/tools/vdb/types.d.ts +138 -0
  357. package/dist/tools/vdb/types.js +3 -0
  358. package/dist/tools/vdb/types.js.map +1 -0
  359. package/dist/tools/wvdb/bake.d.ts +116 -0
  360. package/dist/tools/wvdb/bake.js +311 -0
  361. package/dist/tools/wvdb/bake.js.map +1 -0
  362. package/dist/tools/wvdb/dense.d.ts +112 -0
  363. package/dist/tools/wvdb/dense.js +309 -0
  364. package/dist/tools/wvdb/dense.js.map +1 -0
  365. package/dist/tools/wvdb/format.d.ts +161 -0
  366. package/dist/tools/wvdb/format.js +303 -0
  367. package/dist/tools/wvdb/format.js.map +1 -0
  368. package/dist/tools/wvdb/index.d.ts +13 -0
  369. package/dist/tools/wvdb/index.js +14 -0
  370. package/dist/tools/wvdb/index.js.map +1 -0
  371. package/dist/tools/wvdb/level-set.d.ts +48 -0
  372. package/dist/tools/wvdb/level-set.js +153 -0
  373. package/dist/tools/wvdb/level-set.js.map +1 -0
  374. package/dist/tools/wvdb/nanovdb.d.ts +54 -0
  375. package/dist/tools/wvdb/nanovdb.js +60 -0
  376. package/dist/tools/wvdb/nanovdb.js.map +1 -0
  377. package/dist/tools/wvdb/read.d.ts +260 -0
  378. package/dist/tools/wvdb/read.js +743 -0
  379. package/dist/tools/wvdb/read.js.map +1 -0
  380. package/dist/tools/wvdb/sha256.d.ts +7 -0
  381. package/dist/tools/wvdb/sha256.js +76 -0
  382. package/dist/tools/wvdb/sha256.js.map +1 -0
  383. package/dist/tools/wvdb/write.d.ts +127 -0
  384. package/dist/tools/wvdb/write.js +396 -0
  385. package/dist/tools/wvdb/write.js.map +1 -0
  386. package/package.json +82 -4
  387. package/vendor/LICENSE +201 -0
  388. package/vendor/NOTICE +19 -0
  389. package/vendor/VENDOR.md +85 -0
  390. package/vendor/pnanovdb.wgsl +1539 -0
@@ -0,0 +1,348 @@
1
+ // Portions derived from mjurczyk/openvdb (MIT), commit 75e7345 (v0.26.0):
2
+ // src/three-openvdb/frame/webgpu/frameShaderChunks.js L94–107 (frameSliceDepth, frameGetViewPosition),
3
+ // L129–142 (frameDistanceFade), L157–185 (getSampledLod, getBoxSteps, frameNoise), L187–194
4
+ // (frameHenyeyGreenstein), L273–288 (framePhaseWeight), L330–373 (shadow step / depth / transmittance),
5
+ // L464–481 (frameShadowedLight);
6
+ // src/three-openvdb/frame/webgpu/FrameInjectMaterial.js L193–232 (slice pre-integration);
7
+ // src/three-openvdb/frame/webgpu/FrameIntegrateMaterial.js L219–293 (slice march and composite);
8
+ // src/three-openvdb/frame/core/frameView.js L258–271 (getFroxelSlice, getFroxelSliceRange).
9
+ // Copyright (c) mjurczyk/openvdb contributors. Licensed under the MIT License (see THIRD_PARTY_NOTICES.md).
10
+ // K3.4: frameShaderChunks.js L196–203 (frameHenyeyGreensteinColor), L273–328 (the Lorenz-Mie branches
11
+ // of framePhaseWeight / framePhaseColor, framePhaseWeightScaled), L342–399 (octave march depth and
12
+ // transmittance, frameShadowOpticalDepth, frameOctaveLight), L416–462 (frameTwoSidedDiffusion,
13
+ // frameShadowTotal), L464–481 (frameShadowedLight with octaves); core/framePhase.js L110–129
14
+ // (getFrameScatteringOctaves).
15
+ // Changes: CPU (f64) twins of the TSL shader maths, used as test oracles (grey; the spectral twins are in
16
+ // spectral.ts). Divergences: DIVERGES.md (K3.1 and K3.4 rows).
17
+ /**
18
+ * CPU twins of the froxel pipeline maths (K3.1, R1 §6 Step 1; CLAUDE.md "every WGSL entry has a CPU
19
+ * twin"). Each function mirrors one TSL chunk of `@pmndrs/vdb/three` `frame/chunks.ts`, in f64, so
20
+ * the GPU passes can be checked against it (e2e `k3-frame` probe) and the maths can move into `core`
21
+ * as WGSL later (K3.8) with the same oracle. Engine-free: plain numbers and tuples.
22
+ */
23
+ import { vdbFrameMieAsymmetry, vdbFrameMiePhase, vdbFrameMieRgbMode, vdbFrameMieRgbPhase } from "./mie.js";
24
+ const dot3 = (a, b) => a[0] * b[0] + a[1] * b[1] + a[2] * b[2];
25
+ const clamp = (x, lo, hi) => Math.min(hi, Math.max(lo, x));
26
+ const fract = (x) => x - Math.floor(x);
27
+ /** frameSliceDepth: view depth at the slice fraction `t` of the log range (near, far). */
28
+ export function vdbFrameSliceDepth(range, t) {
29
+ return range[0] * Math.pow(range[1] / range[0], t);
30
+ }
31
+ /** frameView.getFroxelSlice: fractional slice of a view depth (inverse of {@link vdbFrameSliceDepth} × depth). */
32
+ export function vdbFrameFroxelSlice(viewDepth, range, depth) {
33
+ return (depth * Math.log(Math.max(viewDepth, range[0]) / range[0])) / Math.log(range[1] / range[0]);
34
+ }
35
+ /** frameView.getFroxelSliceRange: first slice and slice count of a view depth range. */
36
+ export function vdbFrameSliceRange(viewNear, viewFar, range, depth) {
37
+ const first = Math.max(0, Math.floor(vdbFrameFroxelSlice(viewNear, range, depth)));
38
+ const last = Math.min(depth - 1, Math.ceil(vdbFrameFroxelSlice(viewFar, range, depth)));
39
+ return { first, count: last - first + 1 };
40
+ }
41
+ /** Column-major 4x4 times (x, y, z, w). */
42
+ function mul4(m, v) {
43
+ const o = [0, 0, 0, 0];
44
+ for (let r = 0; r < 4; r++)
45
+ o[r] = m[r] * v[0] + m[4 + r] * v[1] + m[8 + r] * v[2] + m[12 + r] * v[3];
46
+ return o;
47
+ }
48
+ /**
49
+ * frameGetViewPosition: the view-space point at view depth `viewDepth` on the ray of `uv`
50
+ * (bottom-left [0, 1]²), from the inverse projection (column-major). NDC depth 0 and 1 are both in
51
+ * the frustum (WebGPU and WebGL), so the ray is the line through the two unprojected points.
52
+ */
53
+ export function vdbFrameViewPosition(projectionInverse, uv, viewDepth) {
54
+ const ndc = [uv[0] * 2 - 1, uv[1] * 2 - 1];
55
+ const n = mul4(projectionInverse, [ndc[0], ndc[1], 0, 1]);
56
+ const f = mul4(projectionInverse, [ndc[0], ndc[1], 1, 1]);
57
+ const near = [n[0] / n[3], n[1] / n[3], n[2] / n[3]];
58
+ const far = [f[0] / f[3], f[1] / f[3], f[2] / f[3]];
59
+ const t = (viewDepth + near[2]) / (near[2] - far[2]);
60
+ return [near[0] + (far[0] - near[0]) * t, near[1] + (far[1] - near[1]) * t, near[2] + (far[2] - near[2]) * t];
61
+ }
62
+ /** frameGetFroxel: slice, uv and view positions of the froxel at an atlas pixel (bottom-left `fragCoord`). */
63
+ export function vdbFrameFroxel(grid, columns, range, projectionInverse, fragCoord) {
64
+ const tile = [Math.floor(fragCoord[0] / grid[0]), Math.floor(fragCoord[1] / grid[1])];
65
+ const slice = tile[1] * columns + tile[0];
66
+ const uv = [(fragCoord[0] - tile[0] * grid[0]) / grid[0], (fragCoord[1] - tile[1] * grid[1]) / grid[1]];
67
+ const sliceNear = vdbFrameSliceDepth(range, slice / grid[2]);
68
+ const sliceFar = vdbFrameSliceDepth(range, (slice + 1) / grid[2]);
69
+ return {
70
+ tile,
71
+ slice,
72
+ uv,
73
+ sliceNear,
74
+ sliceFar,
75
+ viewNear: vdbFrameViewPosition(projectionInverse, uv, sliceNear),
76
+ viewFar: vdbFrameViewPosition(projectionInverse, uv, sliceFar),
77
+ };
78
+ }
79
+ /** frameDistanceFade: density scale at a view position (radius 0 = no fade). */
80
+ export function vdbFrameDistanceFade(fadeRadius, viewPosition) {
81
+ if (!(fadeRadius > 0))
82
+ return 1;
83
+ const k = 4.0;
84
+ const end = Math.exp(-k);
85
+ const x = clamp(Math.hypot(...viewPosition) / fadeRadius, 0, 1);
86
+ return (Math.exp(-k * x * x) - end) / (1 - end);
87
+ }
88
+ /** getBoxSteps: sub-steps across the in-box part of a slice (2 per voxel of the read level, ≤ subSteps). */
89
+ export function vdbFrameBoxSteps(boxLength, maxTexels, sampledLod, subSteps) {
90
+ const lod = Math.max(0, Math.log2(boxLength * maxTexels));
91
+ return Math.trunc(clamp(Math.ceil(Math.pow(2, lod - sampledLod) * 2), 1, subSteps));
92
+ }
93
+ /** frameNoise: interleaved gradient noise (Jimenez 2014); 0.5 when jitter is off (negative). */
94
+ export function vdbFrameNoise(jitter, pixel) {
95
+ const noise = fract(52.9829189 * fract(pixel[0] * 0.06711056 + pixel[1] * 0.00583715));
96
+ return jitter < 0 ? 0.5 : fract(noise + jitter);
97
+ }
98
+ /** frameHenyeyGreenstein: HG phase divided by the isotropic phase 1/(4π); g = 0 gives 1. */
99
+ export function vdbFrameHenyeyGreenstein(cosTheta, g) {
100
+ const g2 = g * g;
101
+ return (1 - g2) / Math.pow(Math.max(1 + g2 - 2 * g * cosTheta, 1e-4), 1.5);
102
+ }
103
+ /**
104
+ * framePhaseWeight: `phase` is (forward g, back g, back weight, Lorenz-Mie mode); dual-lobe is a mix
105
+ * of two HG lobes; mode > 0 mixes the 'lorenz-mie' table in by the mode (his code; only modes 0 and 1
106
+ * reach it, 'lorenz-mie-rgb' takes the per-channel branch of {@link vdbFramePhaseColor}).
107
+ * `rayDirection` camera → sample, `lightDirection` sample → light (both unit).
108
+ */
109
+ export function vdbFramePhaseWeight(phase, rayDirection, lightDirection) {
110
+ const c = dot3(rayDirection, lightDirection);
111
+ const a = vdbFrameHenyeyGreenstein(c, phase[0]);
112
+ const b = vdbFrameHenyeyGreenstein(c, phase[1]);
113
+ const w = a + (b - a) * phase[2];
114
+ return phase[3] > 0 ? w + (vdbFrameMiePhase(c) - w) * phase[3] : w;
115
+ }
116
+ /** frameHenyeyGreensteinColor: HG of each channel, g of each channel. */
117
+ export function vdbFrameHenyeyGreensteinColor(cosTheta, g) {
118
+ return [vdbFrameHenyeyGreenstein(cosTheta, g[0]), vdbFrameHenyeyGreenstein(cosTheta, g[1]), vdbFrameHenyeyGreenstein(cosTheta, g[2])];
119
+ }
120
+ /**
121
+ * framePhaseColor: the phase of each channel. `phaseSpectrum` is (red g scale, blue g scale, flag)
122
+ * (`getFramePhaseSpectrum`): flag 0 the same phase for all channels; 'lorenz-mie-rgb' its three
123
+ * tables; else per-channel g = clamp(g × scale, ±0.99) of both lobes (`phaseGExponent`).
124
+ */
125
+ export function vdbFramePhaseColor(phase, phaseSpectrum, rayDirection, lightDirection) {
126
+ const c = dot3(rayDirection, lightDirection);
127
+ if (phaseSpectrum[2] < 0.5) {
128
+ const w = vdbFramePhaseWeight(phase, rayDirection, lightDirection);
129
+ return [w, w, w];
130
+ }
131
+ if (phase[3] > vdbFrameMieRgbMode - 0.5)
132
+ return vdbFrameMieRgbPhase(c);
133
+ const scale = [phaseSpectrum[0], 1, phaseSpectrum[1]];
134
+ const g = (base) => scale.map((s) => clamp(s * base, -0.99, 0.99));
135
+ const a = vdbFrameHenyeyGreensteinColor(c, g(phase[0]));
136
+ const b = vdbFrameHenyeyGreensteinColor(c, g(phase[1]));
137
+ return [0, 1, 2].map((i) => a[i] + (b[i] - a[i]) * phase[2]);
138
+ }
139
+ /**
140
+ * framePhaseWeightScaled: the phase with every g × gScale; the Lorenz-Mie modes use HG with the table
141
+ * asymmetry (0.8526) × gScale, mixed in by min(mode, 1).
142
+ */
143
+ export function vdbFramePhaseWeightScaled(phase, cosTheta, gScale) {
144
+ const a = vdbFrameHenyeyGreenstein(cosTheta, phase[0] * gScale);
145
+ const b = vdbFrameHenyeyGreenstein(cosTheta, phase[1] * gScale);
146
+ const lobes = a + (b - a) * phase[2];
147
+ const mie = vdbFrameHenyeyGreenstein(cosTheta, gScale * vdbFrameMieAsymmetry);
148
+ return lobes + (mie - lobes) * Math.min(phase[3], 1);
149
+ }
150
+ /** frameShadowAbsorption: the part of the extinction the albedo (Rec. 709 luminance) does not scatter. */
151
+ export function vdbFrameShadowAbsorption(extinction, albedo) {
152
+ return extinction * (1 - clamp(albedo[0] * 0.2126 + albedo[1] * 0.7152 + albedo[2] * 0.0722, 0, 1));
153
+ }
154
+ /** frameShadowStep: (extinction, effective extinction, reduced scattering) of one march step. */
155
+ export function vdbFrameShadowStep(extinction, absorption, multipleScattering) {
156
+ const absorbed = Math.min(absorption, extinction);
157
+ const reduced = (extinction - absorbed) * multipleScattering;
158
+ return [extinction, Math.sqrt(absorbed * 3 * (absorbed + reduced)), reduced];
159
+ }
160
+ /** frameShadowDepth: −log of the total transmittance (1D diffusion when multipleScattering > 0). */
161
+ export function vdbFrameShadowDepth(depths, multipleScattering) {
162
+ return multipleScattering > 0 ? Math.min(depths[0], depths[1] + Math.log(depths[2] * 0.75 + 1)) : depths[0];
163
+ }
164
+ /** Octaves off: (count 0, …). */
165
+ export const vdbFrameOctavesOff = [0, 0, 0, 0];
166
+ /** Most octaves (his `frameMaxScatteringOctaves`). */
167
+ export const vdbFrameMaxScatteringOctaves = 8;
168
+ const clampUnit = (value, fallback) => Math.min(1, Math.max(0, Number.isFinite(Number(value)) ? Number(value) : fallback));
169
+ /**
170
+ * getFrameScatteringOctaves: (count N, extinction a, contribution b, phase c) of multipleScattering
171
+ * 'octaves' (octave n = 1..N has extinction × aⁿ, light × bⁿ, phase g × cⁿ); (0, 0, 0, 0) otherwise.
172
+ */
173
+ export function vdbFrameScatteringOctaves(settings) {
174
+ if (settings.multipleScattering !== "octaves")
175
+ return [0, 0, 0, 0];
176
+ const count = Math.min(vdbFrameMaxScatteringOctaves, Math.max(1, Math.round(Number(settings.scatteringOctaves) || 1)));
177
+ return [count, clampUnit(settings.scatteringOctaveExtinction, 0.5), clampUnit(settings.scatteringOctaveContribution, 0.5), clampUnit(settings.scatteringOctavePhase, 0.5)];
178
+ }
179
+ /** frameShadowMarchDepth: the optical depth that stops a march; with octaves the last octave's σ·aᴺ depth. */
180
+ export function vdbFrameShadowMarchDepth(depths, multipleScattering, octaves = vdbFrameOctavesOff) {
181
+ return octaves[0] > 0 ? depths[0] * Math.pow(octaves[1], octaves[0]) : vdbFrameShadowDepth(depths, multipleScattering);
182
+ }
183
+ /** frameShadowTransmittance: (direct, total); with octaves the total slot holds 1 / (1 + optical depth). */
184
+ export function vdbFrameShadowTransmittance(depths, multipleScattering, octaves = vdbFrameOctavesOff) {
185
+ return [Math.exp(-depths[0]), octaves[0] > 0 ? 1 / (depths[0] + 1) : Math.exp(-vdbFrameShadowDepth(depths, multipleScattering))];
186
+ }
187
+ /** frameShadowOpticalDepth: the optical depth back from the octave shadow value 1 / (1 + τ). */
188
+ export function vdbFrameShadowOpticalDepth(shadowY) {
189
+ return Math.max(1 / Math.max(shadowY, 1e-6) - 1, 0);
190
+ }
191
+ /** frameOctaveLight: Σₙ₌₁..N bⁿ · phase(g cⁿ) · exp(−aⁿ τ); `phase` null is isotropic (phase 1). */
192
+ export function vdbFrameOctaveLight(octaves, opticalDepth, phase, cosTheta) {
193
+ let light = 0;
194
+ let extinctionScale = 1;
195
+ let contribution = 1;
196
+ let gScale = 1;
197
+ for (let i = 0; i < vdbFrameMaxScatteringOctaves; i++) {
198
+ if (i + 1 > octaves[0])
199
+ break;
200
+ extinctionScale *= octaves[1];
201
+ contribution *= octaves[2];
202
+ gScale *= octaves[3];
203
+ const p = phase ? vdbFramePhaseWeightScaled(phase, cosTheta, gScale) : 1;
204
+ light += contribution * p * Math.exp(-opticalDepth * extinctionScale);
205
+ }
206
+ return light;
207
+ }
208
+ /** frameShadowTotal: total transmittance of isotropic light from the y shadow value; octaves: exp(−τ) + Σ bⁿ exp(−aⁿ τ). */
209
+ export function vdbFrameShadowTotal(shadowY, octaves = vdbFrameOctavesOff) {
210
+ if (!(octaves[0] > 0))
211
+ return shadowY;
212
+ const tau = vdbFrameShadowOpticalDepth(shadowY);
213
+ return Math.exp(-tau) + vdbFrameOctaveLight(octaves, tau, null, 0);
214
+ }
215
+ /**
216
+ * frameTwoSidedDiffusion (multipleScattering 'two-sided'): 1D slab diffusion with a collimated source
217
+ * between the light side (front reduced depth f) and the far side (back b), the lowest side mode
218
+ * (k² = 2 (π / (f + b + 2 z₀))²), Robin boundaries with z₀ = ⅔; the diffuse plus the reduced beam
219
+ * exp(−f), times exp(−effective front), never below the direct light.
220
+ */
221
+ export function vdbFrameTwoSidedDiffusion(direct, frontReduced, frontEffective, backReduced) {
222
+ const z0 = 2 / 3;
223
+ const slab = frontReduced + backReduced;
224
+ const k0 = (Math.SQRT2 * Math.PI) / (slab + 2 * z0);
225
+ // k = 1 has no particular solution of this form; a small shift keeps the result continuous (step(0.01, |1 − k0²|)).
226
+ const k = k0 + (1 - (Math.abs(1 - k0 * k0) >= 0.01 ? 1 : 0)) * 0.01;
227
+ const p = -3 / (1 - k * k);
228
+ const kl = k * slab;
229
+ const coshKl = (Math.exp(kl) + Math.exp(-kl)) * 0.5;
230
+ const sinhKl = (Math.exp(kl) - Math.exp(-kl)) * 0.5;
231
+ const c12 = k * -z0;
232
+ const r1 = p * -(1 + z0);
233
+ const c21 = coshKl + k * z0 * sinhKl;
234
+ const c22 = sinhKl + k * z0 * coshKl;
235
+ const r2 = -p * Math.exp(-slab) * (1 - z0);
236
+ const det = c22 - c12 * c21;
237
+ const c = (r1 * c22 - c12 * r2) / det;
238
+ const d = (r2 - c21 * r1) / det;
239
+ const kf = k * frontReduced;
240
+ const beam = Math.exp(-frontReduced);
241
+ const diffuse = p * beam + c * (Math.exp(kf) + Math.exp(-kf)) * 0.5 + d * (Math.exp(kf) - Math.exp(-kf)) * 0.5;
242
+ return Math.max(direct, (diffuse + beam) * Math.exp(-frontEffective));
243
+ }
244
+ /**
245
+ * The shadow march of the inject pass (`volumeTransmittance`), over given extinction samples per unit
246
+ * length already multiplied by the world step and absorbance (`stepScale`). Returns (direct, total,
247
+ * reduced depth, effective depth), stopping when the march depth exceeds 8.
248
+ */
249
+ export function vdbFrameShadowMarch(scaledExtinctions, albedo, multipleScattering, octaves = vdbFrameOctavesOff) {
250
+ const depths = [0, 0, 0];
251
+ for (const e of scaledExtinctions) {
252
+ const s = vdbFrameShadowStep(e, vdbFrameShadowAbsorption(e, albedo), multipleScattering);
253
+ depths[0] += s[0];
254
+ depths[1] += s[1];
255
+ depths[2] += s[2];
256
+ if (vdbFrameShadowMarchDepth(depths, multipleScattering, octaves) > 8)
257
+ break;
258
+ }
259
+ const t = vdbFrameShadowTransmittance(depths, multipleScattering, octaves);
260
+ return [t[0], t[1], depths[2], depths[1]];
261
+ }
262
+ /**
263
+ * frameShadowedLight (grey): phase × direct + scattered; the scattered light is (total − direct)
264
+ * (isotropic), or with octaves Σ bⁿ phase(g cⁿ) exp(−aⁿ τ) from the octave shadow value.
265
+ */
266
+ export function vdbFrameShadowedLight(phase, rayDirection, lightDirection, shadow, octaves = vdbFrameOctavesOff) {
267
+ const direct = vdbFramePhaseWeight(phase, rayDirection, lightDirection) * shadow[0];
268
+ if (octaves[0] > 0)
269
+ return direct + vdbFrameOctaveLight(octaves, vdbFrameShadowOpticalDepth(shadow[1]), phase, dot3(rayDirection, lightDirection));
270
+ return direct + (shadow[1] - shadow[0]);
271
+ }
272
+ /** frameShadowedLight of each channel (per-channel phases: `phaseSpectrum`, see {@link vdbFramePhaseColor}). */
273
+ export function vdbFrameShadowedLightColor(phase, phaseSpectrum, octaves, rayDirection, lightDirection, shadow) {
274
+ const p = vdbFramePhaseColor(phase, phaseSpectrum, rayDirection, lightDirection);
275
+ const scattered = octaves[0] > 0 ? vdbFrameOctaveLight(octaves, vdbFrameShadowOpticalDepth(shadow[1]), phase, dot3(rayDirection, lightDirection)) : shadow[1] - shadow[0];
276
+ return [p[0] * shadow[0] + scattered, p[1] * shadow[0] + scattered, p[2] * shadow[0] + scattered];
277
+ }
278
+ /**
279
+ * The view-ray pre-integration of one froxel in the inject pass: `opticalDepths[i]` is
280
+ * extinction × opacity × fade × sub-step length at sub-step i (t = segX + seg × (i + jitter) / n).
281
+ * Returns the slice alpha and the visibility-weighted mean t (the lit position), or null when the
282
+ * froxel is discarded.
283
+ */
284
+ export function vdbFrameInjectSlice(opticalDepths, segment, jitter = 0.5) {
285
+ const n = opticalDepths.length;
286
+ const seg = segment[1] - segment[0];
287
+ let transmittance = 1;
288
+ let visibleWeight = 0;
289
+ let visibleTSum = 0;
290
+ for (let i = 0; i < n; i++) {
291
+ const t = segment[0] + seg * ((i + jitter) / n);
292
+ const stepT = Math.exp(-opticalDepths[i]);
293
+ const w = transmittance * (1 - stepT);
294
+ visibleWeight += w;
295
+ visibleTSum += w * t;
296
+ transmittance *= stepT;
297
+ }
298
+ const alpha = 1 - transmittance;
299
+ if (visibleWeight <= 0 || alpha <= 1e-5)
300
+ return null;
301
+ return { alpha, t: visibleTSum / visibleWeight };
302
+ }
303
+ /**
304
+ * The integrate pass for one pixel (`createFragmentNode`, grey): front to back over the slices
305
+ * [first, end) of the log range, stopping at the scene depth. `froxels[k]` is the atlas sample of
306
+ * slice `first + k`. Returns premultiplied (radiance, alpha), or null when discarded.
307
+ */
308
+ export function vdbFrameIntegrate(froxels, sliceRange, range, depth, sceneDepth) {
309
+ const radiance = [0, 0, 0];
310
+ let transmittance = 1;
311
+ let sliceStart = vdbFrameSliceDepth(range, sliceRange[0] / depth);
312
+ for (let i = 0; i < 1024; i++) {
313
+ const slice = sliceRange[0] + i;
314
+ if (slice >= sliceRange[1] || sliceStart >= sceneDepth || transmittance < 0.001)
315
+ break;
316
+ const sliceEnd = vdbFrameSliceDepth(range, (slice + 1) / depth);
317
+ const coverage = (Math.min(sliceEnd, sceneDepth) - sliceStart) / (sliceEnd - sliceStart);
318
+ const f = froxels[i] ?? [0, 0, 0, 0];
319
+ const a = clamp(f[3], 0, 1);
320
+ if (a > 0) {
321
+ const sliceAlpha = coverage < 1 ? 1 - Math.pow(1 - a, coverage) : a;
322
+ for (let c = 0; c < 3; c++)
323
+ radiance[c] = radiance[c] + transmittance * f[c] * (sliceAlpha / a);
324
+ transmittance *= 1 - sliceAlpha;
325
+ }
326
+ sliceStart = sliceEnd;
327
+ }
328
+ const alpha = 1 - transmittance;
329
+ return alpha <= 0 ? null : { radiance, alpha };
330
+ }
331
+ /** sRGB OETF (three `sRGBTransferOETF`). */
332
+ export function vdbSrgbOetf(x) {
333
+ return x < 0.0031308 ? x * 12.92 : 1.055 * Math.pow(x, 0.41666) - 0.055;
334
+ }
335
+ /** sRGB EOTF (three `sRGBTransferEOTF`). */
336
+ export function vdbSrgbEotf(x) {
337
+ return x < 0.04045 ? x * 0.0773993808 : Math.pow(x * 0.9478672986 + 0.0521327014, 2.4);
338
+ }
339
+ /** The integrate pass's sRGB blend (`srgbBlending`, clamp on): linear out. */
340
+ export function vdbFrameSrgbBlend(background, radiance, alpha, clampColors = true) {
341
+ const enc = (x) => (clampColors ? clamp(vdbSrgbOetf(x), 0, 1) : vdbSrgbOetf(x));
342
+ return [0, 1, 2].map((c) => {
343
+ const bg = enc(background[c]);
344
+ const vol = enc(radiance[c] / alpha);
345
+ return vdbSrgbEotf(bg + (vol - bg) * alpha);
346
+ });
347
+ }
348
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/tools/frame/index.ts"],"names":[],"mappings":"AAAA,0EAA0E;AAC1E,yGAAyG;AACzG,8FAA8F;AAC9F,0GAA0G;AAC1G,mCAAmC;AACnC,4FAA4F;AAC5F,mGAAmG;AACnG,8FAA8F;AAC9F,4GAA4G;AAC5G,wGAAwG;AACxG,qGAAqG;AACrG,iGAAiG;AACjG,+FAA+F;AAC/F,iCAAiC;AACjC,0GAA0G;AAC1G,+DAA+D;AAE/D;;;;;GAKG;AAEH,OAAO,EAAE,oBAAoB,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,mBAAmB,EAAE,MAAM,UAAU,CAAC;AAM3G,MAAM,IAAI,GAAG,CAAC,CAAO,EAAE,CAAO,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,G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,GAAG,CAAC,CAAS,EAAE,EAAE,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,CAAC;IACxF,OAAO,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE;QACzB,MAAM,EAAE,GAAG,GAAG,CAAC,UAAU,CAAC,CAAC,CAAE,CAAC,CAAC;QAC/B,MAAM,GAAG,GAAG,GAAG,CAAC,QAAQ,CAAC,CAAC,CAAE,GAAG,KAAK,CAAC,CAAC;QACtC,OAAO,WAAW,CAAC,EAAE,GAAG,CAAC,GAAG,GAAG,EAAE,CAAC,GAAG,KAAK,CAAC,CAAC;IAC9C,CAAC,CAAS,CAAC;AACb,CAAC","sourcesContent":["// Portions derived from mjurczyk/openvdb (MIT), commit 75e7345 (v0.26.0):\n// src/three-openvdb/frame/webgpu/frameShaderChunks.js L94–107 (frameSliceDepth, frameGetViewPosition),\n// L129–142 (frameDistanceFade), L157–185 (getSampledLod, getBoxSteps, frameNoise), L187–194\n// (frameHenyeyGreenstein), L273–288 (framePhaseWeight), L330–373 (shadow step / depth / transmittance),\n// L464–481 (frameShadowedLight);\n// src/three-openvdb/frame/webgpu/FrameInjectMaterial.js L193–232 (slice pre-integration);\n// src/three-openvdb/frame/webgpu/FrameIntegrateMaterial.js L219–293 (slice march and composite);\n// src/three-openvdb/frame/core/frameView.js L258–271 (getFroxelSlice, getFroxelSliceRange).\n// Copyright (c) mjurczyk/openvdb contributors. Licensed under the MIT License (see THIRD_PARTY_NOTICES.md).\n// K3.4: frameShaderChunks.js L196–203 (frameHenyeyGreensteinColor), L273–328 (the Lorenz-Mie branches\n// of framePhaseWeight / framePhaseColor, framePhaseWeightScaled), L342–399 (octave march depth and\n// transmittance, frameShadowOpticalDepth, frameOctaveLight), L416–462 (frameTwoSidedDiffusion,\n// frameShadowTotal), L464–481 (frameShadowedLight with octaves); core/framePhase.js L110–129\n// (getFrameScatteringOctaves).\n// Changes: CPU (f64) twins of the TSL shader maths, used as test oracles (grey; the spectral twins are in\n// spectral.ts). Divergences: DIVERGES.md (K3.1 and K3.4 rows).\n\n/**\n * CPU twins of the froxel pipeline maths (K3.1, R1 §6 Step 1; CLAUDE.md \"every WGSL entry has a CPU\n * twin\"). Each function mirrors one TSL chunk of `@pmndrs/vdb/three` `frame/chunks.ts`, in f64, so\n * the GPU passes can be checked against it (e2e `k3-frame` probe) and the maths can move into `core`\n * as WGSL later (K3.8) with the same oracle. Engine-free: plain numbers and tuples.\n */\n\nimport { vdbFrameMieAsymmetry, vdbFrameMiePhase, vdbFrameMieRgbMode, vdbFrameMieRgbPhase } from \"./mie.js\";\n\nexport type Vec2 = [number, number];\nexport type Vec3 = [number, number, number];\nexport type Vec4 = [number, number, number, number];\n\nconst dot3 = (a: Vec3, b: Vec3) => a[0] * b[0] + a[1] * b[1] + a[2] * b[2];\nconst clamp = (x: number, lo: number, hi: number) => Math.min(hi, Math.max(lo, x));\nconst fract = (x: number) => x - Math.floor(x);\n\n/** frameSliceDepth: view depth at the slice fraction `t` of the log range (near, far). */\nexport function vdbFrameSliceDepth(range: Vec2, t: number): number {\n return range[0] * Math.pow(range[1] / range[0], t);\n}\n\n/** frameView.getFroxelSlice: fractional slice of a view depth (inverse of {@link vdbFrameSliceDepth} × depth). */\nexport function vdbFrameFroxelSlice(viewDepth: number, range: Vec2, depth: number): number {\n return (depth * Math.log(Math.max(viewDepth, range[0]) / range[0])) / Math.log(range[1] / range[0]);\n}\n\n/** frameView.getFroxelSliceRange: first slice and slice count of a view depth range. */\nexport function vdbFrameSliceRange(viewNear: number, viewFar: number, range: Vec2, depth: number): { first: number; count: number } {\n const first = Math.max(0, Math.floor(vdbFrameFroxelSlice(viewNear, range, depth)));\n const last = Math.min(depth - 1, Math.ceil(vdbFrameFroxelSlice(viewFar, range, depth)));\n return { first, count: last - first + 1 };\n}\n\n/** Column-major 4x4 times (x, y, z, w). */\nfunction mul4(m: ArrayLike<number>, v: Vec4): Vec4 {\n const o: Vec4 = [0, 0, 0, 0];\n for (let r = 0; r < 4; r++) o[r] = m[r]! * v[0] + m[4 + r]! * v[1] + m[8 + r]! * v[2] + m[12 + r]! * v[3];\n return o;\n}\n\n/**\n * frameGetViewPosition: the view-space point at view depth `viewDepth` on the ray of `uv`\n * (bottom-left [0, 1]²), from the inverse projection (column-major). NDC depth 0 and 1 are both in\n * the frustum (WebGPU and WebGL), so the ray is the line through the two unprojected points.\n */\nexport function vdbFrameViewPosition(projectionInverse: ArrayLike<number>, uv: Vec2, viewDepth: number): Vec3 {\n const ndc: Vec2 = [uv[0] * 2 - 1, uv[1] * 2 - 1];\n const n = mul4(projectionInverse, [ndc[0], ndc[1], 0, 1]);\n const f = mul4(projectionInverse, [ndc[0], ndc[1], 1, 1]);\n const near: Vec3 = [n[0] / n[3], n[1] / n[3], n[2] / n[3]];\n const far: Vec3 = [f[0] / f[3], f[1] / f[3], f[2] / f[3]];\n const t = (viewDepth + near[2]) / (near[2] - far[2]);\n return [near[0] + (far[0] - near[0]) * t, near[1] + (far[1] - near[1]) * t, near[2] + (far[2] - near[2]) * t];\n}\n\n/** frameGetFroxel: slice, uv and view positions of the froxel at an atlas pixel (bottom-left `fragCoord`). */\nexport function vdbFrameFroxel(\n grid: Vec3,\n columns: number,\n range: Vec2,\n projectionInverse: ArrayLike<number>,\n fragCoord: Vec2,\n): { tile: Vec2; slice: number; uv: Vec2; sliceNear: number; sliceFar: number; viewNear: Vec3; viewFar: Vec3 } {\n const tile: Vec2 = [Math.floor(fragCoord[0] / grid[0]), Math.floor(fragCoord[1] / grid[1])];\n const slice = tile[1] * columns + tile[0];\n const uv: Vec2 = [(fragCoord[0] - tile[0] * grid[0]) / grid[0], (fragCoord[1] - tile[1] * grid[1]) / grid[1]];\n const sliceNear = vdbFrameSliceDepth(range, slice / grid[2]);\n const sliceFar = vdbFrameSliceDepth(range, (slice + 1) / grid[2]);\n return {\n tile,\n slice,\n uv,\n sliceNear,\n sliceFar,\n viewNear: vdbFrameViewPosition(projectionInverse, uv, sliceNear),\n viewFar: vdbFrameViewPosition(projectionInverse, uv, sliceFar),\n };\n}\n\n/** frameDistanceFade: density scale at a view position (radius 0 = no fade). */\nexport function vdbFrameDistanceFade(fadeRadius: number, viewPosition: Vec3): number {\n if (!(fadeRadius > 0)) return 1;\n const k = 4.0;\n const end = Math.exp(-k);\n const x = clamp(Math.hypot(...viewPosition) / fadeRadius, 0, 1);\n return (Math.exp(-k * x * x) - end) / (1 - end);\n}\n\n/** getBoxSteps: sub-steps across the in-box part of a slice (2 per voxel of the read level, ≤ subSteps). */\nexport function vdbFrameBoxSteps(boxLength: number, maxTexels: number, sampledLod: number, subSteps: number): number {\n const lod = Math.max(0, Math.log2(boxLength * maxTexels));\n return Math.trunc(clamp(Math.ceil(Math.pow(2, lod - sampledLod) * 2), 1, subSteps));\n}\n\n/** frameNoise: interleaved gradient noise (Jimenez 2014); 0.5 when jitter is off (negative). */\nexport function vdbFrameNoise(jitter: number, pixel: Vec2): number {\n const noise = fract(52.9829189 * fract(pixel[0] * 0.06711056 + pixel[1] * 0.00583715));\n return jitter < 0 ? 0.5 : fract(noise + jitter);\n}\n\n/** frameHenyeyGreenstein: HG phase divided by the isotropic phase 1/(4π); g = 0 gives 1. */\nexport function vdbFrameHenyeyGreenstein(cosTheta: number, g: number): number {\n const g2 = g * g;\n return (1 - g2) / Math.pow(Math.max(1 + g2 - 2 * g * cosTheta, 1e-4), 1.5);\n}\n\n/**\n * framePhaseWeight: `phase` is (forward g, back g, back weight, Lorenz-Mie mode); dual-lobe is a mix\n * of two HG lobes; mode > 0 mixes the 'lorenz-mie' table in by the mode (his code; only modes 0 and 1\n * reach it, 'lorenz-mie-rgb' takes the per-channel branch of {@link vdbFramePhaseColor}).\n * `rayDirection` camera → sample, `lightDirection` sample → light (both unit).\n */\nexport function vdbFramePhaseWeight(phase: Vec4, rayDirection: Vec3, lightDirection: Vec3): number {\n const c = dot3(rayDirection, lightDirection);\n const a = vdbFrameHenyeyGreenstein(c, phase[0]);\n const b = vdbFrameHenyeyGreenstein(c, phase[1]);\n const w = a + (b - a) * phase[2];\n return phase[3] > 0 ? w + (vdbFrameMiePhase(c) - w) * phase[3] : w;\n}\n\n/** frameHenyeyGreensteinColor: HG of each channel, g of each channel. */\nexport function vdbFrameHenyeyGreensteinColor(cosTheta: number, g: Vec3): Vec3 {\n return [vdbFrameHenyeyGreenstein(cosTheta, g[0]), vdbFrameHenyeyGreenstein(cosTheta, g[1]), vdbFrameHenyeyGreenstein(cosTheta, g[2])];\n}\n\n/**\n * framePhaseColor: the phase of each channel. `phaseSpectrum` is (red g scale, blue g scale, flag)\n * (`getFramePhaseSpectrum`): flag 0 the same phase for all channels; 'lorenz-mie-rgb' its three\n * tables; else per-channel g = clamp(g × scale, ±0.99) of both lobes (`phaseGExponent`).\n */\nexport function vdbFramePhaseColor(phase: Vec4, phaseSpectrum: Vec3, rayDirection: Vec3, lightDirection: Vec3): Vec3 {\n const c = dot3(rayDirection, lightDirection);\n if (phaseSpectrum[2] < 0.5) {\n const w = vdbFramePhaseWeight(phase, rayDirection, lightDirection);\n return [w, w, w];\n }\n if (phase[3] > vdbFrameMieRgbMode - 0.5) return vdbFrameMieRgbPhase(c);\n const scale: Vec3 = [phaseSpectrum[0], 1, phaseSpectrum[1]];\n const g = (base: number) => scale.map((s) => clamp(s * base, -0.99, 0.99)) as Vec3;\n const a = vdbFrameHenyeyGreensteinColor(c, g(phase[0]));\n const b = vdbFrameHenyeyGreensteinColor(c, g(phase[1]));\n return [0, 1, 2].map((i) => a[i]! + (b[i]! - a[i]!) * phase[2]) as Vec3;\n}\n\n/**\n * framePhaseWeightScaled: the phase with every g × gScale; the Lorenz-Mie modes use HG with the table\n * asymmetry (0.8526) × gScale, mixed in by min(mode, 1).\n */\nexport function vdbFramePhaseWeightScaled(phase: Vec4, cosTheta: number, gScale: number): number {\n const a = vdbFrameHenyeyGreenstein(cosTheta, phase[0] * gScale);\n const b = vdbFrameHenyeyGreenstein(cosTheta, phase[1] * gScale);\n const lobes = a + (b - a) * phase[2];\n const mie = vdbFrameHenyeyGreenstein(cosTheta, gScale * vdbFrameMieAsymmetry);\n return lobes + (mie - lobes) * Math.min(phase[3], 1);\n}\n\n/** frameShadowAbsorption: the part of the extinction the albedo (Rec. 709 luminance) does not scatter. */\nexport function vdbFrameShadowAbsorption(extinction: number, albedo: Vec3): number {\n return extinction * (1 - clamp(albedo[0] * 0.2126 + albedo[1] * 0.7152 + albedo[2] * 0.0722, 0, 1));\n}\n\n/** frameShadowStep: (extinction, effective extinction, reduced scattering) of one march step. */\nexport function vdbFrameShadowStep(extinction: number, absorption: number, multipleScattering: number): Vec3 {\n const absorbed = Math.min(absorption, extinction);\n const reduced = (extinction - absorbed) * multipleScattering;\n return [extinction, Math.sqrt(absorbed * 3 * (absorbed + reduced)), reduced];\n}\n\n/** frameShadowDepth: −log of the total transmittance (1D diffusion when multipleScattering > 0). */\nexport function vdbFrameShadowDepth(depths: Vec3, multipleScattering: number): number {\n return multipleScattering > 0 ? Math.min(depths[0], depths[1] + Math.log(depths[2] * 0.75 + 1)) : depths[0];\n}\n\n/** Octaves off: (count 0, …). */\nexport const vdbFrameOctavesOff: Vec4 = [0, 0, 0, 0];\n\n/** Most octaves (his `frameMaxScatteringOctaves`). */\nexport const vdbFrameMaxScatteringOctaves = 8;\n\n/** The renderer settings {@link vdbFrameScatteringOctaves} reads (his `frameRenderer.settings`). */\nexport interface VDBFrameOctaveSettings {\n multipleScattering: boolean | string;\n scatteringOctaves: number;\n scatteringOctaveExtinction: number;\n scatteringOctaveContribution: number;\n scatteringOctavePhase: number;\n}\n\nconst clampUnit = (value: unknown, fallback: number) => Math.min(1, Math.max(0, Number.isFinite(Number(value)) ? Number(value) : fallback));\n\n/**\n * getFrameScatteringOctaves: (count N, extinction a, contribution b, phase c) of multipleScattering\n * 'octaves' (octave n = 1..N has extinction × aⁿ, light × bⁿ, phase g × cⁿ); (0, 0, 0, 0) otherwise.\n */\nexport function vdbFrameScatteringOctaves(settings: VDBFrameOctaveSettings): Vec4 {\n if (settings.multipleScattering !== \"octaves\") return [0, 0, 0, 0];\n const count = Math.min(vdbFrameMaxScatteringOctaves, Math.max(1, Math.round(Number(settings.scatteringOctaves) || 1)));\n return [count, clampUnit(settings.scatteringOctaveExtinction, 0.5), clampUnit(settings.scatteringOctaveContribution, 0.5), clampUnit(settings.scatteringOctavePhase, 0.5)];\n}\n\n/** frameShadowMarchDepth: the optical depth that stops a march; with octaves the last octave's σ·aᴺ depth. */\nexport function vdbFrameShadowMarchDepth(depths: Vec3, multipleScattering: number, octaves: Vec4 = vdbFrameOctavesOff): number {\n return octaves[0] > 0 ? depths[0] * Math.pow(octaves[1], octaves[0]) : vdbFrameShadowDepth(depths, multipleScattering);\n}\n\n/** frameShadowTransmittance: (direct, total); with octaves the total slot holds 1 / (1 + optical depth). */\nexport function vdbFrameShadowTransmittance(depths: Vec3, multipleScattering: number, octaves: Vec4 = vdbFrameOctavesOff): Vec2 {\n return [Math.exp(-depths[0]), octaves[0] > 0 ? 1 / (depths[0] + 1) : Math.exp(-vdbFrameShadowDepth(depths, multipleScattering))];\n}\n\n/** frameShadowOpticalDepth: the optical depth back from the octave shadow value 1 / (1 + τ). */\nexport function vdbFrameShadowOpticalDepth(shadowY: number): number {\n return Math.max(1 / Math.max(shadowY, 1e-6) - 1, 0);\n}\n\n/** frameOctaveLight: Σₙ₌₁..N bⁿ · phase(g cⁿ) · exp(−aⁿ τ); `phase` null is isotropic (phase 1). */\nexport function vdbFrameOctaveLight(octaves: Vec4, opticalDepth: number, phase: Vec4 | null, cosTheta: number): number {\n let light = 0;\n let extinctionScale = 1;\n let contribution = 1;\n let gScale = 1;\n for (let i = 0; i < vdbFrameMaxScatteringOctaves; i++) {\n if (i + 1 > octaves[0]) break;\n extinctionScale *= octaves[1];\n contribution *= octaves[2];\n gScale *= octaves[3];\n const p = phase ? vdbFramePhaseWeightScaled(phase, cosTheta, gScale) : 1;\n light += contribution * p * Math.exp(-opticalDepth * extinctionScale);\n }\n return light;\n}\n\n/** frameShadowTotal: total transmittance of isotropic light from the y shadow value; octaves: exp(−τ) + Σ bⁿ exp(−aⁿ τ). */\nexport function vdbFrameShadowTotal(shadowY: number, octaves: Vec4 = vdbFrameOctavesOff): number {\n if (!(octaves[0] > 0)) return shadowY;\n const tau = vdbFrameShadowOpticalDepth(shadowY);\n return Math.exp(-tau) + vdbFrameOctaveLight(octaves, tau, null, 0);\n}\n\n/**\n * frameTwoSidedDiffusion (multipleScattering 'two-sided'): 1D slab diffusion with a collimated source\n * between the light side (front reduced depth f) and the far side (back b), the lowest side mode\n * (k² = 2 (π / (f + b + 2 z₀))²), Robin boundaries with z₀ = ⅔; the diffuse plus the reduced beam\n * exp(−f), times exp(−effective front), never below the direct light.\n */\nexport function vdbFrameTwoSidedDiffusion(direct: number, frontReduced: number, frontEffective: number, backReduced: number): number {\n const z0 = 2 / 3;\n const slab = frontReduced + backReduced;\n const k0 = (Math.SQRT2 * Math.PI) / (slab + 2 * z0);\n // k = 1 has no particular solution of this form; a small shift keeps the result continuous (step(0.01, |1 − k0²|)).\n const k = k0 + (1 - (Math.abs(1 - k0 * k0) >= 0.01 ? 1 : 0)) * 0.01;\n const p = -3 / (1 - k * k);\n const kl = k * slab;\n const coshKl = (Math.exp(kl) + Math.exp(-kl)) * 0.5;\n const sinhKl = (Math.exp(kl) - Math.exp(-kl)) * 0.5;\n const c12 = k * -z0;\n const r1 = p * -(1 + z0);\n const c21 = coshKl + k * z0 * sinhKl;\n const c22 = sinhKl + k * z0 * coshKl;\n const r2 = -p * Math.exp(-slab) * (1 - z0);\n const det = c22 - c12 * c21;\n const c = (r1 * c22 - c12 * r2) / det;\n const d = (r2 - c21 * r1) / det;\n const kf = k * frontReduced;\n const beam = Math.exp(-frontReduced);\n const diffuse = p * beam + c * (Math.exp(kf) + Math.exp(-kf)) * 0.5 + d * (Math.exp(kf) - Math.exp(-kf)) * 0.5;\n return Math.max(direct, (diffuse + beam) * Math.exp(-frontEffective));\n}\n\n/**\n * The shadow march of the inject pass (`volumeTransmittance`), over given extinction samples per unit\n * length already multiplied by the world step and absorbance (`stepScale`). Returns (direct, total,\n * reduced depth, effective depth), stopping when the march depth exceeds 8.\n */\nexport function vdbFrameShadowMarch(scaledExtinctions: readonly number[], albedo: Vec3, multipleScattering: number, octaves: Vec4 = vdbFrameOctavesOff): Vec4 {\n const depths: Vec3 = [0, 0, 0];\n for (const e of scaledExtinctions) {\n const s = vdbFrameShadowStep(e, vdbFrameShadowAbsorption(e, albedo), multipleScattering);\n depths[0] += s[0];\n depths[1] += s[1];\n depths[2] += s[2];\n if (vdbFrameShadowMarchDepth(depths, multipleScattering, octaves) > 8) break;\n }\n const t = vdbFrameShadowTransmittance(depths, multipleScattering, octaves);\n return [t[0], t[1], depths[2], depths[1]];\n}\n\n/**\n * frameShadowedLight (grey): phase × direct + scattered; the scattered light is (total − direct)\n * (isotropic), or with octaves Σ bⁿ phase(g cⁿ) exp(−aⁿ τ) from the octave shadow value.\n */\nexport function vdbFrameShadowedLight(phase: Vec4, rayDirection: Vec3, lightDirection: Vec3, shadow: Vec2, octaves: Vec4 = vdbFrameOctavesOff): number {\n const direct = vdbFramePhaseWeight(phase, rayDirection, lightDirection) * shadow[0];\n if (octaves[0] > 0) return direct + vdbFrameOctaveLight(octaves, vdbFrameShadowOpticalDepth(shadow[1]), phase, dot3(rayDirection, lightDirection));\n return direct + (shadow[1] - shadow[0]);\n}\n\n/** frameShadowedLight of each channel (per-channel phases: `phaseSpectrum`, see {@link vdbFramePhaseColor}). */\nexport function vdbFrameShadowedLightColor(phase: Vec4, phaseSpectrum: Vec3, octaves: Vec4, rayDirection: Vec3, lightDirection: Vec3, shadow: Vec2): Vec3 {\n const p = vdbFramePhaseColor(phase, phaseSpectrum, rayDirection, lightDirection);\n const scattered = octaves[0] > 0 ? vdbFrameOctaveLight(octaves, vdbFrameShadowOpticalDepth(shadow[1]), phase, dot3(rayDirection, lightDirection)) : shadow[1] - shadow[0];\n return [p[0] * shadow[0] + scattered, p[1] * shadow[0] + scattered, p[2] * shadow[0] + scattered];\n}\n\n/**\n * The view-ray pre-integration of one froxel in the inject pass: `opticalDepths[i]` is\n * extinction × opacity × fade × sub-step length at sub-step i (t = segX + seg × (i + jitter) / n).\n * Returns the slice alpha and the visibility-weighted mean t (the lit position), or null when the\n * froxel is discarded.\n */\nexport function vdbFrameInjectSlice(opticalDepths: readonly number[], segment: Vec2, jitter = 0.5): { alpha: number; t: number } | null {\n const n = opticalDepths.length;\n const seg = segment[1] - segment[0];\n let transmittance = 1;\n let visibleWeight = 0;\n let visibleTSum = 0;\n for (let i = 0; i < n; i++) {\n const t = segment[0] + seg * ((i + jitter) / n);\n const stepT = Math.exp(-opticalDepths[i]!);\n const w = transmittance * (1 - stepT);\n visibleWeight += w;\n visibleTSum += w * t;\n transmittance *= stepT;\n }\n const alpha = 1 - transmittance;\n if (visibleWeight <= 0 || alpha <= 1e-5) return null;\n return { alpha, t: visibleTSum / visibleWeight };\n}\n\n/** One premultiplied froxel of the atlas: rgb = radiance × alpha, a = alpha. */\nexport type VDBFrameFroxelSample = Vec4;\n\n/**\n * The integrate pass for one pixel (`createFragmentNode`, grey): front to back over the slices\n * [first, end) of the log range, stopping at the scene depth. `froxels[k]` is the atlas sample of\n * slice `first + k`. Returns premultiplied (radiance, alpha), or null when discarded.\n */\nexport function vdbFrameIntegrate(\n froxels: readonly VDBFrameFroxelSample[],\n sliceRange: Vec2,\n range: Vec2,\n depth: number,\n sceneDepth: number,\n): { radiance: Vec3; alpha: number } | null {\n const radiance: Vec3 = [0, 0, 0];\n let transmittance = 1;\n let sliceStart = vdbFrameSliceDepth(range, sliceRange[0] / depth);\n for (let i = 0; i < 1024; i++) {\n const slice = sliceRange[0] + i;\n if (slice >= sliceRange[1] || sliceStart >= sceneDepth || transmittance < 0.001) break;\n const sliceEnd = vdbFrameSliceDepth(range, (slice + 1) / depth);\n const coverage = (Math.min(sliceEnd, sceneDepth) - sliceStart) / (sliceEnd - sliceStart);\n const f = froxels[i] ?? [0, 0, 0, 0];\n const a = clamp(f[3], 0, 1);\n if (a > 0) {\n const sliceAlpha = coverage < 1 ? 1 - Math.pow(1 - a, coverage) : a;\n for (let c = 0; c < 3; c++) radiance[c] = radiance[c]! + transmittance * f[c]! * (sliceAlpha / a);\n transmittance *= 1 - sliceAlpha;\n }\n sliceStart = sliceEnd;\n }\n const alpha = 1 - transmittance;\n return alpha <= 0 ? null : { radiance, alpha };\n}\n\n/** sRGB OETF (three `sRGBTransferOETF`). */\nexport function vdbSrgbOetf(x: number): number {\n return x < 0.0031308 ? x * 12.92 : 1.055 * Math.pow(x, 0.41666) - 0.055;\n}\n\n/** sRGB EOTF (three `sRGBTransferEOTF`). */\nexport function vdbSrgbEotf(x: number): number {\n return x < 0.04045 ? x * 0.0773993808 : Math.pow(x * 0.9478672986 + 0.0521327014, 2.4);\n}\n\n/** The integrate pass's sRGB blend (`srgbBlending`, clamp on): linear out. */\nexport function vdbFrameSrgbBlend(background: Vec3, radiance: Vec3, alpha: number, clampColors = true): Vec3 {\n const enc = (x: number) => (clampColors ? clamp(vdbSrgbOetf(x), 0, 1) : vdbSrgbOetf(x));\n return [0, 1, 2].map((c) => {\n const bg = enc(background[c]!);\n const vol = enc(radiance[c]! / alpha);\n return vdbSrgbEotf(bg + (vol - bg) * alpha);\n }) as Vec3;\n}\n"]}
@@ -0,0 +1,61 @@
1
+ export interface VDBFrameMediumPreset {
2
+ readonly albedo: readonly [number, number, number];
3
+ readonly angstromExponent: number;
4
+ readonly phase: "henyey-greenstein" | "lorenz-mie-rgb";
5
+ /** g at 550 nm. */
6
+ readonly phaseG: number;
7
+ /** Fits g at 450 nm and 650 nm: g of a channel is phaseG × (λ / 550)^−phaseGExponent. */
8
+ readonly phaseGExponent: number;
9
+ }
10
+ export declare const vdbFrameMediumPresets: Readonly<Record<string, VDBFrameMediumPreset>>;
11
+ /** The preset names of {@link vdbFrameMediumPresets} (his GUI 'Medium' options without 'custom'). */
12
+ export declare const vdbFrameMediumNames: readonly string[];
13
+ /** Engine-free {@link VDBFrameMediumProps}: the volume props of a preset. */
14
+ export interface VDBFrameMediumProps {
15
+ /** Linear albedo (the volume's `baseColor`). */
16
+ albedo: [number, number, number];
17
+ /** Always (1, 1, 1): extinction depends on the scene scale. */
18
+ extinctionScale: [number, number, number];
19
+ angstromExponent: number;
20
+ phase: VDBFrameMediumPreset["phase"];
21
+ phaseG: number;
22
+ phaseGExponent: number;
23
+ }
24
+ /**
25
+ * His `getFrameMediumProps` without three: the volume props of a preset (base colour, extinction scale,
26
+ * Ångström exponent, phase). Unknown names give null.
27
+ */
28
+ export declare function vdbFrameMediumProps(name: string): VDBFrameMediumProps | null;
29
+ /** A value or a measured range [min, max] (its midpoint is used). */
30
+ export type VDBFrameMeasured = number | readonly [number, number];
31
+ /**
32
+ * The measurements his notes cite for each preset. `albedo`: red, green (null: not measured) and blue;
33
+ * `g`: the asymmetry at 550 nm, or blue and red (and green when measured); `asymmetryFromMieRgb`: g is the
34
+ * 'lorenz-mie-rgb' tables' green asymmetry (cloud).
35
+ */
36
+ export interface VDBFrameMediumMeasurement {
37
+ readonly citation: string;
38
+ readonly albedo: readonly [VDBFrameMeasured, VDBFrameMeasured | null, VDBFrameMeasured];
39
+ readonly angstromExponent: VDBFrameMeasured;
40
+ readonly phase: VDBFrameMediumPreset["phase"];
41
+ readonly g: {
42
+ readonly green?: VDBFrameMeasured;
43
+ readonly blue?: number;
44
+ readonly red?: number;
45
+ readonly asymmetryFromMieRgb?: boolean;
46
+ };
47
+ }
48
+ /** The measurements of his frameMedium.js notes (Pope & Fry 1997, Hess 1998, Baran 2012, Bond & Bergstrom 2006, Dubovik 2002, Kim 2011). */
49
+ export declare const vdbFrameMediumMeasurements: Readonly<Record<string, VDBFrameMediumMeasurement>>;
50
+ /**
51
+ * The phase g exponent e of g(λ) = g₅₅₀ (λ / 550)^−e through g at 450 nm (blue) and 650 nm (red):
52
+ * e = ln(g_blue / g_red) / ln(650 / 450).
53
+ */
54
+ export declare function vdbFrameFitPhaseGExponent(gBlue: number, gRed: number): number;
55
+ /**
56
+ * A preset from its measurements (unrounded): midpoints of ranges; a green albedo that is not measured is the
57
+ * mean of red and blue; phaseGExponent fits the blue and red g; g at 550 nm is the measured green g, else the
58
+ * blue g moved to 550 nm by the fit. `mieRgbGreenAsymmetry` is the green asymmetry of the 'lorenz-mie-rgb'
59
+ * tables (`vdbFrameMieTable`), for cloud.
60
+ */
61
+ export declare function vdbFrameMediumFromMeasurements(m: VDBFrameMediumMeasurement, mieRgbGreenAsymmetry?: number): VDBFrameMediumPreset;
@@ -0,0 +1,99 @@
1
+ // Portions derived from mjurczyk/openvdb (MIT), commit 75e7345 (v0.26.0):
2
+ // src/three-openvdb/frame/core/frameMedium.js L1–76 (frameMediumPresets with their citations),
3
+ // L78–90 (getFrameMediumProps, engine-free here).
4
+ // Copyright (c) mjurczyk/openvdb contributors. Licensed under the MIT License (see THIRD_PARTY_NOTICES.md).
5
+ // Changes: TypeScript, engine-free (albedo and extinction scale as arrays; the three adapter
6
+ // `getFrameMediumProps` in `@pmndrs/vdb/three` makes his `Color` / `Vector3`). He has no generator for the
7
+ // table: its values are midpoints and fits of the cited measurements. `vdbFrameMediumMeasurements` holds
8
+ // those measurements as his notes cite them and `vdbFrameMediumFromMeasurements` is the fit (midpoint of a
9
+ // range, green albedo = mean of red and blue when not measured, phaseGExponent from the blue and red g); the
10
+ // unit tests check that the ported table is that fit at his precision (3 decimals). Divergences: none.
11
+ /** A measured medium: linear albedo (red 650 nm, green 550 nm, blue 450 nm), Ångström exponent, phase. */
12
+ import { VDBToolsError } from "../errors.js";
13
+ // NOTE Measured media. Albedo is linear (red 650 nm, green 550 nm, blue 450 nm). A range gives its midpoint.
14
+ // NOTE A green albedo that is not measured is the mean of red and blue.
15
+ // NOTE phaseG is g at 550 nm. phaseGExponent fits g at 450 nm and 650 nm. Extinction depends on the scene scale, so it is not here.
16
+ export const vdbFrameMediumPresets = {
17
+ // NOTE Mie, Pope & Fry 1997. g 0.857 / 0.853 / 0.850 (blue / green / red): the 'lorenz-mie-rgb' tables.
18
+ cloud: { albedo: [1.0, 1.0, 1.0], angstromExponent: 0.0, phase: "lorenz-mie-rgb", phaseG: 0.853, phaseGExponent: 0.0 },
19
+ // NOTE Hess et al. 1998 (OPAC). g 0.866 at 550 nm.
20
+ fog: { albedo: [1.0, 1.0, 1.0], angstromExponent: 0.0, phase: "henyey-greenstein", phaseG: 0.866, phaseGExponent: 0.0 },
21
+ // NOTE OPAC, Baran 2012. g 0.76 to 0.78.
22
+ ice: { albedo: [1.0, 1.0, 1.0], angstromExponent: 0.0, phase: "henyey-greenstein", phaseG: 0.77, phaseGExponent: 0.0 },
23
+ // NOTE Fresh soot (black carbon), Bond & Bergstrom 2006. Albedo 0.20 to 0.30 (flat), g 0.3 to 0.4 (estimate).
24
+ soot: { albedo: [0.25, 0.25, 0.25], angstromExponent: 1.0, phase: "henyey-greenstein", phaseG: 0.35, phaseGExponent: 0.0 },
25
+ // NOTE Boreal forest smoke, Dubovik et al. 2002. Angstrom 1.0 to 2.3, g 0.69 / 0.61 (blue / red).
26
+ "white-smoke": { albedo: [0.935, 0.9375, 0.94], angstromExponent: 1.65, phase: "henyey-greenstein", phaseG: 0.645, phaseGExponent: 0.335 },
27
+ // NOTE Savanna smoke, Dubovik et al. 2002. Angstrom 1.4 to 2.2, g 0.64 / 0.53 (blue / red).
28
+ "dark-smoke": { albedo: [0.84, 0.86, 0.88], angstromExponent: 1.8, phase: "henyey-greenstein", phaseG: 0.577, phaseGExponent: 0.513 },
29
+ // NOTE Urban haze, Dubovik et al. 2002. Angstrom 1.2 to 2.5, g 0.68 / 0.59 (blue / red).
30
+ haze: { albedo: [0.97, 0.975, 0.98], angstromExponent: 1.85, phase: "henyey-greenstein", phaseG: 0.629, phaseGExponent: 0.386 },
31
+ // NOTE Saharan dust, Dubovik et al. 2002, Kim et al. 2011. Angstrom -0.1 to 0.7, g 0.73 / 0.752 / 0.71 (blue / green / red).
32
+ dust: { albedo: [0.98, 0.944, 0.93], angstromExponent: 0.3, phase: "henyey-greenstein", phaseG: 0.752, phaseGExponent: 0.076 },
33
+ };
34
+ /** The preset names of {@link vdbFrameMediumPresets} (his GUI 'Medium' options without 'custom'). */
35
+ export const vdbFrameMediumNames = Object.keys(vdbFrameMediumPresets);
36
+ /**
37
+ * His `getFrameMediumProps` without three: the volume props of a preset (base colour, extinction scale,
38
+ * Ångström exponent, phase). Unknown names give null.
39
+ */
40
+ export function vdbFrameMediumProps(name) {
41
+ const preset = Object.prototype.hasOwnProperty.call(vdbFrameMediumPresets, name) ? vdbFrameMediumPresets[name] : undefined;
42
+ if (!preset) {
43
+ return null;
44
+ }
45
+ return {
46
+ albedo: [...preset.albedo],
47
+ extinctionScale: [1.0, 1.0, 1.0],
48
+ angstromExponent: preset.angstromExponent,
49
+ phase: preset.phase,
50
+ phaseG: preset.phaseG,
51
+ phaseGExponent: preset.phaseGExponent,
52
+ };
53
+ }
54
+ /** The measurements of his frameMedium.js notes (Pope & Fry 1997, Hess 1998, Baran 2012, Bond & Bergstrom 2006, Dubovik 2002, Kim 2011). */
55
+ export const vdbFrameMediumMeasurements = {
56
+ cloud: { citation: "Mie, Pope & Fry 1997", albedo: [1, 1, 1], angstromExponent: 0, phase: "lorenz-mie-rgb", g: { asymmetryFromMieRgb: true } },
57
+ fog: { citation: "Hess et al. 1998 (OPAC)", albedo: [1, 1, 1], angstromExponent: 0, phase: "henyey-greenstein", g: { green: 0.866 } },
58
+ ice: { citation: "OPAC, Baran 2012", albedo: [1, 1, 1], angstromExponent: 0, phase: "henyey-greenstein", g: { green: [0.76, 0.78] } },
59
+ soot: { citation: "Bond & Bergstrom 2006", albedo: [[0.2, 0.3], [0.2, 0.3], [0.2, 0.3]], angstromExponent: 1, phase: "henyey-greenstein", g: { green: [0.3, 0.4] } },
60
+ "white-smoke": { citation: "Dubovik et al. 2002 (boreal forest)", albedo: [0.935, null, 0.94], angstromExponent: [1.0, 2.3], phase: "henyey-greenstein", g: { blue: 0.69, red: 0.61 } },
61
+ "dark-smoke": { citation: "Dubovik et al. 2002 (savanna)", albedo: [0.84, null, 0.88], angstromExponent: [1.4, 2.2], phase: "henyey-greenstein", g: { blue: 0.64, red: 0.53 } },
62
+ haze: { citation: "Dubovik et al. 2002 (urban)", albedo: [0.97, null, 0.98], angstromExponent: [1.2, 2.5], phase: "henyey-greenstein", g: { blue: 0.68, red: 0.59 } },
63
+ dust: { citation: "Dubovik et al. 2002, Kim et al. 2011 (Saharan)", albedo: [0.98, 0.944, 0.93], angstromExponent: [-0.1, 0.7], phase: "henyey-greenstein", g: { blue: 0.73, green: 0.752, red: 0.71 } },
64
+ };
65
+ const midpoint = (v) => (typeof v === "number" ? v : (v[0] + v[1]) / 2);
66
+ /**
67
+ * The phase g exponent e of g(λ) = g₅₅₀ (λ / 550)^−e through g at 450 nm (blue) and 650 nm (red):
68
+ * e = ln(g_blue / g_red) / ln(650 / 450).
69
+ */
70
+ export function vdbFrameFitPhaseGExponent(gBlue, gRed) {
71
+ return Math.log(gBlue / gRed) / Math.log(650 / 450);
72
+ }
73
+ /**
74
+ * A preset from its measurements (unrounded): midpoints of ranges; a green albedo that is not measured is the
75
+ * mean of red and blue; phaseGExponent fits the blue and red g; g at 550 nm is the measured green g, else the
76
+ * blue g moved to 550 nm by the fit. `mieRgbGreenAsymmetry` is the green asymmetry of the 'lorenz-mie-rgb'
77
+ * tables (`vdbFrameMieTable`), for cloud.
78
+ */
79
+ export function vdbFrameMediumFromMeasurements(m, mieRgbGreenAsymmetry) {
80
+ const red = midpoint(m.albedo[0]);
81
+ const blue = midpoint(m.albedo[2]);
82
+ const green = m.albedo[1] === null ? (red + blue) / 2 : midpoint(m.albedo[1]);
83
+ const { g } = m;
84
+ const phaseGExponent = g.blue !== undefined && g.red !== undefined ? vdbFrameFitPhaseGExponent(g.blue, g.red) : 0;
85
+ let phaseG;
86
+ if (g.asymmetryFromMieRgb) {
87
+ if (mieRgbGreenAsymmetry === undefined)
88
+ throw new VDBToolsError("VDB_BAD_OPTION", "vdbFrameMediumFromMeasurements: pass the 'lorenz-mie-rgb' green asymmetry");
89
+ phaseG = mieRgbGreenAsymmetry;
90
+ }
91
+ else if (g.green !== undefined) {
92
+ phaseG = midpoint(g.green);
93
+ }
94
+ else {
95
+ phaseG = g.blue * Math.pow(450 / 550, phaseGExponent);
96
+ }
97
+ return { albedo: [red, green, blue], angstromExponent: midpoint(m.angstromExponent), phase: m.phase, phaseG, phaseGExponent };
98
+ }
99
+ //# sourceMappingURL=medium.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"medium.js","sourceRoot":"","sources":["../../../src/tools/frame/medium.ts"],"names":[],"mappings":"AAAA,0EAA0E;AAC1E,iGAAiG;AACjG,oDAAoD;AACpD,4GAA4G;AAC5G,6FAA6F;AAC7F,2GAA2G;AAC3G,yGAAyG;AACzG,2GAA2G;AAC3G,6GAA6G;AAC7G,uGAAuG;AAEvG,0GAA0G;AAE1G,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAW7C,6GAA6G;AAC7G,wEAAwE;AACxE,oIAAoI;AACpI,MAAM,CAAC,MAAM,qBAAqB,GAAmD;IACnF,wGAAwG;IACxG,KAAK,EAAE,EAAE,MAAM,EAAE,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,EAAE,gBAAgB,EAAE,GAAG,EAAE,KAAK,EAAE,gBAAgB,EAAE,MAAM,EAAE,KAAK,EAAE,cAAc,EAAE,GAAG,EAAE;IACtH,mDAAmD;IACnD,GAAG,EAAE,EAAE,MAAM,EAAE,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,EAAE,gBAAgB,EAAE,GAAG,EAAE,KAAK,EAAE,mBAAmB,EAAE,MAAM,EAAE,KAAK,EAAE,cAAc,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E,MAAM,EAAE,CAAC,EAAE,GAAG,CAAC,CAAC;IAChB,MAAM,cAAc,GAAG,CAAC,CAAC,IAAI,KAAK,SAAS,IAAI,CAAC,CAAC,GAAG,KAAK,SAAS,CAAC,CAAC,CAAC,yBAAyB,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IAClH,IAAI,MAAc,CAAC;IAEnB,IAAI,CAAC,CAAC,mBAAmB,EAAE,CAAC;QAC1B,IAAI,oBAAoB,KAAK,SAAS;YAAE,MAAM,IAAI,aAAa,CAAC,gBAAgB,EAAE,2EAA2E,CAAC,CAAC;QAC/J,MAAM,GAAG,oBAAoB,CAAC;IAChC,CAAC;SAAM,IAAI,CAAC,CAAC,KAAK,KAAK,SAAS,EAAE,CAAC;QACjC,MAAM,GAAG,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC;IAC7B,CAAC;SAAM,CAAC;QACN,MAAM,GAAG,CAAC,CAAC,IAAK,GAAG,IAAI,CAAC,GAAG,CAAC,GAAG,GAAG,GAAG,EAAE,cAAc,CAAC,CAAC;IACzD,CAAC;IAED,OAAO,EAAE,MAAM,EAAE,CAAC,GAAG,EAAE,KAAK,EAAE,IAAI,CAAC,EAAE,gBAAgB,EAAE,QAAQ,CAAC,CAAC,CAAC,gBAAgB,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC,KAAK,EAAE,MAAM,EAAE,cAAc,EAAE,CAAC;AAChI,CAAC","sourcesContent":["// Portions derived from mjurczyk/openvdb (MIT), commit 75e7345 (v0.26.0):\n// src/three-openvdb/frame/core/frameMedium.js L1–76 (frameMediumPresets with their citations),\n// L78–90 (getFrameMediumProps, engine-free here).\n// Copyright (c) mjurczyk/openvdb contributors. Licensed under the MIT License (see THIRD_PARTY_NOTICES.md).\n// Changes: TypeScript, engine-free (albedo and extinction scale as arrays; the three adapter\n// `getFrameMediumProps` in `@pmndrs/vdb/three` makes his `Color` / `Vector3`). He has no generator for the\n// table: its values are midpoints and fits of the cited measurements. `vdbFrameMediumMeasurements` holds\n// those measurements as his notes cite them and `vdbFrameMediumFromMeasurements` is the fit (midpoint of a\n// range, green albedo = mean of red and blue when not measured, phaseGExponent from the blue and red g); the\n// unit tests check that the ported table is that fit at his precision (3 decimals). Divergences: none.\n\n/** A measured medium: linear albedo (red 650 nm, green 550 nm, blue 450 nm), Ångström exponent, phase. */\n\nimport { VDBToolsError } from \"../errors.js\";\nexport interface VDBFrameMediumPreset {\n readonly albedo: readonly [number, number, number];\n readonly angstromExponent: number;\n readonly phase: \"henyey-greenstein\" | \"lorenz-mie-rgb\";\n /** g at 550 nm. */\n readonly phaseG: number;\n /** Fits g at 450 nm and 650 nm: g of a channel is phaseG × (λ / 550)^−phaseGExponent. */\n readonly phaseGExponent: number;\n}\n\n// NOTE Measured media. Albedo is linear (red 650 nm, green 550 nm, blue 450 nm). A range gives its midpoint.\n// NOTE A green albedo that is not measured is the mean of red and blue.\n// NOTE phaseG is g at 550 nm. phaseGExponent fits g at 450 nm and 650 nm. Extinction depends on the scene scale, so it is not here.\nexport const vdbFrameMediumPresets: Readonly<Record<string, VDBFrameMediumPreset>> = {\n // NOTE Mie, Pope & Fry 1997. g 0.857 / 0.853 / 0.850 (blue / green / red): the 'lorenz-mie-rgb' tables.\n cloud: { albedo: [1.0, 1.0, 1.0], angstromExponent: 0.0, phase: \"lorenz-mie-rgb\", phaseG: 0.853, phaseGExponent: 0.0 },\n // NOTE Hess et al. 1998 (OPAC). g 0.866 at 550 nm.\n fog: { albedo: [1.0, 1.0, 1.0], angstromExponent: 0.0, phase: \"henyey-greenstein\", phaseG: 0.866, phaseGExponent: 0.0 },\n // NOTE OPAC, Baran 2012. g 0.76 to 0.78.\n ice: { albedo: [1.0, 1.0, 1.0], angstromExponent: 0.0, phase: \"henyey-greenstein\", phaseG: 0.77, phaseGExponent: 0.0 },\n // NOTE Fresh soot (black carbon), Bond & Bergstrom 2006. Albedo 0.20 to 0.30 (flat), g 0.3 to 0.4 (estimate).\n soot: { albedo: [0.25, 0.25, 0.25], angstromExponent: 1.0, phase: \"henyey-greenstein\", phaseG: 0.35, phaseGExponent: 0.0 },\n // NOTE Boreal forest smoke, Dubovik et al. 2002. Angstrom 1.0 to 2.3, g 0.69 / 0.61 (blue / red).\n \"white-smoke\": { albedo: [0.935, 0.9375, 0.94], angstromExponent: 1.65, phase: \"henyey-greenstein\", phaseG: 0.645, phaseGExponent: 0.335 },\n // NOTE Savanna smoke, Dubovik et al. 2002. Angstrom 1.4 to 2.2, g 0.64 / 0.53 (blue / red).\n \"dark-smoke\": { albedo: [0.84, 0.86, 0.88], angstromExponent: 1.8, phase: \"henyey-greenstein\", phaseG: 0.577, phaseGExponent: 0.513 },\n // NOTE Urban haze, Dubovik et al. 2002. Angstrom 1.2 to 2.5, g 0.68 / 0.59 (blue / red).\n haze: { albedo: [0.97, 0.975, 0.98], angstromExponent: 1.85, phase: \"henyey-greenstein\", phaseG: 0.629, phaseGExponent: 0.386 },\n // NOTE Saharan dust, Dubovik et al. 2002, Kim et al. 2011. Angstrom -0.1 to 0.7, g 0.73 / 0.752 / 0.71 (blue / green / red).\n dust: { albedo: [0.98, 0.944, 0.93], angstromExponent: 0.3, phase: \"henyey-greenstein\", phaseG: 0.752, phaseGExponent: 0.076 },\n};\n\n/** The preset names of {@link vdbFrameMediumPresets} (his GUI 'Medium' options without 'custom'). */\nexport const vdbFrameMediumNames = Object.keys(vdbFrameMediumPresets) as readonly string[];\n\n/** Engine-free {@link VDBFrameMediumProps}: the volume props of a preset. */\nexport interface VDBFrameMediumProps {\n /** Linear albedo (the volume's `baseColor`). */\n albedo: [number, number, number];\n /** Always (1, 1, 1): extinction depends on the scene scale. */\n extinctionScale: [number, number, number];\n angstromExponent: number;\n phase: VDBFrameMediumPreset[\"phase\"];\n phaseG: number;\n phaseGExponent: number;\n}\n\n/**\n * His `getFrameMediumProps` without three: the volume props of a preset (base colour, extinction scale,\n * Ångström exponent, phase). Unknown names give null.\n */\nexport function vdbFrameMediumProps(name: string): VDBFrameMediumProps | null {\n const preset = Object.prototype.hasOwnProperty.call(vdbFrameMediumPresets, name) ? vdbFrameMediumPresets[name] : undefined;\n\n if (!preset) {\n return null;\n }\n\n return {\n albedo: [...preset.albedo],\n extinctionScale: [1.0, 1.0, 1.0],\n angstromExponent: preset.angstromExponent,\n phase: preset.phase,\n phaseG: preset.phaseG,\n phaseGExponent: preset.phaseGExponent,\n };\n}\n\n// ── The cited measurements and the fit that gives the table ─────────────────────────────────────────\n\n/** A value or a measured range [min, max] (its midpoint is used). */\nexport type VDBFrameMeasured = number | readonly [number, number];\n\n/**\n * The measurements his notes cite for each preset. `albedo`: red, green (null: not measured) and blue;\n * `g`: the asymmetry at 550 nm, or blue and red (and green when measured); `asymmetryFromMieRgb`: g is the\n * 'lorenz-mie-rgb' tables' green asymmetry (cloud).\n */\nexport interface VDBFrameMediumMeasurement {\n readonly citation: string;\n readonly albedo: readonly [VDBFrameMeasured, VDBFrameMeasured | null, VDBFrameMeasured];\n readonly angstromExponent: VDBFrameMeasured;\n readonly phase: VDBFrameMediumPreset[\"phase\"];\n readonly g: { readonly green?: VDBFrameMeasured; readonly blue?: number; readonly red?: number; readonly asymmetryFromMieRgb?: boolean };\n}\n\n/** The measurements of his frameMedium.js notes (Pope & Fry 1997, Hess 1998, Baran 2012, Bond & Bergstrom 2006, Dubovik 2002, Kim 2011). */\nexport const vdbFrameMediumMeasurements: Readonly<Record<string, VDBFrameMediumMeasurement>> = {\n cloud: { citation: \"Mie, Pope & Fry 1997\", albedo: [1, 1, 1], angstromExponent: 0, phase: \"lorenz-mie-rgb\", g: { asymmetryFromMieRgb: true } },\n fog: { citation: \"Hess et al. 1998 (OPAC)\", albedo: [1, 1, 1], angstromExponent: 0, phase: \"henyey-greenstein\", g: { green: 0.866 } },\n ice: { citation: \"OPAC, Baran 2012\", albedo: [1, 1, 1], angstromExponent: 0, phase: \"henyey-greenstein\", g: { green: [0.76, 0.78] } },\n soot: { citation: \"Bond & Bergstrom 2006\", albedo: [[0.2, 0.3], [0.2, 0.3], [0.2, 0.3]], angstromExponent: 1, phase: \"henyey-greenstein\", g: { green: [0.3, 0.4] } },\n \"white-smoke\": { citation: \"Dubovik et al. 2002 (boreal forest)\", albedo: [0.935, null, 0.94], angstromExponent: [1.0, 2.3], phase: \"henyey-greenstein\", g: { blue: 0.69, red: 0.61 } },\n \"dark-smoke\": { citation: \"Dubovik et al. 2002 (savanna)\", albedo: [0.84, null, 0.88], angstromExponent: [1.4, 2.2], phase: \"henyey-greenstein\", g: { blue: 0.64, red: 0.53 } },\n haze: { citation: \"Dubovik et al. 2002 (urban)\", albedo: [0.97, null, 0.98], angstromExponent: [1.2, 2.5], phase: \"henyey-greenstein\", g: { blue: 0.68, red: 0.59 } },\n dust: { citation: \"Dubovik et al. 2002, Kim et al. 2011 (Saharan)\", albedo: [0.98, 0.944, 0.93], angstromExponent: [-0.1, 0.7], phase: \"henyey-greenstein\", g: { blue: 0.73, green: 0.752, red: 0.71 } },\n};\n\nconst midpoint = (v: VDBFrameMeasured) => (typeof v === \"number\" ? v : (v[0] + v[1]) / 2);\n\n/**\n * The phase g exponent e of g(λ) = g₅₅₀ (λ / 550)^−e through g at 450 nm (blue) and 650 nm (red):\n * e = ln(g_blue / g_red) / ln(650 / 450).\n */\nexport function vdbFrameFitPhaseGExponent(gBlue: number, gRed: number): number {\n return Math.log(gBlue / gRed) / Math.log(650 / 450);\n}\n\n/**\n * A preset from its measurements (unrounded): midpoints of ranges; a green albedo that is not measured is the\n * mean of red and blue; phaseGExponent fits the blue and red g; g at 550 nm is the measured green g, else the\n * blue g moved to 550 nm by the fit. `mieRgbGreenAsymmetry` is the green asymmetry of the 'lorenz-mie-rgb'\n * tables (`vdbFrameMieTable`), for cloud.\n */\nexport function vdbFrameMediumFromMeasurements(m: VDBFrameMediumMeasurement, mieRgbGreenAsymmetry?: number): VDBFrameMediumPreset {\n const red = midpoint(m.albedo[0]);\n const blue = midpoint(m.albedo[2]);\n const green = m.albedo[1] === null ? (red + blue) / 2 : midpoint(m.albedo[1]);\n const { g } = m;\n const phaseGExponent = g.blue !== undefined && g.red !== undefined ? vdbFrameFitPhaseGExponent(g.blue, g.red) : 0;\n let phaseG: number;\n\n if (g.asymmetryFromMieRgb) {\n if (mieRgbGreenAsymmetry === undefined) throw new VDBToolsError(\"VDB_BAD_OPTION\", \"vdbFrameMediumFromMeasurements: pass the 'lorenz-mie-rgb' green asymmetry\");\n phaseG = mieRgbGreenAsymmetry;\n } else if (g.green !== undefined) {\n phaseG = midpoint(g.green);\n } else {\n phaseG = g.blue! * Math.pow(450 / 550, phaseGExponent);\n }\n\n return { albedo: [red, green, blue], angstromExponent: midpoint(m.angstromExponent), phase: m.phase, phaseG, phaseGExponent };\n}\n"]}