@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,257 +0,0 @@
1
- // Portions derived from mjurczyk/openvdb (MIT), commit 75e7345 (v0.26.0):
2
- // src/three-openvdb/frame/webgpu/FrameLightingMaterial.js L43–119 (constructor, uniforms),
3
- // L277–437 (the grey `createFragmentNode`); K3.5: L55–62 (the spectral maps and groups), L86–112
4
- // (setSpectral, rebuildNodes), L114–275 (createSpectralFragmentNode).
5
- // Copyright (c) mjurczyk/openvdb contributors. Licensed under the MIT License (see THIRD_PARTY_NOTICES.md).
6
- // Changes: TypeScript; source-free. K3.4: the octave uniform (L71–72) and the octave light of lights
7
- // without a shadow slot (L386–397).
8
- // Divergences: DIVERGES.md (K3.3 rows).
9
- /**
10
- * The lighting pass of `'frame'` lighting (R1 §2 step 4): each froxel of the volumes' froxel area is
11
- * lit once from the combined density targets: ambient, light probe SH and hemisphere light with the
12
- * sky up / down transmittance, the scene lights (with a shadow slot: the density pass's
13
- * phase × direct + scattered; else unshadowed), and the dominant directional environment light in
14
- * its slot. Writes premultiplied (radiance × alpha, alpha) into the froxel atlas, as the inject pass.
15
- * Spectral (K3.5): the transmittance of each channel is sampled from the slot groups' targets at the
16
- * froxel's visible position (the density pass has no slots then); two atlas targets, (radiance × alpha
17
- * of each channel, green alpha) and (red alpha, blue alpha, 0, green alpha).
18
- */
19
- import * as THREE from "three";
20
- import { NodeMaterial } from "three/webgpu";
21
- import * as TSL from "three/tsl";
22
- import { createGridNodes, frameFragCoord, frameGetFroxel, frameLoad, framePhaseColor, frameShadowedLight, frameSpectralShadowTotal, frameSpectralShadowedLight, frameTileVertex, frameUnpackSpectralGroup } from "./chunks.js";
23
- import { frameSpectralGroupCount } from "./spectrum.js";
24
- const { Discard, Fn, If, Loop, clamp, dot, exp, float, getDistanceAttenuation, getShIrradianceAt, int, ivec2, length, mat3, max, mix, normalize, outputStruct, property, select, smoothstep, texture, uniform, vec2, vec3, vec4 } = TSL;
25
- // NOTE Lights each froxel one time from the combined data of all volumes.
26
- // NOTE The environment is added in the density pass, along the outward direction of each volume.
27
- export class VDBFrameLightingMaterial extends NodeMaterial {
28
- frameDensityAlbedoMap = texture(new THREE.Texture());
29
- frameDensityEmissionMap = texture(new THREE.Texture());
30
- frameDensityShadowMap0 = texture(new THREE.Texture());
31
- frameDensityShadowMap1 = texture(new THREE.Texture());
32
- frameShadowLightCount = uniform(0, "int");
33
- frameCameraMatrixWorld = uniform(new THREE.Matrix4());
34
- // NOTE One phase for all volumes, from the renderer settings
35
- framePhase = uniform(new THREE.Vector4());
36
- framePhaseSpectrum = uniform(new THREE.Vector3());
37
- // NOTE Scattering octaves of the renderer settings (phase.ts). Count 0 is off.
38
- frameScatteringOctaves = uniform(new THREE.Vector4());
39
- // NOTE Environment lights with a shadow slot (0 or 1). Light i has slot frameEnvironmentShadowSlot + i.
40
- frameEnvironmentLightCount = uniform(0, "int");
41
- frameEnvironmentShadowSlot = uniform(0, "int");
42
- frameUniforms;
43
- // NOTE Renderer settings.spectral: extinction of each channel (density target 2), and the 3 transmittance
44
- // targets of each slot group (spectrum.ts), in group order. Groups from frameSpectralGroups on are not read.
45
- frameDensityExtinctionMap = texture(new THREE.Texture());
46
- frameSpectralTransmittanceMaps = Array.from({ length: frameSpectralGroupCount * 3 }, () => texture(new THREE.Texture()));
47
- frameSpectralGroups = uniform(0, "int");
48
- // NOTE Renderer settings.spectral: two atlas targets
49
- spectral = false;
50
- constructor(o) {
51
- super();
52
- this.name = "VDBFrameLightingMaterial";
53
- this.frameUniforms = o;
54
- // NOTE Only the froxel area of the volumes. Other froxels have no density.
55
- this.vertexNode = frameTileVertex(o.froxelTileUniforms, o.froxelAreaUniforms.frameAreaRect, o.froxelAreaUniforms.frameAreaSliceStart);
56
- this.rebuildNodes();
57
- this.side = THREE.DoubleSide;
58
- this.forceSinglePass = true;
59
- this.depthTest = false;
60
- this.depthWrite = false;
61
- this.blending = THREE.NoBlending;
62
- }
63
- setSpectral(spectral) {
64
- if (spectral !== this.spectral) {
65
- this.spectral = spectral;
66
- this.rebuildNodes();
67
- this.needsUpdate = true;
68
- }
69
- }
70
- // NOTE Spectral: atlas target 0 is (color, green alpha), target 1 is (red alpha, blue alpha, 0, green alpha)
71
- rebuildNodes() {
72
- if (!this.spectral) {
73
- this.colorNode = null;
74
- this.outputNode = null;
75
- this.fragmentNode = this.createFragmentNode();
76
- return;
77
- }
78
- const lightingColor = property("vec4");
79
- const lightingAlpha = property("vec4");
80
- this.fragmentNode = null;
81
- this.colorNode = this.createSpectralFragmentNode({ color: lightingColor, alpha: lightingAlpha });
82
- this.outputNode = outputStruct(lightingColor, lightingAlpha);
83
- }
84
- // NOTE Spectral lighting. The density pass has no light slots, so the slots are sampled here,
85
- // at the extinction-weighted visible position of all volumes in the froxel. Albedo and extinction are of each channel.
86
- createSpectralFragmentNode(outputs) {
87
- const { froxelUniforms, lightUniforms, gridUniforms } = this.frameUniforms;
88
- const { frameAmbientColor, frameLightProbe, frameHemiSkyColor, frameHemiGroundColor, frameSkyDirection, frameLightCount, frameLightPositions, frameLightColors, frameLightSpots, frameLightFalloffs, frameEnvironmentColors } = lightUniforms;
89
- const grid = createGridNodes(gridUniforms);
90
- const atlasSize = froxelUniforms.froxelAtlasSize;
91
- const octaves = this.frameScatteringOctaves;
92
- return Fn(() => {
93
- const fragCoord = frameFragCoord(atlasSize).toVar();
94
- const texel = ivec2(fragCoord).toVar();
95
- const densityAlbedo = frameLoad(this.frameDensityAlbedoMap, texel, atlasSize).toVar();
96
- const weight = densityAlbedo.a.toVar();
97
- If(weight.lessThanEqual(0.0), () => {
98
- Discard();
99
- });
100
- const densityEmission = frameLoad(this.frameDensityEmissionMap, texel, atlasSize).toVar();
101
- const extinction = frameLoad(this.frameDensityExtinctionMap, texel, atlasSize).rgb.toVar();
102
- const froxel = frameGetFroxel(froxelUniforms, fragCoord);
103
- const viewNear = froxel.viewNear.toVar();
104
- const viewFar = froxel.viewFar.toVar();
105
- const visibleT = clamp(densityEmission.a.div(weight), 0.0, 1.0);
106
- const worldPosition = this.frameCameraMatrixWorld.mul(vec4(mix(viewNear, viewFar, visibleT), 1.0)).xyz.toVar();
107
- const rayDirection = normalize(mat3(this.frameCameraMatrixWorld).mul(viewFar.sub(viewNear))).toVar();
108
- const albedo = densityAlbedo.rgb.div(max(extinction, vec3(1e-8))).toVar();
109
- const emission = densityEmission.rgb.div(weight);
110
- // NOTE Transmittance targets of the slot groups in use. 1.0 outside the grid, with no shadows and for other groups.
111
- const maps = this.frameSpectralTransmittanceMaps.map(() => vec4(1.0).toVar());
112
- for (let group = 0; group < frameSpectralGroupCount; group++) {
113
- const groupMaps = this.frameSpectralTransmittanceMaps.slice(group * 3, group * 3 + 3);
114
- If(int(group).lessThan(this.frameSpectralGroups), () => {
115
- const shadows = grid.sampleShadows(groupMaps, worldPosition);
116
- shadows.forEach((shadow, index) => maps[group * 3 + index].assign(shadow));
117
- });
118
- }
119
- // NOTE Group 0: sky (up, down) and slot 0. Group g: slots 2g - 1 and 2g. Slot entries are (total, direct).
120
- const groups = Array.from({ length: frameSpectralGroupCount }, (_, group) => frameUnpackSpectralGroup(maps[group * 3], maps[group * 3 + 1], maps[group * 3 + 2]));
121
- const slotEntry = (slot) => (slot === 0 ? groups[0].b : slot % 2 === 1 ? groups[(slot + 1) / 2].a : groups[slot / 2].b);
122
- const skyDirection = normalize(frameSkyDirection).toVar();
123
- const skyUp = frameSpectralShadowTotal(groups[0].a.x, octaves, albedo).mul(0.5).toVar();
124
- const skyDown = frameSpectralShadowTotal(groups[0].a.y, octaves, albedo).mul(0.5).toVar();
125
- const irradiance = vec3(frameAmbientColor).toVar();
126
- irradiance.addAssign(getShIrradianceAt(skyDirection, frameLightProbe).mul(skyUp));
127
- irradiance.addAssign(getShIrradianceAt(skyDirection.negate(), frameLightProbe).mul(skyDown));
128
- irradiance.addAssign(frameHemiSkyColor.mul(skyUp));
129
- irradiance.addAssign(frameHemiGroundColor.mul(skyDown));
130
- const slots = Array.from({ length: 6 }, (_, slot) => ({
131
- total: slotEntry(slot).x.toVar(),
132
- direct: slotEntry(slot).y.toVar(),
133
- }));
134
- Loop(frameLightCount, ({ i }) => {
135
- const position = frameLightPositions.element(i).toVar();
136
- const color = frameLightColors.element(i).toVar();
137
- const spot = frameLightSpots.element(i).toVar();
138
- const falloff = frameLightFalloffs.element(i).toVar();
139
- const lightVector = position.xyz.sub(worldPosition).toVar();
140
- // NOTE A light with no shadow slot: no shadow (1.0), then octaves still add their light
141
- let total = vec3(1.0);
142
- let direct = vec3(1.0);
143
- slots.forEach((slot, index) => {
144
- const useSlot = i.equal(index).and(i.lessThan(this.frameShadowLightCount));
145
- total = select(useSlot, slot.total, total);
146
- direct = select(useSlot, slot.direct, direct);
147
- });
148
- const spotAttenuation = select(position.w.greaterThan(2.5), smoothstep(spot.w, color.w, dot(normalize(lightVector), spot.xyz)), float(1.0));
149
- const distanceAttenuation = select(position.w.greaterThan(1.5), getDistanceAttenuation({ lightDistance: length(lightVector), cutoffDistance: falloff.x, decayExponent: falloff.y }), float(1.0));
150
- // NOTE Directional position xyz is the direction to the light
151
- const light = frameSpectralShadowedLight(this.framePhase, this.framePhaseSpectrum, octaves, rayDirection, select(position.w.lessThan(1.5), position.xyz, normalize(lightVector)), { x: direct.toVar(), y: total.toVar() }, albedo);
152
- irradiance.addAssign(color.rgb.mul(light).mul(spotAttenuation).mul(distanceAttenuation));
153
- });
154
- // NOTE Dominant directional environment light with a shadow slot. Isotropic, no phase.
155
- Loop(this.frameEnvironmentLightCount, ({ i }) => {
156
- const slot = this.frameEnvironmentShadowSlot.add(i).toVar();
157
- let total = vec3(1.0);
158
- slots.forEach((value, index) => {
159
- total = select(slot.equal(index), value.total, total);
160
- });
161
- irradiance.addAssign(frameEnvironmentColors.element(i).mul(frameSpectralShadowTotal(total.toVar(), octaves, albedo)));
162
- });
163
- const radiance = albedo.mul(irradiance).mul(1.0 / Math.PI).add(emission);
164
- const alpha = vec3(1.0).sub(exp(extinction.negate().mul(length(viewFar.sub(viewNear))))).toVar();
165
- outputs.color.assign(vec4(radiance.mul(alpha), alpha.y));
166
- outputs.alpha.assign(vec4(alpha.x, alpha.z, 0.0, alpha.y));
167
- return vec4(0.0);
168
- })();
169
- }
170
- createFragmentNode() {
171
- const { froxelUniforms, lightUniforms, densityShadowUniforms, gridUniforms } = this.frameUniforms;
172
- const { frameAmbientColor, frameLightProbe, frameHemiSkyColor, frameHemiGroundColor, frameSkyDirection, frameLightCount, frameLightPositions, frameLightColors, frameLightSpots, frameLightFalloffs, frameEnvironmentColors } = lightUniforms;
173
- const grid = createGridNodes(gridUniforms);
174
- const atlasSize = froxelUniforms.froxelAtlasSize;
175
- return Fn(() => {
176
- const fragCoord = frameFragCoord(atlasSize).toVar();
177
- const texel = ivec2(fragCoord).toVar();
178
- const densityAlbedo = frameLoad(this.frameDensityAlbedoMap, texel, atlasSize).toVar();
179
- const extinction = densityAlbedo.a.toVar();
180
- If(extinction.lessThanEqual(0.0), () => {
181
- Discard();
182
- });
183
- const densityEmission = frameLoad(this.frameDensityEmissionMap, texel, atlasSize).toVar();
184
- const froxel = frameGetFroxel(froxelUniforms, fragCoord);
185
- const viewNear = froxel.viewNear.toVar();
186
- const viewFar = froxel.viewFar.toVar();
187
- // NOTE Spot light angles and light falloff use the extinction-weighted visible position of all volumes
188
- const visibleT = clamp(densityEmission.a.div(extinction), 0.0, 1.0);
189
- const worldPosition = this.frameCameraMatrixWorld.mul(vec4(mix(viewNear, viewFar, visibleT), 1.0)).xyz.toVar();
190
- const rayDirection = normalize(mat3(this.frameCameraMatrixWorld).mul(viewFar.sub(viewNear))).toVar();
191
- // NOTE Extinction-weighted mean transmittance. Each volume sampled its own visible position.
192
- const shadow0 = frameLoad(this.frameDensityShadowMap0, texel, atlasSize).div(extinction).toVar();
193
- const shadow1 = frameLoad(this.frameDensityShadowMap1, texel, atlasSize).div(extinction).toVar();
194
- const shadowSlots = [shadow0.z, shadow0.w, shadow1.x, shadow1.y, shadow1.z, shadow1.w];
195
- // NOTE Phases of each channel: slots hold the green phase. Direct transmittance from the shadow grid adds the red and blue difference.
196
- const colorPhase = this.framePhaseSpectrum.z.greaterThan(0.5).toVar();
197
- const direct0 = vec4(1.0).toVar();
198
- const direct1 = vec4(1.0).toVar();
199
- If(colorPhase.and(densityShadowUniforms.frameUseShadows.equal(1)), () => {
200
- const directs = grid.sampleShadows([densityShadowUniforms.frameTransmittanceMap2, densityShadowUniforms.frameTransmittanceMap3], worldPosition);
201
- direct0.assign(directs[0]);
202
- direct1.assign(directs[1]);
203
- });
204
- const directSlots = [direct0.x, direct0.y, direct0.z, direct0.w, direct1.x, direct1.y];
205
- const skyDirection = normalize(frameSkyDirection).toVar();
206
- const skyUp = shadow0.x.mul(0.5);
207
- const skyDown = shadow0.y.mul(0.5);
208
- const irradiance = vec3(frameAmbientColor).toVar();
209
- irradiance.addAssign(getShIrradianceAt(skyDirection, frameLightProbe).mul(skyUp));
210
- irradiance.addAssign(getShIrradianceAt(skyDirection.negate(), frameLightProbe).mul(skyDown));
211
- irradiance.addAssign(frameHemiSkyColor.mul(skyUp));
212
- irradiance.addAssign(frameHemiGroundColor.mul(skyDown));
213
- Loop(frameLightCount, ({ i }) => {
214
- const position = frameLightPositions.element(i).toVar();
215
- const color = frameLightColors.element(i).toVar();
216
- const spot = frameLightSpots.element(i).toVar();
217
- const falloff = frameLightFalloffs.element(i).toVar();
218
- const lightVector = position.xyz.sub(worldPosition).toVar();
219
- let shadow = float(1.0);
220
- let direct = float(1.0);
221
- shadowSlots.forEach((slot, index) => {
222
- shadow = select(i.equal(index), slot, shadow);
223
- direct = select(i.equal(index), directSlots[index], direct);
224
- });
225
- const spotAttenuation = select(position.w.greaterThan(2.5), smoothstep(spot.w, color.w, dot(normalize(lightVector), spot.xyz)), float(1.0));
226
- const distanceAttenuation = select(position.w.greaterThan(1.5), getDistanceAttenuation({ lightDistance: length(lightVector), cutoffDistance: falloff.x, decayExponent: falloff.y }), float(1.0));
227
- // NOTE Directional position xyz is the direction to the light
228
- const lightDirection = select(position.w.lessThan(1.5), position.xyz, normalize(lightVector)).toVar();
229
- const unshadowed = frameShadowedLight(this.framePhase, this.framePhaseSpectrum, this.frameScatteringOctaves, rayDirection, lightDirection, vec2(1.0));
230
- const hasSlot = i.lessThan(this.frameShadowLightCount).toVar();
231
- // NOTE A light with a shadow slot: the density pass stored phase * direct + scattered light.
232
- // A light with no shadow slot: no shadow, then octaves still add their light.
233
- const lightFactor = select(hasSlot, vec3(shadow), unshadowed).toVar();
234
- If(colorPhase.and(hasSlot), () => {
235
- const phase = framePhaseColor(this.framePhase, this.framePhaseSpectrum, rayDirection, lightDirection).toVar();
236
- lightFactor.addAssign(phase.sub(phase.g).mul(direct));
237
- });
238
- irradiance.addAssign(color.rgb.mul(lightFactor).mul(spotAttenuation).mul(distanceAttenuation));
239
- });
240
- // NOTE Dominant directional environment light with a shadow slot. Isotropic, no phase.
241
- Loop(this.frameEnvironmentLightCount, ({ i }) => {
242
- const slot = this.frameEnvironmentShadowSlot.add(i).toVar();
243
- let shadow = float(1.0);
244
- shadowSlots.forEach((value, index) => {
245
- shadow = select(slot.equal(index), value, shadow);
246
- });
247
- irradiance.addAssign(frameEnvironmentColors.element(i).mul(shadow));
248
- });
249
- const albedo = densityAlbedo.rgb.div(extinction);
250
- const emission = densityEmission.rgb.div(extinction);
251
- const radiance = albedo.mul(irradiance).mul(1.0 / Math.PI).add(emission);
252
- const alpha = float(1.0).sub(exp(extinction.negate().mul(length(viewFar.sub(viewNear)))));
253
- return vec4(radiance.mul(alpha), alpha);
254
- })();
255
- }
256
- }
257
- //# sourceMappingURL=lighting-material.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"lighting-material.js","sourceRoot":"","sources":["../../../src/three/frame/lighting-material.ts"],"names":[],"mappings":"AAAA,0EAA0E;AAC1E,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KAAK,CAAC,GAAG,CAAC,CAAC;gBAEpC,WAAW,CAAC,OAAO,CAAC,CAAC,KAAK,EAAE,KAAK,EAAE,EAAE;oBACnC,MAAM,GAAG,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,EAAE,KAAK,EAAE,MAAM,CAAC,CAAC;gBACpD,CAAC,CAAC,CAAC;gBAEH,UAAU,CAAC,SAAS,CAAC,sBAAsB,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC;YACtE,CAAC,CAAC,CAAC;YAEH,MAAM,MAAM,GAAG,aAAa,CAAC,GAAG,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC;YACjD,MAAM,QAAQ,GAAG,eAAe,CAAC,GAAG,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC;YACrD,MAAM,QAAQ,GAAG,MAAM,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC,GAAG,CAAC,GAAG,GAAG,IAAI,CAAC,EAAE,CAAC,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;YACzE,MAAM,KAAK,GAAG,KAAK,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,UAAU,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;YAE1F,OAAO,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE,KAAK,CAAC,CAAC;QAC1C,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/FrameLightingMaterial.js L43–119 (constructor, uniforms),\n// L277–437 (the grey `createFragmentNode`); K3.5: L55–62 (the spectral maps and groups), L86–112\n// (setSpectral, rebuildNodes), L114–275 (createSpectralFragmentNode).\n// Copyright (c) mjurczyk/openvdb contributors. Licensed under the MIT License (see THIRD_PARTY_NOTICES.md).\n// Changes: TypeScript; source-free. K3.4: the octave uniform (L71–72) and the octave light of lights\n// without a shadow slot (L386–397).\n// Divergences: DIVERGES.md (K3.3 rows).\n\n/**\n * The lighting pass of `'frame'` lighting (R1 §2 step 4): each froxel of the volumes' froxel area is\n * lit once from the combined density targets: ambient, light probe SH and hemisphere light with the\n * sky up / down transmittance, the scene lights (with a shadow slot: the density pass's\n * phase × direct + scattered; else unshadowed), and the dominant directional environment light in\n * its slot. Writes premultiplied (radiance × alpha, alpha) into the froxel atlas, as the inject pass.\n * Spectral (K3.5): the transmittance of each channel is sampled from the slot groups' targets at the\n * froxel's visible position (the density pass has no slots then); two atlas targets, (radiance × alpha\n * of each channel, green alpha) and (red alpha, blue alpha, 0, green alpha).\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 { createGridNodes, frameFragCoord, frameGetFroxel, frameLoad, framePhaseColor, frameShadowedLight, frameSpectralShadowTotal, frameSpectralShadowedLight, frameTileVertex, frameUnpackSpectralGroup, type FroxelUniforms, type GridUniforms, type LightUniforms, type TileUniforms } from \"./chunks.js\";\nimport type { DensityShadowUniforms } from \"./density-material.js\";\nimport { frameSpectralGroupCount } from \"./spectrum.js\";\n\nconst { Discard, Fn, If, Loop, clamp, dot, exp, float, getDistanceAttenuation, getShIrradianceAt, int, ivec2, length, mat3, max, mix, normalize, outputStruct, property, select, smoothstep, texture, uniform, vec2, vec3, vec4 } = TSL as unknown as Record<string, VDBTslNode>;\n\nexport interface VDBFrameLightingMaterialOptions {\n froxelUniforms: FroxelUniforms;\n froxelTileUniforms: TileUniforms;\n froxelAreaUniforms: { frameAreaRect: VDBTslNode; frameAreaSliceStart: VDBTslNode };\n lightUniforms: LightUniforms;\n gridUniforms: GridUniforms;\n densityShadowUniforms: DensityShadowUniforms;\n}\n\n// NOTE Lights each froxel one time from the combined data of all volumes.\n// NOTE The environment is added in the density pass, along the outward direction of each volume.\nexport class VDBFrameLightingMaterial extends NodeMaterial {\n readonly frameDensityAlbedoMap = texture(new THREE.Texture());\n readonly frameDensityEmissionMap = texture(new THREE.Texture());\n readonly frameDensityShadowMap0 = texture(new THREE.Texture());\n readonly frameDensityShadowMap1 = texture(new THREE.Texture());\n readonly frameShadowLightCount = uniform(0, \"int\");\n readonly frameCameraMatrixWorld = uniform(new THREE.Matrix4());\n // NOTE One phase for all volumes, from the renderer settings\n readonly framePhase = uniform(new THREE.Vector4());\n readonly framePhaseSpectrum = uniform(new THREE.Vector3());\n // NOTE Scattering octaves of the renderer settings (phase.ts). Count 0 is off.\n readonly frameScatteringOctaves = uniform(new THREE.Vector4());\n // NOTE Environment lights with a shadow slot (0 or 1). Light i has slot frameEnvironmentShadowSlot + i.\n readonly frameEnvironmentLightCount = uniform(0, \"int\");\n readonly frameEnvironmentShadowSlot = uniform(0, \"int\");\n readonly frameUniforms: VDBFrameLightingMaterialOptions;\n // NOTE Renderer settings.spectral: extinction of each channel (density target 2), and the 3 transmittance\n // targets of each slot group (spectrum.ts), in group order. Groups from frameSpectralGroups on are not read.\n readonly frameDensityExtinctionMap = texture(new THREE.Texture());\n readonly frameSpectralTransmittanceMaps = Array.from({ length: frameSpectralGroupCount * 3 }, () => texture(new THREE.Texture()));\n readonly frameSpectralGroups = uniform(0, \"int\");\n // NOTE Renderer settings.spectral: two atlas targets\n spectral = false;\n\n constructor(o: VDBFrameLightingMaterialOptions) {\n super();\n\n this.name = \"VDBFrameLightingMaterial\";\n this.frameUniforms = o;\n\n // NOTE Only the froxel area of the volumes. Other froxels have no density.\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: atlas target 0 is (color, green alpha), target 1 is (red alpha, blue alpha, 0, green alpha)\n rebuildNodes(): void {\n if (!this.spectral) {\n this.colorNode = null;\n this.outputNode = null;\n this.fragmentNode = this.createFragmentNode();\n\n return;\n }\n\n const lightingColor = property(\"vec4\");\n const lightingAlpha = property(\"vec4\");\n\n this.fragmentNode = null;\n this.colorNode = this.createSpectralFragmentNode({ color: lightingColor, alpha: lightingAlpha });\n this.outputNode = outputStruct(lightingColor, lightingAlpha);\n }\n\n // NOTE Spectral lighting. The density pass has no light slots, so the slots are sampled here,\n // at the extinction-weighted visible position of all volumes in the froxel. Albedo and extinction are of each channel.\n createSpectralFragmentNode(outputs: { color: VDBTslNode; alpha: VDBTslNode }): VDBTslNode {\n const { froxelUniforms, lightUniforms, gridUniforms } = this.frameUniforms;\n const { frameAmbientColor, frameLightProbe, frameHemiSkyColor, frameHemiGroundColor, frameSkyDirection, frameLightCount, frameLightPositions, frameLightColors, frameLightSpots, frameLightFalloffs, frameEnvironmentColors } = lightUniforms;\n const grid = createGridNodes(gridUniforms);\n const atlasSize = froxelUniforms.froxelAtlasSize;\n const octaves = this.frameScatteringOctaves;\n\n return Fn(() => {\n const fragCoord = frameFragCoord(atlasSize).toVar();\n const texel = ivec2(fragCoord).toVar();\n const densityAlbedo = frameLoad(this.frameDensityAlbedoMap, texel, atlasSize).toVar();\n const weight = densityAlbedo.a.toVar();\n\n If(weight.lessThanEqual(0.0), () => {\n Discard();\n });\n\n const densityEmission = frameLoad(this.frameDensityEmissionMap, texel, atlasSize).toVar();\n const extinction = frameLoad(this.frameDensityExtinctionMap, texel, atlasSize).rgb.toVar();\n const froxel = frameGetFroxel(froxelUniforms, fragCoord);\n const viewNear = froxel.viewNear.toVar();\n const viewFar = froxel.viewFar.toVar();\n\n const visibleT = clamp(densityEmission.a.div(weight), 0.0, 1.0);\n const worldPosition = this.frameCameraMatrixWorld.mul(vec4(mix(viewNear, viewFar, visibleT), 1.0)).xyz.toVar();\n const rayDirection = normalize(mat3(this.frameCameraMatrixWorld).mul(viewFar.sub(viewNear))).toVar();\n const albedo = densityAlbedo.rgb.div(max(extinction, vec3(1e-8))).toVar();\n const emission = densityEmission.rgb.div(weight);\n\n // NOTE Transmittance targets of the slot groups in use. 1.0 outside the grid, with no shadows and for other groups.\n const maps = this.frameSpectralTransmittanceMaps.map(() => vec4(1.0).toVar());\n\n for (let group = 0; group < frameSpectralGroupCount; group++) {\n const groupMaps = this.frameSpectralTransmittanceMaps.slice(group * 3, group * 3 + 3);\n\n If(int(group).lessThan(this.frameSpectralGroups), () => {\n const shadows = grid.sampleShadows(groupMaps, worldPosition);\n\n shadows.forEach((shadow, index) => maps[group * 3 + index]!.assign(shadow));\n });\n }\n\n // NOTE Group 0: sky (up, down) and slot 0. Group g: slots 2g - 1 and 2g. Slot entries are (total, direct).\n const groups = Array.from({ length: frameSpectralGroupCount }, (_, group) => frameUnpackSpectralGroup(maps[group * 3]!, maps[group * 3 + 1]!, maps[group * 3 + 2]!));\n const slotEntry = (slot: number) => (slot === 0 ? groups[0]!.b : slot % 2 === 1 ? groups[(slot + 1) / 2]!.a : groups[slot / 2]!.b);\n\n const skyDirection = normalize(frameSkyDirection).toVar();\n const skyUp = frameSpectralShadowTotal(groups[0]!.a.x, octaves, albedo).mul(0.5).toVar();\n const skyDown = frameSpectralShadowTotal(groups[0]!.a.y, octaves, albedo).mul(0.5).toVar();\n\n const irradiance = vec3(frameAmbientColor).toVar();\n\n irradiance.addAssign(getShIrradianceAt(skyDirection, frameLightProbe).mul(skyUp));\n irradiance.addAssign(getShIrradianceAt(skyDirection.negate(), frameLightProbe).mul(skyDown));\n irradiance.addAssign(frameHemiSkyColor.mul(skyUp));\n irradiance.addAssign(frameHemiGroundColor.mul(skyDown));\n\n const slots = Array.from({ length: 6 }, (_, slot) => ({\n total: slotEntry(slot).x.toVar(),\n direct: slotEntry(slot).y.toVar(),\n }));\n\n Loop(frameLightCount, ({ i }: { i: VDBTslNode }) => {\n const position = frameLightPositions.element(i).toVar();\n const color = frameLightColors.element(i).toVar();\n const spot = frameLightSpots.element(i).toVar();\n const falloff = frameLightFalloffs.element(i).toVar();\n const lightVector = position.xyz.sub(worldPosition).toVar();\n\n // NOTE A light with no shadow slot: no shadow (1.0), then octaves still add their light\n let total: VDBTslNode = vec3(1.0);\n let direct: VDBTslNode = vec3(1.0);\n\n slots.forEach((slot, index) => {\n const useSlot = i.equal(index).and(i.lessThan(this.frameShadowLightCount));\n\n total = select(useSlot, slot.total, total);\n direct = select(useSlot, slot.direct, direct);\n });\n\n const spotAttenuation = select(position.w.greaterThan(2.5), smoothstep(spot.w, color.w, dot(normalize(lightVector), spot.xyz)), float(1.0));\n\n const distanceAttenuation = select(\n position.w.greaterThan(1.5),\n getDistanceAttenuation({ lightDistance: length(lightVector), cutoffDistance: falloff.x, decayExponent: falloff.y }),\n float(1.0),\n );\n\n // NOTE Directional position xyz is the direction to the light\n const light = frameSpectralShadowedLight(\n this.framePhase,\n this.framePhaseSpectrum,\n octaves,\n rayDirection,\n select(position.w.lessThan(1.5), position.xyz, normalize(lightVector)),\n { x: direct.toVar(), y: total.toVar() },\n albedo,\n );\n\n irradiance.addAssign(color.rgb.mul(light).mul(spotAttenuation).mul(distanceAttenuation));\n });\n\n // NOTE Dominant directional environment light with a shadow slot. Isotropic, no phase.\n Loop(this.frameEnvironmentLightCount, ({ i }: { i: VDBTslNode }) => {\n const slot = this.frameEnvironmentShadowSlot.add(i).toVar();\n let total: VDBTslNode = vec3(1.0);\n\n slots.forEach((value, index) => {\n total = select(slot.equal(index), value.total, total);\n });\n\n irradiance.addAssign(frameEnvironmentColors.element(i).mul(frameSpectralShadowTotal(total.toVar(), octaves, albedo)));\n });\n\n const radiance = albedo.mul(irradiance).mul(1.0 / Math.PI).add(emission);\n const alpha = vec3(1.0).sub(exp(extinction.negate().mul(length(viewFar.sub(viewNear))))).toVar();\n\n outputs.color.assign(vec4(radiance.mul(alpha), alpha.y));\n outputs.alpha.assign(vec4(alpha.x, alpha.z, 0.0, alpha.y));\n\n return vec4(0.0);\n })();\n }\n\n createFragmentNode(): VDBTslNode {\n const { froxelUniforms, lightUniforms, densityShadowUniforms, gridUniforms } = this.frameUniforms;\n const { frameAmbientColor, frameLightProbe, frameHemiSkyColor, frameHemiGroundColor, frameSkyDirection, frameLightCount, frameLightPositions, frameLightColors, frameLightSpots, frameLightFalloffs, frameEnvironmentColors } = lightUniforms;\n const grid = createGridNodes(gridUniforms);\n const atlasSize = froxelUniforms.froxelAtlasSize;\n\n return Fn(() => {\n const fragCoord = frameFragCoord(atlasSize).toVar();\n const texel = ivec2(fragCoord).toVar();\n const densityAlbedo = frameLoad(this.frameDensityAlbedoMap, texel, atlasSize).toVar();\n const extinction = densityAlbedo.a.toVar();\n\n If(extinction.lessThanEqual(0.0), () => {\n Discard();\n });\n\n const densityEmission = frameLoad(this.frameDensityEmissionMap, texel, atlasSize).toVar();\n const froxel = frameGetFroxel(froxelUniforms, fragCoord);\n const viewNear = froxel.viewNear.toVar();\n const viewFar = froxel.viewFar.toVar();\n\n // NOTE Spot light angles and light falloff use the extinction-weighted visible position of all volumes\n const visibleT = clamp(densityEmission.a.div(extinction), 0.0, 1.0);\n const worldPosition = this.frameCameraMatrixWorld.mul(vec4(mix(viewNear, viewFar, visibleT), 1.0)).xyz.toVar();\n const rayDirection = normalize(mat3(this.frameCameraMatrixWorld).mul(viewFar.sub(viewNear))).toVar();\n\n // NOTE Extinction-weighted mean transmittance. Each volume sampled its own visible position.\n const shadow0 = frameLoad(this.frameDensityShadowMap0, texel, atlasSize).div(extinction).toVar();\n const shadow1 = frameLoad(this.frameDensityShadowMap1, texel, atlasSize).div(extinction).toVar();\n const shadowSlots = [shadow0.z, shadow0.w, shadow1.x, shadow1.y, shadow1.z, shadow1.w];\n\n // NOTE Phases of each channel: slots hold the green phase. Direct transmittance from the shadow grid adds the red and blue difference.\n const colorPhase = this.framePhaseSpectrum.z.greaterThan(0.5).toVar();\n const direct0 = vec4(1.0).toVar();\n const direct1 = vec4(1.0).toVar();\n\n If(colorPhase.and(densityShadowUniforms.frameUseShadows.equal(1)), () => {\n const directs = grid.sampleShadows([densityShadowUniforms.frameTransmittanceMap2, densityShadowUniforms.frameTransmittanceMap3], worldPosition);\n\n direct0.assign(directs[0]);\n direct1.assign(directs[1]);\n });\n\n const directSlots = [direct0.x, direct0.y, direct0.z, direct0.w, direct1.x, direct1.y];\n\n const skyDirection = normalize(frameSkyDirection).toVar();\n const skyUp = shadow0.x.mul(0.5);\n const skyDown = shadow0.y.mul(0.5);\n\n const irradiance = vec3(frameAmbientColor).toVar();\n\n irradiance.addAssign(getShIrradianceAt(skyDirection, frameLightProbe).mul(skyUp));\n irradiance.addAssign(getShIrradianceAt(skyDirection.negate(), frameLightProbe).mul(skyDown));\n irradiance.addAssign(frameHemiSkyColor.mul(skyUp));\n irradiance.addAssign(frameHemiGroundColor.mul(skyDown));\n\n Loop(frameLightCount, ({ i }: { i: VDBTslNode }) => {\n const position = frameLightPositions.element(i).toVar();\n const color = frameLightColors.element(i).toVar();\n const spot = frameLightSpots.element(i).toVar();\n const falloff = frameLightFalloffs.element(i).toVar();\n const lightVector = position.xyz.sub(worldPosition).toVar();\n\n let shadow: VDBTslNode = float(1.0);\n let direct: VDBTslNode = float(1.0);\n\n shadowSlots.forEach((slot, index) => {\n shadow = select(i.equal(index), slot, shadow);\n direct = select(i.equal(index), directSlots[index], direct);\n });\n\n const spotAttenuation = select(position.w.greaterThan(2.5), smoothstep(spot.w, color.w, dot(normalize(lightVector), spot.xyz)), float(1.0));\n\n const distanceAttenuation = select(\n position.w.greaterThan(1.5),\n getDistanceAttenuation({ lightDistance: length(lightVector), cutoffDistance: falloff.x, decayExponent: falloff.y }),\n float(1.0),\n );\n\n // NOTE Directional position xyz is the direction to the light\n const lightDirection = select(position.w.lessThan(1.5), position.xyz, normalize(lightVector)).toVar();\n const unshadowed = frameShadowedLight(this.framePhase, this.framePhaseSpectrum, this.frameScatteringOctaves, rayDirection, lightDirection, vec2(1.0));\n const hasSlot = i.lessThan(this.frameShadowLightCount).toVar();\n\n // NOTE A light with a shadow slot: the density pass stored phase * direct + scattered light.\n // A light with no shadow slot: no shadow, then octaves still add their light.\n const lightFactor = select(hasSlot, vec3(shadow), unshadowed).toVar();\n\n If(colorPhase.and(hasSlot), () => {\n const phase = framePhaseColor(this.framePhase, this.framePhaseSpectrum, rayDirection, lightDirection).toVar();\n\n lightFactor.addAssign(phase.sub(phase.g).mul(direct));\n });\n\n irradiance.addAssign(color.rgb.mul(lightFactor).mul(spotAttenuation).mul(distanceAttenuation));\n });\n\n // NOTE Dominant directional environment light with a shadow slot. Isotropic, no phase.\n Loop(this.frameEnvironmentLightCount, ({ i }: { i: VDBTslNode }) => {\n const slot = this.frameEnvironmentShadowSlot.add(i).toVar();\n let shadow: VDBTslNode = float(1.0);\n\n shadowSlots.forEach((value, index) => {\n shadow = select(slot.equal(index), value, shadow);\n });\n\n irradiance.addAssign(frameEnvironmentColors.element(i).mul(shadow));\n });\n\n const albedo = densityAlbedo.rgb.div(extinction);\n const emission = densityEmission.rgb.div(extinction);\n const radiance = albedo.mul(irradiance).mul(1.0 / Math.PI).add(emission);\n const alpha = float(1.0).sub(exp(extinction.negate().mul(length(viewFar.sub(viewNear)))));\n\n return vec4(radiance.mul(alpha), alpha);\n })();\n }\n}\n"]}
@@ -1,11 +0,0 @@
1
- /** Light types of the `VDBFrameVolume` `lights` bitmask (his `frameLights`). */
2
- export declare const vdbFrameLights: {
3
- readonly useAmbientLights: 32;
4
- readonly usePointLights: 16;
5
- readonly useDirectionalLights: 8;
6
- readonly useSpotLights: 4;
7
- readonly useHemisphereLights: 2;
8
- readonly useEnvironment: 1;
9
- };
10
- /** Every light type (his FrameVolume default `lights`). */
11
- export declare const vdbFrameAllLights: number;
@@ -1,16 +0,0 @@
1
- // Portions derived from mjurczyk/openvdb (MIT), commit 75e7345 (v0.26.0):
2
- // src/three-openvdb/frame/core/frameLights.js (all, 9 lines).
3
- // Copyright (c) mjurczyk/openvdb contributors. Licensed under the MIT License (see THIRD_PARTY_NOTICES.md).
4
- // Changes: TypeScript. Divergences: none.
5
- /** Light types of the `VDBFrameVolume` `lights` bitmask (his `frameLights`). */
6
- export const vdbFrameLights = {
7
- useAmbientLights: 0b100000,
8
- usePointLights: 0b010000,
9
- useDirectionalLights: 0b001000,
10
- useSpotLights: 0b000100,
11
- useHemisphereLights: 0b000010,
12
- useEnvironment: 0b000001,
13
- };
14
- /** Every light type (his FrameVolume default `lights`). */
15
- export const vdbFrameAllLights = Object.values(vdbFrameLights).reduce((mask, flag) => mask | flag, 0);
16
- //# sourceMappingURL=lights.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"lights.js","sourceRoot":"","sources":["../../../src/three/frame/lights.ts"],"names":[],"mappings":"AAAA,0EAA0E;AAC1E,gEAAgE;AAChE,4GAA4G;AAC5G,0CAA0C;AAE1C,gFAAgF;AAChF,MAAM,CAAC,MAAM,cAAc,GAAG;IAC5B,gBAAgB,EAAE,QAAQ;IAC1B,cAAc,EAAE,QAAQ;IACxB,oBAAoB,EAAE,QAAQ;IAC9B,aAAa,EAAE,QAAQ;IACvB,mBAAmB,EAAE,QAAQ;IAC7B,cAAc,EAAE,QAAQ;CAChB,CAAC;AAEX,2DAA2D;AAC3D,MAAM,CAAC,MAAM,iBAAiB,GAAG,MAAM,CAAC,MAAM,CAAC,cAAc,CAAC,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,IAAI,EAAE,EAAE,CAAC,IAAI,GAAG,IAAI,EAAE,CAAC,CAAC,CAAC","sourcesContent":["// Portions derived from mjurczyk/openvdb (MIT), commit 75e7345 (v0.26.0):\n// src/three-openvdb/frame/core/frameLights.js (all, 9 lines).\n// Copyright (c) mjurczyk/openvdb contributors. Licensed under the MIT License (see THIRD_PARTY_NOTICES.md).\n// Changes: TypeScript. Divergences: none.\n\n/** Light types of the `VDBFrameVolume` `lights` bitmask (his `frameLights`). */\nexport const vdbFrameLights = {\n useAmbientLights: 0b100000,\n usePointLights: 0b010000,\n useDirectionalLights: 0b001000,\n useSpotLights: 0b000100,\n useHemisphereLights: 0b000010,\n useEnvironment: 0b000001,\n} as const;\n\n/** Every light type (his FrameVolume default `lights`). */\nexport const vdbFrameAllLights = Object.values(vdbFrameLights).reduce((mask, flag) => mask | flag, 0);\n"]}
@@ -1,14 +0,0 @@
1
- import type { VDBTslNode } from "../grid-node.js";
2
- import { type VDBFrameNeuralNetwork } from "../../tools/frame/neural.js";
3
- import { type GridNodes, type GridUniforms } from "./chunks.js";
4
- type N = VDBTslNode;
5
- /**
6
- * Network nodes over the grid uniforms and nodes (createGridNodes), the grid atlas texture node, the mip
7
- * texture nodes (levels 1 and up) and their atlas layout uniforms (columns, width, height).
8
- */
9
- export declare const createNeuralNodes: (network: VDBFrameNeuralNetwork, gridUniforms: GridUniforms, grid: GridNodes, densityMap: N, mipMaps: N[], mipLayouts: N[]) => {
10
- getLocalInputs: (worldPosition: N) => [N, N];
11
- neuralLight: any;
12
- sampleLevel: (level: number, worldPosition: N) => N;
13
- };
14
- export {};
@@ -1,105 +0,0 @@
1
- // Portions derived from mjurczyk/openvdb (MIT), commit 75e7345 (v0.26.0):
2
- // src/three-openvdb/frame/webgpu/frameNeuralChunks.js L1–131 (all: weight layout, dense layers,
3
- // sampleLevel, getLocalInputs, neuralLight).
4
- // Copyright (c) mjurczyk/openvdb contributors. Licensed under the MIT License (see THIRD_PARTY_NOTICES.md).
5
- // Changes: TypeScript; the network (weights and sizes) is a parameter (VDBFrameNeuralNetwork) instead of
6
- // a module import, so the weights module can be swapped or left out. CPU twin: tools/frame/neural.ts.
7
- // Divergences: DIVERGES.md (K3.4 rows).
8
- /**
9
- * multipleScattering `'neural'` (K3.4): the scattered light of a shadow slot from a small network
10
- * (`@pmndrs/vdb/tools` `vdbFrameNeuralWeights`, his `scripts/neural-indirect`). Level 0 is the last
11
- * cascade of the grid atlas, levels 1 and up are the atlases of {@link VDBFrameGridMipMaterial}. Values
12
- * outside the last cascade are 0. The weights are constants in the shader (one WGSL function,
13
- * `frameNeuralLight`, called per slot).
14
- */
15
- import * as TSL from "three/tsl";
16
- import { vdbFrameNeuralLayout } from "../../tools/frame/neural.js";
17
- import { maxComponent, minComponent } from "./chunks.js";
18
- const { Fn, clamp, dot, exp, float, floor, log, max, min, select, sqrt, vec2, vec4 } = TSL;
19
- /**
20
- * Network nodes over the grid uniforms and nodes (createGridNodes), the grid atlas texture node, the mip
21
- * texture nodes (levels 1 and up) and their atlas layout uniforms (columns, width, height).
22
- */
23
- export const createNeuralNodes = (network, gridUniforms, grid, densityMap, mipMaps, mipLayouts) => {
24
- const { frameGridCount, frameGridVoxel, frameGridResolution } = gridUniforms;
25
- const layout = vdbFrameNeuralLayout(network);
26
- const levels = network.levels;
27
- const weights = network.weights;
28
- const weight = (index) => vec4(weights[index * 4], weights[index * 4 + 1], weights[index * 4 + 2], weights[index * 4 + 3]);
29
- const lastCascade = () => frameGridCount.sub(1);
30
- // NOTE Dense layer with ReLU. inputs: vec4 nodes. Weights are constants in the shader.
31
- const dense = (inputs, weightOffset, biasOffset) => {
32
- const outputs = [];
33
- for (let group = 0; group < layout.hiddenVectors; group++) {
34
- const bias = weight(biasOffset + group);
35
- const values = [0, 1, 2, 3].map((component) => {
36
- const row = weightOffset + (group * 4 + component) * inputs.length;
37
- return inputs.reduce((sum, input, i) => sum.add(dot(weight(row + i), input)), bias.element(component));
38
- });
39
- outputs.push(max(vec4(...values), vec4(0.0)).toVar());
40
- }
41
- return outputs;
42
- };
43
- // NOTE (extinction, absorption) of a level at a world position. Linear filter, edge texels clamped.
44
- const sampleLevel = (level, worldPosition) => {
45
- const cascade = lastCascade();
46
- const uvw = grid.gridUvw(cascade, worldPosition).toVar();
47
- const inside = minComponent(uvw).greaterThanEqual(0.0).and(maxComponent(uvw).lessThanEqual(1.0));
48
- let value;
49
- if (level === 0) {
50
- value = grid.sampleGrid(densityMap, cascade, uvw).rg;
51
- }
52
- else {
53
- const resolution = max(floor(frameGridResolution.div(2 ** level)), 1.0);
54
- const mipLayout = mipLayouts[level - 1];
55
- value = grid.sampleTiles(mipMaps[level - 1], resolution, float(0.0), mipLayout.x, mipLayout.yz, uvw).rg;
56
- }
57
- return select(inside, value, vec2(0.0));
58
- };
59
- const unit = () => maxComponent(frameGridVoxel.element(lastCascade()));
60
- // NOTE Inputs that do not depend on the light: (local 0 to 3), (local 4, local 5, albedo input, 0)
61
- const getLocalInputs = (worldPosition) => {
62
- const h = unit().toVar();
63
- const samples = Array.from({ length: levels }, (_, level) => sampleLevel(level, worldPosition).toVar());
64
- const local = samples.map((value, level) => log(value.x.mul(h.mul(2 ** level)).add(1.0)));
65
- // NOTE The albedo input uses the level 1 sample
66
- const albedoSample = samples[1];
67
- const albedoInput = select(albedoSample.x.greaterThan(0.0), sqrt(clamp(albedoSample.y.div(max(albedoSample.x, 1e-20)), 0.0, 1.0)), float(0.0));
68
- return [vec4(local[0], local[1], local[2], local[3]).toVar(), vec4(local[4], local[5], albedoInput, 0.0).toVar()];
69
- };
70
- // NOTE Scattered light (total - direct) for each unit of light. direction: unit direction to the light,
71
- // opticalDepth: direct optical depth of the slot march.
72
- const neuralLight = Fn(([worldPosition, direction, opticalDepth, local0, local1]) => {
73
- const h = unit().toVar();
74
- const toward = [];
75
- const away = [];
76
- for (let level = 0; level < levels; level++) {
77
- const length = h.mul(2 ** level).toVar();
78
- toward.push(log(sampleLevel(level, worldPosition.add(direction.mul(length))).x.mul(length).add(1.0)));
79
- away.push(log(sampleLevel(level, worldPosition.sub(direction.mul(length))).x.mul(length).add(1.0)));
80
- }
81
- const inputs = [
82
- local0,
83
- vec4(local1.x, local1.y, toward[0], toward[1]),
84
- vec4(toward[2], toward[3], toward[4], toward[5]),
85
- vec4(away[0], away[1], away[2], away[3]),
86
- vec4(away[4], away[5], log(opticalDepth.add(1.0)), local1.z),
87
- ].map((input) => input.toVar());
88
- const hidden1 = dense(inputs, layout.w1, layout.b1);
89
- const hidden2 = dense(hidden1, layout.w2, layout.b2);
90
- const output = hidden2.reduce((sum, value, i) => sum.add(dot(weight(layout.w3 + i), value)), weight(layout.b3).x);
91
- return exp(min(output, 4.0));
92
- }).setLayout({
93
- name: "frameNeuralLight",
94
- type: "float",
95
- inputs: [
96
- { name: "worldPosition", type: "vec3" },
97
- { name: "direction", type: "vec3" },
98
- { name: "opticalDepth", type: "float" },
99
- { name: "local0", type: "vec4" },
100
- { name: "local1", type: "vec4" },
101
- ],
102
- });
103
- return { getLocalInputs, neuralLight, sampleLevel };
104
- };
105
- //# sourceMappingURL=neural.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"neural.js","sourceRoot":"","sources":["../../../src/three/frame/neural.ts"],"names":[],"mappings":"AAAA,0EAA0E;AAC1E,kGAAkG;AAClG,+CAA+C;AAC/C,4GAA4G;AAC5G,yGAAyG;AACzG,sGAAsG;AACtG,wCAAwC;AAExC;;;;;;GAMG;AAEH,OAAO,KAAK,GAAG,MAAM,WAAW,CAAC;AAEjC,OAAO,EAAE,oBAAoB,EAA8B,MAAM,6BAA6B,CAAC;AAC/F,OAAO,EAAE,YAAY,EAAE,YAAY,EAAqC,MAAM,aAAa,CAAC;AAE5F,MAAM,EAAE,EAAE,EAAE,KAAK,EAAE,GAAG,EAAE,GAAG,EAAE,KAAK,EAAE,KAAK,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,GAAG,GAA4C,CAAC;AAIpI;;;GAGG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAAC,OAA8B,EAAE,YAA0B,EAAE,IAAe,EAAE,UAAa,EAAE,OAAY,EAAE,UAAe,EAAE,EAAE;IAC7J,MAAM,EAAE,cAAc,EAAE,cAAc,EAAE,mBAAmB,EAAE,GAAG,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AAC;QACX,IAAI,EAAE,kBAAkB;QACxB,IAAI,EAAE,OAAO;QACb,MAAM,EAAE;YACN,EAAE,IAAI,EAAE,eAAe,EAAE,IAAI,EAAE,MAAM,EAAE;YACvC,EAAE,IAAI,EAAE,WAAW,EAAE,IAAI,EAAE,MAAM,EAAE;YACnC,EAAE,IAAI,EAAE,cAAc,EAAE,IAAI,EAAE,OAAO,EAAE;YACvC,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,EAAE;YAChC,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,EAAE;SACjC;KACF,CAAC,CAAC;IAEH,OAAO,EAAE,cAAc,EAAE,WAAW,EAAE,WAAW,EAAE,CAAC;AACtD,CAAC,CAAC","sourcesContent":["// Portions derived from mjurczyk/openvdb (MIT), commit 75e7345 (v0.26.0):\n// src/three-openvdb/frame/webgpu/frameNeuralChunks.js L1–131 (all: weight layout, dense layers,\n// sampleLevel, getLocalInputs, neuralLight).\n// Copyright (c) mjurczyk/openvdb contributors. Licensed under the MIT License (see THIRD_PARTY_NOTICES.md).\n// Changes: TypeScript; the network (weights and sizes) is a parameter (VDBFrameNeuralNetwork) instead of\n// a module import, so the weights module can be swapped or left out. CPU twin: tools/frame/neural.ts.\n// Divergences: DIVERGES.md (K3.4 rows).\n\n/**\n * multipleScattering `'neural'` (K3.4): the scattered light of a shadow slot from a small network\n * (`@pmndrs/vdb/tools` `vdbFrameNeuralWeights`, his `scripts/neural-indirect`). Level 0 is the last\n * cascade of the grid atlas, levels 1 and up are the atlases of {@link VDBFrameGridMipMaterial}. Values\n * outside the last cascade are 0. The weights are constants in the shader (one WGSL function,\n * `frameNeuralLight`, called per slot).\n */\n\nimport * as TSL from \"three/tsl\";\nimport type { VDBTslNode } from \"../grid-node.js\";\nimport { vdbFrameNeuralLayout, type VDBFrameNeuralNetwork } from \"../../tools/frame/neural.js\";\nimport { maxComponent, minComponent, type GridNodes, type GridUniforms } from \"./chunks.js\";\n\nconst { Fn, clamp, dot, exp, float, floor, log, max, min, select, sqrt, vec2, vec4 } = TSL as unknown as Record<string, VDBTslNode>;\n\ntype N = VDBTslNode;\n\n/**\n * Network nodes over the grid uniforms and nodes (createGridNodes), the grid atlas texture node, the mip\n * texture nodes (levels 1 and up) and their atlas layout uniforms (columns, width, height).\n */\nexport const createNeuralNodes = (network: VDBFrameNeuralNetwork, gridUniforms: GridUniforms, grid: GridNodes, densityMap: N, mipMaps: N[], mipLayouts: N[]) => {\n const { frameGridCount, frameGridVoxel, frameGridResolution } = gridUniforms;\n const layout = vdbFrameNeuralLayout(network);\n const levels = network.levels;\n const weights = network.weights;\n const weight = (index: number): N => vec4(weights[index * 4]!, weights[index * 4 + 1]!, weights[index * 4 + 2]!, weights[index * 4 + 3]!);\n const lastCascade = () => frameGridCount.sub(1);\n\n // NOTE Dense layer with ReLU. inputs: vec4 nodes. Weights are constants in the shader.\n const dense = (inputs: N[], weightOffset: number, biasOffset: number): N[] => {\n const outputs: N[] = [];\n\n for (let group = 0; group < layout.hiddenVectors; group++) {\n const bias = weight(biasOffset + group);\n const values = [0, 1, 2, 3].map((component) => {\n const row = weightOffset + (group * 4 + component) * inputs.length;\n\n return inputs.reduce((sum: N, input, i) => sum.add(dot(weight(row + i), input)), bias.element(component));\n });\n\n outputs.push(max(vec4(...values), vec4(0.0)).toVar());\n }\n\n return outputs;\n };\n\n // NOTE (extinction, absorption) of a level at a world position. Linear filter, edge texels clamped.\n const sampleLevel = (level: number, worldPosition: N): N => {\n const cascade = lastCascade();\n const uvw = grid.gridUvw(cascade, worldPosition).toVar();\n const inside = minComponent(uvw).greaterThanEqual(0.0).and(maxComponent(uvw).lessThanEqual(1.0));\n let value: N;\n\n if (level === 0) {\n value = grid.sampleGrid(densityMap, cascade, uvw).rg;\n } else {\n const resolution = max(floor(frameGridResolution.div(2 ** level)), 1.0);\n const mipLayout = mipLayouts[level - 1]!;\n\n value = grid.sampleTiles(mipMaps[level - 1], resolution, float(0.0), mipLayout.x, mipLayout.yz, uvw).rg;\n }\n\n return select(inside, value, vec2(0.0));\n };\n\n const unit = () => maxComponent(frameGridVoxel.element(lastCascade()));\n\n // NOTE Inputs that do not depend on the light: (local 0 to 3), (local 4, local 5, albedo input, 0)\n const getLocalInputs = (worldPosition: N): [N, N] => {\n const h = unit().toVar();\n const samples = Array.from({ length: levels }, (_, level) => sampleLevel(level, worldPosition).toVar());\n const local = samples.map((value, level) => log(value.x.mul(h.mul(2 ** level)).add(1.0)));\n // NOTE The albedo input uses the level 1 sample\n const albedoSample = samples[1]!;\n const albedoInput = select(albedoSample.x.greaterThan(0.0), sqrt(clamp(albedoSample.y.div(max(albedoSample.x, 1e-20)), 0.0, 1.0)), float(0.0));\n\n return [vec4(local[0], local[1], local[2], local[3]).toVar(), vec4(local[4], local[5], albedoInput, 0.0).toVar()];\n };\n\n // NOTE Scattered light (total - direct) for each unit of light. direction: unit direction to the light,\n // opticalDepth: direct optical depth of the slot march.\n const neuralLight = Fn(([worldPosition, direction, opticalDepth, local0, local1]: N[]) => {\n const h = unit().toVar();\n const toward: N[] = [];\n const away: N[] = [];\n\n for (let level = 0; level < levels; level++) {\n const length = h.mul(2 ** level).toVar();\n\n toward.push(log(sampleLevel(level, worldPosition!.add(direction!.mul(length))).x.mul(length).add(1.0)));\n away.push(log(sampleLevel(level, worldPosition!.sub(direction!.mul(length))).x.mul(length).add(1.0)));\n }\n\n const inputs = [\n local0,\n vec4(local1!.x, local1!.y, toward[0], toward[1]),\n vec4(toward[2], toward[3], toward[4], toward[5]),\n vec4(away[0], away[1], away[2], away[3]),\n vec4(away[4], away[5], log(opticalDepth!.add(1.0)), local1!.z),\n ].map((input) => input!.toVar());\n\n const hidden1 = dense(inputs, layout.w1, layout.b1);\n const hidden2 = dense(hidden1, layout.w2, layout.b2);\n const output = hidden2.reduce((sum: N, value, i) => sum.add(dot(weight(layout.w3 + i), value)), weight(layout.b3).x);\n\n return exp(min(output, 4.0));\n }).setLayout({\n name: \"frameNeuralLight\",\n type: \"float\",\n inputs: [\n { name: \"worldPosition\", type: \"vec3\" },\n { name: \"direction\", type: \"vec3\" },\n { name: \"opticalDepth\", type: \"float\" },\n { name: \"local0\", type: \"vec4\" },\n { name: \"local1\", type: \"vec4\" },\n ],\n });\n\n return { getLocalInputs, neuralLight, sampleLevel };\n};\n"]}
@@ -1,44 +0,0 @@
1
- import type { Vector3, Vector4 } from "three";
2
- import { vdbFrameMieTexels } from "../../tools/frame/mie.js";
3
- import { type VDBFrameOctaveSettings } from "../../tools/frame/index.js";
4
- /** Phase functions of a volume (his `phase` prop). */
5
- export type VDBFramePhase = "isotropic" | "henyey-greenstein" | "dual-lobe" | "lorenz-mie" | "lorenz-mie-rgb";
6
- /** Multiple scattering modes (his `frameRenderer.settings.multipleScattering`). */
7
- export type VDBFrameMultipleScattering = boolean | "two-sided" | "octaves" | "neural";
8
- export interface VDBFramePhaseSource {
9
- phase: VDBFramePhase;
10
- phaseG: number;
11
- phaseBackG: number;
12
- phaseBackWeight: number;
13
- phaseGExponent: number;
14
- }
15
- /** Lorenz-Mie mode of 'lorenz-mie-rgb' in the phase vector. */
16
- export declare const frameMieRgbMode = 2;
17
- /** Asymmetry g of the Lorenz-Mie table. */
18
- export declare const frameMieAsymmetry = 0.8526;
19
- /**
20
- * Texels of the Lorenz-Mie texture: the 'lorenz-mie-rgb' tables in red, green, blue and the
21
- * 'lorenz-mie' table in alpha (one texture keeps the texture count of the shaders below 16).
22
- */
23
- export declare const getFrameMieTexels: typeof vdbFrameMieTexels;
24
- /**
25
- * Writes (forward g, back g, back weight, Lorenz-Mie mode) to target. Isotropic is (0, 0, 0, 0).
26
- * Lorenz-Mie mode: 0 off, 1 the 550 nm table, 2 the red, green and blue tables (frameMieRgbMode).
27
- */
28
- export declare const getFramePhase: (source: VDBFramePhaseSource, target: Vector4) => Vector4;
29
- /** Writes (red g scale, blue g scale, flag) to target; flag 1 when the channels have other phases. */
30
- export declare const getFramePhaseSpectrum: (source: VDBFramePhaseSource, target: Vector3) => Vector3;
31
- /** Asymmetry g (mean cosine of the scattering angle) of the phase of source. */
32
- export declare const getFramePhaseAsymmetry: (source: VDBFramePhaseSource) => number;
33
- /** Modes with the diffusion approximation: true (1D), 'two-sided' (2D) and 'neural'. */
34
- export declare const isFrameDiffusion: (mode: VDBFrameMultipleScattering) => mode is true | "two-sided" | "neural";
35
- /** 1.0 for multipleScattering 'two-sided'. */
36
- export declare const getFrameTwoSidedDiffusion: (mode: VDBFrameMultipleScattering) => 1 | 0;
37
- /** Multiple scattering value of the shadow marches: 1 − g for the diffusion modes, else 0. */
38
- export declare const getFrameMultipleScattering: (mode: VDBFrameMultipleScattering, source: VDBFramePhaseSource) => number;
39
- export declare const frameMaxScatteringOctaves = 8;
40
- /**
41
- * Indirect light octaves of multipleScattering 'octaves': writes (count N, extinction a, contribution b,
42
- * phase c) to target. Octave n (1 to N) has extinction × aⁿ, light × bⁿ and phase g × cⁿ. Count 0 is off.
43
- */
44
- export declare const getFrameScatteringOctaves: (settings: VDBFrameOctaveSettings, target: Vector4) => Vector4;