@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
@@ -1,80 +0,0 @@
1
- // Portions derived from mjurczyk/openvdb (MIT), commit 75e7345 (v0.26.0):
2
- // src/three-openvdb/frame/core/framePhase.js L5–58 (getFramePhase, getFramePhaseSpectrum),
3
- // L79–108 (getFramePhaseAsymmetry, isFrameDiffusion, getFrameTwoSidedDiffusion,
4
- // getFrameMultipleScattering); K3.4: L61–76 (getFrameMieTexels, via tools/frame/mie.ts), L110–129
5
- // (frameMaxScatteringOctaves, getFrameScatteringOctaves).
6
- // Copyright (c) mjurczyk/openvdb contributors. Licensed under the MIT License (see THIRD_PARTY_NOTICES.md).
7
- // Changes: TypeScript; the Mie tables are our generator's output (tools/frame/mie-table.ts, identical
8
- // numbers). Divergences: DIVERGES.md (K3.1, K3.4 rows).
9
- import { vdbFrameMieAsymmetry, vdbFrameMieRgbMode, vdbFrameMieTexels } from "../../tools/frame/mie.js";
10
- import { vdbFrameMaxScatteringOctaves, vdbFrameScatteringOctaves } from "../../tools/frame/index.js";
11
- import { frameSpectrumWavelengths } from "./spectrum.js";
12
- const clampG = (g) => Math.min(0.99, Math.max(-0.99, Number(g) || 0.0));
13
- const clampWeight = (weight) => Math.min(1.0, Math.max(0.0, Number(weight) || 0.0));
14
- /** Lorenz-Mie mode of 'lorenz-mie-rgb' in the phase vector. */
15
- export const frameMieRgbMode = vdbFrameMieRgbMode;
16
- /** Asymmetry g of the Lorenz-Mie table. */
17
- export const frameMieAsymmetry = vdbFrameMieAsymmetry;
18
- /**
19
- * Texels of the Lorenz-Mie texture: the 'lorenz-mie-rgb' tables in red, green, blue and the
20
- * 'lorenz-mie' table in alpha (one texture keeps the texture count of the shaders below 16).
21
- */
22
- export const getFrameMieTexels = vdbFrameMieTexels;
23
- /**
24
- * Writes (forward g, back g, back weight, Lorenz-Mie mode) to target. Isotropic is (0, 0, 0, 0).
25
- * Lorenz-Mie mode: 0 off, 1 the 550 nm table, 2 the red, green and blue tables (frameMieRgbMode).
26
- */
27
- export const getFramePhase = (source, target) => {
28
- if (source.phase === "henyey-greenstein") {
29
- return target.set(clampG(source.phaseG), 0.0, 0.0, 0.0);
30
- }
31
- if (source.phase === "dual-lobe") {
32
- return target.set(clampG(source.phaseG), clampG(source.phaseBackG), clampWeight(source.phaseBackWeight), 0.0);
33
- }
34
- if (source.phase === "lorenz-mie") {
35
- return target.set(0.0, 0.0, 0.0, 1.0);
36
- }
37
- if (source.phase === "lorenz-mie-rgb") {
38
- return target.set(0.0, 0.0, 0.0, frameMieRgbMode);
39
- }
40
- return target.set(0.0, 0.0, 0.0, 0.0);
41
- };
42
- /** Writes (red g scale, blue g scale, flag) to target; flag 1 when the channels have other phases. */
43
- export const getFramePhaseSpectrum = (source, target) => {
44
- const exponent = Number.isFinite(Number(source.phaseGExponent)) ? Number(source.phaseGExponent) : 0.0;
45
- if (source.phase === "lorenz-mie-rgb") {
46
- return target.set(1.0, 1.0, 1.0);
47
- }
48
- if ((source.phase === "henyey-greenstein" || source.phase === "dual-lobe") && exponent !== 0.0) {
49
- const [red, green, blue] = frameSpectrumWavelengths;
50
- return target.set(Math.pow(red / green, -exponent), Math.pow(blue / green, -exponent), 1.0);
51
- }
52
- return target.set(1.0, 1.0, 0.0);
53
- };
54
- /** Asymmetry g (mean cosine of the scattering angle) of the phase of source. */
55
- export const getFramePhaseAsymmetry = (source) => {
56
- if (source.phase === "henyey-greenstein") {
57
- return clampG(source.phaseG);
58
- }
59
- if (source.phase === "dual-lobe") {
60
- const weight = clampWeight(source.phaseBackWeight);
61
- return clampG(source.phaseG) * (1.0 - weight) + clampG(source.phaseBackG) * weight;
62
- }
63
- if (source.phase === "lorenz-mie" || source.phase === "lorenz-mie-rgb") {
64
- return frameMieAsymmetry;
65
- }
66
- return 0.0;
67
- };
68
- /** Modes with the diffusion approximation: true (1D), 'two-sided' (2D) and 'neural'. */
69
- export const isFrameDiffusion = (mode) => !!mode && mode !== "octaves";
70
- /** 1.0 for multipleScattering 'two-sided'. */
71
- export const getFrameTwoSidedDiffusion = (mode) => (mode === "two-sided" ? 1.0 : 0.0);
72
- /** Multiple scattering value of the shadow marches: 1 − g for the diffusion modes, else 0. */
73
- export const getFrameMultipleScattering = (mode, source) => isFrameDiffusion(mode) ? 1.0 - getFramePhaseAsymmetry(source) : 0.0;
74
- export const frameMaxScatteringOctaves = vdbFrameMaxScatteringOctaves;
75
- /**
76
- * Indirect light octaves of multipleScattering 'octaves': writes (count N, extinction a, contribution b,
77
- * phase c) to target. Octave n (1 to N) has extinction × aⁿ, light × bⁿ and phase g × cⁿ. Count 0 is off.
78
- */
79
- export const getFrameScatteringOctaves = (settings, target) => target.fromArray(vdbFrameScatteringOctaves(settings));
80
- //# sourceMappingURL=phase.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"phase.js","sourceRoot":"","sources":["../../../src/three/frame/phase.ts"],"names":[],"mappings":"AAAA,0EAA0E;AAC1E,6FAA6F;AAC7F,kFAAkF;AAClF,oGAAoG;AACpG,4DAA4D;AAC5D,4GAA4G;AAC5G,sGAAsG;AACtG,wDAAwD;AAGxD,OAAO,EAAE,oBAAoB,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AACvG,OAAO,EAAE,4BAA4B,EAAE,yBAAyB,EAA+B,MAAM,4BAA4B,CAAC;AAClI,OAAO,EAAE,wBAAwB,EAAE,MAAM,eAAe,CAAC;AAgBzD,MAAM,MAAM,GAAG,CAAC,CAAU,EAAE,EAAE,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC,CAAC,IAAI,GAAG,CAAC,CAAC,CAAC;AACjF,MAAM,WAAW,GAAG,CAAC,MAAe,EAAE,EAAE,CAAC,I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um),\n// L79–108 (getFramePhaseAsymmetry, isFrameDiffusion, getFrameTwoSidedDiffusion,\n// getFrameMultipleScattering); K3.4: L61–76 (getFrameMieTexels, via tools/frame/mie.ts), L110–129\n// (frameMaxScatteringOctaves, getFrameScatteringOctaves).\n// Copyright (c) mjurczyk/openvdb contributors. Licensed under the MIT License (see THIRD_PARTY_NOTICES.md).\n// Changes: TypeScript; the Mie tables are our generator's output (tools/frame/mie-table.ts, identical\n// numbers). Divergences: DIVERGES.md (K3.1, K3.4 rows).\n\nimport type { Vector3, Vector4 } from \"three\";\nimport { vdbFrameMieAsymmetry, vdbFrameMieRgbMode, vdbFrameMieTexels } from \"../../tools/frame/mie.js\";\nimport { vdbFrameMaxScatteringOctaves, vdbFrameScatteringOctaves, type VDBFrameOctaveSettings } from \"../../tools/frame/index.js\";\nimport { frameSpectrumWavelengths } from \"./spectrum.js\";\n\n/** Phase functions of a volume (his `phase` prop). */\nexport type VDBFramePhase = \"isotropic\" | \"henyey-greenstein\" | \"dual-lobe\" | \"lorenz-mie\" | \"lorenz-mie-rgb\";\n\n/** Multiple scattering modes (his `frameRenderer.settings.multipleScattering`). */\nexport type VDBFrameMultipleScattering = boolean | \"two-sided\" | \"octaves\" | \"neural\";\n\nexport interface VDBFramePhaseSource {\n phase: VDBFramePhase;\n phaseG: number;\n phaseBackG: number;\n phaseBackWeight: number;\n phaseGExponent: number;\n}\n\nconst clampG = (g: unknown) => Math.min(0.99, Math.max(-0.99, Number(g) || 0.0));\nconst clampWeight = (weight: unknown) => Math.min(1.0, Math.max(0.0, Number(weight) || 0.0));\n\n/** Lorenz-Mie mode of 'lorenz-mie-rgb' in the phase vector. */\nexport const frameMieRgbMode = vdbFrameMieRgbMode;\n\n/** Asymmetry g of the Lorenz-Mie table. */\nexport const frameMieAsymmetry = vdbFrameMieAsymmetry;\n\n/**\n * Texels of the Lorenz-Mie texture: the 'lorenz-mie-rgb' tables in red, green, blue and the\n * 'lorenz-mie' table in alpha (one texture keeps the texture count of the shaders below 16).\n */\nexport const getFrameMieTexels = vdbFrameMieTexels;\n\n/**\n * Writes (forward g, back g, back weight, Lorenz-Mie mode) to target. Isotropic is (0, 0, 0, 0).\n * Lorenz-Mie mode: 0 off, 1 the 550 nm table, 2 the red, green and blue tables (frameMieRgbMode).\n */\nexport const getFramePhase = (source: VDBFramePhaseSource, target: Vector4) => {\n if (source.phase === \"henyey-greenstein\") {\n return target.set(clampG(source.phaseG), 0.0, 0.0, 0.0);\n }\n\n if (source.phase === \"dual-lobe\") {\n return target.set(clampG(source.phaseG), clampG(source.phaseBackG), clampWeight(source.phaseBackWeight), 0.0);\n }\n\n if (source.phase === \"lorenz-mie\") {\n return target.set(0.0, 0.0, 0.0, 1.0);\n }\n\n if (source.phase === \"lorenz-mie-rgb\") {\n return target.set(0.0, 0.0, 0.0, frameMieRgbMode);\n }\n\n return target.set(0.0, 0.0, 0.0, 0.0);\n};\n\n/** Writes (red g scale, blue g scale, flag) to target; flag 1 when the channels have other phases. */\nexport const getFramePhaseSpectrum = (source: VDBFramePhaseSource, target: Vector3) => {\n const exponent = Number.isFinite(Number(source.phaseGExponent)) ? Number(source.phaseGExponent) : 0.0;\n\n if (source.phase === \"lorenz-mie-rgb\") {\n return target.set(1.0, 1.0, 1.0);\n }\n\n if ((source.phase === \"henyey-greenstein\" || source.phase === \"dual-lobe\") && exponent !== 0.0) {\n const [red, green, blue] = frameSpectrumWavelengths;\n\n return target.set(Math.pow(red / green, -exponent), Math.pow(blue / green, -exponent), 1.0);\n }\n\n return target.set(1.0, 1.0, 0.0);\n};\n\n/** Asymmetry g (mean cosine of the scattering angle) of the phase of source. */\nexport const getFramePhaseAsymmetry = (source: VDBFramePhaseSource) => {\n if (source.phase === \"henyey-greenstein\") {\n return clampG(source.phaseG);\n }\n\n if (source.phase === \"dual-lobe\") {\n const weight = clampWeight(source.phaseBackWeight);\n\n return clampG(source.phaseG) * (1.0 - weight) + clampG(source.phaseBackG) * weight;\n }\n\n if (source.phase === \"lorenz-mie\" || source.phase === \"lorenz-mie-rgb\") {\n return frameMieAsymmetry;\n }\n\n return 0.0;\n};\n\n/** Modes with the diffusion approximation: true (1D), 'two-sided' (2D) and 'neural'. */\nexport const isFrameDiffusion = (mode: VDBFrameMultipleScattering) => !!mode && mode !== \"octaves\";\n\n/** 1.0 for multipleScattering 'two-sided'. */\nexport const getFrameTwoSidedDiffusion = (mode: VDBFrameMultipleScattering) => (mode === \"two-sided\" ? 1.0 : 0.0);\n\n/** Multiple scattering value of the shadow marches: 1 − g for the diffusion modes, else 0. */\nexport const getFrameMultipleScattering = (mode: VDBFrameMultipleScattering, source: VDBFramePhaseSource) =>\n isFrameDiffusion(mode) ? 1.0 - getFramePhaseAsymmetry(source) : 0.0;\n\nexport const frameMaxScatteringOctaves = vdbFrameMaxScatteringOctaves;\n\n/**\n * Indirect light octaves of multipleScattering 'octaves': writes (count N, extinction a, contribution b,\n * phase c) to target. Octave n (1 to N) has extinction × aⁿ, light × bⁿ and phase g × cⁿ. Count 0 is off.\n */\nexport const getFrameScatteringOctaves = (settings: VDBFrameOctaveSettings, target: Vector4) => target.fromArray(vdbFrameScatteringOctaves(settings));\n"]}
@@ -1,30 +0,0 @@
1
- import { NodeMaterial } from "three/webgpu";
2
- import type { VDBTslNode } from "../grid-node.js";
3
- import type { VDBThreeVolumeSource, VDBVolumeUniforms } from "../volume-source.js";
4
- import { type FrameVolumeUniforms, type GridUniforms, type TileUniforms } from "./chunks.js";
5
- export interface VDBFrameShadowDensityMaterialOptions {
6
- gridUniforms: GridUniforms;
7
- gridTileUniforms: TileUniforms;
8
- source: VDBThreeVolumeSource;
9
- sourceUniforms: VDBVolumeUniforms;
10
- mipmaps: boolean;
11
- }
12
- export declare class VDBFrameShadowDensityMaterial extends NodeMaterial {
13
- readonly volumeUniforms: FrameVolumeUniforms;
14
- readonly sourceUniforms: VDBVolumeUniforms;
15
- readonly source: VDBThreeVolumeSource;
16
- readonly gridUniforms: GridUniforms;
17
- readonly frameRect: any;
18
- readonly frameSliceStart: any;
19
- mipmaps: boolean;
20
- spectral: boolean;
21
- constructor(o: VDBFrameShadowDensityMaterialOptions);
22
- private readonly gridTileUniforms;
23
- setMipmaps(mipmaps: boolean): void;
24
- setSpectral(spectral: boolean): void;
25
- rebuildNodes(): void;
26
- createFragmentNode(gridTileUniforms: TileUniforms, spectralOutputs?: {
27
- extinction: VDBTslNode;
28
- absorption: VDBTslNode;
29
- } | null): VDBTslNode;
30
- }
@@ -1,123 +0,0 @@
1
- // Portions derived from mjurczyk/openvdb (MIT), commit 75e7345 (v0.26.0):
2
- // src/three-openvdb/frame/webgpu/FrameShadowDensityMaterial.js L12–131 (K3.5: with the spectral
3
- // outputs, setSpectral / rebuildNodes and the spectral branch L111–121).
4
- // Copyright (c) mjurczyk/openvdb contributors. Licensed under the MIT License (see THIRD_PARTY_NOTICES.md).
5
- // Changes: TypeScript; reads density only through `vdbVolumeNodes` (the VDBVolumeSource seam), so
6
- // one material is built per volume source (as the inject material, DIVERGES V30); with the sparse
7
- // source the grid voxel lod reads its coarse LOD (`'coarse-pyramid'`, D28). Divergences: DIVERGES.md (K3.3 rows), V23–V25, V30.
8
- /**
9
- * The shadow density pass of `'frame'` lighting (R1 §2 step 1): writes the extinction and the
10
- * absorption of one volume into one cascade of the world shadow grid (RG half-float slice atlas,
11
- * additive, so overlapping volumes sum; spectral: two RGBA targets, (extinction rgb, 0) and
12
- * (absorption rgb, 0), with the volume's extinction spectrum and per-channel albedo). The source is read at the grid voxel's lod. Absorption
13
- * limits multiple scattering in the shadow marches: dark volumes keep sharp shadows.
14
- */
15
- import * as THREE from "three";
16
- import { NodeMaterial } from "three/webgpu";
17
- import * as TSL from "three/tsl";
18
- import { vdbVolumeNodes } from "../volume-source.js";
19
- import { createFrameVolumeUniforms, createGridNodes, frameFragCoord, frameShadowAbsorption, frameTileVertex } from "./chunks.js";
20
- const { Discard, Fn, If, clamp, float, max, outputStruct, property, uniform, vec4 } = TSL;
21
- // NOTE Writes the extinction and absorption of one volume into one cascade of the world-space shadow grid.
22
- // NOTE One material per volume source. Pool meshes (one per cascade) set the rect and slices before each draw.
23
- export class VDBFrameShadowDensityMaterial extends NodeMaterial {
24
- volumeUniforms;
25
- sourceUniforms;
26
- source;
27
- gridUniforms;
28
- frameRect = uniform(new THREE.Vector4());
29
- frameSliceStart = uniform(0.0);
30
- mipmaps;
31
- // NOTE Renderer settings.spectral: two targets, (extinction rgb, 0) and (absorption rgb, 0)
32
- spectral = false;
33
- constructor(o) {
34
- super();
35
- this.name = "VDBFrameShadowDensityMaterial";
36
- this.volumeUniforms = createFrameVolumeUniforms();
37
- this.sourceUniforms = o.sourceUniforms;
38
- this.source = o.source;
39
- this.gridUniforms = o.gridUniforms;
40
- this.mipmaps = o.mipmaps;
41
- this.vertexNode = frameTileVertex(o.gridTileUniforms, this.frameRect, this.frameSliceStart);
42
- this.gridTileUniforms = o.gridTileUniforms;
43
- this.rebuildNodes();
44
- this.side = THREE.DoubleSide;
45
- this.forceSinglePass = true;
46
- this.depthTest = false;
47
- this.depthWrite = false;
48
- this.transparent = true;
49
- this.blending = THREE.CustomBlending;
50
- this.blendEquation = THREE.AddEquation;
51
- this.blendSrc = THREE.OneFactor;
52
- this.blendDst = THREE.OneFactor;
53
- this.blendSrcAlpha = THREE.OneFactor;
54
- this.blendDstAlpha = THREE.OneFactor;
55
- }
56
- gridTileUniforms;
57
- // NOTE Mip sampling is in the shader only when the volume uses mipmaps
58
- setMipmaps(mipmaps) {
59
- if (mipmaps !== this.mipmaps) {
60
- this.mipmaps = mipmaps;
61
- this.rebuildNodes();
62
- this.needsUpdate = true;
63
- }
64
- }
65
- setSpectral(spectral) {
66
- if (spectral !== this.spectral) {
67
- this.spectral = spectral;
68
- this.rebuildNodes();
69
- this.needsUpdate = true;
70
- }
71
- }
72
- rebuildNodes() {
73
- if (!this.spectral) {
74
- this.colorNode = null;
75
- this.outputNode = null;
76
- this.fragmentNode = this.createFragmentNode(this.gridTileUniforms);
77
- return;
78
- }
79
- const extinction = property("vec4");
80
- const absorption = property("vec4");
81
- this.fragmentNode = null;
82
- this.colorNode = this.createFragmentNode(this.gridTileUniforms, { extinction, absorption });
83
- this.outputNode = outputStruct(extinction, absorption);
84
- }
85
- // NOTE spectralOutputs: { extinction, absorption } property nodes of the spectral targets. null: one target.
86
- createFragmentNode(gridTileUniforms, spectralOutputs = null) {
87
- const { gridUniforms, sourceUniforms } = this;
88
- const volume = vdbVolumeNodes(this.source, sourceUniforms, { useMipmaps: this.mipmaps });
89
- const grid = createGridNodes(gridUniforms);
90
- const { frameWorldToLocal, frameAbsorbance, frameExtinctionSpectrum } = this.volumeUniforms;
91
- const frameWorldScale = sourceUniforms.worldScale;
92
- const { frameGridMin, frameGridSize, frameGridVoxel, frameGridCount } = gridUniforms;
93
- return Fn(() => {
94
- const cell = grid.getGridCell(frameFragCoord(gridTileUniforms.frameTargetSize));
95
- const cascade = cell.cascade.toVar();
96
- If(cascade.greaterThanEqual(frameGridCount), () => {
97
- Discard();
98
- });
99
- const worldPosition = frameGridMin.element(cascade).add(cell.gridUvw.mul(frameGridSize.element(cascade)));
100
- const localPosition = frameWorldToLocal.mul(vec4(worldPosition, 1.0)).xyz.toVar();
101
- If(volume.insideBox(localPosition).not(), () => {
102
- Discard();
103
- });
104
- // NOTE Absorbance scales the shadow of this volume, not its look from the camera
105
- const voxel = frameGridVoxel.element(cascade);
106
- const lod = volume.getLod(max(voxel.x, max(voxel.y, voxel.z)).div(frameWorldScale));
107
- const extinction = volume.sampleExtinction(localPosition, lod).mul(frameAbsorbance).toVar();
108
- If(extinction.lessThanEqual(0.0), () => {
109
- Discard();
110
- });
111
- if (spectralOutputs) {
112
- // NOTE Extinction and absorption of each channel. Absorption is the part that the albedo of the channel does not scatter.
113
- const spectralExtinction = frameExtinctionSpectrum.mul(extinction).toVar();
114
- const albedo = clamp(volume.sampleAlbedo(localPosition, lod), 0.0, 1.0);
115
- spectralOutputs.extinction.assign(vec4(spectralExtinction, 0.0));
116
- spectralOutputs.absorption.assign(vec4(spectralExtinction.mul(float(1.0).sub(albedo)), 0.0));
117
- return vec4(0.0);
118
- }
119
- return vec4(extinction, frameShadowAbsorption(extinction, volume.sampleAlbedo(localPosition, lod)), 0.0, 0.0);
120
- })();
121
- }
122
- }
123
- //# sourceMappingURL=shadow-density-material.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"shadow-density-material.js","sourceRoot":"","sources":["../../../src/three/frame/shadow-density-material.ts"],"names":[],"mappings":"AAAA,0EAA0E;AAC1E,kGAAkG;AAClG,2EAA2E;AAC3E,4GAA4G;AAC5G,kGAAkG;AAClG,kGAAkG;AAClG,gIAAgI;AAEhI;;;;;;GAMG;AAEH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAC5C,OAAO,KAAK,GAAG,MAAM,WAAW,CAAC;AAGjC,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AACrD,OAAO,EAAE,yBAAyB,EAAE,eAAe,EAAE,cAAc,EAAE,qBAAqB,EAAE,eAAe,EAAkE,MAAM,aAAa,CAAC;AAEjM,MAAM,EAAE,OAAO,EAAE,EAAE,EAAE,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE,GAAG,EAAE,YAAY,EAAE,QAAQ,EAAE,OAAO,EAAE,IAAI,EAAE,GAAG,GAA4C,CAAC;AAUnI,2GAA2G;AAC3G,+GAA+G;AAC/G,MAAM,OAAO,6BAA8B,SAAQ,YAAY;IACpD,cAAc,CAAsB;IACpC,cAAc,CAAoB;IAClC,MAAM,CAAuB;IAC7B,YAAY,CAAe;IAC3B,SAAS,GAAG,OAAO,CAAC,IAAI,KAAK,CAAC,OAAO,EAAE,CAAC,CAAC;IACzC,eAAe,GAAG,OAAO,CAAC,GAAG,CAAC,CAAC;IACxC,OAAO,CAAU;IACjB,4FAA4F;IAC5F,QAAQ,GAAG,KAAK,CAAC;IAEjB,YAAY,CAAuC;QACjD,KAAK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K3.5: with the spectral\n// outputs, setSpectral / rebuildNodes and the spectral branch L111–121).\n// Copyright (c) mjurczyk/openvdb contributors. Licensed under the MIT License (see THIRD_PARTY_NOTICES.md).\n// Changes: TypeScript; reads density only through `vdbVolumeNodes` (the VDBVolumeSource seam), so\n// one material is built per volume source (as the inject material, DIVERGES V30); with the sparse\n// source the grid voxel lod reads its coarse LOD (`'coarse-pyramid'`, D28). Divergences: DIVERGES.md (K3.3 rows), V23–V25, V30.\n\n/**\n * The shadow density pass of `'frame'` lighting (R1 §2 step 1): writes the extinction and the\n * absorption of one volume into one cascade of the world shadow grid (RG half-float slice atlas,\n * additive, so overlapping volumes sum; spectral: two RGBA targets, (extinction rgb, 0) and\n * (absorption rgb, 0), with the volume's extinction spectrum and per-channel albedo). The source is read at the grid voxel's lod. Absorption\n * limits multiple scattering in the shadow marches: dark volumes keep sharp shadows.\n */\n\nimport * as THREE from \"three\";\nimport { NodeMaterial } from \"three/webgpu\";\nimport * as TSL from \"three/tsl\";\nimport type { VDBTslNode } from \"../grid-node.js\";\nimport type { VDBThreeVolumeSource, VDBVolumeNodes, VDBVolumeUniforms } from \"../volume-source.js\";\nimport { vdbVolumeNodes } from \"../volume-source.js\";\nimport { createFrameVolumeUniforms, createGridNodes, frameFragCoord, frameShadowAbsorption, frameTileVertex, type FrameVolumeUniforms, type GridUniforms, type TileUniforms } from \"./chunks.js\";\n\nconst { Discard, Fn, If, clamp, float, max, outputStruct, property, uniform, vec4 } = TSL as unknown as Record<string, VDBTslNode>;\n\nexport interface VDBFrameShadowDensityMaterialOptions {\n gridUniforms: GridUniforms;\n gridTileUniforms: TileUniforms;\n source: VDBThreeVolumeSource;\n sourceUniforms: VDBVolumeUniforms;\n mipmaps: boolean;\n}\n\n// NOTE Writes the extinction and absorption of one volume into one cascade of the world-space shadow grid.\n// NOTE One material per volume source. Pool meshes (one per cascade) set the rect and slices before each draw.\nexport class VDBFrameShadowDensityMaterial extends NodeMaterial {\n readonly volumeUniforms: FrameVolumeUniforms;\n readonly sourceUniforms: VDBVolumeUniforms;\n readonly source: VDBThreeVolumeSource;\n readonly gridUniforms: GridUniforms;\n readonly frameRect = uniform(new THREE.Vector4());\n readonly frameSliceStart = uniform(0.0);\n mipmaps: boolean;\n // NOTE Renderer settings.spectral: two targets, (extinction rgb, 0) and (absorption rgb, 0)\n spectral = false;\n\n constructor(o: VDBFrameShadowDensityMaterialOptions) {\n super();\n\n this.name = \"VDBFrameShadowDensityMaterial\";\n this.volumeUniforms = createFrameVolumeUniforms();\n this.sourceUniforms = o.sourceUniforms;\n this.source = o.source;\n this.gridUniforms = o.gridUniforms;\n this.mipmaps = o.mipmaps;\n this.vertexNode = frameTileVertex(o.gridTileUniforms, this.frameRect, this.frameSliceStart);\n this.gridTileUniforms = o.gridTileUniforms;\n this.rebuildNodes();\n\n this.side = THREE.DoubleSide;\n this.forceSinglePass = true;\n this.depthTest = false;\n this.depthWrite = false;\n this.transparent = true;\n this.blending = THREE.CustomBlending;\n this.blendEquation = THREE.AddEquation;\n this.blendSrc = THREE.OneFactor;\n this.blendDst = THREE.OneFactor;\n this.blendSrcAlpha = THREE.OneFactor;\n this.blendDstAlpha = THREE.OneFactor;\n }\n\n private readonly gridTileUniforms: TileUniforms;\n\n // NOTE Mip sampling is in the shader only when the volume uses mipmaps\n setMipmaps(mipmaps: boolean): void {\n if (mipmaps !== this.mipmaps) {\n this.mipmaps = mipmaps;\n this.rebuildNodes();\n this.needsUpdate = true;\n }\n }\n\n setSpectral(spectral: boolean): void {\n if (spectral !== this.spectral) {\n this.spectral = spectral;\n this.rebuildNodes();\n this.needsUpdate = true;\n }\n }\n\n rebuildNodes(): void {\n if (!this.spectral) {\n this.colorNode = null;\n this.outputNode = null;\n this.fragmentNode = this.createFragmentNode(this.gridTileUniforms);\n\n return;\n }\n\n const extinction = property(\"vec4\");\n const absorption = property(\"vec4\");\n\n this.fragmentNode = null;\n this.colorNode = this.createFragmentNode(this.gridTileUniforms, { extinction, absorption });\n this.outputNode = outputStruct(extinction, absorption);\n }\n\n // NOTE spectralOutputs: { extinction, absorption } property nodes of the spectral targets. null: one target.\n createFragmentNode(gridTileUniforms: TileUniforms, spectralOutputs: { extinction: VDBTslNode; absorption: VDBTslNode } | null = null): VDBTslNode {\n const { gridUniforms, sourceUniforms } = this;\n const volume: VDBVolumeNodes = vdbVolumeNodes(this.source, sourceUniforms, { useMipmaps: this.mipmaps });\n const grid = createGridNodes(gridUniforms);\n const { frameWorldToLocal, frameAbsorbance, frameExtinctionSpectrum } = this.volumeUniforms;\n const frameWorldScale = sourceUniforms.worldScale;\n const { frameGridMin, frameGridSize, frameGridVoxel, frameGridCount } = gridUniforms;\n\n return Fn(() => {\n const cell = grid.getGridCell(frameFragCoord(gridTileUniforms.frameTargetSize));\n const cascade = cell.cascade.toVar();\n\n If(cascade.greaterThanEqual(frameGridCount), () => {\n Discard();\n });\n\n const worldPosition = frameGridMin.element(cascade).add(cell.gridUvw.mul(frameGridSize.element(cascade)));\n const localPosition = frameWorldToLocal.mul(vec4(worldPosition, 1.0)).xyz.toVar();\n\n If(volume.insideBox(localPosition).not(), () => {\n Discard();\n });\n\n // NOTE Absorbance scales the shadow of this volume, not its look from the camera\n const voxel = frameGridVoxel.element(cascade);\n const lod = volume.getLod(max(voxel.x, max(voxel.y, voxel.z)).div(frameWorldScale));\n const extinction = volume.sampleExtinction(localPosition, lod).mul(frameAbsorbance).toVar();\n\n If(extinction.lessThanEqual(0.0), () => {\n Discard();\n });\n\n if (spectralOutputs) {\n // NOTE Extinction and absorption of each channel. Absorption is the part that the albedo of the channel does not scatter.\n const spectralExtinction = frameExtinctionSpectrum.mul(extinction).toVar();\n const albedo = clamp(volume.sampleAlbedo(localPosition, lod), 0.0, 1.0);\n\n spectralOutputs.extinction.assign(vec4(spectralExtinction, 0.0));\n spectralOutputs.absorption.assign(vec4(spectralExtinction.mul(float(1.0).sub(albedo)), 0.0));\n\n return vec4(0.0);\n }\n\n return vec4(extinction, frameShadowAbsorption(extinction, volume.sampleAlbedo(localPosition, lod)), 0.0, 0.0);\n })();\n }\n}\n"]}
@@ -1,29 +0,0 @@
1
- import { NodeMaterial } from "three/webgpu";
2
- import type { VDBTslNode } from "../grid-node.js";
3
- import { type FroxelUniforms, type TileUniforms } from "./chunks.js";
4
- export interface VDBFrameTemporalMaterialOptions {
5
- froxelUniforms: FroxelUniforms;
6
- froxelTileUniforms: TileUniforms;
7
- froxelAreaUniforms: {
8
- frameAreaRect: VDBTslNode;
9
- frameAreaSliceStart: VDBTslNode;
10
- };
11
- }
12
- export declare class VDBFrameTemporalMaterial extends NodeMaterial {
13
- readonly frameCurrentMap: any;
14
- readonly frameHistoryMap: any;
15
- readonly frameCurrentAlphaMap: any;
16
- readonly frameHistoryAlphaMap: any;
17
- spectral: boolean;
18
- readonly frameUseHistory: any;
19
- readonly frameTemporalBlend: any;
20
- readonly frameCameraMatrixWorld: any;
21
- readonly framePreviousViewMatrix: any;
22
- readonly framePreviousProjectionMatrix: any;
23
- readonly framePreviousRange: any;
24
- readonly froxelUniforms: FroxelUniforms;
25
- constructor(o: VDBFrameTemporalMaterialOptions);
26
- setSpectral(spectral: boolean): void;
27
- rebuildNodes(): void;
28
- createFragmentNode(maps: [VDBTslNode, VDBTslNode][], outputs?: VDBTslNode[] | null): VDBTslNode;
29
- }
@@ -1,152 +0,0 @@
1
- // Portions derived from mjurczyk/openvdb (MIT), commit 75e7345 (v0.26.0):
2
- // src/three-openvdb/frame/webgpu/FrameTemporalMaterial.js L31–217 (K3.5: with the spectral second
3
- // atlas target: setSpectral, rebuildNodes, the [current, history] map pairs).
4
- // Copyright (c) mjurczyk/openvdb contributors. Licensed under the MIT License (see THIRD_PARTY_NOTICES.md).
5
- // Changes: TypeScript. Divergences: none.
6
- /**
7
- * The temporal pass (R1 §2 step 5): blends this frame's froxels with the previous frames', each
8
- * froxel centre reprojected into the previous froxel grid (bilinear in the slice, linear between
9
- * slices), the history clamped to the current froxel's 6 neighbours (less ghosting), and the history
10
- * weight dropping to 0 for a quarter cell of motion or more. CPU twin of the reprojection:
11
- * `@pmndrs/vdb/tools` `vdbFrameReproject`. Spectral (K3.5): both atlas targets are blended and
12
- * clamped with one reprojection.
13
- */
14
- import * as THREE from "three";
15
- import { NodeMaterial } from "three/webgpu";
16
- import * as TSL from "three/tsl";
17
- import { frameFragCoord, frameGetViewPosition, frameLoad, frameSample, frameSliceDepth, frameTileVertex } from "./chunks.js";
18
- const { Fn, If, clamp, floor, ivec2, length, log, max, min, mix, mod, outputStruct, property, texture, uniform, vec2, vec3, vec4 } = TSL;
19
- // NOTE Blends the froxels of this frame with the reprojected froxels of the previous frames
20
- export class VDBFrameTemporalMaterial extends NodeMaterial {
21
- frameCurrentMap = texture(new THREE.Texture());
22
- frameHistoryMap = texture(new THREE.Texture());
23
- // NOTE Renderer settings.spectral: second atlas target (red alpha, blue alpha, 0, green alpha)
24
- frameCurrentAlphaMap = texture(new THREE.Texture());
25
- frameHistoryAlphaMap = texture(new THREE.Texture());
26
- spectral = false;
27
- frameUseHistory = uniform(0, "int");
28
- frameTemporalBlend = uniform(0.1);
29
- frameCameraMatrixWorld = uniform(new THREE.Matrix4());
30
- framePreviousViewMatrix = uniform(new THREE.Matrix4());
31
- framePreviousProjectionMatrix = uniform(new THREE.Matrix4());
32
- framePreviousRange = uniform(new THREE.Vector2(0.1, 1.0));
33
- froxelUniforms;
34
- constructor(o) {
35
- super();
36
- this.name = "VDBFrameTemporalMaterial";
37
- this.froxelUniforms = o.froxelUniforms;
38
- // NOTE Only the froxel area of the volumes. The renderer clears the target first.
39
- this.vertexNode = frameTileVertex(o.froxelTileUniforms, o.froxelAreaUniforms.frameAreaRect, o.froxelAreaUniforms.frameAreaSliceStart);
40
- this.rebuildNodes();
41
- this.side = THREE.DoubleSide;
42
- this.forceSinglePass = true;
43
- this.depthTest = false;
44
- this.depthWrite = false;
45
- this.blending = THREE.NoBlending;
46
- }
47
- setSpectral(spectral) {
48
- if (spectral !== this.spectral) {
49
- this.spectral = spectral;
50
- this.rebuildNodes();
51
- this.needsUpdate = true;
52
- }
53
- }
54
- // NOTE Spectral: both atlas targets are blended and clamped. They share one reprojection.
55
- rebuildNodes() {
56
- if (!this.spectral) {
57
- this.colorNode = null;
58
- this.outputNode = null;
59
- this.fragmentNode = this.createFragmentNode([[this.frameCurrentMap, this.frameHistoryMap]]);
60
- return;
61
- }
62
- const outputs = [property("vec4"), property("vec4")];
63
- this.fragmentNode = null;
64
- this.colorNode = this.createFragmentNode([
65
- [this.frameCurrentMap, this.frameHistoryMap],
66
- [this.frameCurrentAlphaMap, this.frameHistoryAlphaMap],
67
- ], outputs);
68
- this.outputNode = outputStruct(...outputs);
69
- }
70
- // NOTE maps: [current, history] pairs. outputs: property nodes for each pair, or null for one output.
71
- createFragmentNode(maps, outputs = null) {
72
- const { froxelUniforms } = this;
73
- const { froxelGrid, froxelColumns, froxelAtlasSize } = froxelUniforms;
74
- const getTileOrigin = (slice) => vec2(mod(slice, froxelColumns), floor(slice.div(froxelColumns))).mul(froxelGrid.xy);
75
- // NOTE Bilinear filter in the slice. Half a cell inside the tile, then the filter does not read other tiles.
76
- const sampleHistory = (historyMap, slice, uv) => {
77
- const cell = clamp(uv.mul(froxelGrid.xy), vec2(0.5), froxelGrid.xy.sub(0.5));
78
- return frameSample(historyMap, getTileOrigin(slice).add(cell).div(froxelAtlasSize));
79
- };
80
- const loadCurrent = (currentMap, texel) => frameLoad(currentMap, ivec2(texel), froxelAtlasSize);
81
- return Fn(() => {
82
- const fragCoord = frameFragCoord(froxelAtlasSize).toVar();
83
- const currents = maps.map(([currentMap]) => loadCurrent(currentMap, fragCoord).toVar());
84
- const resolved = currents.map((current) => vec4(current).toVar());
85
- const tile = floor(fragCoord.div(froxelGrid.xy)).toVar();
86
- const slice = tile.y.mul(froxelColumns).add(tile.x).toVar();
87
- If(this.frameUseHistory.equal(1).and(slice.lessThan(froxelGrid.z)), () => {
88
- // NOTE Reproject the froxel center into the froxel grid of the previous frame
89
- const cell = fragCoord.sub(tile.mul(froxelGrid.xy)).toVar();
90
- const uv = cell.div(froxelGrid.xy);
91
- const viewDepth = frameSliceDepth(froxelUniforms, slice.add(0.5).div(froxelGrid.z));
92
- const worldPosition = this.frameCameraMatrixWorld.mul(vec4(frameGetViewPosition(froxelUniforms, uv, viewDepth), 1.0));
93
- const previousView = this.framePreviousViewMatrix.mul(worldPosition).toVar();
94
- const previousClip = this.framePreviousProjectionMatrix.mul(previousView).toVar();
95
- If(previousClip.w.greaterThan(0.0), () => {
96
- const previousUv = previousClip.xy.div(previousClip.w).mul(0.5).add(0.5).toVar();
97
- const previousRange = this.framePreviousRange;
98
- const previousT = log(max(previousView.z.negate(), 1e-6).div(previousRange.x)).div(log(previousRange.y.div(previousRange.x)));
99
- const previousSlice = previousT.mul(froxelGrid.z).sub(0.5).toVar();
100
- const inside = min(previousUv.x, previousUv.y)
101
- .greaterThanEqual(0.0)
102
- .and(max(previousUv.x, previousUv.y).lessThanEqual(1.0))
103
- .and(previousSlice.greaterThanEqual(-0.5))
104
- .and(previousSlice.lessThanEqual(froxelGrid.z.sub(0.5)));
105
- If(inside, () => {
106
- const slice0 = clamp(floor(previousSlice), 0.0, froxelGrid.z.sub(1.0)).toVar();
107
- const slice1 = min(slice0.add(1.0), froxelGrid.z.sub(1.0));
108
- const sliceBlend = clamp(previousSlice.sub(slice0), 0.0, 1.0).toVar();
109
- // NOTE The history counts less as the froxel moves: a quarter of a cell of motion in a frame uses only the
110
- // current froxel. A still camera moves no froxel, so the history still gathers the jittered samples.
111
- const motion = length(vec3(previousUv.sub(uv).mul(froxelGrid.xy), previousSlice.sub(slice)));
112
- const blend = mix(this.frameTemporalBlend, 1.0, clamp(motion.mul(4.0), 0.0, 1.0)).toVar();
113
- const histories = maps.map(([, historyMap]) => mix(sampleHistory(historyMap, slice0, previousUv), sampleHistory(historyMap, slice1, previousUv), sliceBlend));
114
- // NOTE Clamp the history to the current neighbors. This limits ghosting of moving volumes.
115
- const tileOrigin = tile.mul(froxelGrid.xy);
116
- const cellMax = froxelGrid.xy.sub(1.0);
117
- const neighborMins = currents.map((current) => vec4(current).toVar());
118
- const neighborMaxs = currents.map((current) => vec4(current).toVar());
119
- const addNeighbor = (texel) => {
120
- maps.forEach(([currentMap], index) => {
121
- const neighbor = loadCurrent(currentMap, texel).toVar();
122
- neighborMins[index].assign(min(neighborMins[index], neighbor));
123
- neighborMaxs[index].assign(max(neighborMaxs[index], neighbor));
124
- });
125
- };
126
- [
127
- vec2(max(cell.x.sub(1.0), 0.5), cell.y),
128
- vec2(min(cell.x.add(1.0), cellMax.x.add(0.5)), cell.y),
129
- vec2(cell.x, max(cell.y.sub(1.0), 0.5)),
130
- vec2(cell.x, min(cell.y.add(1.0), cellMax.y.add(0.5))),
131
- ].forEach((neighborCell) => {
132
- addNeighbor(tileOrigin.add(neighborCell));
133
- });
134
- [-1.0, 1.0].forEach((offset) => {
135
- const neighborSlice = slice.add(offset);
136
- If(neighborSlice.greaterThanEqual(0.0).and(neighborSlice.lessThan(froxelGrid.z)), () => {
137
- addNeighbor(getTileOrigin(neighborSlice).add(cell));
138
- });
139
- });
140
- resolved.forEach((value, index) => value.assign(mix(clamp(histories[index], neighborMins[index], neighborMaxs[index]), currents[index], blend)));
141
- });
142
- });
143
- });
144
- if (outputs) {
145
- outputs.forEach((output, index) => output.assign(resolved[index]));
146
- return vec4(0.0);
147
- }
148
- return resolved[0];
149
- })();
150
- }
151
- }
152
- //# sourceMappingURL=temporal-material.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"temporal-material.js","sourceRoot":"","sources":["../../../src/three/frame/temporal-material.ts"],"names":[],"mappings":"AAAA,0EAA0E;AAC1E,oGAAoG;AACpG,gFAAgF;AAChF,4GAA4G;AAC5G,0CAA0C;AAE1C;;;;;;;GAOG;AAEH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAC5C,OAAO,KAAK,GAAG,MAAM,WAAW,CAAC;AA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AC,EAAE,QAAQ,CAAC,KAAK,CAAC,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC;oBACnJ,CAAC,CAAC,CAAC;gBACL,CAAC,CAAC,CAAC;YACL,CAAC,CAAC,CAAC;YAEH,IAAI,OAAO,EAAE,CAAC;gBACZ,OAAO,CAAC,OAAO,CAAC,CAAC,MAAM,EAAE,KAAK,EAAE,EAAE,CAAC,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;gBAEnE,OAAO,IAAI,CAAC,GAAG,CAAC,CAAC;YACnB,CAAC;YAED,OAAO,QAAQ,CAAC,CAAC,CAAC,CAAC;QACrB,CAAC,CAAC,EAAE,CAAC;IACP,CAAC;CACF","sourcesContent":["// Portions derived from mjurczyk/openvdb (MIT), commit 75e7345 (v0.26.0):\n// src/three-openvdb/frame/webgpu/FrameTemporalMaterial.js L31–217 (K3.5: with the spectral second\n// atlas target: setSpectral, rebuildNodes, the [current, history] map pairs).\n// Copyright (c) mjurczyk/openvdb contributors. Licensed under the MIT License (see THIRD_PARTY_NOTICES.md).\n// Changes: TypeScript. Divergences: none.\n\n/**\n * The temporal pass (R1 §2 step 5): blends this frame's froxels with the previous frames', each\n * froxel centre reprojected into the previous froxel grid (bilinear in the slice, linear between\n * slices), the history clamped to the current froxel's 6 neighbours (less ghosting), and the history\n * weight dropping to 0 for a quarter cell of motion or more. CPU twin of the reprojection:\n * `@pmndrs/vdb/tools` `vdbFrameReproject`. Spectral (K3.5): both atlas targets are blended and\n * clamped with one reprojection.\n */\n\nimport * as THREE from \"three\";\nimport { NodeMaterial } from \"three/webgpu\";\nimport * as TSL from \"three/tsl\";\nimport type { VDBTslNode } from \"../grid-node.js\";\nimport { frameFragCoord, frameGetViewPosition, frameLoad, frameSample, frameSliceDepth, frameTileVertex, type FroxelUniforms, type TileUniforms } from \"./chunks.js\";\n\nconst { Fn, If, clamp, floor, ivec2, length, log, max, min, mix, mod, outputStruct, property, texture, uniform, vec2, vec3, vec4 } = TSL as unknown as Record<string, VDBTslNode>;\n\nexport interface VDBFrameTemporalMaterialOptions {\n froxelUniforms: FroxelUniforms;\n froxelTileUniforms: TileUniforms;\n froxelAreaUniforms: { frameAreaRect: VDBTslNode; frameAreaSliceStart: VDBTslNode };\n}\n\n// NOTE Blends the froxels of this frame with the reprojected froxels of the previous frames\nexport class VDBFrameTemporalMaterial extends NodeMaterial {\n readonly frameCurrentMap = texture(new THREE.Texture());\n readonly frameHistoryMap = texture(new THREE.Texture());\n // NOTE Renderer settings.spectral: second atlas target (red alpha, blue alpha, 0, green alpha)\n readonly frameCurrentAlphaMap = texture(new THREE.Texture());\n readonly frameHistoryAlphaMap = texture(new THREE.Texture());\n spectral = false;\n readonly frameUseHistory = uniform(0, \"int\");\n readonly frameTemporalBlend = uniform(0.1);\n readonly frameCameraMatrixWorld = uniform(new THREE.Matrix4());\n readonly framePreviousViewMatrix = uniform(new THREE.Matrix4());\n readonly framePreviousProjectionMatrix = uniform(new THREE.Matrix4());\n readonly framePreviousRange = uniform(new THREE.Vector2(0.1, 1.0));\n readonly froxelUniforms: FroxelUniforms;\n\n constructor(o: VDBFrameTemporalMaterialOptions) {\n super();\n\n this.name = \"VDBFrameTemporalMaterial\";\n this.froxelUniforms = o.froxelUniforms;\n\n // NOTE Only the froxel area of the volumes. The renderer clears the target first.\n this.vertexNode = frameTileVertex(o.froxelTileUniforms, o.froxelAreaUniforms.frameAreaRect, o.froxelAreaUniforms.frameAreaSliceStart);\n this.rebuildNodes();\n\n this.side = THREE.DoubleSide;\n this.forceSinglePass = true;\n this.depthTest = false;\n this.depthWrite = false;\n this.blending = THREE.NoBlending;\n }\n\n setSpectral(spectral: boolean): void {\n if (spectral !== this.spectral) {\n this.spectral = spectral;\n this.rebuildNodes();\n this.needsUpdate = true;\n }\n }\n\n // NOTE Spectral: both atlas targets are blended and clamped. They share one reprojection.\n rebuildNodes(): void {\n if (!this.spectral) {\n this.colorNode = null;\n this.outputNode = null;\n this.fragmentNode = this.createFragmentNode([[this.frameCurrentMap, this.frameHistoryMap]]);\n\n return;\n }\n\n const outputs = [property(\"vec4\"), property(\"vec4\")];\n\n this.fragmentNode = null;\n this.colorNode = this.createFragmentNode(\n [\n [this.frameCurrentMap, this.frameHistoryMap],\n [this.frameCurrentAlphaMap, this.frameHistoryAlphaMap],\n ],\n outputs,\n );\n this.outputNode = outputStruct(...outputs);\n }\n\n // NOTE maps: [current, history] pairs. outputs: property nodes for each pair, or null for one output.\n createFragmentNode(maps: [VDBTslNode, VDBTslNode][], outputs: VDBTslNode[] | null = null): VDBTslNode {\n const { froxelUniforms } = this;\n const { froxelGrid, froxelColumns, froxelAtlasSize } = froxelUniforms;\n\n const getTileOrigin = (slice: VDBTslNode) => vec2(mod(slice, froxelColumns), floor(slice.div(froxelColumns))).mul(froxelGrid.xy);\n\n // NOTE Bilinear filter in the slice. Half a cell inside the tile, then the filter does not read other tiles.\n const sampleHistory = (historyMap: VDBTslNode, slice: VDBTslNode, uv: VDBTslNode) => {\n const cell = clamp(uv.mul(froxelGrid.xy), vec2(0.5), froxelGrid.xy.sub(0.5));\n\n return frameSample(historyMap, getTileOrigin(slice).add(cell).div(froxelAtlasSize));\n };\n\n const loadCurrent = (currentMap: VDBTslNode, texel: VDBTslNode) => frameLoad(currentMap, ivec2(texel), froxelAtlasSize);\n\n return Fn(() => {\n const fragCoord = frameFragCoord(froxelAtlasSize).toVar();\n const currents = maps.map(([currentMap]) => loadCurrent(currentMap, fragCoord).toVar());\n const resolved = currents.map((current) => vec4(current).toVar());\n\n const tile = floor(fragCoord.div(froxelGrid.xy)).toVar();\n const slice = tile.y.mul(froxelColumns).add(tile.x).toVar();\n\n If(this.frameUseHistory.equal(1).and(slice.lessThan(froxelGrid.z)), () => {\n // NOTE Reproject the froxel center into the froxel grid of the previous frame\n const cell = fragCoord.sub(tile.mul(froxelGrid.xy)).toVar();\n const uv = cell.div(froxelGrid.xy);\n const viewDepth = frameSliceDepth(froxelUniforms, slice.add(0.5).div(froxelGrid.z));\n const worldPosition = this.frameCameraMatrixWorld.mul(vec4(frameGetViewPosition(froxelUniforms, uv, viewDepth), 1.0));\n const previousView = this.framePreviousViewMatrix.mul(worldPosition).toVar();\n const previousClip = this.framePreviousProjectionMatrix.mul(previousView).toVar();\n\n If(previousClip.w.greaterThan(0.0), () => {\n const previousUv = previousClip.xy.div(previousClip.w).mul(0.5).add(0.5).toVar();\n const previousRange = this.framePreviousRange;\n const previousT = log(max(previousView.z.negate(), 1e-6).div(previousRange.x)).div(log(previousRange.y.div(previousRange.x)));\n const previousSlice = previousT.mul(froxelGrid.z).sub(0.5).toVar();\n\n const inside = min(previousUv.x, previousUv.y)\n .greaterThanEqual(0.0)\n .and(max(previousUv.x, previousUv.y).lessThanEqual(1.0))\n .and(previousSlice.greaterThanEqual(-0.5))\n .and(previousSlice.lessThanEqual(froxelGrid.z.sub(0.5)));\n\n If(inside, () => {\n const slice0 = clamp(floor(previousSlice), 0.0, froxelGrid.z.sub(1.0)).toVar();\n const slice1 = min(slice0.add(1.0), froxelGrid.z.sub(1.0));\n const sliceBlend = clamp(previousSlice.sub(slice0), 0.0, 1.0).toVar();\n\n // NOTE The history counts less as the froxel moves: a quarter of a cell of motion in a frame uses only the\n // current froxel. A still camera moves no froxel, so the history still gathers the jittered samples.\n const motion = length(vec3(previousUv.sub(uv).mul(froxelGrid.xy), previousSlice.sub(slice)));\n const blend = mix(this.frameTemporalBlend, 1.0, clamp(motion.mul(4.0), 0.0, 1.0)).toVar();\n const histories = maps.map(([, historyMap]) => mix(sampleHistory(historyMap, slice0, previousUv), sampleHistory(historyMap, slice1, previousUv), sliceBlend));\n\n // NOTE Clamp the history to the current neighbors. This limits ghosting of moving volumes.\n const tileOrigin = tile.mul(froxelGrid.xy);\n const cellMax = froxelGrid.xy.sub(1.0);\n const neighborMins = currents.map((current) => vec4(current).toVar());\n const neighborMaxs = currents.map((current) => vec4(current).toVar());\n\n const addNeighbor = (texel: VDBTslNode) => {\n maps.forEach(([currentMap], index) => {\n const neighbor = loadCurrent(currentMap, texel).toVar();\n\n neighborMins[index]!.assign(min(neighborMins[index], neighbor));\n neighborMaxs[index]!.assign(max(neighborMaxs[index], neighbor));\n });\n };\n\n [\n vec2(max(cell.x.sub(1.0), 0.5), cell.y),\n vec2(min(cell.x.add(1.0), cellMax.x.add(0.5)), cell.y),\n vec2(cell.x, max(cell.y.sub(1.0), 0.5)),\n vec2(cell.x, min(cell.y.add(1.0), cellMax.y.add(0.5))),\n ].forEach((neighborCell) => {\n addNeighbor(tileOrigin.add(neighborCell));\n });\n\n [-1.0, 1.0].forEach((offset) => {\n const neighborSlice = slice.add(offset);\n\n If(neighborSlice.greaterThanEqual(0.0).and(neighborSlice.lessThan(froxelGrid.z)), () => {\n addNeighbor(getTileOrigin(neighborSlice).add(cell));\n });\n });\n\n resolved.forEach((value, index) => value.assign(mix(clamp(histories[index], neighborMins[index], neighborMaxs[index]), currents[index], blend)));\n });\n });\n });\n\n if (outputs) {\n outputs.forEach((output, index) => output.assign(resolved[index]));\n\n return vec4(0.0);\n }\n\n return resolved[0];\n })();\n }\n}\n"]}
@@ -1,31 +0,0 @@
1
- import { NodeMaterial } from "three/webgpu";
2
- import { type GridUniforms, type LightUniforms } from "./chunks.js";
3
- import type { VDBFrameNeuralNetwork } from "../../tools/frame/neural.js";
4
- export declare const frameShadowLightSlots = 6;
5
- export declare const frameNeuralMipLevels = 5;
6
- export interface VDBFrameTransmittanceMaterialOptions {
7
- gridUniforms: GridUniforms;
8
- lightUniforms: LightUniforms;
9
- }
10
- export declare class VDBFrameTransmittanceMaterial extends NodeMaterial {
11
- readonly frameShadowDensityMap: any;
12
- readonly frameShadowLightCount: any;
13
- readonly frameShadowLights: any;
14
- readonly frameMultipleScattering: any;
15
- readonly frameScatteringOctaves: any;
16
- readonly frameTwoSided: any;
17
- readonly frameShadowAbsorptionMap: any;
18
- readonly frameSpectralGroup: any;
19
- readonly frameNeuralMipMaps: any[];
20
- readonly frameNeuralMipLayouts: any[];
21
- readonly gridUniforms: GridUniforms;
22
- readonly lightUniforms: LightUniforms;
23
- /** The network compiled in (multipleScattering 'neural'), or null. */
24
- neural: VDBFrameNeuralNetwork | null;
25
- spectral: boolean;
26
- constructor(o: VDBFrameTransmittanceMaterialOptions);
27
- setNeural(neural: VDBFrameNeuralNetwork | null): void;
28
- setSpectral(spectral: boolean): void;
29
- buildNodes(): void;
30
- buildSpectralNodes(): void;
31
- }