@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 @@
1
+ {"version":3,"file":"environment-gpu.js","sourceRoot":"","sources":["../../../src/tools/frame/environment-gpu.ts"],"names":[],"mappings":"AAAA,0EAA0E;AAC1E,mHAAmH;AACnH,gHAAgH;AAChH,uEAAuE;AACvE,4GAA4G;AAC5G,qHAAqH;AACrH,qHAAqH;AACrH,mHAAmH;AACnH,6DAA6D;AAE7D;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,EAAE,yBAAyB,EAAE,yBAAyB,EAAE,wBAAwB,EAAE,qBAAqB,EAAE,yBAAyB,EAAE,+BAA+B,EAAE,MAAM,kBAAkB,CAAC;AACrM,OAAO,EAAE,kBAAkB,EAAE,mBAAmB,EAAwB,MAAM,YAAY,CAAC;AAE3F,gDAAgD;AAChD,MAAM,CAAC,MAAM,wBAAwB,GAAG,GAAG,CAAC;AAC5C,MAAM,CAAC,MAAM,yBAAyB,GAAG,EAAE,CAAC;AAC5C,2FAA2F;AAC3F,MAAM,CAAC,MAAM,uBAAuB,GAAG,GAAG,CAAC;AAC3C,kFAAkF;AAClF,MAAM,CAAC,MAAM,sBAAsB,GAAG,GAAG,CAAC;AAC1C,wHAAwH;AACxH,MAAM,CAAC,MAAM,iBAAiB,GAAG,IAAI,CAAC;AACtC,wDAAwD;AACxD,MAAM,CAAC,MAAM,6BAA6B,GAAG,EAAE,CAAC;AAKhD,iCAAiC;AACjC,MAAM,CAAC,MAAM,sBAAsB,GAAsB,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;AAErF,kCAAkC;AAClC,MAAM,UAAU,gBAAgB,CAAC,CAAsB,EA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,OAAO,CAAC,CAAC,CAAC,GAAG,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,GAAG,GAAG,GAAG,CAAC;IAC5F,MAAM,CAAC,EAAE,EAAE,IAAI,CAAC,GAAG,SAAS,CAAC;IAC7B,MAAM,MAAM,GAAG,IAAI,GAAG,CAAC,EAAE,GAAG,IAAI,CAAC,GAAG,KAAK,CAAC;IAC1C,MAAM,CAAC,GAAG,6BAA6B,CAAC,GAAG,CAAC,EAAE,EAAE,OAAO,CAAC,CAAC;IACzD,IAAI,CAAC,KAAK,CAAC,SAAS;QAAE,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,MAAM,EAAE,CAAC,CAAC,CAAC,CAAC,GAAG,MAAM,EAAE,CAAC,CAAC,CAAC,CAAC,GAAG,MAAM,CAAC,CAAC;IAC3E,MAAM,MAAM,GAAG,EAAE,GAAG,CAAC,IAAI,GAAG,EAAE,CAAC,GAAG,KAAK,CAAC;IACxC,MAAM,IAAI,GAAG,6BAA6B,CAAC,GAAG,CAAC,EAAE,EAAE,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IAC5F,OAAO,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAE,GAAG,MAAM,GAAG,IAAI,CAAC,CAAC,CAAE,GAAG,MAAM,CAAC,GAAG,GAAG,CAAS,CAAC;AAClF,CAAC","sourcesContent":["// Portions derived from mjurczyk/openvdb (MIT), commit 75e7345 (v0.26.0):\n// src/three-openvdb/frame/core/frameEnvironment.js (setTexels, getDirectionalLights, getShLights: reused through\n// VDBFrameEnvironmentLights in environment.ts), src/three-openvdb/frame/webgpu/FrameEnvironmentMapMaterial.js\n// (the 64 × 32 map of PMREM roughness 0.4 the lights are made from).\n// Copyright (c) mjurczyk/openvdb contributors. Licensed under the MIT License (see THIRD_PARTY_NOTICES.md).\n// Changes (K6.2b, design §3.5, Q3): the host's equirect or cube texture is reduced by our kernels instead of three's\n// PMREM: an exact-area (equirect) or supersampled (cube) 128 × 64 work map, a GGX roughness-0.4 convolution standing\n// in for PMREM roughness 0.4, and SH L2 irradiance (Ramamoorthi–Hanrahan) for the 'outward' term. CPU twins of the\n// core kernels (f64). Divergences: DIVERGES.md (K6.2b rows).\n\n/**\n * The environment reduction of the core frame renderer (K6.2b) as f64 CPU twins of its WGSL kernels:\n *\n * - `vdbFrameEnvironmentAreaTexel` / `vdbFrameEnvironmentCubeTexel`: one texel of the 128 × 64 work map (map space,\n * row 0 the zenith) from the host texture.\n * - `vdbFrameEnvironmentBlurTexel`: one texel of his 64 × 32 map (world space, his directions) as the GGX\n * (roughness 0.4) convolution of the work map.\n * - `vdbFrameEnvironmentIrradianceSh`: the SH9 radiance projection of the work map in world space (three's basis),\n * which `vdbFrameEnvironmentIrradiance` turns into irradiance (three's getShIrradianceAt).\n * - `vdbFrameEnvironmentReduce`: the environment buffer (lights and SH) from the read-back maps, through\n * {@link VDBFrameEnvironmentLights} (his extraction, unchanged).\n *\n * Map convention of the host texture (equirect): u = atan2(m.z, m.x) / 2π + ½ along x, row 0 is +Y (the zenith),\n * m = R · d the map direction of a world direction d (R: a 3 × 3 column-major rotation, or a rotation with a\n * reflection: three's flipY equirect is diag(1, −1, 1) · R). Cube: WebGPU's face order and orientation.\n */\n\nimport { VDBFrameEnvironmentLights, frameEnvironmentMapHeight, frameEnvironmentMapWidth, frameEnvironmentModes, frameMaxEnvironmentLights, vdbFrameEnvironmentMapDirection } from \"./environment.js\";\nimport { vdbFrameOctavesOff, vdbFrameShadowTotal, type Vec3, type Vec4 } from \"./index.js\";\n\n/** Work map size (design §3.3 envPrefilter). */\nexport const VDB_FRAME_ENV_WORK_WIDTH = 128;\nexport const VDB_FRAME_ENV_WORK_HEIGHT = 64;\n/** GGX roughness of the blur (his PMREM roughness 0.4, `frameEnvironmentMapRoughness`). */\nexport const VDB_FRAME_ENV_ROUGHNESS = 0.4;\n/** Most source texels per axis one work texel reads (larger maps are strided). */\nexport const VDB_FRAME_ENV_MAX_SPAN = 256;\n/** Near-ties of the 'directional' extraction (brightest texel, nearest seed) go to the first candidate (f32 vs f64). */\nexport const VDB_FRAME_ENV_TIE = 1e-5;\n/** Most cube sub-samples per axis of one work texel. */\nexport const VDB_FRAME_ENV_MAX_SUPERSAMPLE = 16;\n\n/** A 3 × 3 column-major matrix (world → map). */\nexport type VDBFrameEnvRotation = ArrayLike<number>;\n\n/** The identity map rotation. */\nexport const VDB_FRAME_ENV_IDENTITY: readonly number[] = [1, 0, 0, 0, 1, 0, 0, 0, 1];\n\n/** m = R · d (R column-major). */\nexport function vdbFrameEnvToMap(r: VDBFrameEnvRotation, d: Vec3): Vec3 {\n return [r[0]! * d[0] + r[3]! * d[1] + r[6]! * d[2], r[1]! * d[0] + r[4]! * d[1] + r[7]! * d[2], r[2]! * d[0] + r[5]! * d[1] + r[8]! * d[2]];\n}\n\n/** d = Rᵀ · m (R orthogonal: its inverse). */\nexport function vdbFrameEnvToWorld(r: VDBFrameEnvRotation, m: Vec3): Vec3 {\n return [r[0]! * m[0] + r[1]! * m[1] + r[2]! * m[2], r[3]! * m[0] + r[4]! * m[1] + r[5]! * m[2], r[6]! * m[0] + r[7]! * m[1] + r[8]! * m[2]];\n}\n\n/** The map direction of an equirect point: u along x (u = atan2(z, x) / 2π + ½), v from the top row (+Y). */\nexport function vdbFrameEquirectDirection(u: number, v: number): Vec3 {\n const theta = v * Math.PI;\n const phi = (u - 0.5) * 2 * Math.PI;\n return [Math.sin(theta) * Math.cos(phi), Math.cos(theta), Math.sin(theta) * Math.sin(phi)];\n}\n\n/** Solid angle of work map row `y` (exact: Δφ · (cos θ₀ − cos θ₁)). */\nexport function vdbFrameEnvWorkSolidAngle(y: number, width = VDB_FRAME_ENV_WORK_WIDTH, height = VDB_FRAME_ENV_WORK_HEIGHT): number {\n return ((2 * Math.PI) / width) * (Math.cos((y * Math.PI) / height) - Math.cos(((y + 1) * Math.PI) / height));\n}\n\n/** An RGBA float image, rows from the top (row 0 is the first `width · 4` floats). */\nexport interface VDBFrameEnvImage {\n data: ArrayLike<number>;\n width: number;\n height: number;\n}\n\n/**\n * One work map texel from an equirect source: the solid-angle mean of the source over the texel's box (exact\n * overlaps; sources wider than {@link VDB_FRAME_ENV_MAX_SPAN} texels per work texel are strided).\n */\nexport function vdbFrameEnvironmentAreaTexel(src: VDBFrameEnvImage, x: number, y: number, workWidth = VDB_FRAME_ENV_WORK_WIDTH, workHeight = VDB_FRAME_ENV_WORK_HEIGHT): [number, number, number, number] {\n const { width: W, height: H, data } = src;\n const u0 = x / workWidth;\n const u1 = (x + 1) / workWidth;\n const v0 = y / workHeight;\n const v1 = (y + 1) / workHeight;\n const i0 = Math.floor(u0 * W);\n const i1 = Math.min(W, Math.ceil(u1 * W));\n const j0 = Math.floor(v0 * H);\n const j1 = Math.min(H, Math.ceil(v1 * H));\n const si = Math.max(1, Math.ceil((i1 - i0) / VDB_FRAME_ENV_MAX_SPAN));\n const sj = Math.max(1, Math.ceil((j1 - j0) / VDB_FRAME_ENV_MAX_SPAN));\n const sum = [0, 0, 0];\n let weight = 0;\n for (let j = j0; j < j1; j += sj) {\n const a = Math.max(j / H, v0) * Math.PI;\n const b = Math.min((j + sj) / H, v1) * Math.PI;\n if (!(b > a)) continue;\n const wv = Math.cos(a) - Math.cos(b);\n for (let i = i0; i < i1; i += si) {\n const wu = Math.min((i + si) / W, u1) - Math.max(i / W, u0);\n if (!(wu > 0)) continue;\n const w = wu * wv;\n const at = (j * W + i) * 4;\n for (let c = 0; c < 3; c++) sum[c] = sum[c]! + data[at + c]! * w;\n weight += w;\n }\n }\n return weight > 0 ? [sum[0]! / weight, sum[1]! / weight, sum[2]! / weight, 1] : [0, 0, 0, 1];\n}\n\n/** The face and texel of a cube direction (WebGPU's face order +X, −X, +Y, −Y, +Z, −Z and orientation). */\nexport function vdbFrameCubeTexel(m: Vec3, size: number): { face: number; x: number; y: number } {\n const ax = Math.abs(m[0]);\n const ay = Math.abs(m[1]);\n const az = Math.abs(m[2]);\n let face: number;\n let ma: number;\n let sc: number;\n let tc: number;\n if (ax >= ay && ax >= az) {\n face = m[0] >= 0 ? 0 : 1;\n ma = ax;\n sc = m[0] >= 0 ? -m[2] : m[2];\n tc = -m[1];\n } else if (ay >= az) {\n face = m[1] >= 0 ? 2 : 3;\n ma = ay;\n sc = m[0];\n tc = m[1] >= 0 ? m[2] : -m[2];\n } else {\n face = m[2] >= 0 ? 4 : 5;\n ma = az;\n sc = m[2] >= 0 ? m[0] : -m[0];\n tc = -m[1];\n }\n const s = (sc / ma + 1) * 0.5;\n const t = (tc / ma + 1) * 0.5;\n return { face, x: Math.min(Math.max(Math.floor(s * size), 0), size - 1), y: Math.min(Math.max(Math.floor(t * size), 0), size - 1) };\n}\n\n/** Cube sub-samples per axis of a work texel for a face of `size` texels (about two per cube texel). */\nexport function vdbFrameEnvCubeSupersample(size: number, workHeight = VDB_FRAME_ENV_WORK_HEIGHT): number {\n return Math.min(VDB_FRAME_ENV_MAX_SUPERSAMPLE, Math.max(1, Math.ceil((4 * size) / workHeight)));\n}\n\n/**\n * One work map texel from a cube source (`faces[f]` an RGBA image of `size`²): k × k sub-samples of the texel's box,\n * each the nearest cube texel, weighted by sin θ (solid angle).\n */\nexport function vdbFrameEnvironmentCubeTexel(faces: readonly VDBFrameEnvImage[], size: number, x: number, y: number, workWidth = VDB_FRAME_ENV_WORK_WIDTH, workHeight = VDB_FRAME_ENV_WORK_HEIGHT): [number, number, number, number] {\n const k = vdbFrameEnvCubeSupersample(size, workHeight);\n const sum = [0, 0, 0];\n let weight = 0;\n for (let b = 0; b < k; b++) {\n const v = (y + (b + 0.5) / k) / workHeight;\n const w = Math.sin(v * Math.PI);\n for (let a = 0; a < k; a++) {\n const u = (x + (a + 0.5) / k) / workWidth;\n const t = vdbFrameCubeTexel(vdbFrameEquirectDirection(u, v), size);\n const f = faces[t.face]!;\n const at = (t.y * size + t.x) * 4;\n for (let c = 0; c < 3; c++) sum[c] = sum[c]! + f.data[at + c]! * w;\n weight += w;\n }\n }\n return weight > 0 ? [sum[0]! / weight, sum[1]! / weight, sum[2]! / weight, 1] : [0, 0, 0, 1];\n}\n\n/** The GGX weight of input direction cosine `c` around the output direction (n = v = r; D(h) · n·l). */\nexport function vdbFrameEnvGgxWeight(c: number, roughness = VDB_FRAME_ENV_ROUGHNESS): number {\n if (!(c > 0)) return 0;\n const a2 = roughness * roughness * roughness * roughness;\n const nh2 = (1 + c) * 0.5;\n const d = nh2 * (a2 - 1) + 1;\n return (a2 / (Math.PI * d * d)) * c;\n}\n\n/**\n * One texel (x, y) of his 64 × 32 map: the GGX (roughness 0.4) weighted mean of the work map around his direction\n * of the texel centre (`vdbFrameEnvironmentMapDirection`), the work map in map space (`rotation` world → map).\n */\nexport function vdbFrameEnvironmentBlurTexel(work: VDBFrameEnvImage, rotation: VDBFrameEnvRotation, x: number, y: number, roughness = VDB_FRAME_ENV_ROUGHNESS): [number, number, number, number] {\n const d = vdbFrameEnvironmentMapDirection((x + 0.5) / frameEnvironmentMapWidth, (y + 0.5) / frameEnvironmentMapHeight);\n const m = vdbFrameEnvToMap(rotation, d);\n const sum = [0, 0, 0];\n let weight = 0;\n for (let j = 0; j < work.height; j++) {\n const omega = vdbFrameEnvWorkSolidAngle(j, work.width, work.height);\n for (let i = 0; i < work.width; i++) {\n const mj = vdbFrameEquirectDirection((i + 0.5) / work.width, (j + 0.5) / work.height);\n const w = vdbFrameEnvGgxWeight(m[0] * mj[0] + m[1] * mj[1] + m[2] * mj[2], roughness) * omega;\n if (!(w > 0)) continue;\n const at = (j * work.width + i) * 4;\n for (let c = 0; c < 3; c++) sum[c] = sum[c]! + work.data[at + c]! * w;\n weight += w;\n }\n }\n return weight > 0 ? [sum[0]! / weight, sum[1]! / weight, sum[2]! / weight, 1] : [0, 0, 0, 1];\n}\n\n/** three's SH9 basis (SphericalHarmonics3.getBasisAt). */\nexport function vdbFrameSh9Basis(d: Vec3): number[] {\n const [x, y, z] = d;\n return [0.282095, 0.488603 * y, 0.488603 * z, 0.488603 * x, 1.092548 * x * y, 1.092548 * y * z, 0.315392 * (3 * z * z - 1), 1.092548 * x * z, 0.546274 * (x * x - y * y)];\n}\n\n/** SH9 radiance coefficients (rgb each, three's basis) of the work map in world space: Σ L · Y(Rᵀ m) · Ω. */\nexport function vdbFrameEnvironmentIrradianceSh(work: VDBFrameEnvImage, rotation: VDBFrameEnvRotation): Vec3[] {\n const out: Vec3[] = Array.from({ length: 9 }, () => [0, 0, 0] as Vec3);\n for (let j = 0; j < work.height; j++) {\n const omega = vdbFrameEnvWorkSolidAngle(j, work.width, work.height);\n for (let i = 0; i < work.width; i++) {\n const d = vdbFrameEnvToWorld(rotation, vdbFrameEquirectDirection((i + 0.5) / work.width, (j + 0.5) / work.height));\n const basis = vdbFrameSh9Basis(d);\n const at = (j * work.width + i) * 4;\n for (let k = 0; k < 9; k++) for (let c = 0; c < 3; c++) out[k]![c] = out[k]![c]! + Math.max(0, work.data[at + c]!) * basis[k]! * omega;\n }\n }\n return out;\n}\n\n/** Irradiance at a unit normal from SH9 radiance coefficients (three's getShIrradianceAt, Ramamoorthi–Hanrahan). */\nexport function vdbFrameEnvironmentIrradiance(sh: readonly Vec3[], n: Vec3): Vec3 {\n const [x, y, z] = n;\n const w = [0.886227, 2 * 0.511664 * y, 2 * 0.511664 * z, 2 * 0.511664 * x, 2 * 0.429043 * x * y, 2 * 0.429043 * y * z, 0.743125 * z * z - 0.247708, 2 * 0.429043 * x * z, 0.429043 * (x * x - y * y)];\n const out: Vec3 = [0, 0, 0];\n for (let k = 0; k < 9; k++) for (let c = 0; c < 3; c++) out[c] = out[c]! + sh[k]![c]! * w[k]!;\n return [Math.max(out[0], 0), Math.max(out[1], 0), Math.max(out[2], 0)];\n}\n\n/** Environment modes as the buffer codes them. */\nexport const VDB_FRAME_ENV_MODE = { outward: 0, directional: 1, sphericalHarmonics: 2 } as const;\n\n/** The environment buffer's content (`VdbFrameEnvironment`), as the twin computes it. */\nexport interface VDBFrameEnvironmentGpuResult {\n /** An environment with finite, positive energy. */\n valid: boolean;\n mode: number;\n count: number;\n directions: Vec3[];\n colors: Vec3[];\n /** SH9 radiance coefficients × intensity (irradiance through {@link vdbFrameEnvironmentIrradiance}). */\n sh: Vec3[];\n}\n\n/** The settings the reduction reads. */\nexport interface VDBFrameEnvironmentReduceSettings {\n environmentLighting: string;\n environmentSamples: number;\n environmentShOrder: number;\n /** Diffusion multiple scattering: the 'directional' seeds come in opposite pairs. */\n pairs: boolean;\n intensity: number;\n}\n\n/**\n * The `envReduce` kernel's output from the read-back 64 × 32 map (`blurred`, his directions, rows from v = 0) and the\n * work map SH (`sh`, before intensity): his lights ('directional' cells sorted by power, or 'spherical-harmonics'\n * quadrature lights) through {@link VDBFrameEnvironmentLights}, colours and SH × intensity.\n */\nexport function vdbFrameEnvironmentReduce(blurred: ArrayLike<number>, sh: readonly Vec3[], s: VDBFrameEnvironmentReduceSettings): VDBFrameEnvironmentGpuResult {\n const w = frameEnvironmentMapWidth;\n const h = frameEnvironmentMapHeight;\n const pixels = new Float64Array(w * h * 4);\n for (let i = 0; i < w * h; i++) {\n for (let c = 0; c < 3; c++) pixels[i * 4 + c] = blurred[i * 4 + c]!;\n pixels[i * 4 + 3] = (Math.floor(i / w) + 0.5) / h;\n }\n const lights = new VDBFrameEnvironmentLights(() => Promise.resolve([]));\n const valid = lights.setTexels(pixels);\n const mode = s.environmentLighting === frameEnvironmentModes.directional ? VDB_FRAME_ENV_MODE.directional : s.environmentLighting === frameEnvironmentModes.sphericalHarmonics ? VDB_FRAME_ENV_MODE.sphericalHarmonics : VDB_FRAME_ENV_MODE.outward;\n const out: VDBFrameEnvironmentGpuResult = { valid, mode, count: 0, directions: [], colors: [], sh: sh.map((c) => c.map((v) => (valid ? v * s.intensity : 0)) as Vec3) };\n if (!valid || mode === VDB_FRAME_ENV_MODE.outward) return out;\n const list = mode === VDB_FRAME_ENV_MODE.directional ? lights.getDirectionalLights(s.environmentSamples, s.pairs, VDB_FRAME_ENV_TIE) : lights.getShLights(s.environmentShOrder);\n out.count = Math.min(list.length, frameMaxEnvironmentLights);\n out.directions = list.slice(0, out.count).map((l) => [...l.direction] as Vec3);\n out.colors = list.slice(0, out.count).map((l) => l.color.map((v) => v * s.intensity) as Vec3);\n return out;\n}\n\n/** The renderer's environment flags of 'frame' lighting (`VdbFrameUniforms.environment`, `lighting.z`, `lighting.w`). */\nexport interface VDBFrameEnvironmentFlags {\n /** The shadow grid is in use. */\n useShadows: boolean;\n /** The dominant 'directional' light has a shadow slot. */\n slot: boolean;\n /** The environment grid holds this frame's lights. */\n grid: boolean;\n /** Diffusion multiple scattering. */\n diffusion: boolean;\n}\n\n/**\n * The environment term of his density pass in the core ('frame' lighting, K6.2b): the irradiance E a volume adds as\n * albedo · E / π at its visible position. With environment-grid lights the grid (`gridAt`, null outside: then the\n * unshadowed sum of those lights); with only the slot light nothing (the lighting adds it); else 'outward' SH\n * irradiance along `outward`, shadowed between the sky down and up totals (diffusion: the outward and inward halves).\n */\nexport function vdbFrameEnvironmentDensityTerm(env: VDBFrameEnvironmentGpuResult, flags: VDBFrameEnvironmentFlags, outward: Vec3, sky: Vec3, skyTotals: [number, number], gridAt: () => Vec3 | null, octaves: Vec4 = vdbFrameOctavesOff): Vec3 {\n if (!env.valid) return [0, 0, 0];\n const first = flags.slot ? 1 : 0;\n if (flags.useShadows && flags.grid && env.count > first) {\n const inside = gridAt();\n if (inside) return inside;\n const sum: Vec3 = [0, 0, 0];\n for (let i = first; i < env.count; i++) for (let c = 0; c < 3; c++) sum[c] = sum[c]! + env.colors[i]![c]!;\n // K6.3: the unshadowed light gets the octave total of 1\n const total = vdbFrameShadowTotal(1, octaves);\n return [Math.max(sum[0], 0) * total, Math.max(sum[1], 0) * total, Math.max(sum[2], 0) * total];\n }\n if (flags.useShadows && flags.slot && env.count > 0) return [0, 0, 0];\n const blend = (outward[0] * sky[0] + outward[1] * sky[1] + outward[2] * sky[2]) * 0.5 + 0.5;\n const [up, down] = skyTotals;\n const shadow = down + (up - down) * blend;\n const e = vdbFrameEnvironmentIrradiance(env.sh, outward);\n if (!flags.diffusion) return [e[0] * shadow, e[1] * shadow, e[2] * shadow];\n const inward = up + (down - up) * blend;\n const back = vdbFrameEnvironmentIrradiance(env.sh, [-outward[0], -outward[1], -outward[2]]);\n return [0, 1, 2].map((c) => (e[c]! * shadow + back[c]! * inward) * 0.5) as Vec3;\n}\n"]}
@@ -93,9 +93,10 @@ export declare class VDBFrameEnvironmentLights<R = unknown, S extends VDBFrameEn
93
93
  * Dominant direction (brightest texel) and fixed sky directions: zenith, nadir, then a horizon ring.
94
94
  * Each texel goes to the nearest direction; a light is at the energy centroid of its texels with
95
95
  * their energy; colour is energy / 4 (a uniform environment then gives the 'outward' light).
96
- * `pairs`: seeds in opposite pairs (diffusion weights of a pair sum to 2).
96
+ * `pairs`: seeds in opposite pairs (diffusion weights of a pair sum to 2). `tie` (K6.2b, the core): near-ties go to
97
+ * the first candidate.
97
98
  */
98
- getDirectionalLights(samples: number, pairs?: boolean): VDBFrameEnvironmentLight[];
99
+ getDirectionalLights(samples: number, pairs?: boolean, tie?: number): VDBFrameEnvironmentLight[];
99
100
  /**
100
101
  * SH projection of the environment (L1: 4, L2: 9 coefficients) evaluated at quadrature directions:
101
102
  * direction m gets the colour (4π / M) L_sh(w_m) / 4. The shaders clamp the sum to ≥ 0.
@@ -188,12 +188,16 @@ export class VDBFrameEnvironmentLights {
188
188
  * Dominant direction (brightest texel) and fixed sky directions: zenith, nadir, then a horizon ring.
189
189
  * Each texel goes to the nearest direction; a light is at the energy centroid of its texels with
190
190
  * their energy; colour is energy / 4 (a uniform environment then gives the 'outward' light).
191
- * `pairs`: seeds in opposite pairs (diffusion weights of a pair sum to 2).
191
+ * `pairs`: seeds in opposite pairs (diffusion weights of a pair sum to 2). `tie` (K6.2b, the core): near-ties go to
192
+ * the first candidate.
192
193
  */
193
- getDirectionalLights(samples, pairs = false) {
194
+ getDirectionalLights(samples, pairs = false, tie = 0) {
194
195
  const texels = this.texels;
195
196
  const count = Math.min(frameMaxEnvironmentSamples, Math.max(1, Math.round(samples) || 1));
196
- const peak = texels.reduce((best, texel) => (texel.luminance > best.luminance ? texel : best));
197
+ // K6.2b `tie` (the core twin): the first texel within `tie` (relative) of the maximum, and a seed must be nearer
198
+ // by more than `tie`; 0 is his (the first exact maximum, strictly nearer)
199
+ const brightest = Math.max(...texels.map((texel) => texel.luminance));
200
+ const peak = tie > 0 ? texels.find((texel) => texel.luminance >= brightest * (1 - tie)) : texels.reduce((best, texel) => (texel.luminance > best.luminance ? texel : best));
197
201
  const seeds = [peak.direction];
198
202
  const ringCount = pairs ? Math.max(0, count - 4) - (Math.max(0, count - 4) % 2) : count - 3;
199
203
  if (pairs) {
@@ -220,7 +224,7 @@ export class VDBFrameEnvironmentLights {
220
224
  let nearestDot = -Infinity;
221
225
  for (const cell of cells) {
222
226
  const dot = cell.seed[0] * direction[0] + cell.seed[1] * direction[1] + cell.seed[2] * direction[2];
223
- if (dot > nearestDot) {
227
+ if (dot > nearestDot + tie) {
224
228
  nearest = cell;
225
229
  nearestDot = dot;
226
230
  }
@@ -1 +1 @@
1
- {"version":3,"file":"environment.js","sourceRoot":"","sources":["../../../src/tools/frame/environment.ts"],"names":[],"mappings":"AAAA,0EAA0E;AAC1E,uEAAuE;AACvE,4GAA4G;AAC5G,6FAA6F;AAC7F,6FAA6F;AAC7F,sFAAsF;AAEtF;;;;;;;;GAQG;AAEH,MAAM,CAAC,MAAM,yBAAyB,GAAG,EAAE,CAAC;AAC5C,MAAM,CAAC,MAAM,0BAA0B,GAAG,CAAC,CAAC;AAC5C,MAAM,CAAC,MAAM,wBAAwB,GAAG,EAAE,CAAC;AAC3C,MAAM,CAAC,MAAM,yBAAyB,GAAG,EAAE,CAAC;A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,GAAG,CAAC,EAAE,CAAC,EAAE;oBAAE,KAAK,CAAC,CAAC,CAAC,GAAG,KAAK,CAAC,CAAC,CAAE,GAAG,YAAY,CAAC,KAAK,CAAE,CAAC,CAAC,CAAE,GAAG,KAAK,GAAG,MAAM,CAAC;YAC/F,CAAC,CAAC,CAAC;YACH,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,CAAC;QAC9B,CAAC,CAAC,CAAC;IACL,CAAC;CACF","sourcesContent":["// Portions derived from mjurczyk/openvdb (MIT), commit 75e7345 (v0.26.0):\n// src/three-openvdb/frame/core/frameEnvironment.js (all, 331 lines).\n// Copyright (c) mjurczyk/openvdb contributors. Licensed under the MIT License (see THIRD_PARTY_NOTICES.md).\n// Changes: TypeScript; `isFrameDiffusion` inlined (tools does not import the three adapter);\n// the readback promise may also resolve to a Uint16Array of half floats (decoded here). Same\n// directions, cells, colours and SH quadrature. Divergences: DIVERGES.md (K3.3 rows).\n\n/**\n * Multi-directional environment light (Disney \"Deep Scattering\", §4.4 and §7), engine-free (K3.3):\n * the scene environment is read once into a small lat-long map (64 × 32, PMREM roughness 0.4); the\n * CPU turns it into ≤ 12 directional lights. `'directional'`: the brightest texel plus fixed sky\n * directions (zenith, nadir, a horizon ring; opposite pairs with diffusion), each texel to its\n * nearest seed, a light at the energy centroid with energy / 4. `'spherical-harmonics'`: SH L1/L2\n * projection evaluated at quadrature directions. The three adapter draws the map and passes the\n * readback through `extract`.\n */\n\nexport const frameMaxEnvironmentLights = 12;\nexport const frameMaxEnvironmentSamples = 8;\nexport const frameEnvironmentMapWidth = 64;\nexport const frameEnvironmentMapHeight = 32;\n/** PMREM blur of the map: a small sun covers more than one texel and is not lost between texels. */\nexport const frameEnvironmentMapRoughness = 0.4;\n\nexport const frameEnvironmentModes = {\n outward: \"outward\",\n directional: \"directional\",\n sphericalHarmonics: \"spherical-harmonics\",\n} as const;\n\nexport type VDBFrameEnvironmentMode = (typeof frameEnvironmentModes)[keyof typeof frameEnvironmentModes];\n\n/** The renderer settings the environment lights read. */\nexport interface VDBFrameEnvironmentSettings {\n environmentLighting: string;\n environmentSamples: number;\n environmentShOrder: number;\n multipleScattering: boolean | string;\n}\n\n/** The scene fields the environment lights read (three's `Scene` fits). */\nexport interface VDBFrameEnvironmentScene {\n environment: { uuid: string; version: number } | null;\n environmentRotation: { x: number; y: number; z: number; order: string };\n environmentIntensity: number;\n}\n\n// NOTE Retry an empty map (environment or PMREM not ready) after this number of updates\nconst retryInterval = 30;\n\ntype V3 = [number, number, number];\n\nconst normalize = (x: number, y: number, z: number): V3 => {\n const length = Math.hypot(x, y, z) || 1.0;\n return [x / length, y / length, z / length];\n};\n\n/** His `isFrameDiffusion` (three `frame/phase.ts`): true, 'two-sided' and 'neural'. */\nconst isDiffusion = (mode: boolean | string) => !!mode && mode !== \"octaves\";\n\n/** The same direction as the map shaders. u and v are 0 to 1; v = 0 is +Y. */\nexport const vdbFrameEnvironmentMapDirection = (u: number, v: number): V3 => {\n const phi = u * 2.0 * Math.PI;\n const theta = v * Math.PI;\n return [Math.sin(theta) * Math.cos(phi), Math.cos(theta), Math.sin(theta) * Math.sin(phi)];\n};\n\n// NOTE Real SH basis, bands 0 to 2. Same constants as three.js SphericalHarmonics3.\nconst getShBasis = ([x, y, z]: V3, count: number) =>\n [0.282095, 0.488603 * y, 0.488603 * z, 0.488603 * x, 1.092548 * x * y, 1.092548 * y * z, 0.315392 * (3.0 * z * z - 1.0), 1.092548 * x * z, 0.546274 * (x * x - y * y)].slice(0, count);\n\n// NOTE Quadrature directions. Octahedron (spherical 3-design) for L1, icosahedron (5-design) for L2.\nconst goldenRatio = (1.0 + Math.sqrt(5.0)) / 2.0;\nconst octahedron: V3[] = [\n [1, 0, 0],\n [-1, 0, 0],\n [0, 1, 0],\n [0, -1, 0],\n [0, 0, 1],\n [0, 0, -1],\n];\nconst icosahedron: V3[] = (\n [\n [0, 1, goldenRatio],\n [0, -1, goldenRatio],\n [0, 1, -goldenRatio],\n [0, -1, -goldenRatio],\n [1, goldenRatio, 0],\n [-1, goldenRatio, 0],\n [1, -goldenRatio, 0],\n [-1, -goldenRatio, 0],\n [goldenRatio, 0, 1],\n [-goldenRatio, 0, 1],\n [goldenRatio, 0, -1],\n [-goldenRatio, 0, -1],\n ] as V3[]\n).map(([x, y, z]) => normalize(x, y, z));\n\nconst luminance = (r: number, g: number, b: number) => 0.2126 * r + 0.7152 * g + 0.0722 * b;\n\nexport const vdbFrameEnvironmentMode = (settings: Pick<VDBFrameEnvironmentSettings, \"environmentLighting\">): VDBFrameEnvironmentMode => {\n const mode = settings.environmentLighting;\n return mode === frameEnvironmentModes.directional || mode === frameEnvironmentModes.sphericalHarmonics ? mode : frameEnvironmentModes.outward;\n};\n\ninterface Texel {\n radiance: V3;\n luminance: number;\n direction: V3;\n solidAngle: number;\n}\n\n/** One environment light: world direction to the light and its isotropic irradiance colour (energy / 4). */\nexport interface VDBFrameEnvironmentLight {\n direction: V3;\n color: V3;\n power?: number;\n}\n\n/** Output of {@link VDBFrameEnvironmentLights.update}. Colours include `scene.environmentIntensity`. */\nexport interface VDBFrameEnvironmentResult {\n mode: VDBFrameEnvironmentMode;\n count: number;\n directions: V3[];\n colors: V3[];\n}\n\nconst halfToFloat = (h: number): number => {\n const s = h & 0x8000 ? -1 : 1;\n const e = (h >> 10) & 0x1f;\n const f = h & 0x3ff;\n if (e === 0) return s * Math.pow(2, -14) * (f / 1024);\n if (e === 31) return f ? NaN : s * Infinity;\n return s * Math.pow(2, e - 15) * (1 + f / 1024);\n};\n\n/**\n * His `FrameEnvironmentLights`: holds the lat-long map of the scene environment and the lights made\n * from it. `extract(renderer, scene)` is the engine part: it draws the map (RGB radiance, A the\n * texel's v, so the readback row order does not matter) and resolves RGBA floats.\n */\nexport class VDBFrameEnvironmentLights<R = unknown, S extends VDBFrameEnvironmentScene = VDBFrameEnvironmentScene> {\n key: string | null = null;\n pending = false;\n retryAt = 0;\n updates = 0;\n texels: Texel[] | null = null;\n texelsVersion = 0;\n warned = false;\n lightsKey: string | null = null;\n lights: VDBFrameEnvironmentLight[] = [];\n\n readonly result: VDBFrameEnvironmentResult = {\n mode: frameEnvironmentModes.outward,\n count: 0,\n directions: Array.from({ length: frameMaxEnvironmentLights }, () => [0.0, 1.0, 0.0] as V3),\n colors: Array.from({ length: frameMaxEnvironmentLights }, () => [0.0, 0.0, 0.0] as V3),\n };\n\n constructor(readonly extract: (renderer: R, scene: S) => Promise<ArrayLike<number>>) {}\n\n getKey(scene: S): string {\n const { environment, environmentRotation: rotation } = scene;\n return `${environment!.uuid}:${environment!.version}:${rotation.x}:${rotation.y}:${rotation.z}:${rotation.order}`;\n }\n\n /** Null when the 'outward' path must be used: another mode, no environment, or no map yet. */\n update(renderer: R, scene: S, settings: VDBFrameEnvironmentSettings): VDBFrameEnvironmentResult | null {\n const mode = vdbFrameEnvironmentMode(settings);\n this.updates++;\n if (mode === frameEnvironmentModes.outward || !scene.environment) return null;\n\n const key = this.getKey(scene);\n if (key !== this.key && !this.pending && this.updates >= this.retryAt) this.requestMap(renderer, scene, key);\n if (!this.texels) return null;\n\n // NOTE Diffusion multiple scattering needs the directions in opposite pairs (getDirectionalLights)\n const pairs = isDiffusion(settings.multipleScattering);\n const lightsKey = `${mode}:${settings.environmentSamples}:${settings.environmentShOrder}:${this.texelsVersion}:${pairs}`;\n if (lightsKey !== this.lightsKey) {\n this.lights = mode === frameEnvironmentModes.directional ? this.getDirectionalLights(settings.environmentSamples, pairs) : this.getShLights(settings.environmentShOrder);\n this.lightsKey = lightsKey;\n }\n\n const { result } = this;\n const intensity = scene.environmentIntensity;\n result.mode = mode;\n result.count = this.lights.length;\n this.lights.forEach(({ direction, color }, index) => {\n result.directions[index] = direction;\n result.colors[index] = color.map((value) => value * intensity) as V3;\n });\n return result;\n }\n\n /** Resolves when a pending map readback has settled (tests and harnesses; not his). */\n settled: Promise<void> = Promise.resolve();\n\n requestMap(renderer: R, scene: S, key: string): void {\n this.pending = true;\n this.settled = this.extract(renderer, scene)\n .then((pixels) => {\n this.pending = false;\n if (this.setTexels(pixels)) this.key = key;\n else this.retryAt = this.updates + retryInterval;\n })\n .catch((error: unknown) => {\n this.pending = false;\n this.retryAt = this.updates + retryInterval;\n if (!this.warned) {\n console.warn(\"VDBFrameRenderer: could not read the environment map.\", error);\n this.warned = true;\n }\n });\n }\n\n /** Radiance, direction and solid angle of each texel. Returns false for an empty map. Half floats (Uint16Array) are decoded. */\n setTexels(pixels: ArrayLike<number>): boolean {\n const width = frameEnvironmentMapWidth;\n const height = frameEnvironmentMapHeight;\n const half = pixels instanceof Uint16Array;\n const at = (i: number) => (half ? halfToFloat(pixels[i]!) : pixels[i]!);\n const texels: Texel[] = [];\n let energy = 0.0;\n\n for (let i = 0; i < width * height; i++) {\n const r = Math.max(0.0, at(i * 4));\n const g = Math.max(0.0, at(i * 4 + 1));\n const b = Math.max(0.0, at(i * 4 + 2));\n const v = at(i * 4 + 3);\n const u = ((i % width) + 0.5) / width;\n const theta = v * Math.PI;\n const solidAngle = ((2.0 * Math.PI) / width) * (Math.PI / height) * Math.sin(theta);\n if (!Number.isFinite(r + g + b + v)) return false;\n energy += luminance(r, g, b) * solidAngle;\n texels.push({ radiance: [r, g, b], luminance: luminance(r, g, b), direction: vdbFrameEnvironmentMapDirection(u, v), solidAngle });\n }\n if (energy <= 0.0) return false;\n this.texels = texels;\n this.texelsVersion++;\n return true;\n }\n\n /**\n * Dominant direction (brightest texel) and fixed sky directions: zenith, nadir, then a horizon ring.\n * Each texel goes to the nearest direction; a light is at the energy centroid of its texels with\n * their energy; colour is energy / 4 (a uniform environment then gives the 'outward' light).\n * `pairs`: seeds in opposite pairs (diffusion weights of a pair sum to 2).\n */\n getDirectionalLights(samples: number, pairs = false): VDBFrameEnvironmentLight[] {\n const texels = this.texels!;\n const count = Math.min(frameMaxEnvironmentSamples, Math.max(1, Math.round(samples) || 1));\n const peak = texels.reduce((best, texel) => (texel.luminance > best.luminance ? texel : best));\n const seeds: V3[] = [peak.direction];\n const ringCount = pairs ? Math.max(0, count - 4) - (Math.max(0, count - 4) % 2) : count - 3;\n\n if (pairs) {\n if (count >= 2) seeds.push(peak.direction.map((value) => -value) as V3);\n if (count >= 4) seeds.push([0.0, 1.0, 0.0], [0.0, -1.0, 0.0]);\n } else {\n if (count >= 2) seeds.push([0.0, 1.0, 0.0]);\n if (count >= 3) seeds.push([0.0, -1.0, 0.0]);\n }\n\n // NOTE The horizon ring starts opposite the dominant direction\n const peakAzimuth = Math.atan2(peak.direction[2], peak.direction[0]);\n for (let i = 0; i < ringCount; i++) {\n const azimuth = peakAzimuth + Math.PI + (2.0 * Math.PI * i) / ringCount;\n seeds.push([Math.cos(azimuth), 0.0, Math.sin(azimuth)]);\n }\n\n const cells = seeds.map((seed) => ({ seed, energy: [0.0, 0.0, 0.0] as V3, centroid: [0.0, 0.0, 0.0] as V3 }));\n for (const { radiance, luminance: texelLuminance, direction, solidAngle } of texels) {\n let nearest = cells[0]!;\n let nearestDot = -Infinity;\n for (const cell of cells) {\n const dot = cell.seed[0] * direction[0] + cell.seed[1] * direction[1] + cell.seed[2] * direction[2];\n if (dot > nearestDot) {\n nearest = cell;\n nearestDot = dot;\n }\n }\n for (let c = 0; c < 3; c++) {\n nearest.energy[c] = nearest.energy[c]! + radiance[c]! * solidAngle;\n nearest.centroid[c] = nearest.centroid[c]! + direction[c]! * texelLuminance * solidAngle;\n }\n }\n\n return cells\n .filter(({ energy }) => luminance(...energy) > 0.0)\n .map(({ seed, energy, centroid }) => ({\n direction: Math.hypot(...centroid) > 1e-6 ? normalize(...centroid) : seed,\n color: energy.map((value) => value / 4.0) as V3,\n power: luminance(...energy),\n }))\n .sort((a, b) => b.power - a.power);\n }\n\n /**\n * SH projection of the environment (L1: 4, L2: 9 coefficients) evaluated at quadrature directions:\n * direction m gets the colour (4π / M) L_sh(w_m) / 4. The shaders clamp the sum to ≥ 0.\n */\n getShLights(order: number): VDBFrameEnvironmentLight[] {\n const texels = this.texels!;\n const coefficientCount = Number(order) === 1 ? 4 : 9;\n const directions = coefficientCount === 4 ? octahedron : icosahedron;\n const coefficients = Array.from({ length: coefficientCount }, () => [0.0, 0.0, 0.0] as V3);\n for (const { radiance, direction, solidAngle } of texels) {\n getShBasis(direction, coefficientCount).forEach((basis, index) => {\n for (let c = 0; c < 3; c++) coefficients[index]![c] = coefficients[index]![c]! + radiance[c]! * basis * solidAngle;\n });\n }\n const weight = (4.0 * Math.PI) / directions.length / 4.0;\n return directions.map((direction) => {\n const color: V3 = [0.0, 0.0, 0.0];\n getShBasis(direction, coefficientCount).forEach((basis, index) => {\n for (let c = 0; c < 3; c++) color[c] = color[c]! + coefficients[index]![c]! * basis * weight;\n });\n return { direction, color };\n });\n }\n}\n"]}
1
+ {"version":3,"file":"environment.js","sourceRoot":"","sources":["../../../src/tools/frame/environment.ts"],"names":[],"mappings":"AAAA,0EAA0E;AAC1E,uEAAuE;AACvE,4GAA4G;AAC5G,6FAA6F;AAC7F,6FAA6F;AAC7F,sFAAsF;AAEtF;;;;;;;;GAQG;AAEH,MAAM,CAAC,MAAM,yBAAyB,GAAG,EAAE,CAAC;AAC5C,MAAM,CAAC,MAAM,0BAA0B,GAAG,CAAC,CAAC;AAC5C,MAAM,CAAC,MAAM,wBAAwB,GAAG,EAAE,CAAC;AAC3C,MAAM,CAAC,MAAM,yBAAyB,GAAG,EAAE,CAAC;AAC5C,oGAAoG;AACpG,MAAM,CAAC,MAAM,4BAA4B,GAAG,GAAG,CAAC;AAEhD,MAAM,CAAC,MAAM,qBAAqB,GAAG;IACnC,OAAO,EAAE,SAAS;IAClB,WAAW,EAAE,aAAa;IAC1B,kBAAkB,EAAE,qBAAqB;CACjC,CAAC;AAmBX,wFAAwF;AACxF,MAAM,aAAa,GAAG,EAAE,CAAC;AAIzB,MAAM,SAAS,GAAG,CAAC,CAAS,EAAE,CAAS,EAAE,CAAS,EAAM,EAAE;IACxD,MAAM,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,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AG,CAAC,EAAE,CAAC,EAAE;oBAAE,KAAK,CAAC,CAAC,CAAC,GAAG,KAAK,CAAC,CAAC,CAAE,GAAG,YAAY,CAAC,KAAK,CAAE,CAAC,CAAC,CAAE,GAAG,KAAK,GAAG,MAAM,CAAC;YAC/F,CAAC,CAAC,CAAC;YACH,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,CAAC;QAC9B,CAAC,CAAC,CAAC;IACL,CAAC;CACF","sourcesContent":["// Portions derived from mjurczyk/openvdb (MIT), commit 75e7345 (v0.26.0):\n// src/three-openvdb/frame/core/frameEnvironment.js (all, 331 lines).\n// Copyright (c) mjurczyk/openvdb contributors. Licensed under the MIT License (see THIRD_PARTY_NOTICES.md).\n// Changes: TypeScript; `isFrameDiffusion` inlined (tools does not import the three adapter);\n// the readback promise may also resolve to a Uint16Array of half floats (decoded here). Same\n// directions, cells, colours and SH quadrature. Divergences: DIVERGES.md (K3.3 rows).\n\n/**\n * Multi-directional environment light (Disney \"Deep Scattering\", §4.4 and §7), engine-free (K3.3):\n * the scene environment is read once into a small lat-long map (64 × 32, PMREM roughness 0.4); the\n * CPU turns it into ≤ 12 directional lights. `'directional'`: the brightest texel plus fixed sky\n * directions (zenith, nadir, a horizon ring; opposite pairs with diffusion), each texel to its\n * nearest seed, a light at the energy centroid with energy / 4. `'spherical-harmonics'`: SH L1/L2\n * projection evaluated at quadrature directions. The three adapter draws the map and passes the\n * readback through `extract`.\n */\n\nexport const frameMaxEnvironmentLights = 12;\nexport const frameMaxEnvironmentSamples = 8;\nexport const frameEnvironmentMapWidth = 64;\nexport const frameEnvironmentMapHeight = 32;\n/** PMREM blur of the map: a small sun covers more than one texel and is not lost between texels. */\nexport const frameEnvironmentMapRoughness = 0.4;\n\nexport const frameEnvironmentModes = {\n outward: \"outward\",\n directional: \"directional\",\n sphericalHarmonics: \"spherical-harmonics\",\n} as const;\n\nexport type VDBFrameEnvironmentMode = (typeof frameEnvironmentModes)[keyof typeof frameEnvironmentModes];\n\n/** The renderer settings the environment lights read. */\nexport interface VDBFrameEnvironmentSettings {\n environmentLighting: string;\n environmentSamples: number;\n environmentShOrder: number;\n multipleScattering: boolean | string;\n}\n\n/** The scene fields the environment lights read (three's `Scene` fits). */\nexport interface VDBFrameEnvironmentScene {\n environment: { uuid: string; version: number } | null;\n environmentRotation: { x: number; y: number; z: number; order: string };\n environmentIntensity: number;\n}\n\n// NOTE Retry an empty map (environment or PMREM not ready) after this number of updates\nconst retryInterval = 30;\n\ntype V3 = [number, number, number];\n\nconst normalize = (x: number, y: number, z: number): V3 => {\n const length = Math.hypot(x, y, z) || 1.0;\n return [x / length, y / length, z / length];\n};\n\n/** His `isFrameDiffusion` (three `frame/phase.ts`): true, 'two-sided' and 'neural'. */\nconst isDiffusion = (mode: boolean | string) => !!mode && mode !== \"octaves\";\n\n/** The same direction as the map shaders. u and v are 0 to 1; v = 0 is +Y. */\nexport const vdbFrameEnvironmentMapDirection = (u: number, v: number): V3 => {\n const phi = u * 2.0 * Math.PI;\n const theta = v * Math.PI;\n return [Math.sin(theta) * Math.cos(phi), Math.cos(theta), Math.sin(theta) * Math.sin(phi)];\n};\n\n// NOTE Real SH basis, bands 0 to 2. Same constants as three.js SphericalHarmonics3.\nconst getShBasis = ([x, y, z]: V3, count: number) =>\n [0.282095, 0.488603 * y, 0.488603 * z, 0.488603 * x, 1.092548 * x * y, 1.092548 * y * z, 0.315392 * (3.0 * z * z - 1.0), 1.092548 * x * z, 0.546274 * (x * x - y * y)].slice(0, count);\n\n// NOTE Quadrature directions. Octahedron (spherical 3-design) for L1, icosahedron (5-design) for L2.\nconst goldenRatio = (1.0 + Math.sqrt(5.0)) / 2.0;\nconst octahedron: V3[] = [\n [1, 0, 0],\n [-1, 0, 0],\n [0, 1, 0],\n [0, -1, 0],\n [0, 0, 1],\n [0, 0, -1],\n];\nconst icosahedron: V3[] = (\n [\n [0, 1, goldenRatio],\n [0, -1, goldenRatio],\n [0, 1, -goldenRatio],\n [0, -1, -goldenRatio],\n [1, goldenRatio, 0],\n [-1, goldenRatio, 0],\n [1, -goldenRatio, 0],\n [-1, -goldenRatio, 0],\n [goldenRatio, 0, 1],\n [-goldenRatio, 0, 1],\n [goldenRatio, 0, -1],\n [-goldenRatio, 0, -1],\n ] as V3[]\n).map(([x, y, z]) => normalize(x, y, z));\n\nconst luminance = (r: number, g: number, b: number) => 0.2126 * r + 0.7152 * g + 0.0722 * b;\n\nexport const vdbFrameEnvironmentMode = (settings: Pick<VDBFrameEnvironmentSettings, \"environmentLighting\">): VDBFrameEnvironmentMode => {\n const mode = settings.environmentLighting;\n return mode === frameEnvironmentModes.directional || mode === frameEnvironmentModes.sphericalHarmonics ? mode : frameEnvironmentModes.outward;\n};\n\ninterface Texel {\n radiance: V3;\n luminance: number;\n direction: V3;\n solidAngle: number;\n}\n\n/** One environment light: world direction to the light and its isotropic irradiance colour (energy / 4). */\nexport interface VDBFrameEnvironmentLight {\n direction: V3;\n color: V3;\n power?: number;\n}\n\n/** Output of {@link VDBFrameEnvironmentLights.update}. Colours include `scene.environmentIntensity`. */\nexport interface VDBFrameEnvironmentResult {\n mode: VDBFrameEnvironmentMode;\n count: number;\n directions: V3[];\n colors: V3[];\n}\n\nconst halfToFloat = (h: number): number => {\n const s = h & 0x8000 ? -1 : 1;\n const e = (h >> 10) & 0x1f;\n const f = h & 0x3ff;\n if (e === 0) return s * Math.pow(2, -14) * (f / 1024);\n if (e === 31) return f ? NaN : s * Infinity;\n return s * Math.pow(2, e - 15) * (1 + f / 1024);\n};\n\n/**\n * His `FrameEnvironmentLights`: holds the lat-long map of the scene environment and the lights made\n * from it. `extract(renderer, scene)` is the engine part: it draws the map (RGB radiance, A the\n * texel's v, so the readback row order does not matter) and resolves RGBA floats.\n */\nexport class VDBFrameEnvironmentLights<R = unknown, S extends VDBFrameEnvironmentScene = VDBFrameEnvironmentScene> {\n key: string | null = null;\n pending = false;\n retryAt = 0;\n updates = 0;\n texels: Texel[] | null = null;\n texelsVersion = 0;\n warned = false;\n lightsKey: string | null = null;\n lights: VDBFrameEnvironmentLight[] = [];\n\n readonly result: VDBFrameEnvironmentResult = {\n mode: frameEnvironmentModes.outward,\n count: 0,\n directions: Array.from({ length: frameMaxEnvironmentLights }, () => [0.0, 1.0, 0.0] as V3),\n colors: Array.from({ length: frameMaxEnvironmentLights }, () => [0.0, 0.0, 0.0] as V3),\n };\n\n constructor(readonly extract: (renderer: R, scene: S) => Promise<ArrayLike<number>>) {}\n\n getKey(scene: S): string {\n const { environment, environmentRotation: rotation } = scene;\n return `${environment!.uuid}:${environment!.version}:${rotation.x}:${rotation.y}:${rotation.z}:${rotation.order}`;\n }\n\n /** Null when the 'outward' path must be used: another mode, no environment, or no map yet. */\n update(renderer: R, scene: S, settings: VDBFrameEnvironmentSettings): VDBFrameEnvironmentResult | null {\n const mode = vdbFrameEnvironmentMode(settings);\n this.updates++;\n if (mode === frameEnvironmentModes.outward || !scene.environment) return null;\n\n const key = this.getKey(scene);\n if (key !== this.key && !this.pending && this.updates >= this.retryAt) this.requestMap(renderer, scene, key);\n if (!this.texels) return null;\n\n // NOTE Diffusion multiple scattering needs the directions in opposite pairs (getDirectionalLights)\n const pairs = isDiffusion(settings.multipleScattering);\n const lightsKey = `${mode}:${settings.environmentSamples}:${settings.environmentShOrder}:${this.texelsVersion}:${pairs}`;\n if (lightsKey !== this.lightsKey) {\n this.lights = mode === frameEnvironmentModes.directional ? this.getDirectionalLights(settings.environmentSamples, pairs) : this.getShLights(settings.environmentShOrder);\n this.lightsKey = lightsKey;\n }\n\n const { result } = this;\n const intensity = scene.environmentIntensity;\n result.mode = mode;\n result.count = this.lights.length;\n this.lights.forEach(({ direction, color }, index) => {\n result.directions[index] = direction;\n result.colors[index] = color.map((value) => value * intensity) as V3;\n });\n return result;\n }\n\n /** Resolves when a pending map readback has settled (tests and harnesses; not his). */\n settled: Promise<void> = Promise.resolve();\n\n requestMap(renderer: R, scene: S, key: string): void {\n this.pending = true;\n this.settled = this.extract(renderer, scene)\n .then((pixels) => {\n this.pending = false;\n if (this.setTexels(pixels)) this.key = key;\n else this.retryAt = this.updates + retryInterval;\n })\n .catch((error: unknown) => {\n this.pending = false;\n this.retryAt = this.updates + retryInterval;\n if (!this.warned) {\n console.warn(\"VDBFrameRenderer: could not read the environment map.\", error);\n this.warned = true;\n }\n });\n }\n\n /** Radiance, direction and solid angle of each texel. Returns false for an empty map. Half floats (Uint16Array) are decoded. */\n setTexels(pixels: ArrayLike<number>): boolean {\n const width = frameEnvironmentMapWidth;\n const height = frameEnvironmentMapHeight;\n const half = pixels instanceof Uint16Array;\n const at = (i: number) => (half ? halfToFloat(pixels[i]!) : pixels[i]!);\n const texels: Texel[] = [];\n let energy = 0.0;\n\n for (let i = 0; i < width * height; i++) {\n const r = Math.max(0.0, at(i * 4));\n const g = Math.max(0.0, at(i * 4 + 1));\n const b = Math.max(0.0, at(i * 4 + 2));\n const v = at(i * 4 + 3);\n const u = ((i % width) + 0.5) / width;\n const theta = v * Math.PI;\n const solidAngle = ((2.0 * Math.PI) / width) * (Math.PI / height) * Math.sin(theta);\n if (!Number.isFinite(r + g + b + v)) return false;\n energy += luminance(r, g, b) * solidAngle;\n texels.push({ radiance: [r, g, b], luminance: luminance(r, g, b), direction: vdbFrameEnvironmentMapDirection(u, v), solidAngle });\n }\n if (energy <= 0.0) return false;\n this.texels = texels;\n this.texelsVersion++;\n return true;\n }\n\n /**\n * Dominant direction (brightest texel) and fixed sky directions: zenith, nadir, then a horizon ring.\n * Each texel goes to the nearest direction; a light is at the energy centroid of its texels with\n * their energy; colour is energy / 4 (a uniform environment then gives the 'outward' light).\n * `pairs`: seeds in opposite pairs (diffusion weights of a pair sum to 2). `tie` (K6.2b, the core): near-ties go to\n * the first candidate.\n */\n getDirectionalLights(samples: number, pairs = false, tie = 0): VDBFrameEnvironmentLight[] {\n const texels = this.texels!;\n const count = Math.min(frameMaxEnvironmentSamples, Math.max(1, Math.round(samples) || 1));\n // K6.2b `tie` (the core twin): the first texel within `tie` (relative) of the maximum, and a seed must be nearer\n // by more than `tie`; 0 is his (the first exact maximum, strictly nearer)\n const brightest = Math.max(...texels.map((texel) => texel.luminance));\n const peak = tie > 0 ? texels.find((texel) => texel.luminance >= brightest * (1 - tie))! : texels.reduce((best, texel) => (texel.luminance > best.luminance ? texel : best));\n const seeds: V3[] = [peak.direction];\n const ringCount = pairs ? Math.max(0, count - 4) - (Math.max(0, count - 4) % 2) : count - 3;\n\n if (pairs) {\n if (count >= 2) seeds.push(peak.direction.map((value) => -value) as V3);\n if (count >= 4) seeds.push([0.0, 1.0, 0.0], [0.0, -1.0, 0.0]);\n } else {\n if (count >= 2) seeds.push([0.0, 1.0, 0.0]);\n if (count >= 3) seeds.push([0.0, -1.0, 0.0]);\n }\n\n // NOTE The horizon ring starts opposite the dominant direction\n const peakAzimuth = Math.atan2(peak.direction[2], peak.direction[0]);\n for (let i = 0; i < ringCount; i++) {\n const azimuth = peakAzimuth + Math.PI + (2.0 * Math.PI * i) / ringCount;\n seeds.push([Math.cos(azimuth), 0.0, Math.sin(azimuth)]);\n }\n\n const cells = seeds.map((seed) => ({ seed, energy: [0.0, 0.0, 0.0] as V3, centroid: [0.0, 0.0, 0.0] as V3 }));\n for (const { radiance, luminance: texelLuminance, direction, solidAngle } of texels) {\n let nearest = cells[0]!;\n let nearestDot = -Infinity;\n for (const cell of cells) {\n const dot = cell.seed[0] * direction[0] + cell.seed[1] * direction[1] + cell.seed[2] * direction[2];\n if (dot > nearestDot + tie) {\n nearest = cell;\n nearestDot = dot;\n }\n }\n for (let c = 0; c < 3; c++) {\n nearest.energy[c] = nearest.energy[c]! + radiance[c]! * solidAngle;\n nearest.centroid[c] = nearest.centroid[c]! + direction[c]! * texelLuminance * solidAngle;\n }\n }\n\n return cells\n .filter(({ energy }) => luminance(...energy) > 0.0)\n .map(({ seed, energy, centroid }) => ({\n direction: Math.hypot(...centroid) > 1e-6 ? normalize(...centroid) : seed,\n color: energy.map((value) => value / 4.0) as V3,\n power: luminance(...energy),\n }))\n .sort((a, b) => b.power - a.power);\n }\n\n /**\n * SH projection of the environment (L1: 4, L2: 9 coefficients) evaluated at quadrature directions:\n * direction m gets the colour (4π / M) L_sh(w_m) / 4. The shaders clamp the sum to ≥ 0.\n */\n getShLights(order: number): VDBFrameEnvironmentLight[] {\n const texels = this.texels!;\n const coefficientCount = Number(order) === 1 ? 4 : 9;\n const directions = coefficientCount === 4 ? octahedron : icosahedron;\n const coefficients = Array.from({ length: coefficientCount }, () => [0.0, 0.0, 0.0] as V3);\n for (const { radiance, direction, solidAngle } of texels) {\n getShBasis(direction, coefficientCount).forEach((basis, index) => {\n for (let c = 0; c < 3; c++) coefficients[index]![c] = coefficients[index]![c]! + radiance[c]! * basis * solidAngle;\n });\n }\n const weight = (4.0 * Math.PI) / directions.length / 4.0;\n return directions.map((direction) => {\n const color: V3 = [0.0, 0.0, 0.0];\n getShBasis(direction, coefficientCount).forEach((basis, index) => {\n for (let c = 0; c < 3; c++) color[c] = color[c]! + coefficients[index]![c]! * basis * weight;\n });\n return { direction, color };\n });\n }\n}\n"]}
@@ -0,0 +1,58 @@
1
+ /**
2
+ * CPU twins (f64) of the core frame renderer's froxel stages (K6.1): `vdbFrameGatherCs`'s combine of
3
+ * the volumes in one froxel, `vdbFrameResolveCs`'s temporal blend and column scan, and
4
+ * `vdbFrameIntegrate`'s two-tap composite. Engine-free; the oracles of `e2e/k6-core.spec.ts`.
5
+ */
6
+ import { type Vec2, type Vec3, type Vec4 } from "./index.js";
7
+ /** One volume's lit froxel: unpremultiplied slice radiance and slice alpha (`vdbFrameInjectSlice` + lights). */
8
+ export interface VDBFrameVolumeFroxel {
9
+ radiance: Vec3;
10
+ alpha: number;
11
+ }
12
+ /** Optical depths above this are clamped (T = 1.3e-14), so an opaque volume gives a finite τ. */
13
+ export declare const vdbFrameMaxOpticalDepth = 32;
14
+ /**
15
+ * The gather kernel's combine of the volumes in one froxel, premultiplied (rgb = L·α, a = α).
16
+ *
17
+ * Design §3.4: co-located media; τᵢ = −log(1 − αᵢ), α = 1 − exp(−Στᵢ),
18
+ * L = Σ τᵢLᵢ / Στᵢ. Order-independent; one volume gives exactly (Lα, α).
19
+ * Volumes with α ≤ 0 do not count (discarded froxels).
20
+ */
21
+ export declare function vdbFrameGatherFroxel(volumes: readonly VDBFrameVolumeFroxel[]): Vec4;
22
+ /**
23
+ * His temporal blend of one froxel (`FrameTemporalMaterial`): the reprojected history clamped to the
24
+ * per-channel min and max of the current froxel and its neighbours, then `mix(history, current, blend)`
25
+ * (`blend` from `vdbFrameReproject`).
26
+ */
27
+ export declare function vdbFrameTemporalFroxel(current: Vec4, history: Vec4, neighbours: readonly Vec4[], blend: number): Vec4;
28
+ /** Transmittance below which the scan stops adding slices (his integrate's break). */
29
+ export declare const vdbFrameScanStop = 0.001;
30
+ /**
31
+ * The resolve kernel's column scan (his integrate loop over whole slices): boundary k holds the
32
+ * radiance of slices 0..k−1 and their opacity A = 1 − T. `froxels[z]` is the premultiplied
33
+ * (rgb, α) of slice z (α clamped to [0, 1]); a slice whose start has T < 0.001 adds nothing (his break).
34
+ * Returns `froxels.length + 1` boundaries; boundary 0 is (0, 0, 0, 0).
35
+ */
36
+ export declare function vdbFrameScanColumn(froxels: readonly Vec4[], o?: {
37
+ stop?: number;
38
+ }): Vec4[];
39
+ /** What the composite reads at a pixel: radiance and transmittance (grey: one T). */
40
+ export interface VDBFrameIntegrated {
41
+ radiance: Vec3;
42
+ transmittance: number;
43
+ }
44
+ /**
45
+ * The composite's two taps (design §3.4): the scene depth falls `c` ∈ [0, 1] into the slice between
46
+ * boundaries `a` and `b` (each (L rgb, A = 1 − T)). With α = 1 − T_b / T_a:
47
+ * radiance = L_a + (L_b − L_a)·(1 − (1 − α)^c)/α (→ c as α → 0), T = T_a·(1 − α)^c: his `sliceAlpha`.
48
+ */
49
+ export declare function vdbFrameIntegratePrefix(a: Vec4, b: Vec4, c: number): VDBFrameIntegrated;
50
+ /**
51
+ * The composite's slice of a scene view depth: the slice `k` it falls in on his log slices (`range` the
52
+ * froxel near and far; ≤ depth − 1) and his coverage `c` of that slice, linear in view depth:
53
+ * (depth − sliceStart) / (sliceEnd − sliceStart), clamped to [0, 1].
54
+ */
55
+ export declare function vdbFrameSliceCoord(viewDepth: number, range: Vec2, depth: number): {
56
+ k: number;
57
+ c: number;
58
+ };
@@ -0,0 +1,115 @@
1
+ // Portions derived from mjurczyk/openvdb (MIT), commit 75e7345 (v0.26.0):
2
+ // src/three-openvdb/frame/webgpu/FrameInjectMaterial.js L59–101 (the premultiplied "over" blend of
3
+ // overlapping volumes), src/three-openvdb/frame/webgpu/FrameTemporalMaterial.js L120–200 (the
4
+ // neighbourhood clamp and blend), src/three-openvdb/frame/webgpu/FrameIntegrateMaterial.js L219–294
5
+ // (the slice march with the T < 0.001 stop and the `sliceAlpha` coverage of the last slice).
6
+ // Copyright (c) mjurczyk/openvdb contributors. Licensed under the MIT License (see THIRD_PARTY_NOTICES.md).
7
+ // Changes: the core renderer's froxel stages (K6.1, design §3.4): an order-independent 'mixture' of the
8
+ // volumes in a froxel beside his 'over'; his integrate split into a per-column prefix scan and a two-tap
9
+ // composite. Divergences: DIVERGES.md (K6.1 rows).
10
+ /**
11
+ * CPU twins (f64) of the core frame renderer's froxel stages (K6.1): `vdbFrameGatherCs`'s combine of
12
+ * the volumes in one froxel, `vdbFrameResolveCs`'s temporal blend and column scan, and
13
+ * `vdbFrameIntegrate`'s two-tap composite. Engine-free; the oracles of `e2e/k6-core.spec.ts`.
14
+ */
15
+ import { vdbFrameFroxelSlice, vdbFrameSliceDepth } from "./index.js";
16
+ /** Optical depths above this are clamped (T = 1.3e-14), so an opaque volume gives a finite τ. */
17
+ export const vdbFrameMaxOpticalDepth = 32;
18
+ /**
19
+ * The gather kernel's combine of the volumes in one froxel, premultiplied (rgb = L·α, a = α).
20
+ *
21
+ * Design §3.4: co-located media; τᵢ = −log(1 − αᵢ), α = 1 − exp(−Στᵢ),
22
+ * L = Σ τᵢLᵢ / Στᵢ. Order-independent; one volume gives exactly (Lα, α).
23
+ * Volumes with α ≤ 0 do not count (discarded froxels).
24
+ */
25
+ export function vdbFrameGatherFroxel(volumes) {
26
+ const lit = volumes.filter((v) => v.alpha > 0);
27
+ if (lit.length === 0)
28
+ return [0, 0, 0, 0];
29
+ if (lit.length === 1) {
30
+ const v = lit[0];
31
+ return [v.radiance[0] * v.alpha, v.radiance[1] * v.alpha, v.radiance[2] * v.alpha, v.alpha];
32
+ }
33
+ let tau = 0;
34
+ const tl = [0, 0, 0];
35
+ for (const v of lit) {
36
+ const t = Math.min(-Math.log(Math.max(1 - v.alpha, 0)), vdbFrameMaxOpticalDepth);
37
+ tau += t;
38
+ for (let c = 0; c < 3; c++)
39
+ tl[c] = tl[c] + t * v.radiance[c];
40
+ }
41
+ const alpha = 1 - Math.exp(-tau);
42
+ return [(tl[0] / tau) * alpha, (tl[1] / tau) * alpha, (tl[2] / tau) * alpha, alpha];
43
+ }
44
+ /**
45
+ * His temporal blend of one froxel (`FrameTemporalMaterial`): the reprojected history clamped to the
46
+ * per-channel min and max of the current froxel and its neighbours, then `mix(history, current, blend)`
47
+ * (`blend` from `vdbFrameReproject`).
48
+ */
49
+ export function vdbFrameTemporalFroxel(current, history, neighbours, blend) {
50
+ const lo = [...current];
51
+ const hi = [...current];
52
+ for (const n of neighbours) {
53
+ for (let c = 0; c < 4; c++) {
54
+ lo[c] = Math.min(lo[c], n[c]);
55
+ hi[c] = Math.max(hi[c], n[c]);
56
+ }
57
+ }
58
+ return [0, 1, 2, 3].map((c) => {
59
+ const h = Math.min(Math.max(history[c], lo[c]), hi[c]);
60
+ return h + (current[c] - h) * blend;
61
+ });
62
+ }
63
+ /** Transmittance below which the scan stops adding slices (his integrate's break). */
64
+ export const vdbFrameScanStop = 0.001;
65
+ /**
66
+ * The resolve kernel's column scan (his integrate loop over whole slices): boundary k holds the
67
+ * radiance of slices 0..k−1 and their opacity A = 1 − T. `froxels[z]` is the premultiplied
68
+ * (rgb, α) of slice z (α clamped to [0, 1]); a slice whose start has T < 0.001 adds nothing (his break).
69
+ * Returns `froxels.length + 1` boundaries; boundary 0 is (0, 0, 0, 0).
70
+ */
71
+ export function vdbFrameScanColumn(froxels, o = {}) {
72
+ const stop = o.stop ?? vdbFrameScanStop;
73
+ const out = [[0, 0, 0, 0]];
74
+ const L = [0, 0, 0];
75
+ let T = 1;
76
+ for (const f of froxels) {
77
+ const a = Math.min(Math.max(f[3], 0), 1);
78
+ if (T >= stop && a > 0) {
79
+ for (let c = 0; c < 3; c++)
80
+ L[c] = L[c] + T * f[c];
81
+ T *= 1 - a;
82
+ }
83
+ out.push([L[0], L[1], L[2], 1 - T]);
84
+ }
85
+ return out;
86
+ }
87
+ /**
88
+ * The composite's two taps (design §3.4): the scene depth falls `c` ∈ [0, 1] into the slice between
89
+ * boundaries `a` and `b` (each (L rgb, A = 1 − T)). With α = 1 − T_b / T_a:
90
+ * radiance = L_a + (L_b − L_a)·(1 − (1 − α)^c)/α (→ c as α → 0), T = T_a·(1 − α)^c: his `sliceAlpha`.
91
+ */
92
+ export function vdbFrameIntegratePrefix(a, b, c) {
93
+ const ta = 1 - a[3];
94
+ const tb = 1 - b[3];
95
+ const alpha = Math.min(Math.max(ta > 1e-6 ? 1 - tb / ta : 0, 0), 1);
96
+ const keep = Math.pow(1 - alpha, c);
97
+ const w = alpha > 1e-4 ? (1 - keep) / alpha : c;
98
+ return {
99
+ radiance: [a[0] + (b[0] - a[0]) * w, a[1] + (b[1] - a[1]) * w, a[2] + (b[2] - a[2]) * w],
100
+ transmittance: Math.max(ta, 0) * keep,
101
+ };
102
+ }
103
+ /**
104
+ * The composite's slice of a scene view depth: the slice `k` it falls in on his log slices (`range` the
105
+ * froxel near and far; ≤ depth − 1) and his coverage `c` of that slice, linear in view depth:
106
+ * (depth − sliceStart) / (sliceEnd − sliceStart), clamped to [0, 1].
107
+ */
108
+ export function vdbFrameSliceCoord(viewDepth, range, depth) {
109
+ const s = Math.min(Math.max(vdbFrameFroxelSlice(viewDepth, range, depth), 0), depth);
110
+ const k = Math.min(Math.floor(s), depth - 1);
111
+ const start = vdbFrameSliceDepth(range, k / depth);
112
+ const end = vdbFrameSliceDepth(range, (k + 1) / depth);
113
+ return { k, c: Math.min(Math.max((viewDepth - start) / (end - start), 0), 1) };
114
+ }
115
+ //# sourceMappingURL=froxel.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"froxel.js","sourceRoot":"","sources":["../../../src/tools/frame/froxel.ts"],"names":[],"mappings":"AAAA,0EAA0E;AAC1E,qGAAqG;AACrG,gGAAgG;AAChG,sGAAsG;AACtG,+FAA+F;AAC/F,4GAA4G;AAC5G,wGAAwG;AACxG,yGAAyG;AACzG,mDAAmD;AAEnD;;;;GAIG;AAEH,OAAO,EAAE,mBAAmB,EAAE,kBAAkB,EAAmC,MAAM,YAAY,CAAC;AAQtG,iGAAiG;AACjG,MAAM,CAAC,MAAM,uBAAuB,GAAG,EAAE,CAAC;AAE1C;;;;;;GAMG;AACH,MAAM,UAAU,oBAAoB,CAAC,OAAwC;IAC3E,MAAM,GAAG,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,KAAK,GAAG,CAAC,CAAC,CAAC;IAC/C,IAAI,GAAG,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;IAC1C,IAAI,GAAG,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACrB,MAAM,CAAC,GAAG,GAAG,CAAC,CAAC,CAAE,CAAC;QAClB,OAAO,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC;IA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,CAAC","sourcesContent":["// Portions derived from mjurczyk/openvdb (MIT), commit 75e7345 (v0.26.0):\n// src/three-openvdb/frame/webgpu/FrameInjectMaterial.js L59–101 (the premultiplied \"over\" blend of\n// overlapping volumes), src/three-openvdb/frame/webgpu/FrameTemporalMaterial.js L120–200 (the\n// neighbourhood clamp and blend), src/three-openvdb/frame/webgpu/FrameIntegrateMaterial.js L219–294\n// (the slice march with the T < 0.001 stop and the `sliceAlpha` coverage of the last slice).\n// Copyright (c) mjurczyk/openvdb contributors. Licensed under the MIT License (see THIRD_PARTY_NOTICES.md).\n// Changes: the core renderer's froxel stages (K6.1, design §3.4): an order-independent 'mixture' of the\n// volumes in a froxel beside his 'over'; his integrate split into a per-column prefix scan and a two-tap\n// composite. Divergences: DIVERGES.md (K6.1 rows).\n\n/**\n * CPU twins (f64) of the core frame renderer's froxel stages (K6.1): `vdbFrameGatherCs`'s combine of\n * the volumes in one froxel, `vdbFrameResolveCs`'s temporal blend and column scan, and\n * `vdbFrameIntegrate`'s two-tap composite. Engine-free; the oracles of `e2e/k6-core.spec.ts`.\n */\n\nimport { vdbFrameFroxelSlice, vdbFrameSliceDepth, type Vec2, type Vec3, type Vec4 } from \"./index.js\";\n\n/** One volume's lit froxel: unpremultiplied slice radiance and slice alpha (`vdbFrameInjectSlice` + lights). */\nexport interface VDBFrameVolumeFroxel {\n radiance: Vec3;\n alpha: number;\n}\n\n/** Optical depths above this are clamped (T = 1.3e-14), so an opaque volume gives a finite τ. */\nexport const vdbFrameMaxOpticalDepth = 32;\n\n/**\n * The gather kernel's combine of the volumes in one froxel, premultiplied (rgb = L·α, a = α).\n *\n * Design §3.4: co-located media; τᵢ = −log(1 − αᵢ), α = 1 − exp(−Στᵢ),\n * L = Σ τᵢLᵢ / Στᵢ. Order-independent; one volume gives exactly (Lα, α).\n * Volumes with α ≤ 0 do not count (discarded froxels).\n */\nexport function vdbFrameGatherFroxel(volumes: readonly VDBFrameVolumeFroxel[]): Vec4 {\n const lit = volumes.filter((v) => v.alpha > 0);\n if (lit.length === 0) return [0, 0, 0, 0];\n if (lit.length === 1) {\n const v = lit[0]!;\n return [v.radiance[0] * v.alpha, v.radiance[1] * v.alpha, v.radiance[2] * v.alpha, v.alpha];\n }\n let tau = 0;\n const tl: Vec3 = [0, 0, 0];\n for (const v of lit) {\n const t = Math.min(-Math.log(Math.max(1 - v.alpha, 0)), vdbFrameMaxOpticalDepth);\n tau += t;\n for (let c = 0; c < 3; c++) tl[c] = tl[c]! + t * v.radiance[c]!;\n }\n const alpha = 1 - Math.exp(-tau);\n return [(tl[0] / tau) * alpha, (tl[1] / tau) * alpha, (tl[2] / tau) * alpha, alpha];\n}\n\n/**\n * His temporal blend of one froxel (`FrameTemporalMaterial`): the reprojected history clamped to the\n * per-channel min and max of the current froxel and its neighbours, then `mix(history, current, blend)`\n * (`blend` from `vdbFrameReproject`).\n */\nexport function vdbFrameTemporalFroxel(current: Vec4, history: Vec4, neighbours: readonly Vec4[], blend: number): Vec4 {\n const lo = [...current] as Vec4;\n const hi = [...current] as Vec4;\n for (const n of neighbours) {\n for (let c = 0; c < 4; c++) {\n lo[c] = Math.min(lo[c]!, n[c]!);\n hi[c] = Math.max(hi[c]!, n[c]!);\n }\n }\n return [0, 1, 2, 3].map((c) => {\n const h = Math.min(Math.max(history[c]!, lo[c]!), hi[c]!);\n return h + (current[c]! - h) * blend;\n }) as Vec4;\n}\n\n/** Transmittance below which the scan stops adding slices (his integrate's break). */\nexport const vdbFrameScanStop = 0.001;\n\n/**\n * The resolve kernel's column scan (his integrate loop over whole slices): boundary k holds the\n * radiance of slices 0..k−1 and their opacity A = 1 − T. `froxels[z]` is the premultiplied\n * (rgb, α) of slice z (α clamped to [0, 1]); a slice whose start has T < 0.001 adds nothing (his break).\n * Returns `froxels.length + 1` boundaries; boundary 0 is (0, 0, 0, 0).\n */\nexport function vdbFrameScanColumn(froxels: readonly Vec4[], o: { stop?: number } = {}): Vec4[] {\n const stop = o.stop ?? vdbFrameScanStop;\n const out: Vec4[] = [[0, 0, 0, 0]];\n const L: Vec3 = [0, 0, 0];\n let T = 1;\n for (const f of froxels) {\n const a = Math.min(Math.max(f[3], 0), 1);\n if (T >= stop && a > 0) {\n for (let c = 0; c < 3; c++) L[c] = L[c]! + T * f[c]!;\n T *= 1 - a;\n }\n out.push([L[0], L[1], L[2], 1 - T]);\n }\n return out;\n}\n\n/** What the composite reads at a pixel: radiance and transmittance (grey: one T). */\nexport interface VDBFrameIntegrated {\n radiance: Vec3;\n transmittance: number;\n}\n\n/**\n * The composite's two taps (design §3.4): the scene depth falls `c` ∈ [0, 1] into the slice between\n * boundaries `a` and `b` (each (L rgb, A = 1 − T)). With α = 1 − T_b / T_a:\n * radiance = L_a + (L_b − L_a)·(1 − (1 − α)^c)/α (→ c as α → 0), T = T_a·(1 − α)^c: his `sliceAlpha`.\n */\nexport function vdbFrameIntegratePrefix(a: Vec4, b: Vec4, c: number): VDBFrameIntegrated {\n const ta = 1 - a[3];\n const tb = 1 - b[3];\n const alpha = Math.min(Math.max(ta > 1e-6 ? 1 - tb / ta : 0, 0), 1);\n const keep = Math.pow(1 - alpha, c);\n const w = alpha > 1e-4 ? (1 - keep) / alpha : c;\n return {\n radiance: [a[0] + (b[0] - a[0]) * w, a[1] + (b[1] - a[1]) * w, a[2] + (b[2] - a[2]) * w],\n transmittance: Math.max(ta, 0) * keep,\n };\n}\n\n/**\n * The composite's slice of a scene view depth: the slice `k` it falls in on his log slices (`range` the\n * froxel near and far; ≤ depth − 1) and his coverage `c` of that slice, linear in view depth:\n * (depth − sliceStart) / (sliceEnd − sliceStart), clamped to [0, 1].\n */\nexport function vdbFrameSliceCoord(viewDepth: number, range: Vec2, depth: number): { k: number; c: number } {\n const s = Math.min(Math.max(vdbFrameFroxelSlice(viewDepth, range, depth), 0), depth);\n const k = Math.min(Math.floor(s), depth - 1);\n const start = vdbFrameSliceDepth(range, k / depth);\n const end = vdbFrameSliceDepth(range, (k + 1) / depth);\n return { k, c: Math.min(Math.max((viewDepth - start) / (end - start), 0), 1) };\n}\n"]}
@@ -37,6 +37,44 @@ export declare function vdbSameValues(a: ArrayLike<unknown>, b: ArrayLike<unknow
37
37
  * Writes `gridMin`, `gridSize`, `gridVoxel` (one entry per cascade); returns the count (0: no casters).
38
38
  */
39
39
  export declare function vdbFrameGridCascades(casterBoxes: readonly VDBBox3Like[], cameraPosition: VDBVec3Like, shadowDistance: number, resolution: number, cascades: number, gridMin: VDBVec3Like[], gridSize: VDBVec3Like[], gridVoxel: VDBVec3Like[]): number;
40
+ /**
41
+ * K6.Q1b: how the size-adaptive shadow grid picks its cell size per caster (`shadowResolutionMax`). `'optical'`: a cell
42
+ * spans at most {@link VDB_FRAME_ADAPTIVE_OPTICAL_DEPTH} of optical depth at the caster's mean density (the shadow
43
+ * grid interpolates transmittance between cell centres; a thicker cell loses the light's falloff into a dense medium).
44
+ * `'voxels'`: a cell spans at most {@link VDB_FRAME_ADAPTIVE_VOXELS} of the caster's own voxels (a large sparse cloud).
45
+ * `'both'` (the renderer's default): the finer of the two. The K6.R A/B (K6-Q1b handoff): 'optical' alone at half an
46
+ * optical depth asked for 112 to 256 voxels a side (the absorbing bunny 256) and moved the 'neural' MS term; 'voxels'
47
+ * alone missed the dense bunny; 'both' at 2 optical depths gives the large and the dense cloud 80.
48
+ */
49
+ export type VDBFrameAdaptiveGridRule = "both" | "optical" | "voxels";
50
+ /** K6.Q1b `'optical'`: the optical depth one shadow grid cell may span at the caster's mean density. */
51
+ export declare const VDB_FRAME_ADAPTIVE_OPTICAL_DEPTH = 2;
52
+ /** K6.Q1b `'voxels'`: the source voxels one shadow grid cell may span. */
53
+ export declare const VDB_FRAME_ADAPTIVE_VOXELS = 16;
54
+ /** K6.Q1b: adaptive resolutions are multiples of this (fewer distinct sizes: fewer grid reallocations). */
55
+ export declare const VDB_FRAME_ADAPTIVE_STEP = 16;
56
+ /** One caster for {@link vdbFrameAdaptiveCellSize}: its world box size, voxels across it, and mean extinction. */
57
+ export interface VDBFrameAdaptiveCaster {
58
+ /** World size of the caster's box on each axis. */
59
+ size: Vec3;
60
+ /** The source's voxels across the box on each axis (level 0). */
61
+ texels: Vec3;
62
+ /** Extinction coefficient (world units⁻¹) of the shadow grid at the caster's mean non-zero density. */
63
+ meanExtinction: number;
64
+ }
65
+ /**
66
+ * K6.Q1b: the largest grid cell (world units) the casters ask for under `rule`: the smallest over the casters
67
+ * (Infinity: none asks, e.g. no extinction).
68
+ */
69
+ export declare function vdbFrameAdaptiveCellSize(casters: readonly VDBFrameAdaptiveCaster[], rule: VDBFrameAdaptiveGridRule): number;
70
+ /**
71
+ * K6.Q1b: the size-adaptive shadow grid resolution. {@link vdbFrameGridCascades} snaps the casters' cascade (the
72
+ * last one) to power-of-two voxels: voxel = 2^⌈log2(extent / (R − 1))⌉, so R alone covers the largest box side with
73
+ * between R / 2 and R cells. This picks the power-of-two voxel at or below `cell` and the smallest R whose cascade
74
+ * uses it (R − 1 ≥ extent / voxel), rounded up to a multiple of {@link VDB_FRAME_ADAPTIVE_STEP}, within [`base`,
75
+ * `max`]. `max` ≤ `base` (the default 0) or no finite `cell` gives `base`: the fixed `shadowResolution`.
76
+ */
77
+ export declare function vdbFrameAdaptiveGridResolution(casterBoxes: readonly VDBBox3Like[], cell: number, base: number, max: number): number;
40
78
  /**
41
79
  * His `getGridRange`: the voxel rectangle (x0, y0, x1, y1) and the atlas slices (first, count) of a
42
80
  * world box in one cascade. Writes `target`; returns false when the box is out of the cascade.
@@ -193,11 +231,26 @@ export interface VDBFrameDensityInputs {
193
231
  scatterColor: Vec3;
194
232
  /** The source's `sampleExtinction(local, lod)` (extinction per world unit). */
195
233
  extinctionAt: (local: Vec3, lod: number) => number;
234
+ /**
235
+ * Issue #2 step 2, the stochastic density filter: sub-step i of the slice reads `at(local, lod, xi)` with
236
+ * `xi = vdbFrameRand3(fragCoord, (volume << 16) | i, seed)` (the WGSL `vdbFrameExtinctionStochastic`) instead of
237
+ * `extinctionAt`. `volume` is the record index, `seed` the frame id. Default: none (trilinear).
238
+ */
239
+ stochastic?: {
240
+ volume: number;
241
+ seed: number;
242
+ at: (local: Vec3, lod: number, xi: Vec3) => number;
243
+ } | null;
196
244
  /** The 4 transmittance atlases and their layout, or null without shadows. */
197
245
  shadows: {
198
246
  atlases: readonly VDBFrameAtlas[];
199
247
  grid: VDBFrameGridLayout;
200
248
  } | null;
249
+ /** K6.2: the 4 transmittance targets at a world position (a stacked 3D texture, `vdbFrameStackShadows`); replaces `shadows`' atlases. */
250
+ shadowsAt?: ((world: Vec3) => number[][]) | null;
251
+ /** K6.2: the source's albedo (base colour × channel) and emission at the visible local position (default: base colour, none). */
252
+ albedoAt?: ((local: Vec3, lod: number) => Vec3) | null;
253
+ emissionAt?: ((local: Vec3, lod: number) => Vec3) | null;
201
254
  /** Scene lights with a shadow slot, their positions (slot order) and the renderer phase. */
202
255
  sceneLightCount: number;
203
256
  lightPositions: readonly Vec4[];
@@ -211,6 +264,30 @@ export interface VDBFrameDensityInputs {
211
264
  columns: number;
212
265
  unshadowed: Vec3;
213
266
  } | null;
267
+ /**
268
+ * K6.2b (the core's environment term): the irradiance added as albedo · E / π at the visible world and local
269
+ * position, given the sky up and down totals there (`vdbFrameEnvironmentDensityTerm`).
270
+ */
271
+ environmentAt?: ((world: Vec3, local: Vec3 | null, skyTotals: Vec2) => Vec3) | null;
272
+ /**
273
+ * K6.5b (the core's mesh → volume shadows): the host occluder visibility of slot light `index` at a world position
274
+ * (`vdbFrameOccluderVisibility`); multiplies the slot's direct light (the scattered part is occluded in the
275
+ * transmittance target already). Default: none.
276
+ */
277
+ occluderAt?: ((index: number, world: Vec3) => number) | null;
278
+ /** K6.Q1 shadowed ambient: the sky up / down totals are the fourth target's hemispherical visibilities (z, w). */
279
+ ambientOcclusion?: boolean;
280
+ /**
281
+ * K6.Q1d ('frame' lighting's `ambientPhase: 'dipole'`, no diffusion totals): the phase weight of the visibilities at the visible
282
+ * world position along the froxel's unit view ray, given them (up, down): both × its green channel. The core reads
283
+ * the dipole target there (`vdbFrameStackTarget`) and `vdbFrameAmbientPhaseWeight`. Default none (1).
284
+ */
285
+ ambientWeight?: ((world: Vec3, ray: Vec3, up: number, down: number) => Vec3) | null;
286
+ /**
287
+ * K7.4c (internal `msExit`): the exit code of the scene slots' scattered part (0 isotropic, his; 1 dipole, 2 hg;
288
+ * `vdbFrameMsExitFactorGrey` with the albedo at the visible position). Default 0.
289
+ */
290
+ msExit?: number;
214
291
  }
215
292
  /**
216
293
  * The density pass of 'frame' lighting at one froxel of one volume (FrameDensityMaterial `buildNodes`,
@@ -219,6 +296,8 @@ export interface VDBFrameDensityInputs {
219
296
  * blending), or null when the froxel is discarded. `fragCoord` is the atlas pixel (bottom-left).
220
297
  */
221
298
  export declare function vdbFrameDensityFroxel(fragCoord: Vec2, p: VDBFrameDensityInputs): [Vec4, Vec4, Vec4, Vec4] | null;
299
+ /** Sub-step `i`'s extinction in the slice march: `extinctionAt`, or the stochastic filter's one-voxel read (issue #2). */
300
+ export declare function vdbFrameSliceExtinction(p: Pick<VDBFrameDensityInputs, "extinctionAt" | "stochastic">, fragCoord: Vec2, i: number, local: Vec3, lod: number): number;
222
301
  /** The froxel geometry of the density pass (and the inject pre-integration): box segment, sub-steps, lods. null: discarded. */
223
302
  export declare function vdbFrameDensityFroxelSteps(fragCoord: Vec2, p: Pick<VDBFrameDensityInputs, "froxelGrid" | "columns" | "range" | "projectionInverse" | "viewToLocal" | "maxTexels" | "mipLevels" | "worldScale" | "subSteps" | "jitter">): {
224
303
  froxel: {
@@ -291,6 +370,17 @@ export interface VDBFrameLightingInputs {
291
370
  /** Environment lights with a shadow slot (colours), from `environmentShadowSlot`. */
292
371
  environmentColors: Vec3[];
293
372
  environmentShadowSlot: number;
373
+ /** K6.2: the light probe SH9 (rgb each; three's convention) and the sky direction (default +y) it is read along. */
374
+ probe?: readonly Vec3[];
375
+ sky?: Vec3;
376
+ /**
377
+ * K6.5b: the host occluder visibility of light `index` at the lit world position: lights without a shadow slot are
378
+ * multiplied by it, and with per-channel phases the slot's red / blue direct difference is (the slot values hold it
379
+ * already, `VDBFrameDensityInputs.occluderAt`). Default: none.
380
+ */
381
+ occluderAt?: ((index: number, world: Vec3) => number) | null;
382
+ /** K6.Q1 shadowed ambient: ambient × the mean of the sky up / down values (the hemispherical visibilities). */
383
+ ambientOcclusion?: boolean;
294
384
  }
295
385
  /**
296
386
  * The lighting pass of 'frame' lighting at one froxel (FrameLightingMaterial `createFragmentNode`,