@pmndrs/vdb 0.0.0-stage → 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 (570) hide show
  1. package/CHANGELOG.md +727 -0
  2. package/LICENSE +21 -0
  3. package/README.md +496 -2
  4. package/THIRD_PARTY_NOTICES.md +315 -0
  5. package/dist/core/compute/atlas.d.ts +102 -0
  6. package/dist/core/compute/atlas.js +103 -0
  7. package/dist/core/compute/atlas.js.map +1 -0
  8. package/dist/core/compute/index.d.ts +13 -0
  9. package/dist/core/compute/index.js +9 -0
  10. package/dist/core/compute/index.js.map +1 -0
  11. package/dist/core/compute/majorant-build.d.ts +45 -0
  12. package/dist/core/compute/majorant-build.js +193 -0
  13. package/dist/core/compute/majorant-build.js.map +1 -0
  14. package/dist/core/compute/multi-scale.d.ts +155 -0
  15. package/dist/core/compute/multi-scale.js +684 -0
  16. package/dist/core/compute/multi-scale.js.map +1 -0
  17. package/dist/core/compute/pyramid.d.ts +120 -0
  18. package/dist/core/compute/pyramid.js +468 -0
  19. package/dist/core/compute/pyramid.js.map +1 -0
  20. package/dist/core/compute/shared.d.ts +116 -0
  21. package/dist/core/compute/shared.js +211 -0
  22. package/dist/core/compute/shared.js.map +1 -0
  23. package/dist/core/compute/stats.d.ts +78 -0
  24. package/dist/core/compute/stats.js +193 -0
  25. package/dist/core/compute/stats.js.map +1 -0
  26. package/dist/core/compute/value-transform.d.ts +30 -0
  27. package/dist/core/compute/value-transform.js +64 -0
  28. package/dist/core/compute/value-transform.js.map +1 -0
  29. package/dist/core/errors.d.ts +21 -0
  30. package/dist/core/errors.js +17 -0
  31. package/dist/core/errors.js.map +1 -0
  32. package/dist/core/frame/emission.d.ts +85 -0
  33. package/dist/core/frame/emission.js +422 -0
  34. package/dist/core/frame/emission.js.map +1 -0
  35. package/dist/core/frame/environment.d.ts +47 -0
  36. package/dist/core/frame/environment.js +178 -0
  37. package/dist/core/frame/environment.js.map +1 -0
  38. package/dist/core/frame/index.d.ts +39 -0
  39. package/dist/core/frame/index.js +27 -0
  40. package/dist/core/frame/index.js.map +1 -0
  41. package/dist/core/frame/kernels.d.ts +115 -0
  42. package/dist/core/frame/kernels.js +496 -0
  43. package/dist/core/frame/kernels.js.map +1 -0
  44. package/dist/core/frame/limits.d.ts +67 -0
  45. package/dist/core/frame/limits.js +109 -0
  46. package/dist/core/frame/limits.js.map +1 -0
  47. package/dist/core/frame/phase.d.ts +17 -0
  48. package/dist/core/frame/phase.js +53 -0
  49. package/dist/core/frame/phase.js.map +1 -0
  50. package/dist/core/frame/pipelines.d.ts +49 -0
  51. package/dist/core/frame/pipelines.js +147 -0
  52. package/dist/core/frame/pipelines.js.map +1 -0
  53. package/dist/core/frame/renderer.d.ts +122 -0
  54. package/dist/core/frame/renderer.js +1712 -0
  55. package/dist/core/frame/renderer.js.map +1 -0
  56. package/dist/core/frame/resources.d.ts +71 -0
  57. package/dist/core/frame/resources.js +100 -0
  58. package/dist/core/frame/resources.js.map +1 -0
  59. package/dist/core/frame/scattering.d.ts +97 -0
  60. package/dist/core/frame/scattering.js +332 -0
  61. package/dist/core/frame/scattering.js.map +1 -0
  62. package/dist/core/frame/settings.d.ts +243 -0
  63. package/dist/core/frame/settings.js +67 -0
  64. package/dist/core/frame/settings.js.map +1 -0
  65. package/dist/core/frame/shadows.d.ts +55 -0
  66. package/dist/core/frame/shadows.js +460 -0
  67. package/dist/core/frame/shadows.js.map +1 -0
  68. package/dist/core/frame/types.d.ts +415 -0
  69. package/dist/core/frame/types.js +49 -0
  70. package/dist/core/frame/types.js.map +1 -0
  71. package/dist/core/frame/uniforms.d.ts +105 -0
  72. package/dist/core/frame/uniforms.js +276 -0
  73. package/dist/core/frame/uniforms.js.map +1 -0
  74. package/dist/core/frame/wgsl/chunks.d.ts +4 -0
  75. package/dist/core/frame/wgsl/chunks.js +728 -0
  76. package/dist/core/frame/wgsl/chunks.js.map +1 -0
  77. package/dist/core/frame/wgsl/emission.d.ts +82 -0
  78. package/dist/core/frame/wgsl/emission.js +353 -0
  79. package/dist/core/frame/wgsl/emission.js.map +1 -0
  80. package/dist/core/frame/wgsl/environment.d.ts +42 -0
  81. package/dist/core/frame/wgsl/environment.js +711 -0
  82. package/dist/core/frame/wgsl/environment.js.map +1 -0
  83. package/dist/core/frame/wgsl/gather.d.ts +55 -0
  84. package/dist/core/frame/wgsl/gather.js +850 -0
  85. package/dist/core/frame/wgsl/gather.js.map +1 -0
  86. package/dist/core/frame/wgsl/integrate.d.ts +78 -0
  87. package/dist/core/frame/wgsl/integrate.js +213 -0
  88. package/dist/core/frame/wgsl/integrate.js.map +1 -0
  89. package/dist/core/frame/wgsl/lighting.d.ts +103 -0
  90. package/dist/core/frame/wgsl/lighting.js +1636 -0
  91. package/dist/core/frame/wgsl/lighting.js.map +1 -0
  92. package/dist/core/frame/wgsl/occluders.d.ts +20 -0
  93. package/dist/core/frame/wgsl/occluders.js +95 -0
  94. package/dist/core/frame/wgsl/occluders.js.map +1 -0
  95. package/dist/core/frame/wgsl/resolve.d.ts +19 -0
  96. package/dist/core/frame/wgsl/resolve.js +205 -0
  97. package/dist/core/frame/wgsl/resolve.js.map +1 -0
  98. package/dist/core/frame/wgsl/shadows.d.ts +35 -0
  99. package/dist/core/frame/wgsl/shadows.js +328 -0
  100. package/dist/core/frame/wgsl/shadows.js.map +1 -0
  101. package/dist/core/half.d.ts +11 -0
  102. package/dist/core/half.js +22 -0
  103. package/dist/core/half.js.map +1 -0
  104. package/dist/core/index.d.ts +52 -0
  105. package/dist/core/index.js +46 -0
  106. package/dist/core/index.js.map +1 -0
  107. package/dist/core/internal.d.ts +31 -0
  108. package/dist/core/internal.js +32 -0
  109. package/dist/core/internal.js.map +1 -0
  110. package/dist/core/pool/affine.d.ts +34 -0
  111. package/dist/core/pool/affine.js +100 -0
  112. package/dist/core/pool/affine.js.map +1 -0
  113. package/dist/core/pool/allocator.d.ts +32 -0
  114. package/dist/core/pool/allocator.js +81 -0
  115. package/dist/core/pool/allocator.js.map +1 -0
  116. package/dist/core/pool/image-header.d.ts +93 -0
  117. package/dist/core/pool/image-header.js +194 -0
  118. package/dist/core/pool/image-header.js.map +1 -0
  119. package/dist/core/pool/layout.d.ts +198 -0
  120. package/dist/core/pool/layout.js +316 -0
  121. package/dist/core/pool/layout.js.map +1 -0
  122. package/dist/core/pool/limits.d.ts +41 -0
  123. package/dist/core/pool/limits.js +80 -0
  124. package/dist/core/pool/limits.js.map +1 -0
  125. package/dist/core/pool/pool.d.ts +384 -0
  126. package/dist/core/pool/pool.js +1184 -0
  127. package/dist/core/pool/pool.js.map +1 -0
  128. package/dist/core/reference/index.d.ts +6 -0
  129. package/dist/core/reference/index.js +7 -0
  130. package/dist/core/reference/index.js.map +1 -0
  131. package/dist/core/reference/renderer.d.ts +105 -0
  132. package/dist/core/reference/renderer.js +474 -0
  133. package/dist/core/reference/renderer.js.map +1 -0
  134. package/dist/core/reference/wgsl.d.ts +65 -0
  135. package/dist/core/reference/wgsl.js +803 -0
  136. package/dist/core/reference/wgsl.js.map +1 -0
  137. package/dist/core/sequence.d.ts +347 -0
  138. package/dist/core/sequence.js +548 -0
  139. package/dist/core/sequence.js.map +1 -0
  140. package/dist/core/source/brick-cache.d.ts +165 -0
  141. package/dist/core/source/brick-cache.js +627 -0
  142. package/dist/core/source/brick-cache.js.map +1 -0
  143. package/dist/core/source/dense-fill.d.ts +53 -0
  144. package/dist/core/source/dense-fill.js +377 -0
  145. package/dist/core/source/dense-fill.js.map +1 -0
  146. package/dist/core/source/dense.d.ts +50 -0
  147. package/dist/core/source/dense.js +384 -0
  148. package/dist/core/source/dense.js.map +1 -0
  149. package/dist/core/source/sparse-wgsl.d.ts +92 -0
  150. package/dist/core/source/sparse-wgsl.js +481 -0
  151. package/dist/core/source/sparse-wgsl.js.map +1 -0
  152. package/dist/core/source/sparse.d.ts +192 -0
  153. package/dist/core/source/sparse.js +762 -0
  154. package/dist/core/source/sparse.js.map +1 -0
  155. package/dist/core/source/types.d.ts +120 -0
  156. package/dist/core/source/types.js +9 -0
  157. package/dist/core/source/types.js.map +1 -0
  158. package/dist/core/surface/index.d.ts +10 -0
  159. package/dist/core/surface/index.js +9 -0
  160. package/dist/core/surface/index.js.map +1 -0
  161. package/dist/core/surface/level-set-pass.d.ts +140 -0
  162. package/dist/core/surface/level-set-pass.js +291 -0
  163. package/dist/core/surface/level-set-pass.js.map +1 -0
  164. package/dist/core/surface/level-set-wgsl.d.ts +46 -0
  165. package/dist/core/surface/level-set-wgsl.js +99 -0
  166. package/dist/core/surface/level-set-wgsl.js.map +1 -0
  167. package/dist/core/surface/points.d.ts +109 -0
  168. package/dist/core/surface/points.js +226 -0
  169. package/dist/core/surface/points.js.map +1 -0
  170. package/dist/core/types.d.ts +37 -0
  171. package/dist/core/types.js +32 -0
  172. package/dist/core/types.js.map +1 -0
  173. package/dist/core/wgsl/api.d.ts +65 -0
  174. package/dist/core/wgsl/api.js +546 -0
  175. package/dist/core/wgsl/api.js.map +1 -0
  176. package/dist/core/wgsl/generate.d.ts +90 -0
  177. package/dist/core/wgsl/generate.js +678 -0
  178. package/dist/core/wgsl/generate.js.map +1 -0
  179. package/dist/core/wgsl/lean.d.ts +50 -0
  180. package/dist/core/wgsl/lean.js +327 -0
  181. package/dist/core/wgsl/lean.js.map +1 -0
  182. package/dist/core/wgsl/level-set.d.ts +58 -0
  183. package/dist/core/wgsl/level-set.js +200 -0
  184. package/dist/core/wgsl/level-set.js.map +1 -0
  185. package/dist/core/wgsl/majorant.d.ts +62 -0
  186. package/dist/core/wgsl/majorant.js +381 -0
  187. package/dist/core/wgsl/majorant.js.map +1 -0
  188. package/dist/core/wgsl/pnanovdb.chunks.generated.d.ts +14 -0
  189. package/dist/core/wgsl/pnanovdb.chunks.generated.js +333 -0
  190. package/dist/core/wgsl/pnanovdb.chunks.generated.js.map +1 -0
  191. package/dist/core/wgsl/reserved.d.ts +9 -0
  192. package/dist/core/wgsl/reserved.js +26 -0
  193. package/dist/core/wgsl/reserved.js.map +1 -0
  194. package/dist/core/wgsl/types.d.ts +198 -0
  195. package/dist/core/wgsl/types.js +2 -0
  196. package/dist/core/wgsl/types.js.map +1 -0
  197. package/dist/three/coarse-first.d.ts +207 -0
  198. package/dist/three/coarse-first.js +205 -0
  199. package/dist/three/coarse-first.js.map +1 -0
  200. package/dist/three/compute.d.ts +73 -0
  201. package/dist/three/compute.js +66 -0
  202. package/dist/three/compute.js.map +1 -0
  203. package/dist/three/device.d.ts +66 -0
  204. package/dist/three/device.js +62 -0
  205. package/dist/three/device.js.map +1 -0
  206. package/dist/three/frame/core-environment.d.ts +38 -0
  207. package/dist/three/frame/core-environment.js +154 -0
  208. package/dist/three/frame/core-environment.js.map +1 -0
  209. package/dist/three/frame/core-integrate-material.d.ts +34 -0
  210. package/dist/three/frame/core-integrate-material.js +162 -0
  211. package/dist/three/frame/core-integrate-material.js.map +1 -0
  212. package/dist/three/frame/core-occluders.d.ts +53 -0
  213. package/dist/three/frame/core-occluders.js +193 -0
  214. package/dist/three/frame/core-occluders.js.map +1 -0
  215. package/dist/three/frame/core-structs.d.ts +34 -0
  216. package/dist/three/frame/core-structs.js +61 -0
  217. package/dist/three/frame/core-structs.js.map +1 -0
  218. package/dist/three/frame/core-textures.d.ts +41 -0
  219. package/dist/three/frame/core-textures.js +114 -0
  220. package/dist/three/frame/core-textures.js.map +1 -0
  221. package/dist/three/frame/emission-light.d.ts +117 -0
  222. package/dist/three/frame/emission-light.js +276 -0
  223. package/dist/three/frame/emission-light.js.map +1 -0
  224. package/dist/three/frame/index.d.ts +19 -0
  225. package/dist/three/frame/index.js +15 -0
  226. package/dist/three/frame/index.js.map +1 -0
  227. package/dist/three/frame/medium.d.ts +33 -0
  228. package/dist/three/frame/medium.js +29 -0
  229. package/dist/three/frame/medium.js.map +1 -0
  230. package/dist/three/frame/renderer.d.ts +97 -0
  231. package/dist/three/frame/renderer.js +480 -0
  232. package/dist/three/frame/renderer.js.map +1 -0
  233. package/dist/three/frame/spectrum.d.ts +4 -0
  234. package/dist/three/frame/spectrum.js +15 -0
  235. package/dist/three/frame/spectrum.js.map +1 -0
  236. package/dist/three/frame/three-internals.d.ts +60 -0
  237. package/dist/three/frame/three-internals.js +152 -0
  238. package/dist/three/frame/three-internals.js.map +1 -0
  239. package/dist/three/frame/volume-shadows.d.ts +139 -0
  240. package/dist/three/frame/volume-shadows.js +403 -0
  241. package/dist/three/frame/volume-shadows.js.map +1 -0
  242. package/dist/three/frame/volume.d.ts +230 -0
  243. package/dist/three/frame/volume.js +268 -0
  244. package/dist/three/frame/volume.js.map +1 -0
  245. package/dist/three/grid-node.d.ts +229 -0
  246. package/dist/three/grid-node.js +545 -0
  247. package/dist/three/grid-node.js.map +1 -0
  248. package/dist/three/index.d.ts +52 -0
  249. package/dist/three/index.js +58 -0
  250. package/dist/three/index.js.map +1 -0
  251. package/dist/three/internal.d.ts +20 -0
  252. package/dist/three/internal.js +18 -0
  253. package/dist/three/internal.js.map +1 -0
  254. package/dist/three/level-set-material.d.ts +185 -0
  255. package/dist/three/level-set-material.js +241 -0
  256. package/dist/three/level-set-material.js.map +1 -0
  257. package/dist/three/level-set-physical-material.d.ts +154 -0
  258. package/dist/three/level-set-physical-material.js +253 -0
  259. package/dist/three/level-set-physical-material.js.map +1 -0
  260. package/dist/three/level-set-velocity.d.ts +94 -0
  261. package/dist/three/level-set-velocity.js +208 -0
  262. package/dist/three/level-set-velocity.js.map +1 -0
  263. package/dist/three/material.d.ts +324 -0
  264. package/dist/three/material.js +502 -0
  265. package/dist/three/material.js.map +1 -0
  266. package/dist/three/points.d.ts +140 -0
  267. package/dist/three/points.js +261 -0
  268. package/dist/three/points.js.map +1 -0
  269. package/dist/three/sparse-source.d.ts +165 -0
  270. package/dist/three/sparse-source.js +405 -0
  271. package/dist/three/sparse-source.js.map +1 -0
  272. package/dist/three/volume-source.d.ts +22 -0
  273. package/dist/three/volume-source.js +110 -0
  274. package/dist/three/volume-source.js.map +1 -0
  275. package/dist/tools/cpu/brick-atlas.d.ts +36 -0
  276. package/dist/tools/cpu/brick-atlas.js +129 -0
  277. package/dist/tools/cpu/brick-atlas.js.map +1 -0
  278. package/dist/tools/cpu/compute.d.ts +116 -0
  279. package/dist/tools/cpu/compute.js +239 -0
  280. package/dist/tools/cpu/compute.js.map +1 -0
  281. package/dist/tools/cpu/lean-reads.d.ts +81 -0
  282. package/dist/tools/cpu/lean-reads.js +262 -0
  283. package/dist/tools/cpu/lean-reads.js.map +1 -0
  284. package/dist/tools/cpu/level-set.d.ts +111 -0
  285. package/dist/tools/cpu/level-set.js +313 -0
  286. package/dist/tools/cpu/level-set.js.map +1 -0
  287. package/dist/tools/cpu/majorant.d.ts +265 -0
  288. package/dist/tools/cpu/majorant.js +541 -0
  289. package/dist/tools/cpu/majorant.js.map +1 -0
  290. package/dist/tools/cpu/march.d.ts +297 -0
  291. package/dist/tools/cpu/march.js +726 -0
  292. package/dist/tools/cpu/march.js.map +1 -0
  293. package/dist/tools/cpu/mesh-decimate.d.ts +124 -0
  294. package/dist/tools/cpu/mesh-decimate.js +1225 -0
  295. package/dist/tools/cpu/mesh-decimate.js.map +1 -0
  296. package/dist/tools/cpu/points.d.ts +29 -0
  297. package/dist/tools/cpu/points.js +38 -0
  298. package/dist/tools/cpu/points.js.map +1 -0
  299. package/dist/tools/cpu/probe-coords.d.ts +70 -0
  300. package/dist/tools/cpu/probe-coords.js +116 -0
  301. package/dist/tools/cpu/probe-coords.js.map +1 -0
  302. package/dist/tools/cpu/read-value.d.ts +44 -0
  303. package/dist/tools/cpu/read-value.js +351 -0
  304. package/dist/tools/cpu/read-value.js.map +1 -0
  305. package/dist/tools/cpu/sample-trilinear.d.ts +43 -0
  306. package/dist/tools/cpu/sample-trilinear.js +168 -0
  307. package/dist/tools/cpu/sample-trilinear.js.map +1 -0
  308. package/dist/tools/cpu/stride-tables.d.ts +56 -0
  309. package/dist/tools/cpu/stride-tables.generated.d.ts +1059 -0
  310. package/dist/tools/cpu/stride-tables.generated.js +1267 -0
  311. package/dist/tools/cpu/stride-tables.generated.js.map +1 -0
  312. package/dist/tools/cpu/stride-tables.js +78 -0
  313. package/dist/tools/cpu/stride-tables.js.map +1 -0
  314. package/dist/tools/cpu/surface-nets.d.ts +90 -0
  315. package/dist/tools/cpu/surface-nets.js +597 -0
  316. package/dist/tools/cpu/surface-nets.js.map +1 -0
  317. package/dist/tools/errors.d.ts +66 -0
  318. package/dist/tools/errors.js +67 -0
  319. package/dist/tools/errors.js.map +1 -0
  320. package/dist/tools/frame/ambient.d.ts +98 -0
  321. package/dist/tools/frame/ambient.js +274 -0
  322. package/dist/tools/frame/ambient.js.map +1 -0
  323. package/dist/tools/frame/blackbody.d.ts +57 -0
  324. package/dist/tools/frame/blackbody.js +151 -0
  325. package/dist/tools/frame/blackbody.js.map +1 -0
  326. package/dist/tools/frame/brick-cache.d.ts +165 -0
  327. package/dist/tools/frame/brick-cache.js +326 -0
  328. package/dist/tools/frame/brick-cache.js.map +1 -0
  329. package/dist/tools/frame/emission.d.ts +137 -0
  330. package/dist/tools/frame/emission.js +290 -0
  331. package/dist/tools/frame/emission.js.map +1 -0
  332. package/dist/tools/frame/environment-gpu.d.ts +111 -0
  333. package/dist/tools/frame/environment-gpu.js +280 -0
  334. package/dist/tools/frame/environment-gpu.js.map +1 -0
  335. package/dist/tools/frame/environment.d.ts +106 -0
  336. package/dist/tools/frame/environment.js +272 -0
  337. package/dist/tools/frame/environment.js.map +1 -0
  338. package/dist/tools/frame/froxel.d.ts +58 -0
  339. package/dist/tools/frame/froxel.js +115 -0
  340. package/dist/tools/frame/froxel.js.map +1 -0
  341. package/dist/tools/frame/grid.d.ts +392 -0
  342. package/dist/tools/frame/grid.js +802 -0
  343. package/dist/tools/frame/grid.js.map +1 -0
  344. package/dist/tools/frame/index.d.ts +150 -0
  345. package/dist/tools/frame/index.js +389 -0
  346. package/dist/tools/frame/index.js.map +1 -0
  347. package/dist/tools/frame/medium.d.ts +77 -0
  348. package/dist/tools/frame/medium.js +101 -0
  349. package/dist/tools/frame/medium.js.map +1 -0
  350. package/dist/tools/frame/mie-table.d.ts +6 -0
  351. package/dist/tools/frame/mie-table.js +16 -0
  352. package/dist/tools/frame/mie-table.js.map +1 -0
  353. package/dist/tools/frame/mie.d.ts +63 -0
  354. package/dist/tools/frame/mie.js +194 -0
  355. package/dist/tools/frame/mie.js.map +1 -0
  356. package/dist/tools/frame/mlp-nn.d.ts +36 -0
  357. package/dist/tools/frame/mlp-nn.js +159 -0
  358. package/dist/tools/frame/mlp-nn.js.map +1 -0
  359. package/dist/tools/frame/mlp-tza.d.ts +29 -0
  360. package/dist/tools/frame/mlp-tza.js +186 -0
  361. package/dist/tools/frame/mlp-tza.js.map +1 -0
  362. package/dist/tools/frame/mlp.d.ts +183 -0
  363. package/dist/tools/frame/mlp.js +434 -0
  364. package/dist/tools/frame/mlp.js.map +1 -0
  365. package/dist/tools/frame/ms-exit.d.ts +42 -0
  366. package/dist/tools/frame/ms-exit.js +90 -0
  367. package/dist/tools/frame/ms-exit.js.map +1 -0
  368. package/dist/tools/frame/multi-scale.d.ts +152 -0
  369. package/dist/tools/frame/multi-scale.js +302 -0
  370. package/dist/tools/frame/multi-scale.js.map +1 -0
  371. package/dist/tools/frame/neural-weights.d.ts +10 -0
  372. package/dist/tools/frame/neural-weights.js +244 -0
  373. package/dist/tools/frame/neural-weights.js.map +1 -0
  374. package/dist/tools/frame/neural.d.ts +80 -0
  375. package/dist/tools/frame/neural.js +150 -0
  376. package/dist/tools/frame/neural.js.map +1 -0
  377. package/dist/tools/frame/occluders.d.ts +51 -0
  378. package/dist/tools/frame/occluders.js +72 -0
  379. package/dist/tools/frame/occluders.js.map +1 -0
  380. package/dist/tools/frame/pyramid-layout.d.ts +55 -0
  381. package/dist/tools/frame/pyramid-layout.js +100 -0
  382. package/dist/tools/frame/pyramid-layout.js.map +1 -0
  383. package/dist/tools/frame/shadows.d.ts +190 -0
  384. package/dist/tools/frame/shadows.js +468 -0
  385. package/dist/tools/frame/shadows.js.map +1 -0
  386. package/dist/tools/frame/sparse.d.ts +147 -0
  387. package/dist/tools/frame/sparse.js +432 -0
  388. package/dist/tools/frame/sparse.js.map +1 -0
  389. package/dist/tools/frame/spectral-stack.d.ts +159 -0
  390. package/dist/tools/frame/spectral-stack.js +391 -0
  391. package/dist/tools/frame/spectral-stack.js.map +1 -0
  392. package/dist/tools/frame/spectral.d.ts +222 -0
  393. package/dist/tools/frame/spectral.js +572 -0
  394. package/dist/tools/frame/spectral.js.map +1 -0
  395. package/dist/tools/frame/stack.d.ts +115 -0
  396. package/dist/tools/frame/stack.js +290 -0
  397. package/dist/tools/frame/stack.js.map +1 -0
  398. package/dist/tools/frame/view.d.ts +131 -0
  399. package/dist/tools/frame/view.js +337 -0
  400. package/dist/tools/frame/view.js.map +1 -0
  401. package/dist/tools/index.d.ts +157 -0
  402. package/dist/tools/index.js +132 -0
  403. package/dist/tools/index.js.map +1 -0
  404. package/dist/tools/internal.d.ts +87 -0
  405. package/dist/tools/internal.js +85 -0
  406. package/dist/tools/internal.js.map +1 -0
  407. package/dist/tools/nanovdb/build-from-vdb.d.ts +59 -0
  408. package/dist/tools/nanovdb/build-from-vdb.js +100 -0
  409. package/dist/tools/nanovdb/build-from-vdb.js.map +1 -0
  410. package/dist/tools/nanovdb/bytes.d.ts +233 -0
  411. package/dist/tools/nanovdb/bytes.js +388 -0
  412. package/dist/tools/nanovdb/bytes.js.map +1 -0
  413. package/dist/tools/nanovdb/coarse-first.d.ts +78 -0
  414. package/dist/tools/nanovdb/coarse-first.js +92 -0
  415. package/dist/tools/nanovdb/coarse-first.js.map +1 -0
  416. package/dist/tools/nanovdb/half.d.ts +22 -0
  417. package/dist/tools/nanovdb/half.js +73 -0
  418. package/dist/tools/nanovdb/half.js.map +1 -0
  419. package/dist/tools/nanovdb/index.d.ts +34 -0
  420. package/dist/tools/nanovdb/index.js +25 -0
  421. package/dist/tools/nanovdb/index.js.map +1 -0
  422. package/dist/tools/nanovdb/inspect.d.ts +33 -0
  423. package/dist/tools/nanovdb/inspect.js +70 -0
  424. package/dist/tools/nanovdb/inspect.js.map +1 -0
  425. package/dist/tools/nanovdb/leaf-codec.d.ts +119 -0
  426. package/dist/tools/nanovdb/leaf-codec.js +356 -0
  427. package/dist/tools/nanovdb/leaf-codec.js.map +1 -0
  428. package/dist/tools/nanovdb/quantize.d.ts +72 -0
  429. package/dist/tools/nanovdb/quantize.js +329 -0
  430. package/dist/tools/nanovdb/quantize.js.map +1 -0
  431. package/dist/tools/nanovdb/resample.d.ts +177 -0
  432. package/dist/tools/nanovdb/resample.js +692 -0
  433. package/dist/tools/nanovdb/resample.js.map +1 -0
  434. package/dist/tools/nanovdb/serialize.d.ts +176 -0
  435. package/dist/tools/nanovdb/serialize.js +439 -0
  436. package/dist/tools/nanovdb/serialize.js.map +1 -0
  437. package/dist/tools/nanovdb/stats.d.ts +87 -0
  438. package/dist/tools/nanovdb/stats.js +225 -0
  439. package/dist/tools/nanovdb/stats.js.map +1 -0
  440. package/dist/tools/nanovdb/transform.d.ts +30 -0
  441. package/dist/tools/nanovdb/transform.js +94 -0
  442. package/dist/tools/nanovdb/transform.js.map +1 -0
  443. package/dist/tools/nanovdb/tree.d.ts +186 -0
  444. package/dist/tools/nanovdb/tree.js +530 -0
  445. package/dist/tools/nanovdb/tree.js.map +1 -0
  446. package/dist/tools/nanovdb/write-nvdb.d.ts +74 -0
  447. package/dist/tools/nanovdb/write-nvdb.js +290 -0
  448. package/dist/tools/nanovdb/write-nvdb.js.map +1 -0
  449. package/dist/tools/nvdb-file.d.ts +265 -0
  450. package/dist/tools/nvdb-file.js +763 -0
  451. package/dist/tools/nvdb-file.js.map +1 -0
  452. package/dist/tools/nvdb-stream.d.ts +154 -0
  453. package/dist/tools/nvdb-stream.js +409 -0
  454. package/dist/tools/nvdb-stream.js.map +1 -0
  455. package/dist/tools/reference/analytic.d.ts +41 -0
  456. package/dist/tools/reference/analytic.js +95 -0
  457. package/dist/tools/reference/analytic.js.map +1 -0
  458. package/dist/tools/reference/environment.d.ts +62 -0
  459. package/dist/tools/reference/environment.js +154 -0
  460. package/dist/tools/reference/environment.js.map +1 -0
  461. package/dist/tools/reference/index.d.ts +12 -0
  462. package/dist/tools/reference/index.js +13 -0
  463. package/dist/tools/reference/index.js.map +1 -0
  464. package/dist/tools/reference/media.d.ts +14 -0
  465. package/dist/tools/reference/media.js +30 -0
  466. package/dist/tools/reference/media.js.map +1 -0
  467. package/dist/tools/reference/rng.d.ts +20 -0
  468. package/dist/tools/reference/rng.js +30 -0
  469. package/dist/tools/reference/rng.js.map +1 -0
  470. package/dist/tools/reference/scene.d.ts +312 -0
  471. package/dist/tools/reference/scene.js +169 -0
  472. package/dist/tools/reference/scene.js.map +1 -0
  473. package/dist/tools/reference/tables.d.ts +98 -0
  474. package/dist/tools/reference/tables.js +264 -0
  475. package/dist/tools/reference/tables.js.map +1 -0
  476. package/dist/tools/reference/trace.d.ts +160 -0
  477. package/dist/tools/reference/trace.js +497 -0
  478. package/dist/tools/reference/trace.js.map +1 -0
  479. package/dist/tools/vdb/bit-utils.d.ts +20 -0
  480. package/dist/tools/vdb/bit-utils.js +42 -0
  481. package/dist/tools/vdb/bit-utils.js.map +1 -0
  482. package/dist/tools/vdb/blosc-write.d.ts +43 -0
  483. package/dist/tools/vdb/blosc-write.js +197 -0
  484. package/dist/tools/vdb/blosc-write.js.map +1 -0
  485. package/dist/tools/vdb/blosc.d.ts +86 -0
  486. package/dist/tools/vdb/blosc.js +287 -0
  487. package/dist/tools/vdb/blosc.js.map +1 -0
  488. package/dist/tools/vdb/blosclz.d.ts +33 -0
  489. package/dist/tools/vdb/blosclz.js +112 -0
  490. package/dist/tools/vdb/blosclz.js.map +1 -0
  491. package/dist/tools/vdb/byte-reader.d.ts +50 -0
  492. package/dist/tools/vdb/byte-reader.js +161 -0
  493. package/dist/tools/vdb/byte-reader.js.map +1 -0
  494. package/dist/tools/vdb/compression.d.ts +81 -0
  495. package/dist/tools/vdb/compression.js +260 -0
  496. package/dist/tools/vdb/compression.js.map +1 -0
  497. package/dist/tools/vdb/errors.d.ts +10 -0
  498. package/dist/tools/vdb/errors.js +11 -0
  499. package/dist/tools/vdb/errors.js.map +1 -0
  500. package/dist/tools/vdb/grid.d.ts +37 -0
  501. package/dist/tools/vdb/grid.js +153 -0
  502. package/dist/tools/vdb/grid.js.map +1 -0
  503. package/dist/tools/vdb/half-float.d.ts +9 -0
  504. package/dist/tools/vdb/half-float.js +24 -0
  505. package/dist/tools/vdb/half-float.js.map +1 -0
  506. package/dist/tools/vdb/index.d.ts +4 -0
  507. package/dist/tools/vdb/index.js +3 -0
  508. package/dist/tools/vdb/index.js.map +1 -0
  509. package/dist/tools/vdb/inflate.d.ts +24 -0
  510. package/dist/tools/vdb/inflate.js +334 -0
  511. package/dist/tools/vdb/inflate.js.map +1 -0
  512. package/dist/tools/vdb/lz4.d.ts +30 -0
  513. package/dist/tools/vdb/lz4.js +228 -0
  514. package/dist/tools/vdb/lz4.js.map +1 -0
  515. package/dist/tools/vdb/metadata.d.ts +17 -0
  516. package/dist/tools/vdb/metadata.js +72 -0
  517. package/dist/tools/vdb/metadata.js.map +1 -0
  518. package/dist/tools/vdb/parse.d.ts +47 -0
  519. package/dist/tools/vdb/parse.js +241 -0
  520. package/dist/tools/vdb/parse.js.map +1 -0
  521. package/dist/tools/vdb/point-render-data.d.ts +79 -0
  522. package/dist/tools/vdb/point-render-data.js +137 -0
  523. package/dist/tools/vdb/point-render-data.js.map +1 -0
  524. package/dist/tools/vdb/points.d.ts +186 -0
  525. package/dist/tools/vdb/points.js +835 -0
  526. package/dist/tools/vdb/points.js.map +1 -0
  527. package/dist/tools/vdb/transform.d.ts +23 -0
  528. package/dist/tools/vdb/transform.js +54 -0
  529. package/dist/tools/vdb/transform.js.map +1 -0
  530. package/dist/tools/vdb/tree.d.ts +111 -0
  531. package/dist/tools/vdb/tree.js +228 -0
  532. package/dist/tools/vdb/tree.js.map +1 -0
  533. package/dist/tools/vdb/types.d.ts +195 -0
  534. package/dist/tools/vdb/types.js +3 -0
  535. package/dist/tools/vdb/types.js.map +1 -0
  536. package/dist/tools/wvdb/bake.d.ts +145 -0
  537. package/dist/tools/wvdb/bake.js +361 -0
  538. package/dist/tools/wvdb/bake.js.map +1 -0
  539. package/dist/tools/wvdb/dense.d.ts +191 -0
  540. package/dist/tools/wvdb/dense.js +368 -0
  541. package/dist/tools/wvdb/dense.js.map +1 -0
  542. package/dist/tools/wvdb/format.d.ts +220 -0
  543. package/dist/tools/wvdb/format.js +306 -0
  544. package/dist/tools/wvdb/format.js.map +1 -0
  545. package/dist/tools/wvdb/index.d.ts +14 -0
  546. package/dist/tools/wvdb/index.js +15 -0
  547. package/dist/tools/wvdb/index.js.map +1 -0
  548. package/dist/tools/wvdb/level-set.d.ts +56 -0
  549. package/dist/tools/wvdb/level-set.js +153 -0
  550. package/dist/tools/wvdb/level-set.js.map +1 -0
  551. package/dist/tools/wvdb/nanovdb.d.ts +59 -0
  552. package/dist/tools/wvdb/nanovdb.js +64 -0
  553. package/dist/tools/wvdb/nanovdb.js.map +1 -0
  554. package/dist/tools/wvdb/partial.d.ts +74 -0
  555. package/dist/tools/wvdb/partial.js +233 -0
  556. package/dist/tools/wvdb/partial.js.map +1 -0
  557. package/dist/tools/wvdb/read.d.ts +336 -0
  558. package/dist/tools/wvdb/read.js +766 -0
  559. package/dist/tools/wvdb/read.js.map +1 -0
  560. package/dist/tools/wvdb/sha256.d.ts +7 -0
  561. package/dist/tools/wvdb/sha256.js +76 -0
  562. package/dist/tools/wvdb/sha256.js.map +1 -0
  563. package/dist/tools/wvdb/write.d.ts +149 -0
  564. package/dist/tools/wvdb/write.js +403 -0
  565. package/dist/tools/wvdb/write.js.map +1 -0
  566. package/package.json +83 -4
  567. package/vendor/LICENSE +201 -0
  568. package/vendor/NOTICE +19 -0
  569. package/vendor/VENDOR.md +100 -0
  570. package/vendor/pnanovdb.wgsl +1577 -0
@@ -0,0 +1,208 @@
1
+ /**
2
+ * `VDBLevelSetVelocityNode`: the screen-space velocity of a traced level set's HIT, for temporal antialiasing and
3
+ * upscalers (G13c-a1b, D42 (3)).
4
+ *
5
+ * A level-set material draws a proxy box and traces the surface inside it. three's `velocity` node reprojects the
6
+ * rasterized vertex position, which is a point on the box, not on the surface: a temporal resolve fed with it fetches
7
+ * its history from the wrong surface point and is worse than no antialiasing (G13c-a1a: ACES error against a 4x4
8
+ * supersampled frame 0.0110, the plain frame 0.0084, with the hit's velocity 0.0048).
9
+ *
10
+ * This node writes the hit's velocity instead, in three's convention (NDC of this frame minus NDC of the previous
11
+ * frame, y up, jitter-free), and three's own `velocity` for every material that has no traced hit. Put ONE node in
12
+ * the MRT of the pass that renders the scene:
13
+ *
14
+ * const hitVelocity = new VDBLevelSetVelocityNode();
15
+ * scenePass.setMRT(mrt({ output, velocity: hitVelocity })); // a RenderPipeline pass (three's TRAA), or
16
+ * renderer.setMRT(mrt({ output, velocity: hitVelocity })); // a render target of your own (an upscaler)
17
+ *
18
+ * Not `material.mrtNode`: three r187 takes a material's `mrtNode` as its whole output in a render into a target that
19
+ * has no MRT (an accumulation pass, a read-back of the same scene).
20
+ *
21
+ * Bookkeeping. "Previous" is the previous render in which this node was drawn with the same camera (three's
22
+ * `renderId`), so it needs no animation loop. Per camera it keeps the jitter-free view-projection; per camera and
23
+ * grid the grid's placement (`pool.setTransform`), so a level set that moves gets its own motion too. The first
24
+ * render after construction or {@link VDBLevelSetVelocityNode.reset} writes zero velocity for level sets.
25
+ */
26
+ import * as THREE from "three";
27
+ import { Node, NodeUpdateType } from "three/webgpu";
28
+ import * as TSL from "three/tsl";
29
+ const { uniform, vec4, velocity, renderGroup } = TSL;
30
+ /**
31
+ * CPU twin of the node's reprojection: the NDC velocity (current − previous, three's convention) of a world-space
32
+ * hit. Matrices are column-major (`Matrix4.elements`): this and the previous frame's jitter-free projection × view,
33
+ * and `motion`, which takes a world position of this frame to the same surface point's world position in the
34
+ * previous frame ({@link vdbLevelSetGridMotion}; identity for a grid that did not move).
35
+ */
36
+ export function vdbLevelSetVelocityCpu(hitWorld, currentViewProjection, previousViewProjection, motion) {
37
+ const apply = (m, p) => [0, 1, 2, 3].map((r) => m[r] * p[0] + m[4 + r] * p[1] + m[8 + r] * p[2] + m[12 + r] * p[3]);
38
+ const now = [hitWorld[0], hitWorld[1], hitWorld[2], 1];
39
+ const before = motion ? apply(motion, now) : now;
40
+ const a = apply(currentViewProjection, now);
41
+ const b = apply(previousViewProjection, before);
42
+ return [a[0] / a[3] - b[0] / b[3], a[1] / a[3] - b[1] / b[3]];
43
+ }
44
+ /**
45
+ * The world-space motion of a grid between two frames: `previous indexToWorld ∘ current worldToIndex` (both 3x4,
46
+ * row-major, as `pool.info(id)` reports them), as a column-major 4x4. It takes this frame's world position of a
47
+ * surface point to its world position in the previous frame.
48
+ */
49
+ export function vdbLevelSetGridMotion(previousIndexToWorld, currentWorldToIndex) {
50
+ const a = previousIndexToWorld;
51
+ const b = currentWorldToIndex;
52
+ const out = new Array(16).fill(0);
53
+ for (let r = 0; r < 3; r++) {
54
+ for (let c = 0; c < 4; c++) {
55
+ out[c * 4 + r] = a[r * 4] * b[c] + a[r * 4 + 1] * b[4 + c] + a[r * 4 + 2] * b[8 + c] + (c === 3 ? a[r * 4 + 3] : 0);
56
+ }
57
+ }
58
+ out[15] = 1;
59
+ return out;
60
+ }
61
+ /**
62
+ * The MRT `velocity` output for scenes with traced level sets: the hit's velocity for `VDBLevelSetMaterial` and
63
+ * `VDBLevelSetPhysicalMaterial` (any material with a `hitWorldNode`), three's `velocity` for every other material.
64
+ * See the file comment for the wiring.
65
+ *
66
+ * - **Convention:** three's: `ndc(current) − ndc(previous)`, x right, y up, in NDC units (2 = the viewport's side).
67
+ * - **Jitter:** the velocity is jitter-free when the projection it uses is. three's TRAA gives its unjittered
68
+ * projection to the `velocity` node; this node reads the same one. A host that jitters the camera itself calls
69
+ * {@link setProjectionMatrix} with the unjittered projection (and with `null` when it stops).
70
+ * - **Moving level sets:** a grid placed with `pool.setTransform` gets the motion of its placement (numeric grid ids
71
+ * only; a material whose `gridId` is a node gets the camera's motion alone). A grid whose image changes
72
+ * (`pool.replace`: a sequence) has no motion vectors: its history is wrong where the surface moved.
73
+ * - **Cuts:** call {@link reset} at a camera cut, after a resize that changes the aspect, and when rendering resumes
74
+ * after frames this node did not draw (and reset the consumer's history too).
75
+ * - **Several materials and grids** share the one node. One node per pass.
76
+ */
77
+ export class VDBLevelSetVelocityNode extends Node {
78
+ static get type() {
79
+ return "VDBLevelSetVelocityNode";
80
+ }
81
+ /** Type flag: true. */
82
+ isVDBLevelSetVelocityNode = true;
83
+ /**
84
+ * The jitter-free projection the velocity is computed with, or `null`: three's `velocity` node's override (what
85
+ * three's TRAA sets), else the camera's own projection. Set it with {@link setProjectionMatrix}.
86
+ */
87
+ projectionMatrix = null;
88
+ /** This render's jitter-free projection × view (a render-group uniform; written by the node). */
89
+ currentViewProjection = uniform(new THREE.Matrix4()).setGroup(renderGroup);
90
+ /** The previous render's jitter-free projection × view (a render-group uniform; written by the node). */
91
+ previousViewProjection = uniform(new THREE.Matrix4()).setGroup(renderGroup);
92
+ /** Per object: this frame's world position to the previous frame's, for a grid whose placement changed. */
93
+ gridMotion = uniform(new THREE.Matrix4());
94
+ #epoch = 0;
95
+ #cameras = new WeakMap();
96
+ constructor() {
97
+ super("vec2");
98
+ const types = NodeUpdateType;
99
+ this.updateType = types.OBJECT;
100
+ }
101
+ /**
102
+ * Gives the velocity a jitter-free projection (a matrix the host keeps up to date, read at every render), or
103
+ * `null` for the default. The same matrix is given to three's `velocity` node, so the other meshes of the pass
104
+ * stay consistent. Not needed with three's TRAA, which sets three's node itself.
105
+ */
106
+ setProjectionMatrix(projectionMatrix) {
107
+ this.projectionMatrix = projectionMatrix;
108
+ velocity.setProjectionMatrix(projectionMatrix);
109
+ }
110
+ /**
111
+ * Forgets the previous frame: the next render writes zero velocity for level sets (previous = current). For a
112
+ * camera cut, an aspect change, or after renders this node did not draw. Other meshes keep three's bookkeeping.
113
+ */
114
+ reset() {
115
+ this.#epoch++;
116
+ }
117
+ /** three's per-object update: latches the camera once per render and the grid's motion per object. */
118
+ update(frame) {
119
+ const { renderId, camera, material } = frame;
120
+ if (!camera)
121
+ return undefined;
122
+ let cam = this.#cameras.get(camera);
123
+ if (!cam) {
124
+ cam = { renderId: -1, epoch: -1, frame: 0, current: new THREE.Matrix4(), previous: new THREE.Matrix4(), grids: new WeakMap() };
125
+ this.#cameras.set(camera, cam);
126
+ }
127
+ if (cam.renderId !== renderId) {
128
+ cam.renderId = renderId;
129
+ const projection = this.projectionMatrix ?? velocity.projectionMatrix ?? camera.projectionMatrix;
130
+ if (cam.epoch !== this.#epoch) {
131
+ cam.epoch = this.#epoch;
132
+ cam.frame = 0;
133
+ cam.grids = new WeakMap();
134
+ cam.current.multiplyMatrices(projection, camera.matrixWorldInverse);
135
+ cam.previous.copy(cam.current);
136
+ }
137
+ else {
138
+ cam.previous.copy(cam.current);
139
+ cam.current.multiplyMatrices(projection, camera.matrixWorldInverse);
140
+ }
141
+ cam.frame++;
142
+ }
143
+ this.currentViewProjection.value.copy(cam.current);
144
+ this.previousViewProjection.value.copy(cam.previous);
145
+ const motion = this.gridMotion.value;
146
+ const pool = material?.grids?.pool;
147
+ const id = material?.gridId?.value;
148
+ if (!material?.hitWorldNode || !pool || typeof pool.info !== "function" || typeof id !== "number") {
149
+ motion.identity();
150
+ return undefined;
151
+ }
152
+ let byId = cam.grids.get(pool);
153
+ if (!byId)
154
+ cam.grids.set(pool, (byId = new Map()));
155
+ let grid = byId.get(id);
156
+ if (grid && grid.frame === cam.frame) {
157
+ motion.copy(grid.motion);
158
+ return undefined;
159
+ }
160
+ // A grid this camera did not draw in the previous frame has no previous placement: no motion.
161
+ const fresh = !grid || grid.frame !== cam.frame - 1;
162
+ if (!grid) {
163
+ grid = { frame: 0, version: undefined, previous: new Float64Array(12), current: new Float64Array(12), worldToIndex: new Float64Array(12), motion: new THREE.Matrix4() };
164
+ byId.set(id, grid);
165
+ }
166
+ grid.frame = cam.frame;
167
+ grid.previous.set(grid.current);
168
+ if (fresh || pool.revision === undefined || pool.revision !== grid.version) {
169
+ let info = null;
170
+ try {
171
+ info = pool.info(id);
172
+ }
173
+ catch {
174
+ info = null;
175
+ }
176
+ if (!info) {
177
+ byId.delete(id);
178
+ motion.identity();
179
+ return undefined;
180
+ }
181
+ grid.version = pool.revision;
182
+ grid.current.set(info.indexToWorld);
183
+ grid.worldToIndex.set(info.worldToIndex);
184
+ }
185
+ if (fresh)
186
+ grid.previous.set(grid.current);
187
+ let moved = false;
188
+ for (let i = 0; i < 12 && !moved; i++)
189
+ moved = grid.previous[i] !== grid.current[i];
190
+ if (moved)
191
+ grid.motion.fromArray(vdbLevelSetGridMotion(grid.previous, grid.worldToIndex));
192
+ else
193
+ grid.motion.identity();
194
+ motion.copy(grid.motion);
195
+ return undefined;
196
+ }
197
+ /** The hit's NDC delta for a material with a traced hit, three's `velocity` otherwise. */
198
+ setup(builder) {
199
+ const hit = builder.material?.hitWorldNode;
200
+ if (!hit)
201
+ return velocity;
202
+ const now = vec4(hit, 1.0);
203
+ const a = this.currentViewProjection.mul(now);
204
+ const b = this.previousViewProjection.mul(this.gridMotion.mul(now));
205
+ return a.xy.div(a.w).sub(b.xy.div(b.w));
206
+ }
207
+ }
208
+ //# sourceMappingURL=level-set-velocity.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"level-set-velocity.js","sourceRoot":"","sources":["../../src/three/level-set-velocity.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAEH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,IAAI,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AACpD,OAAO,KAAK,GAAG,MAAM,WAAW,CAAC;AAGjC,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,WAAW,EAAE,GAAG,GAA4C,CAAC;AAiC9F;;;;;GAKG;AACH,MAAM,UAAU,sBAAsB,CAC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CAAC,CAAC;;YACrF,IAAI,CAAC,MAAM,CAAC,QAAQ,EAAE,CAAC;QAC5B,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QACzB,OAAO,SAAS,CAAC;IACnB,CAAC;IAED,0FAA0F;IACjF,KAAK,CAAC,OAAqC;QAClD,MAAM,GAAG,GAAI,OAAO,CAAC,QAA0C,EAAE,YAAY,CAAC;QAC9E,IAAI,CAAC,GAAG;YAAE,OAAO,QAAiB,CAAC;QACnC,MAAM,GAAG,GAAG,IAAI,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;QAC3B,MAAM,CAAC,GAAG,IAAI,CAAC,qBAAqB,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;QAC9C,MAAM,CAAC,GAAG,IAAI,CAAC,sBAAsB,CAAC,GAAG,CAAC,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC;QACpE,OAAO,CAAC,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAU,CAAC;IACnD,CAAC;CACF","sourcesContent":["/**\n * `VDBLevelSetVelocityNode`: the screen-space velocity of a traced level set's HIT, for temporal antialiasing and\n * upscalers (G13c-a1b, D42 (3)).\n *\n * A level-set material draws a proxy box and traces the surface inside it. three's `velocity` node reprojects the\n * rasterized vertex position, which is a point on the box, not on the surface: a temporal resolve fed with it fetches\n * its history from the wrong surface point and is worse than no antialiasing (G13c-a1a: ACES error against a 4x4\n * supersampled frame 0.0110, the plain frame 0.0084, with the hit's velocity 0.0048).\n *\n * This node writes the hit's velocity instead, in three's convention (NDC of this frame minus NDC of the previous\n * frame, y up, jitter-free), and three's own `velocity` for every material that has no traced hit. Put ONE node in\n * the MRT of the pass that renders the scene:\n *\n * const hitVelocity = new VDBLevelSetVelocityNode();\n * scenePass.setMRT(mrt({ output, velocity: hitVelocity })); // a RenderPipeline pass (three's TRAA), or\n * renderer.setMRT(mrt({ output, velocity: hitVelocity })); // a render target of your own (an upscaler)\n *\n * Not `material.mrtNode`: three r187 takes a material's `mrtNode` as its whole output in a render into a target that\n * has no MRT (an accumulation pass, a read-back of the same scene).\n *\n * Bookkeeping. \"Previous\" is the previous render in which this node was drawn with the same camera (three's\n * `renderId`), so it needs no animation loop. Per camera it keeps the jitter-free view-projection; per camera and\n * grid the grid's placement (`pool.setTransform`), so a level set that moves gets its own motion too. The first\n * render after construction or {@link VDBLevelSetVelocityNode.reset} writes zero velocity for level sets.\n */\n\nimport * as THREE from \"three\";\nimport { Node, NodeUpdateType } from \"three/webgpu\";\nimport * as TSL from \"three/tsl\";\nimport type { VDBTslNode } from \"./grid-node.js\";\n\nconst { uniform, vec4, velocity, renderGroup } = TSL as unknown as Record<string, VDBTslNode>;\n\ntype Mat4Uniform = VDBTslNode & { value: THREE.Matrix4 };\n\n/** What the node reads of a material: the traced hit, and (for a moving grid) the pool and the grid's id. */\ninterface HitMaterial {\n hitWorldNode?: VDBTslNode;\n grids?: { pool?: { info?: (id: number) => { indexToWorld: ArrayLike<number>; worldToIndex: ArrayLike<number> }; revision?: number } };\n gridId?: { value?: unknown };\n}\n\ninterface GridRecord {\n /** The camera frame this record was last advanced in. */\n frame: number;\n /** `pool.revision` when `current` was read. */\n version: number | undefined;\n /** The grid's index-to-world affine (3x4, row-major) in the previous and in this frame. */\n previous: Float64Array;\n current: Float64Array;\n worldToIndex: Float64Array;\n motion: THREE.Matrix4;\n}\n\ninterface CameraRecord {\n renderId: number;\n epoch: number;\n /** Renders of this node with this camera since the last reset. */\n frame: number;\n current: THREE.Matrix4;\n previous: THREE.Matrix4;\n grids: WeakMap<object, Map<number, GridRecord>>;\n}\n\n/**\n * CPU twin of the node's reprojection: the NDC velocity (current − previous, three's convention) of a world-space\n * hit. Matrices are column-major (`Matrix4.elements`): this and the previous frame's jitter-free projection × view,\n * and `motion`, which takes a world position of this frame to the same surface point's world position in the\n * previous frame ({@link vdbLevelSetGridMotion}; identity for a grid that did not move).\n */\nexport function vdbLevelSetVelocityCpu(\n hitWorld: ArrayLike<number>,\n currentViewProjection: ArrayLike<number>,\n previousViewProjection: ArrayLike<number>,\n motion?: ArrayLike<number>,\n): [number, number] {\n const apply = (m: ArrayLike<number>, p: readonly number[]): number[] => [0, 1, 2, 3].map((r) => m[r]! * p[0]! + m[4 + r]! * p[1]! + m[8 + r]! * p[2]! + m[12 + r]! * p[3]!);\n const now = [hitWorld[0]!, hitWorld[1]!, hitWorld[2]!, 1];\n const before = motion ? apply(motion, now) : now;\n const a = apply(currentViewProjection, now);\n const b = apply(previousViewProjection, before);\n return [a[0]! / a[3]! - b[0]! / b[3]!, a[1]! / a[3]! - b[1]! / b[3]!];\n}\n\n/**\n * The world-space motion of a grid between two frames: `previous indexToWorld ∘ current worldToIndex` (both 3x4,\n * row-major, as `pool.info(id)` reports them), as a column-major 4x4. It takes this frame's world position of a\n * surface point to its world position in the previous frame.\n */\nexport function vdbLevelSetGridMotion(previousIndexToWorld: ArrayLike<number>, currentWorldToIndex: ArrayLike<number>): number[] {\n const a = previousIndexToWorld;\n const b = currentWorldToIndex;\n const out = new Array<number>(16).fill(0);\n for (let r = 0; r < 3; r++) {\n for (let c = 0; c < 4; c++) {\n out[c * 4 + r] = a[r * 4]! * b[c]! + a[r * 4 + 1]! * b[4 + c]! + a[r * 4 + 2]! * b[8 + c]! + (c === 3 ? a[r * 4 + 3]! : 0);\n }\n }\n out[15] = 1;\n return out;\n}\n\n/**\n * The MRT `velocity` output for scenes with traced level sets: the hit's velocity for `VDBLevelSetMaterial` and\n * `VDBLevelSetPhysicalMaterial` (any material with a `hitWorldNode`), three's `velocity` for every other material.\n * See the file comment for the wiring.\n *\n * - **Convention:** three's: `ndc(current) − ndc(previous)`, x right, y up, in NDC units (2 = the viewport's side).\n * - **Jitter:** the velocity is jitter-free when the projection it uses is. three's TRAA gives its unjittered\n * projection to the `velocity` node; this node reads the same one. A host that jitters the camera itself calls\n * {@link setProjectionMatrix} with the unjittered projection (and with `null` when it stops).\n * - **Moving level sets:** a grid placed with `pool.setTransform` gets the motion of its placement (numeric grid ids\n * only; a material whose `gridId` is a node gets the camera's motion alone). A grid whose image changes\n * (`pool.replace`: a sequence) has no motion vectors: its history is wrong where the surface moved.\n * - **Cuts:** call {@link reset} at a camera cut, after a resize that changes the aspect, and when rendering resumes\n * after frames this node did not draw (and reset the consumer's history too).\n * - **Several materials and grids** share the one node. One node per pass.\n */\nexport class VDBLevelSetVelocityNode extends Node {\n static get type(): string {\n return \"VDBLevelSetVelocityNode\";\n }\n\n /** Type flag: true. */\n readonly isVDBLevelSetVelocityNode = true;\n /**\n * The jitter-free projection the velocity is computed with, or `null`: three's `velocity` node's override (what\n * three's TRAA sets), else the camera's own projection. Set it with {@link setProjectionMatrix}.\n */\n projectionMatrix: THREE.Matrix4 | null = null;\n /** This render's jitter-free projection × view (a render-group uniform; written by the node). */\n readonly currentViewProjection = (uniform(new THREE.Matrix4()) as VDBTslNode).setGroup(renderGroup) as Mat4Uniform;\n /** The previous render's jitter-free projection × view (a render-group uniform; written by the node). */\n readonly previousViewProjection = (uniform(new THREE.Matrix4()) as VDBTslNode).setGroup(renderGroup) as Mat4Uniform;\n /** Per object: this frame's world position to the previous frame's, for a grid whose placement changed. */\n readonly gridMotion = uniform(new THREE.Matrix4()) as Mat4Uniform;\n\n #epoch = 0;\n readonly #cameras = new WeakMap<object, CameraRecord>();\n\n constructor() {\n super(\"vec2\");\n const types = NodeUpdateType as unknown as { OBJECT: string };\n (this as unknown as { updateType: string }).updateType = types.OBJECT;\n }\n\n /**\n * Gives the velocity a jitter-free projection (a matrix the host keeps up to date, read at every render), or\n * `null` for the default. The same matrix is given to three's `velocity` node, so the other meshes of the pass\n * stay consistent. Not needed with three's TRAA, which sets three's node itself.\n */\n setProjectionMatrix(projectionMatrix: THREE.Matrix4 | null): void {\n this.projectionMatrix = projectionMatrix;\n (velocity as unknown as { setProjectionMatrix(m: THREE.Matrix4 | null): void }).setProjectionMatrix(projectionMatrix);\n }\n\n /**\n * Forgets the previous frame: the next render writes zero velocity for level sets (previous = current). For a\n * camera cut, an aspect change, or after renders this node did not draw. Other meshes keep three's bookkeeping.\n */\n reset(): void {\n this.#epoch++;\n }\n\n /** three's per-object update: latches the camera once per render and the grid's motion per object. */\n override update(frame: Parameters<Node[\"update\"]>[0]): undefined {\n const { renderId, camera, material } = frame as unknown as { renderId: number; camera: THREE.Camera | null; material: HitMaterial | null };\n if (!camera) return undefined;\n let cam = this.#cameras.get(camera);\n if (!cam) {\n cam = { renderId: -1, epoch: -1, frame: 0, current: new THREE.Matrix4(), previous: new THREE.Matrix4(), grids: new WeakMap() };\n this.#cameras.set(camera, cam);\n }\n if (cam.renderId !== renderId) {\n cam.renderId = renderId;\n const projection = this.projectionMatrix ?? (velocity as unknown as { projectionMatrix: THREE.Matrix4 | null }).projectionMatrix ?? camera.projectionMatrix;\n if (cam.epoch !== this.#epoch) {\n cam.epoch = this.#epoch;\n cam.frame = 0;\n cam.grids = new WeakMap();\n cam.current.multiplyMatrices(projection, camera.matrixWorldInverse);\n cam.previous.copy(cam.current);\n } else {\n cam.previous.copy(cam.current);\n cam.current.multiplyMatrices(projection, camera.matrixWorldInverse);\n }\n cam.frame++;\n }\n this.currentViewProjection.value.copy(cam.current);\n this.previousViewProjection.value.copy(cam.previous);\n\n const motion = this.gridMotion.value;\n const pool = material?.grids?.pool;\n const id = material?.gridId?.value;\n if (!material?.hitWorldNode || !pool || typeof pool.info !== \"function\" || typeof id !== \"number\") {\n motion.identity();\n return undefined;\n }\n let byId = cam.grids.get(pool);\n if (!byId) cam.grids.set(pool, (byId = new Map()));\n let grid = byId.get(id);\n if (grid && grid.frame === cam.frame) {\n motion.copy(grid.motion);\n return undefined;\n }\n // A grid this camera did not draw in the previous frame has no previous placement: no motion.\n const fresh = !grid || grid.frame !== cam.frame - 1;\n if (!grid) {\n grid = { frame: 0, version: undefined, previous: new Float64Array(12), current: new Float64Array(12), worldToIndex: new Float64Array(12), motion: new THREE.Matrix4() };\n byId.set(id, grid);\n }\n grid.frame = cam.frame;\n grid.previous.set(grid.current);\n if (fresh || pool.revision === undefined || pool.revision !== grid.version) {\n let info: { indexToWorld: ArrayLike<number>; worldToIndex: ArrayLike<number> } | null = null;\n try {\n info = pool.info(id);\n } catch {\n info = null;\n }\n if (!info) {\n byId.delete(id);\n motion.identity();\n return undefined;\n }\n grid.version = pool.revision;\n grid.current.set(info.indexToWorld);\n grid.worldToIndex.set(info.worldToIndex);\n }\n if (fresh) grid.previous.set(grid.current);\n let moved = false;\n for (let i = 0; i < 12 && !moved; i++) moved = grid.previous[i] !== grid.current[i];\n if (moved) grid.motion.fromArray(vdbLevelSetGridMotion(grid.previous, grid.worldToIndex));\n else grid.motion.identity();\n motion.copy(grid.motion);\n return undefined;\n }\n\n /** The hit's NDC delta for a material with a traced hit, three's `velocity` otherwise. */\n override setup(builder: Parameters<Node[\"setup\"]>[0]): ReturnType<Node[\"setup\"]> {\n const hit = (builder.material as unknown as HitMaterial | null)?.hitWorldNode;\n if (!hit) return velocity as never;\n const now = vec4(hit, 1.0);\n const a = this.currentViewProjection.mul(now);\n const b = this.previousViewProjection.mul(this.gridMotion.mul(now));\n return a.xy.div(a.w).sub(b.xy.div(b.w)) as never;\n }\n}\n"]}
@@ -0,0 +1,324 @@
1
+ /**
2
+ * `VDBVolumeMaterial`: the fragment raymarch of one grid in a `VDBGridPool`,
3
+ * through a `VDBGridNode` (task K2.3, docs/archive/handoffs/K2.md). It replaces v1's
4
+ * `NanoVDBVolumeMaterial`, which bound one grid image as its own storage
5
+ * attribute and rewrote the vendored library's buffer global.
6
+ *
7
+ * const grids = new VDBGridNode(renderer, pool, { helpers: ['rayClipSupport'] });
8
+ * const material = new VDBVolumeMaterial(renderer, grids, id);
9
+ * scene.add(new Mesh(vdbProxyGeometry(pool.info(id)), material));
10
+ * // per frame: pool.update(encoder) (or pool.flush()), then grids.update(), then render.
11
+ *
12
+ * The march is one entry `wgslFn` over the public `vdb*` WGSL API, with
13
+ * `grids.module` as its include (the module carries the pool binding):
14
+ * - the world ray goes into the grid's index space through the record's
15
+ * affine (`vdbWorldToIndex`/`vdbWorldToIndexDir`), so `pool.setTransform`
16
+ * instances render where they are;
17
+ * - it is clipped to the sampler's support box (`vdbRayClipSupport`,
18
+ * `[min - 1, max + 1]` for trilinear), not the voxel-cell box, so the
19
+ * min-side half voxel the trilinear taps reach is marched too;
20
+ * - fixed-step density accumulation with `vdbSample` (the node's sampler),
21
+ * premultiplied front-to-back compositing, early-out at low transmittance.
22
+ * The step lattice is anchored at the voxel-box entry (`vdbRayClip`, where
23
+ * v1 started) and extended back over the support shell, so samples inside
24
+ * the box sit where v1's did; only the shell samples are new (v1 skipped
25
+ * that half voxel, which shows where a grid's min-side voxels are dense);
26
+ * - lighting as in v1: Henyey-Greenstein phase on a directional sun, an
27
+ * N-step shadow march toward the sun (a second accessor), a constant
28
+ * ambient floor, and a per-fragment budget on the total samples;
29
+ * - the look is sized to the grid by default (EX1a, DIVERGES V291): the
30
+ * extinction is `opticalDepth` across the grid's longest index side at the
31
+ * grid's mean density, and the shadow ray spans `shadowReach` of that side.
32
+ * The side is read from the pool record per fragment (`vdbIndexMin` /
33
+ * `vdbIndexMax`), so it follows a `gridId` change, a `pool.replace` and a
34
+ * coarse-first swap; the mean (`densityReference`) is the root node's
35
+ * average statistic, read from `pool.info(id)` at each render. An explicit
36
+ * `densityScale` (> 0) is extinction per index voxel, as in 0.1.
37
+ *
38
+ * Rendered on a proxy box with `side: BackSide` (the camera can be inside);
39
+ * entry and exit come from the analytic clip, not the rasterized faces. The
40
+ * material is `transparent`, `depthWrite: false`, premultiplied alpha. Scene
41
+ * depth compositing is not done (v1 neither).
42
+ *
43
+ * Every tunable is a live TSL uniform (`material.densityScale.value = ...`).
44
+ * The grid is a `uint` uniform too when the constructor got a number
45
+ * (`material.gridId.value = otherId`), so one material can show any grid of
46
+ * the types its `VDBGridNode` compiles without a rebuild.
47
+ *
48
+ * Units and assumptions:
49
+ * - The march runs in the grid's **index space**: `stepSize` is in index
50
+ * voxels, `opticalDepth` is relative to the index box and `densityScale`
51
+ * integrates per index voxel. Opacity therefore does not change with the
52
+ * world size of the grid: `pool.setTransform` (or a NanoVDB map) that scales
53
+ * the grid scales its footprint, not how opaque it looks.
54
+ * - `densityReference` follows the grid: a sequence that replaces the grid
55
+ * each frame is normalised per frame. Pass a number to pin it.
56
+ * - The proxy mesh is not tied to the grid: after `material.gridId.value = id`
57
+ * or `pool.setTransform(id, ...)`, build a new `vdbProxyGeometry(pool.info(id))`
58
+ * for the mesh, or fragments outside the old box are never rasterized.
59
+ * - The view ray is `positionWorld - cameraPosition`: a perspective camera.
60
+ * An orthographic camera's rays are parallel and do not start at
61
+ * `cameraPosition`, so it renders wrongly.
62
+ */
63
+ import * as THREE from "three";
64
+ import { NodeMaterial } from "three/webgpu";
65
+ import { uniform } from "three/tsl";
66
+ import { type VDBThreeRendererLike } from "./device.js";
67
+ import { VDBGridNode, type VDBTslNode } from "./grid-node.js";
68
+ /** Default hard caps of the compiled loops (the live uniforms clamp under them). */
69
+ export declare const VDB_VOLUME_MAX_STEPS_CAP = 1024;
70
+ /** Default compiled cap on `shadowSteps`. */
71
+ export declare const VDB_VOLUME_SHADOW_STEPS_CAP = 128;
72
+ /**
73
+ * Default cap on the total samples (primary + shadow) one fragment takes.
74
+ * `maxSteps` and `shadowSteps` are independent live uniforms, so their product
75
+ * can reach `maxStepsCap * shadowStepsCap` (~131k at the defaults), a driver
76
+ * timeout risk. Once the budget is spent the shadow loop stops first, then the
77
+ * primary loop, and the fragment returns its partial march.
78
+ */
79
+ export declare const VDB_VOLUME_SAMPLE_BUDGET_CAP = 16384;
80
+ /** Parameters of {@link VDBVolumeMaterial}: initial uniform values and compile-time caps. */
81
+ export interface VDBVolumeMaterialParameters {
82
+ /**
83
+ * Extinction per index voxel at density 1. Default 0: the material uses {@link opticalDepth} instead, which
84
+ * suits a grid of any resolution. A value > 0 is used as given (0.1's meaning; 0.1's default was 40).
85
+ */
86
+ densityScale?: number;
87
+ /**
88
+ * Optical depth of a ray that crosses the grid's longest index side at the density `densityReference`, used
89
+ * while `densityScale` is 0: the extinction per index voxel at density 1 is
90
+ * `opticalDepth / (longest side * densityReference)`. Default 6.
91
+ */
92
+ opticalDepth?: number;
93
+ /**
94
+ * The density `opticalDepth` refers to. Default: the mean of the grid's active values (the root node's average
95
+ * statistic, `pool.info(id).rootAverage`), read again at each render, so the default look does not depend on
96
+ * the grid's resolution or value range; 1 for a grid without statistics. A number pins it: for a sequence whose
97
+ * frames should share one scale, or 1 to make `opticalDepth` refer to density 1.
98
+ */
99
+ densityReference?: number;
100
+ /** March step in index voxels. */
101
+ stepSize?: number;
102
+ /** Primary march steps (live, clamped to `maxStepsCap`). Default 512. */
103
+ maxSteps?: number;
104
+ /** Direction toward the sun in world space; normalized at construction. */
105
+ sunDirection?: THREE.Vector3;
106
+ /** Sun colour (linear). Default (1, 0.95, 0.9). */
107
+ sunColor?: THREE.Color;
108
+ /**
109
+ * Sun intensity: the sun term is `sunColor * sunIntensity * phase * shadow`, and a phase function integrates to
110
+ * 1 over the sphere (1 / 4π ≈ 0.08 for isotropic scattering), so 4π lights an unshadowed isotropic sample with
111
+ * `sunColor`. Default 16 (0.1's was 3).
112
+ */
113
+ sunIntensity?: number;
114
+ /** Henyey-Greenstein anisotropy g in (-1, 1). */
115
+ anisotropy?: number;
116
+ /** Shadow-ray steps per lit sample (live, clamped to `shadowStepsCap`). Default 12. */
117
+ shadowSteps?: number;
118
+ /** Density multiplier along the shadow ray only. */
119
+ shadowDensity?: number;
120
+ /**
121
+ * Length of the shadow ray as a fraction of the grid's longest index side: `shadowSteps` steps of
122
+ * `shadowReach * longest side / shadowSteps` voxels, sampled at their midpoints. Default 0.3. 0 steps the
123
+ * shadow ray by `stepSize` (0.1's march: `shadowSteps * stepSize` voxels).
124
+ */
125
+ shadowReach?: number;
126
+ /** Constant ambient term added to the sun light. Default 0.15. */
127
+ ambient?: number;
128
+ /** Per-pixel jitter of the first sample. Default true. */
129
+ jitter?: boolean;
130
+ /** Hard cap on the primary loop. Default {@link VDB_VOLUME_MAX_STEPS_CAP}. */
131
+ maxStepsCap?: number;
132
+ /** Hard cap on the shadow loop. Default {@link VDB_VOLUME_SHADOW_STEPS_CAP}. */
133
+ shadowStepsCap?: number;
134
+ /** Hard cap on the total samples per fragment. Default {@link VDB_VOLUME_SAMPLE_BUDGET_CAP}. */
135
+ sampleBudgetCap?: number;
136
+ }
137
+ /** Default `opticalDepth`: the optical depth across the grid's longest index side at its mean density (EX1a). */
138
+ export declare const VDB_VOLUME_OPTICAL_DEPTH = 6;
139
+ /** Default `shadowReach`: the shadow ray spans this fraction of the grid's longest index side (EX1a). */
140
+ export declare const VDB_VOLUME_SHADOW_REACH = 0.3;
141
+ /** Default `sunIntensity` (EX1a): about 4π × 1.25, so the sun reads against the ambient term (a phase is about 1 / 4π). */
142
+ export declare const VDB_VOLUME_SUN_INTENSITY = 16;
143
+ /** The smallest `densityReference` the march divides by. */
144
+ export declare const VDB_VOLUME_MIN_REFERENCE = 1e-20;
145
+ /**
146
+ * The `densityReference` of a grid: its root average statistic when the image has one above 0, else 1 (no
147
+ * statistics, an empty grid, or a grid of non-positive values).
148
+ *
149
+ * @param rootAverage `pool.info(id).rootAverage`.
150
+ */
151
+ export declare function vdbVolumeDensityReference(rootAverage: number | undefined): number;
152
+ /** What {@link vdbVolumeMarchScales} reads: the uniform values of a `VDBVolumeMaterial`. */
153
+ export interface VDBVolumeMarchScaleInputs {
154
+ densityScale: number;
155
+ opticalDepth: number;
156
+ /** The density `opticalDepth` refers to. Default 1. */
157
+ densityReference?: number;
158
+ stepSize: number;
159
+ shadowSteps: number;
160
+ shadowReach: number;
161
+ /** Compiled cap on `shadowSteps`. Default {@link VDB_VOLUME_SHADOW_STEPS_CAP}. */
162
+ shadowStepsCap?: number;
163
+ }
164
+ /** What the march derives from the grid's size. */
165
+ export interface VDBVolumeMarchScales {
166
+ /** Extinction per index voxel at density 1. */
167
+ extinction: number;
168
+ /** Shadow-ray step, in index voxels. */
169
+ shadowStep: number;
170
+ /** Distance of the first shadow sample from the lit sample, in index voxels. */
171
+ shadowStart: number;
172
+ }
173
+ /**
174
+ * The CPU twin of the scale lines of the march entry (EX1a): what `VDBVolumeMaterial` derives from the grid's
175
+ * longest index side. `densityScale > 0` is the extinction as given, else
176
+ * `opticalDepth / (longest * densityReference)`;
177
+ * `shadowReach > 0` spreads the shadow steps over that fraction of the side (midpoint samples), else they step
178
+ * by `stepSize` (0.1's march).
179
+ *
180
+ * @param longest The grid's longest index side in voxels (`max(indexBBox.max - indexBBox.min) + 1`).
181
+ * @param u The material's uniform values.
182
+ */
183
+ export declare function vdbVolumeMarchScales(longest: number, u: VDBVolumeMarchScaleInputs): VDBVolumeMarchScales;
184
+ /** A live TSL uniform with its value typed (three types `uniform()`'s value as unknown). */
185
+ type ScalarUniform = ReturnType<typeof uniform> & {
186
+ value: number;
187
+ };
188
+ type Vec3Uniform = ReturnType<typeof uniform> & {
189
+ value: THREE.Vector3;
190
+ };
191
+ type ColorUniform = ReturnType<typeof uniform> & {
192
+ value: THREE.Color;
193
+ };
194
+ /** The `uint` uniform `VDBVolumeMaterial` makes for a numeric grid id (`material.gridId.value = otherId`). */
195
+ export type VDBUintUniform = ReturnType<typeof uniform> & {
196
+ value: number;
197
+ };
198
+ /**
199
+ * A fragment raymarch of one grid of a `VDBGridPool` (see the file comment for
200
+ * the march). Put it on a `vdbProxyGeometry(pool.info(id))` mesh; each frame
201
+ * run `pool.update(encoder)` (or `pool.flush()`), then `grids.update()`, then
202
+ * render.
203
+ *
204
+ * const grids = new VDBGridNode(renderer, pool, { helpers: ['rayClipSupport'] });
205
+ * const material = new VDBVolumeMaterial(renderer, grids, id);
206
+ * const mesh = new Mesh(vdbProxyGeometry(pool.info(id)), material);
207
+ *
208
+ * - The defaults are sized to the grid: `opticalDepth` (6) is the optical
209
+ * depth across the grid's longest index side at its mean density
210
+ * (`densityReference`), and the shadow ray spans `shadowReach` (0.3) of
211
+ * that side, so a grid of any resolution and value range draws as a lit
212
+ * volume. `densityScale` > 0 replaces them with an extinction per index
213
+ * voxel; 0.1's look is `{ densityScale: 40, sunIntensity: 3, shadowReach: 0 }`.
214
+ * - `stepSize` is in index voxels and the density integrates in index
215
+ * space, so opacity ignores the grid's world scale (`setTransform` scaling
216
+ * changes the size on screen, not the opacity).
217
+ * - After `gridId.value = otherId` or `pool.setTransform(id, ...)`, give the
218
+ * mesh a new `vdbProxyGeometry(pool.info(id))`.
219
+ * - Perspective cameras only (the ray starts at `cameraPosition`).
220
+ * - The material must be rendered by the renderer `grids` was made with.
221
+ *
222
+ * @typeParam TGridId What the constructor got as the id: a number (default)
223
+ * makes {@link gridId} a `uint` uniform; a node is kept as given.
224
+ */
225
+ export declare class VDBVolumeMaterial<TGridId extends number | VDBTslNode = number> extends NodeMaterial {
226
+ #private;
227
+ /** Type flag: true. */
228
+ readonly isVDBVolumeMaterial = true;
229
+ /** The pool node this material reads (its `module` is the march's include). */
230
+ readonly grids: VDBGridNode;
231
+ /**
232
+ * The grid id: a `uint` uniform when the constructor got a number
233
+ * (`material.gridId.value = otherId`; then give the mesh a new
234
+ * `vdbProxyGeometry`), else the caller's node.
235
+ */
236
+ readonly gridId: TGridId extends number ? VDBUintUniform : VDBTslNode;
237
+ /** The entry `fn` text (for inspection and tests). */
238
+ readonly entrySource: string;
239
+ /**
240
+ * Extinction per index voxel at density 1 (opacity of a step: `1 - exp(-density * densityScale * stepSize)`).
241
+ * Default 0: the extinction comes from `opticalDepth` instead. To hide the volume, hide its mesh.
242
+ */
243
+ readonly densityScale: ScalarUniform;
244
+ /**
245
+ * Optical depth across the grid's longest index side at the density `densityReference`, used while
246
+ * `densityScale` is 0. It follows the grid (a `gridId` change, a coarse-first swap). Default 6.
247
+ */
248
+ readonly opticalDepth: ScalarUniform;
249
+ /**
250
+ * The density `opticalDepth` refers to. While {@link densityReferenceAuto} is true it is set at each render
251
+ * to the mean of the grid's active values (`pool.info(id).rootAverage`; 1 without statistics).
252
+ */
253
+ readonly densityReference: ScalarUniform;
254
+ /**
255
+ * True (the default, unless the constructor got a `densityReference`) while the material reads
256
+ * `densityReference` from the pool at each render. It needs a numeric grid id and a pool with `info(id)`
257
+ * (a `VDBGridPool`); otherwise the uniform keeps its value.
258
+ */
259
+ densityReferenceAuto: boolean;
260
+ /** March step in index voxels (live; the lattice re-anchors per fragment). Default 0.75. */
261
+ readonly stepSize: ScalarUniform;
262
+ /** Primary march steps, clamped to `[1, maxStepsCap]`. Default 512. */
263
+ readonly maxSteps: ScalarUniform;
264
+ /** Direction toward the sun, world space (normalized at construction; keep it normalized). */
265
+ readonly sunDirection: Vec3Uniform;
266
+ /** Sun colour (linear). Default (1, 0.95, 0.9). */
267
+ readonly sunColor: ColorUniform;
268
+ /** Sun intensity; the sun term is `sunColor * sunIntensity * phase * shadow` (phase ≈ 1 / 4π). Default 16. */
269
+ readonly sunIntensity: ScalarUniform;
270
+ /** Henyey-Greenstein anisotropy g in (-1, 1). Default 0.3. */
271
+ readonly anisotropy: ScalarUniform;
272
+ /** Shadow-ray steps toward the sun per lit sample, clamped to `[0, shadowStepsCap]`. Default 12. */
273
+ readonly shadowSteps: ScalarUniform;
274
+ /** Density multiplier along the shadow ray only. Default 1. */
275
+ readonly shadowDensity: ScalarUniform;
276
+ /**
277
+ * Length of the shadow ray as a fraction of the grid's longest index side. Default 0.3. 0 steps the shadow
278
+ * ray by `stepSize` (`shadowSteps * stepSize` voxels, 0.1's march).
279
+ */
280
+ readonly shadowReach: ScalarUniform;
281
+ /** Constant ambient term added to the sun light. Default 0.15. */
282
+ readonly ambient: ScalarUniform;
283
+ /** 1 = per-pixel jitter of the first sample on, 0 = off. */
284
+ readonly jitter: ScalarUniform;
285
+ /**
286
+ *
287
+ * @param params Initial uniform values and compile-time caps ({@link VDBVolumeMaterialParameters}).
288
+ *
289
+ * @param renderer The initialized `WebGPURenderer` the pool and `grids` live on.
290
+ * @param grids A `VDBGridNode` made on this same renderer, with profile
291
+ * `sample` or `march` and `helpers: ['rayClipSupport']`. Share one per
292
+ * pool: one module per shader.
293
+ * @param gridId The grid's pool id (a number, made a `uint` uniform) or a `uint` node.
294
+ * @throws VDBError `VDB_BAD_OPTION` for a `grids` this material can't use
295
+ * (another renderer, profile, helpers), a bad id or cap;
296
+ * `VDB_UNSUPPORTED_DEVICE` for an uninitialized renderer.
297
+ */
298
+ constructor(renderer: VDBThreeRendererLike, grids: VDBGridNode, gridId: TGridId, params?: VDBVolumeMaterialParameters);
299
+ }
300
+ /** What {@link vdbProxyGeometry} reads from `pool.info(id)`. */
301
+ export interface VDBProxyGridInfo {
302
+ /** Inclusive index-space box of the active voxels (`pool.info(id).indexBBox`). */
303
+ readonly indexBBox: {
304
+ readonly min: readonly number[];
305
+ readonly max: readonly number[];
306
+ };
307
+ /** 3x4 row-major index-to-world affine (`pool.info(id).indexToWorld`). */
308
+ readonly indexToWorld: ArrayLike<number>;
309
+ }
310
+ /**
311
+ * A world-space box for a grid's proxy mesh (add it with an identity
312
+ * transform): the AABB of the index box's voxels `[min - pad, max + 1 + pad]`
313
+ * through the grid's index-to-world affine. `pad: 0` (default) is
314
+ * `pool.info(id).worldBBox`, the box v1 used; `pad: 1` also covers the
315
+ * min-side half voxel of the trilinear support that `VDBVolumeMaterial`
316
+ * marches (rays that cross only that shell are otherwise not rasterized).
317
+ *
318
+ * @param info The grid's `pool.info(id)`.
319
+ * @param options `pad`: voxels added on every side of the index box (default 0).
320
+ */
321
+ export declare function vdbProxyGeometry(info: VDBProxyGridInfo, options?: {
322
+ pad?: number;
323
+ }): THREE.BoxGeometry;
324
+ export {};