@pmndrs/vdb 0.0.0-stage → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (570) hide show
  1. package/CHANGELOG.md +727 -0
  2. package/LICENSE +21 -0
  3. package/README.md +496 -2
  4. package/THIRD_PARTY_NOTICES.md +315 -0
  5. package/dist/core/compute/atlas.d.ts +102 -0
  6. package/dist/core/compute/atlas.js +103 -0
  7. package/dist/core/compute/atlas.js.map +1 -0
  8. package/dist/core/compute/index.d.ts +13 -0
  9. package/dist/core/compute/index.js +9 -0
  10. package/dist/core/compute/index.js.map +1 -0
  11. package/dist/core/compute/majorant-build.d.ts +45 -0
  12. package/dist/core/compute/majorant-build.js +193 -0
  13. package/dist/core/compute/majorant-build.js.map +1 -0
  14. package/dist/core/compute/multi-scale.d.ts +155 -0
  15. package/dist/core/compute/multi-scale.js +684 -0
  16. package/dist/core/compute/multi-scale.js.map +1 -0
  17. package/dist/core/compute/pyramid.d.ts +120 -0
  18. package/dist/core/compute/pyramid.js +468 -0
  19. package/dist/core/compute/pyramid.js.map +1 -0
  20. package/dist/core/compute/shared.d.ts +116 -0
  21. package/dist/core/compute/shared.js +211 -0
  22. package/dist/core/compute/shared.js.map +1 -0
  23. package/dist/core/compute/stats.d.ts +78 -0
  24. package/dist/core/compute/stats.js +193 -0
  25. package/dist/core/compute/stats.js.map +1 -0
  26. package/dist/core/compute/value-transform.d.ts +30 -0
  27. package/dist/core/compute/value-transform.js +64 -0
  28. package/dist/core/compute/value-transform.js.map +1 -0
  29. package/dist/core/errors.d.ts +21 -0
  30. package/dist/core/errors.js +17 -0
  31. package/dist/core/errors.js.map +1 -0
  32. package/dist/core/frame/emission.d.ts +85 -0
  33. package/dist/core/frame/emission.js +422 -0
  34. package/dist/core/frame/emission.js.map +1 -0
  35. package/dist/core/frame/environment.d.ts +47 -0
  36. package/dist/core/frame/environment.js +178 -0
  37. package/dist/core/frame/environment.js.map +1 -0
  38. package/dist/core/frame/index.d.ts +39 -0
  39. package/dist/core/frame/index.js +27 -0
  40. package/dist/core/frame/index.js.map +1 -0
  41. package/dist/core/frame/kernels.d.ts +115 -0
  42. package/dist/core/frame/kernels.js +496 -0
  43. package/dist/core/frame/kernels.js.map +1 -0
  44. package/dist/core/frame/limits.d.ts +67 -0
  45. package/dist/core/frame/limits.js +109 -0
  46. package/dist/core/frame/limits.js.map +1 -0
  47. package/dist/core/frame/phase.d.ts +17 -0
  48. package/dist/core/frame/phase.js +53 -0
  49. package/dist/core/frame/phase.js.map +1 -0
  50. package/dist/core/frame/pipelines.d.ts +49 -0
  51. package/dist/core/frame/pipelines.js +147 -0
  52. package/dist/core/frame/pipelines.js.map +1 -0
  53. package/dist/core/frame/renderer.d.ts +122 -0
  54. package/dist/core/frame/renderer.js +1712 -0
  55. package/dist/core/frame/renderer.js.map +1 -0
  56. package/dist/core/frame/resources.d.ts +71 -0
  57. package/dist/core/frame/resources.js +100 -0
  58. package/dist/core/frame/resources.js.map +1 -0
  59. package/dist/core/frame/scattering.d.ts +97 -0
  60. package/dist/core/frame/scattering.js +332 -0
  61. package/dist/core/frame/scattering.js.map +1 -0
  62. package/dist/core/frame/settings.d.ts +243 -0
  63. package/dist/core/frame/settings.js +67 -0
  64. package/dist/core/frame/settings.js.map +1 -0
  65. package/dist/core/frame/shadows.d.ts +55 -0
  66. package/dist/core/frame/shadows.js +460 -0
  67. package/dist/core/frame/shadows.js.map +1 -0
  68. package/dist/core/frame/types.d.ts +415 -0
  69. package/dist/core/frame/types.js +49 -0
  70. package/dist/core/frame/types.js.map +1 -0
  71. package/dist/core/frame/uniforms.d.ts +105 -0
  72. package/dist/core/frame/uniforms.js +276 -0
  73. package/dist/core/frame/uniforms.js.map +1 -0
  74. package/dist/core/frame/wgsl/chunks.d.ts +4 -0
  75. package/dist/core/frame/wgsl/chunks.js +728 -0
  76. package/dist/core/frame/wgsl/chunks.js.map +1 -0
  77. package/dist/core/frame/wgsl/emission.d.ts +82 -0
  78. package/dist/core/frame/wgsl/emission.js +353 -0
  79. package/dist/core/frame/wgsl/emission.js.map +1 -0
  80. package/dist/core/frame/wgsl/environment.d.ts +42 -0
  81. package/dist/core/frame/wgsl/environment.js +711 -0
  82. package/dist/core/frame/wgsl/environment.js.map +1 -0
  83. package/dist/core/frame/wgsl/gather.d.ts +55 -0
  84. package/dist/core/frame/wgsl/gather.js +850 -0
  85. package/dist/core/frame/wgsl/gather.js.map +1 -0
  86. package/dist/core/frame/wgsl/integrate.d.ts +78 -0
  87. package/dist/core/frame/wgsl/integrate.js +213 -0
  88. package/dist/core/frame/wgsl/integrate.js.map +1 -0
  89. package/dist/core/frame/wgsl/lighting.d.ts +103 -0
  90. package/dist/core/frame/wgsl/lighting.js +1636 -0
  91. package/dist/core/frame/wgsl/lighting.js.map +1 -0
  92. package/dist/core/frame/wgsl/occluders.d.ts +20 -0
  93. package/dist/core/frame/wgsl/occluders.js +95 -0
  94. package/dist/core/frame/wgsl/occluders.js.map +1 -0
  95. package/dist/core/frame/wgsl/resolve.d.ts +19 -0
  96. package/dist/core/frame/wgsl/resolve.js +205 -0
  97. package/dist/core/frame/wgsl/resolve.js.map +1 -0
  98. package/dist/core/frame/wgsl/shadows.d.ts +35 -0
  99. package/dist/core/frame/wgsl/shadows.js +328 -0
  100. package/dist/core/frame/wgsl/shadows.js.map +1 -0
  101. package/dist/core/half.d.ts +11 -0
  102. package/dist/core/half.js +22 -0
  103. package/dist/core/half.js.map +1 -0
  104. package/dist/core/index.d.ts +52 -0
  105. package/dist/core/index.js +46 -0
  106. package/dist/core/index.js.map +1 -0
  107. package/dist/core/internal.d.ts +31 -0
  108. package/dist/core/internal.js +32 -0
  109. package/dist/core/internal.js.map +1 -0
  110. package/dist/core/pool/affine.d.ts +34 -0
  111. package/dist/core/pool/affine.js +100 -0
  112. package/dist/core/pool/affine.js.map +1 -0
  113. package/dist/core/pool/allocator.d.ts +32 -0
  114. package/dist/core/pool/allocator.js +81 -0
  115. package/dist/core/pool/allocator.js.map +1 -0
  116. package/dist/core/pool/image-header.d.ts +93 -0
  117. package/dist/core/pool/image-header.js +194 -0
  118. package/dist/core/pool/image-header.js.map +1 -0
  119. package/dist/core/pool/layout.d.ts +198 -0
  120. package/dist/core/pool/layout.js +316 -0
  121. package/dist/core/pool/layout.js.map +1 -0
  122. package/dist/core/pool/limits.d.ts +41 -0
  123. package/dist/core/pool/limits.js +80 -0
  124. package/dist/core/pool/limits.js.map +1 -0
  125. package/dist/core/pool/pool.d.ts +384 -0
  126. package/dist/core/pool/pool.js +1184 -0
  127. package/dist/core/pool/pool.js.map +1 -0
  128. package/dist/core/reference/index.d.ts +6 -0
  129. package/dist/core/reference/index.js +7 -0
  130. package/dist/core/reference/index.js.map +1 -0
  131. package/dist/core/reference/renderer.d.ts +105 -0
  132. package/dist/core/reference/renderer.js +474 -0
  133. package/dist/core/reference/renderer.js.map +1 -0
  134. package/dist/core/reference/wgsl.d.ts +65 -0
  135. package/dist/core/reference/wgsl.js +803 -0
  136. package/dist/core/reference/wgsl.js.map +1 -0
  137. package/dist/core/sequence.d.ts +347 -0
  138. package/dist/core/sequence.js +548 -0
  139. package/dist/core/sequence.js.map +1 -0
  140. package/dist/core/source/brick-cache.d.ts +165 -0
  141. package/dist/core/source/brick-cache.js +627 -0
  142. package/dist/core/source/brick-cache.js.map +1 -0
  143. package/dist/core/source/dense-fill.d.ts +53 -0
  144. package/dist/core/source/dense-fill.js +377 -0
  145. package/dist/core/source/dense-fill.js.map +1 -0
  146. package/dist/core/source/dense.d.ts +50 -0
  147. package/dist/core/source/dense.js +384 -0
  148. package/dist/core/source/dense.js.map +1 -0
  149. package/dist/core/source/sparse-wgsl.d.ts +92 -0
  150. package/dist/core/source/sparse-wgsl.js +481 -0
  151. package/dist/core/source/sparse-wgsl.js.map +1 -0
  152. package/dist/core/source/sparse.d.ts +192 -0
  153. package/dist/core/source/sparse.js +762 -0
  154. package/dist/core/source/sparse.js.map +1 -0
  155. package/dist/core/source/types.d.ts +120 -0
  156. package/dist/core/source/types.js +9 -0
  157. package/dist/core/source/types.js.map +1 -0
  158. package/dist/core/surface/index.d.ts +10 -0
  159. package/dist/core/surface/index.js +9 -0
  160. package/dist/core/surface/index.js.map +1 -0
  161. package/dist/core/surface/level-set-pass.d.ts +140 -0
  162. package/dist/core/surface/level-set-pass.js +291 -0
  163. package/dist/core/surface/level-set-pass.js.map +1 -0
  164. package/dist/core/surface/level-set-wgsl.d.ts +46 -0
  165. package/dist/core/surface/level-set-wgsl.js +99 -0
  166. package/dist/core/surface/level-set-wgsl.js.map +1 -0
  167. package/dist/core/surface/points.d.ts +109 -0
  168. package/dist/core/surface/points.js +226 -0
  169. package/dist/core/surface/points.js.map +1 -0
  170. package/dist/core/types.d.ts +37 -0
  171. package/dist/core/types.js +32 -0
  172. package/dist/core/types.js.map +1 -0
  173. package/dist/core/wgsl/api.d.ts +65 -0
  174. package/dist/core/wgsl/api.js +546 -0
  175. package/dist/core/wgsl/api.js.map +1 -0
  176. package/dist/core/wgsl/generate.d.ts +90 -0
  177. package/dist/core/wgsl/generate.js +678 -0
  178. package/dist/core/wgsl/generate.js.map +1 -0
  179. package/dist/core/wgsl/lean.d.ts +50 -0
  180. package/dist/core/wgsl/lean.js +327 -0
  181. package/dist/core/wgsl/lean.js.map +1 -0
  182. package/dist/core/wgsl/level-set.d.ts +58 -0
  183. package/dist/core/wgsl/level-set.js +200 -0
  184. package/dist/core/wgsl/level-set.js.map +1 -0
  185. package/dist/core/wgsl/majorant.d.ts +62 -0
  186. package/dist/core/wgsl/majorant.js +381 -0
  187. package/dist/core/wgsl/majorant.js.map +1 -0
  188. package/dist/core/wgsl/pnanovdb.chunks.generated.d.ts +14 -0
  189. package/dist/core/wgsl/pnanovdb.chunks.generated.js +333 -0
  190. package/dist/core/wgsl/pnanovdb.chunks.generated.js.map +1 -0
  191. package/dist/core/wgsl/reserved.d.ts +9 -0
  192. package/dist/core/wgsl/reserved.js +26 -0
  193. package/dist/core/wgsl/reserved.js.map +1 -0
  194. package/dist/core/wgsl/types.d.ts +198 -0
  195. package/dist/core/wgsl/types.js +2 -0
  196. package/dist/core/wgsl/types.js.map +1 -0
  197. package/dist/three/coarse-first.d.ts +207 -0
  198. package/dist/three/coarse-first.js +205 -0
  199. package/dist/three/coarse-first.js.map +1 -0
  200. package/dist/three/compute.d.ts +73 -0
  201. package/dist/three/compute.js +66 -0
  202. package/dist/three/compute.js.map +1 -0
  203. package/dist/three/device.d.ts +66 -0
  204. package/dist/three/device.js +62 -0
  205. package/dist/three/device.js.map +1 -0
  206. package/dist/three/frame/core-environment.d.ts +38 -0
  207. package/dist/three/frame/core-environment.js +154 -0
  208. package/dist/three/frame/core-environment.js.map +1 -0
  209. package/dist/three/frame/core-integrate-material.d.ts +34 -0
  210. package/dist/three/frame/core-integrate-material.js +162 -0
  211. package/dist/three/frame/core-integrate-material.js.map +1 -0
  212. package/dist/three/frame/core-occluders.d.ts +53 -0
  213. package/dist/three/frame/core-occluders.js +193 -0
  214. package/dist/three/frame/core-occluders.js.map +1 -0
  215. package/dist/three/frame/core-structs.d.ts +34 -0
  216. package/dist/three/frame/core-structs.js +61 -0
  217. package/dist/three/frame/core-structs.js.map +1 -0
  218. package/dist/three/frame/core-textures.d.ts +41 -0
  219. package/dist/three/frame/core-textures.js +114 -0
  220. package/dist/three/frame/core-textures.js.map +1 -0
  221. package/dist/three/frame/emission-light.d.ts +117 -0
  222. package/dist/three/frame/emission-light.js +276 -0
  223. package/dist/three/frame/emission-light.js.map +1 -0
  224. package/dist/three/frame/index.d.ts +19 -0
  225. package/dist/three/frame/index.js +15 -0
  226. package/dist/three/frame/index.js.map +1 -0
  227. package/dist/three/frame/medium.d.ts +33 -0
  228. package/dist/three/frame/medium.js +29 -0
  229. package/dist/three/frame/medium.js.map +1 -0
  230. package/dist/three/frame/renderer.d.ts +97 -0
  231. package/dist/three/frame/renderer.js +480 -0
  232. package/dist/three/frame/renderer.js.map +1 -0
  233. package/dist/three/frame/spectrum.d.ts +4 -0
  234. package/dist/three/frame/spectrum.js +15 -0
  235. package/dist/three/frame/spectrum.js.map +1 -0
  236. package/dist/three/frame/three-internals.d.ts +60 -0
  237. package/dist/three/frame/three-internals.js +152 -0
  238. package/dist/three/frame/three-internals.js.map +1 -0
  239. package/dist/three/frame/volume-shadows.d.ts +139 -0
  240. package/dist/three/frame/volume-shadows.js +403 -0
  241. package/dist/three/frame/volume-shadows.js.map +1 -0
  242. package/dist/three/frame/volume.d.ts +230 -0
  243. package/dist/three/frame/volume.js +268 -0
  244. package/dist/three/frame/volume.js.map +1 -0
  245. package/dist/three/grid-node.d.ts +229 -0
  246. package/dist/three/grid-node.js +545 -0
  247. package/dist/three/grid-node.js.map +1 -0
  248. package/dist/three/index.d.ts +52 -0
  249. package/dist/three/index.js +58 -0
  250. package/dist/three/index.js.map +1 -0
  251. package/dist/three/internal.d.ts +20 -0
  252. package/dist/three/internal.js +18 -0
  253. package/dist/three/internal.js.map +1 -0
  254. package/dist/three/level-set-material.d.ts +185 -0
  255. package/dist/three/level-set-material.js +241 -0
  256. package/dist/three/level-set-material.js.map +1 -0
  257. package/dist/three/level-set-physical-material.d.ts +154 -0
  258. package/dist/three/level-set-physical-material.js +253 -0
  259. package/dist/three/level-set-physical-material.js.map +1 -0
  260. package/dist/three/level-set-velocity.d.ts +94 -0
  261. package/dist/three/level-set-velocity.js +208 -0
  262. package/dist/three/level-set-velocity.js.map +1 -0
  263. package/dist/three/material.d.ts +324 -0
  264. package/dist/three/material.js +502 -0
  265. package/dist/three/material.js.map +1 -0
  266. package/dist/three/points.d.ts +140 -0
  267. package/dist/three/points.js +261 -0
  268. package/dist/three/points.js.map +1 -0
  269. package/dist/three/sparse-source.d.ts +165 -0
  270. package/dist/three/sparse-source.js +405 -0
  271. package/dist/three/sparse-source.js.map +1 -0
  272. package/dist/three/volume-source.d.ts +22 -0
  273. package/dist/three/volume-source.js +110 -0
  274. package/dist/three/volume-source.js.map +1 -0
  275. package/dist/tools/cpu/brick-atlas.d.ts +36 -0
  276. package/dist/tools/cpu/brick-atlas.js +129 -0
  277. package/dist/tools/cpu/brick-atlas.js.map +1 -0
  278. package/dist/tools/cpu/compute.d.ts +116 -0
  279. package/dist/tools/cpu/compute.js +239 -0
  280. package/dist/tools/cpu/compute.js.map +1 -0
  281. package/dist/tools/cpu/lean-reads.d.ts +81 -0
  282. package/dist/tools/cpu/lean-reads.js +262 -0
  283. package/dist/tools/cpu/lean-reads.js.map +1 -0
  284. package/dist/tools/cpu/level-set.d.ts +111 -0
  285. package/dist/tools/cpu/level-set.js +313 -0
  286. package/dist/tools/cpu/level-set.js.map +1 -0
  287. package/dist/tools/cpu/majorant.d.ts +265 -0
  288. package/dist/tools/cpu/majorant.js +541 -0
  289. package/dist/tools/cpu/majorant.js.map +1 -0
  290. package/dist/tools/cpu/march.d.ts +297 -0
  291. package/dist/tools/cpu/march.js +726 -0
  292. package/dist/tools/cpu/march.js.map +1 -0
  293. package/dist/tools/cpu/mesh-decimate.d.ts +124 -0
  294. package/dist/tools/cpu/mesh-decimate.js +1225 -0
  295. package/dist/tools/cpu/mesh-decimate.js.map +1 -0
  296. package/dist/tools/cpu/points.d.ts +29 -0
  297. package/dist/tools/cpu/points.js +38 -0
  298. package/dist/tools/cpu/points.js.map +1 -0
  299. package/dist/tools/cpu/probe-coords.d.ts +70 -0
  300. package/dist/tools/cpu/probe-coords.js +116 -0
  301. package/dist/tools/cpu/probe-coords.js.map +1 -0
  302. package/dist/tools/cpu/read-value.d.ts +44 -0
  303. package/dist/tools/cpu/read-value.js +351 -0
  304. package/dist/tools/cpu/read-value.js.map +1 -0
  305. package/dist/tools/cpu/sample-trilinear.d.ts +43 -0
  306. package/dist/tools/cpu/sample-trilinear.js +168 -0
  307. package/dist/tools/cpu/sample-trilinear.js.map +1 -0
  308. package/dist/tools/cpu/stride-tables.d.ts +56 -0
  309. package/dist/tools/cpu/stride-tables.generated.d.ts +1059 -0
  310. package/dist/tools/cpu/stride-tables.generated.js +1267 -0
  311. package/dist/tools/cpu/stride-tables.generated.js.map +1 -0
  312. package/dist/tools/cpu/stride-tables.js +78 -0
  313. package/dist/tools/cpu/stride-tables.js.map +1 -0
  314. package/dist/tools/cpu/surface-nets.d.ts +90 -0
  315. package/dist/tools/cpu/surface-nets.js +597 -0
  316. package/dist/tools/cpu/surface-nets.js.map +1 -0
  317. package/dist/tools/errors.d.ts +66 -0
  318. package/dist/tools/errors.js +67 -0
  319. package/dist/tools/errors.js.map +1 -0
  320. package/dist/tools/frame/ambient.d.ts +98 -0
  321. package/dist/tools/frame/ambient.js +274 -0
  322. package/dist/tools/frame/ambient.js.map +1 -0
  323. package/dist/tools/frame/blackbody.d.ts +57 -0
  324. package/dist/tools/frame/blackbody.js +151 -0
  325. package/dist/tools/frame/blackbody.js.map +1 -0
  326. package/dist/tools/frame/brick-cache.d.ts +165 -0
  327. package/dist/tools/frame/brick-cache.js +326 -0
  328. package/dist/tools/frame/brick-cache.js.map +1 -0
  329. package/dist/tools/frame/emission.d.ts +137 -0
  330. package/dist/tools/frame/emission.js +290 -0
  331. package/dist/tools/frame/emission.js.map +1 -0
  332. package/dist/tools/frame/environment-gpu.d.ts +111 -0
  333. package/dist/tools/frame/environment-gpu.js +280 -0
  334. package/dist/tools/frame/environment-gpu.js.map +1 -0
  335. package/dist/tools/frame/environment.d.ts +106 -0
  336. package/dist/tools/frame/environment.js +272 -0
  337. package/dist/tools/frame/environment.js.map +1 -0
  338. package/dist/tools/frame/froxel.d.ts +58 -0
  339. package/dist/tools/frame/froxel.js +115 -0
  340. package/dist/tools/frame/froxel.js.map +1 -0
  341. package/dist/tools/frame/grid.d.ts +392 -0
  342. package/dist/tools/frame/grid.js +802 -0
  343. package/dist/tools/frame/grid.js.map +1 -0
  344. package/dist/tools/frame/index.d.ts +150 -0
  345. package/dist/tools/frame/index.js +389 -0
  346. package/dist/tools/frame/index.js.map +1 -0
  347. package/dist/tools/frame/medium.d.ts +77 -0
  348. package/dist/tools/frame/medium.js +101 -0
  349. package/dist/tools/frame/medium.js.map +1 -0
  350. package/dist/tools/frame/mie-table.d.ts +6 -0
  351. package/dist/tools/frame/mie-table.js +16 -0
  352. package/dist/tools/frame/mie-table.js.map +1 -0
  353. package/dist/tools/frame/mie.d.ts +63 -0
  354. package/dist/tools/frame/mie.js +194 -0
  355. package/dist/tools/frame/mie.js.map +1 -0
  356. package/dist/tools/frame/mlp-nn.d.ts +36 -0
  357. package/dist/tools/frame/mlp-nn.js +159 -0
  358. package/dist/tools/frame/mlp-nn.js.map +1 -0
  359. package/dist/tools/frame/mlp-tza.d.ts +29 -0
  360. package/dist/tools/frame/mlp-tza.js +186 -0
  361. package/dist/tools/frame/mlp-tza.js.map +1 -0
  362. package/dist/tools/frame/mlp.d.ts +183 -0
  363. package/dist/tools/frame/mlp.js +434 -0
  364. package/dist/tools/frame/mlp.js.map +1 -0
  365. package/dist/tools/frame/ms-exit.d.ts +42 -0
  366. package/dist/tools/frame/ms-exit.js +90 -0
  367. package/dist/tools/frame/ms-exit.js.map +1 -0
  368. package/dist/tools/frame/multi-scale.d.ts +152 -0
  369. package/dist/tools/frame/multi-scale.js +302 -0
  370. package/dist/tools/frame/multi-scale.js.map +1 -0
  371. package/dist/tools/frame/neural-weights.d.ts +10 -0
  372. package/dist/tools/frame/neural-weights.js +244 -0
  373. package/dist/tools/frame/neural-weights.js.map +1 -0
  374. package/dist/tools/frame/neural.d.ts +80 -0
  375. package/dist/tools/frame/neural.js +150 -0
  376. package/dist/tools/frame/neural.js.map +1 -0
  377. package/dist/tools/frame/occluders.d.ts +51 -0
  378. package/dist/tools/frame/occluders.js +72 -0
  379. package/dist/tools/frame/occluders.js.map +1 -0
  380. package/dist/tools/frame/pyramid-layout.d.ts +55 -0
  381. package/dist/tools/frame/pyramid-layout.js +100 -0
  382. package/dist/tools/frame/pyramid-layout.js.map +1 -0
  383. package/dist/tools/frame/shadows.d.ts +190 -0
  384. package/dist/tools/frame/shadows.js +468 -0
  385. package/dist/tools/frame/shadows.js.map +1 -0
  386. package/dist/tools/frame/sparse.d.ts +147 -0
  387. package/dist/tools/frame/sparse.js +432 -0
  388. package/dist/tools/frame/sparse.js.map +1 -0
  389. package/dist/tools/frame/spectral-stack.d.ts +159 -0
  390. package/dist/tools/frame/spectral-stack.js +391 -0
  391. package/dist/tools/frame/spectral-stack.js.map +1 -0
  392. package/dist/tools/frame/spectral.d.ts +222 -0
  393. package/dist/tools/frame/spectral.js +572 -0
  394. package/dist/tools/frame/spectral.js.map +1 -0
  395. package/dist/tools/frame/stack.d.ts +115 -0
  396. package/dist/tools/frame/stack.js +290 -0
  397. package/dist/tools/frame/stack.js.map +1 -0
  398. package/dist/tools/frame/view.d.ts +131 -0
  399. package/dist/tools/frame/view.js +337 -0
  400. package/dist/tools/frame/view.js.map +1 -0
  401. package/dist/tools/index.d.ts +157 -0
  402. package/dist/tools/index.js +132 -0
  403. package/dist/tools/index.js.map +1 -0
  404. package/dist/tools/internal.d.ts +87 -0
  405. package/dist/tools/internal.js +85 -0
  406. package/dist/tools/internal.js.map +1 -0
  407. package/dist/tools/nanovdb/build-from-vdb.d.ts +59 -0
  408. package/dist/tools/nanovdb/build-from-vdb.js +100 -0
  409. package/dist/tools/nanovdb/build-from-vdb.js.map +1 -0
  410. package/dist/tools/nanovdb/bytes.d.ts +233 -0
  411. package/dist/tools/nanovdb/bytes.js +388 -0
  412. package/dist/tools/nanovdb/bytes.js.map +1 -0
  413. package/dist/tools/nanovdb/coarse-first.d.ts +78 -0
  414. package/dist/tools/nanovdb/coarse-first.js +92 -0
  415. package/dist/tools/nanovdb/coarse-first.js.map +1 -0
  416. package/dist/tools/nanovdb/half.d.ts +22 -0
  417. package/dist/tools/nanovdb/half.js +73 -0
  418. package/dist/tools/nanovdb/half.js.map +1 -0
  419. package/dist/tools/nanovdb/index.d.ts +34 -0
  420. package/dist/tools/nanovdb/index.js +25 -0
  421. package/dist/tools/nanovdb/index.js.map +1 -0
  422. package/dist/tools/nanovdb/inspect.d.ts +33 -0
  423. package/dist/tools/nanovdb/inspect.js +70 -0
  424. package/dist/tools/nanovdb/inspect.js.map +1 -0
  425. package/dist/tools/nanovdb/leaf-codec.d.ts +119 -0
  426. package/dist/tools/nanovdb/leaf-codec.js +356 -0
  427. package/dist/tools/nanovdb/leaf-codec.js.map +1 -0
  428. package/dist/tools/nanovdb/quantize.d.ts +72 -0
  429. package/dist/tools/nanovdb/quantize.js +329 -0
  430. package/dist/tools/nanovdb/quantize.js.map +1 -0
  431. package/dist/tools/nanovdb/resample.d.ts +177 -0
  432. package/dist/tools/nanovdb/resample.js +692 -0
  433. package/dist/tools/nanovdb/resample.js.map +1 -0
  434. package/dist/tools/nanovdb/serialize.d.ts +176 -0
  435. package/dist/tools/nanovdb/serialize.js +439 -0
  436. package/dist/tools/nanovdb/serialize.js.map +1 -0
  437. package/dist/tools/nanovdb/stats.d.ts +87 -0
  438. package/dist/tools/nanovdb/stats.js +225 -0
  439. package/dist/tools/nanovdb/stats.js.map +1 -0
  440. package/dist/tools/nanovdb/transform.d.ts +30 -0
  441. package/dist/tools/nanovdb/transform.js +94 -0
  442. package/dist/tools/nanovdb/transform.js.map +1 -0
  443. package/dist/tools/nanovdb/tree.d.ts +186 -0
  444. package/dist/tools/nanovdb/tree.js +530 -0
  445. package/dist/tools/nanovdb/tree.js.map +1 -0
  446. package/dist/tools/nanovdb/write-nvdb.d.ts +74 -0
  447. package/dist/tools/nanovdb/write-nvdb.js +290 -0
  448. package/dist/tools/nanovdb/write-nvdb.js.map +1 -0
  449. package/dist/tools/nvdb-file.d.ts +265 -0
  450. package/dist/tools/nvdb-file.js +763 -0
  451. package/dist/tools/nvdb-file.js.map +1 -0
  452. package/dist/tools/nvdb-stream.d.ts +154 -0
  453. package/dist/tools/nvdb-stream.js +409 -0
  454. package/dist/tools/nvdb-stream.js.map +1 -0
  455. package/dist/tools/reference/analytic.d.ts +41 -0
  456. package/dist/tools/reference/analytic.js +95 -0
  457. package/dist/tools/reference/analytic.js.map +1 -0
  458. package/dist/tools/reference/environment.d.ts +62 -0
  459. package/dist/tools/reference/environment.js +154 -0
  460. package/dist/tools/reference/environment.js.map +1 -0
  461. package/dist/tools/reference/index.d.ts +12 -0
  462. package/dist/tools/reference/index.js +13 -0
  463. package/dist/tools/reference/index.js.map +1 -0
  464. package/dist/tools/reference/media.d.ts +14 -0
  465. package/dist/tools/reference/media.js +30 -0
  466. package/dist/tools/reference/media.js.map +1 -0
  467. package/dist/tools/reference/rng.d.ts +20 -0
  468. package/dist/tools/reference/rng.js +30 -0
  469. package/dist/tools/reference/rng.js.map +1 -0
  470. package/dist/tools/reference/scene.d.ts +312 -0
  471. package/dist/tools/reference/scene.js +169 -0
  472. package/dist/tools/reference/scene.js.map +1 -0
  473. package/dist/tools/reference/tables.d.ts +98 -0
  474. package/dist/tools/reference/tables.js +264 -0
  475. package/dist/tools/reference/tables.js.map +1 -0
  476. package/dist/tools/reference/trace.d.ts +160 -0
  477. package/dist/tools/reference/trace.js +497 -0
  478. package/dist/tools/reference/trace.js.map +1 -0
  479. package/dist/tools/vdb/bit-utils.d.ts +20 -0
  480. package/dist/tools/vdb/bit-utils.js +42 -0
  481. package/dist/tools/vdb/bit-utils.js.map +1 -0
  482. package/dist/tools/vdb/blosc-write.d.ts +43 -0
  483. package/dist/tools/vdb/blosc-write.js +197 -0
  484. package/dist/tools/vdb/blosc-write.js.map +1 -0
  485. package/dist/tools/vdb/blosc.d.ts +86 -0
  486. package/dist/tools/vdb/blosc.js +287 -0
  487. package/dist/tools/vdb/blosc.js.map +1 -0
  488. package/dist/tools/vdb/blosclz.d.ts +33 -0
  489. package/dist/tools/vdb/blosclz.js +112 -0
  490. package/dist/tools/vdb/blosclz.js.map +1 -0
  491. package/dist/tools/vdb/byte-reader.d.ts +50 -0
  492. package/dist/tools/vdb/byte-reader.js +161 -0
  493. package/dist/tools/vdb/byte-reader.js.map +1 -0
  494. package/dist/tools/vdb/compression.d.ts +81 -0
  495. package/dist/tools/vdb/compression.js +260 -0
  496. package/dist/tools/vdb/compression.js.map +1 -0
  497. package/dist/tools/vdb/errors.d.ts +10 -0
  498. package/dist/tools/vdb/errors.js +11 -0
  499. package/dist/tools/vdb/errors.js.map +1 -0
  500. package/dist/tools/vdb/grid.d.ts +37 -0
  501. package/dist/tools/vdb/grid.js +153 -0
  502. package/dist/tools/vdb/grid.js.map +1 -0
  503. package/dist/tools/vdb/half-float.d.ts +9 -0
  504. package/dist/tools/vdb/half-float.js +24 -0
  505. package/dist/tools/vdb/half-float.js.map +1 -0
  506. package/dist/tools/vdb/index.d.ts +4 -0
  507. package/dist/tools/vdb/index.js +3 -0
  508. package/dist/tools/vdb/index.js.map +1 -0
  509. package/dist/tools/vdb/inflate.d.ts +24 -0
  510. package/dist/tools/vdb/inflate.js +334 -0
  511. package/dist/tools/vdb/inflate.js.map +1 -0
  512. package/dist/tools/vdb/lz4.d.ts +30 -0
  513. package/dist/tools/vdb/lz4.js +228 -0
  514. package/dist/tools/vdb/lz4.js.map +1 -0
  515. package/dist/tools/vdb/metadata.d.ts +17 -0
  516. package/dist/tools/vdb/metadata.js +72 -0
  517. package/dist/tools/vdb/metadata.js.map +1 -0
  518. package/dist/tools/vdb/parse.d.ts +47 -0
  519. package/dist/tools/vdb/parse.js +241 -0
  520. package/dist/tools/vdb/parse.js.map +1 -0
  521. package/dist/tools/vdb/point-render-data.d.ts +79 -0
  522. package/dist/tools/vdb/point-render-data.js +137 -0
  523. package/dist/tools/vdb/point-render-data.js.map +1 -0
  524. package/dist/tools/vdb/points.d.ts +186 -0
  525. package/dist/tools/vdb/points.js +835 -0
  526. package/dist/tools/vdb/points.js.map +1 -0
  527. package/dist/tools/vdb/transform.d.ts +23 -0
  528. package/dist/tools/vdb/transform.js +54 -0
  529. package/dist/tools/vdb/transform.js.map +1 -0
  530. package/dist/tools/vdb/tree.d.ts +111 -0
  531. package/dist/tools/vdb/tree.js +228 -0
  532. package/dist/tools/vdb/tree.js.map +1 -0
  533. package/dist/tools/vdb/types.d.ts +195 -0
  534. package/dist/tools/vdb/types.js +3 -0
  535. package/dist/tools/vdb/types.js.map +1 -0
  536. package/dist/tools/wvdb/bake.d.ts +145 -0
  537. package/dist/tools/wvdb/bake.js +361 -0
  538. package/dist/tools/wvdb/bake.js.map +1 -0
  539. package/dist/tools/wvdb/dense.d.ts +191 -0
  540. package/dist/tools/wvdb/dense.js +368 -0
  541. package/dist/tools/wvdb/dense.js.map +1 -0
  542. package/dist/tools/wvdb/format.d.ts +220 -0
  543. package/dist/tools/wvdb/format.js +306 -0
  544. package/dist/tools/wvdb/format.js.map +1 -0
  545. package/dist/tools/wvdb/index.d.ts +14 -0
  546. package/dist/tools/wvdb/index.js +15 -0
  547. package/dist/tools/wvdb/index.js.map +1 -0
  548. package/dist/tools/wvdb/level-set.d.ts +56 -0
  549. package/dist/tools/wvdb/level-set.js +153 -0
  550. package/dist/tools/wvdb/level-set.js.map +1 -0
  551. package/dist/tools/wvdb/nanovdb.d.ts +59 -0
  552. package/dist/tools/wvdb/nanovdb.js +64 -0
  553. package/dist/tools/wvdb/nanovdb.js.map +1 -0
  554. package/dist/tools/wvdb/partial.d.ts +74 -0
  555. package/dist/tools/wvdb/partial.js +233 -0
  556. package/dist/tools/wvdb/partial.js.map +1 -0
  557. package/dist/tools/wvdb/read.d.ts +336 -0
  558. package/dist/tools/wvdb/read.js +766 -0
  559. package/dist/tools/wvdb/read.js.map +1 -0
  560. package/dist/tools/wvdb/sha256.d.ts +7 -0
  561. package/dist/tools/wvdb/sha256.js +76 -0
  562. package/dist/tools/wvdb/sha256.js.map +1 -0
  563. package/dist/tools/wvdb/write.d.ts +149 -0
  564. package/dist/tools/wvdb/write.js +403 -0
  565. package/dist/tools/wvdb/write.js.map +1 -0
  566. package/package.json +83 -4
  567. package/vendor/LICENSE +201 -0
  568. package/vendor/NOTICE +19 -0
  569. package/vendor/VENDOR.md +100 -0
  570. package/vendor/pnanovdb.wgsl +1577 -0
@@ -0,0 +1,162 @@
1
+ // Portions derived from mjurczyk/openvdb (MIT), commit 75e7345 (v0.26.0):
2
+ // src/three-openvdb/frame/webgpu/FrameIntegrateMaterial.js L33–138 (the proxy quad over the froxel area,
3
+ // sRGB blending and its clamp rule, the scene depth with the empty-depth rule).
4
+ // Copyright (c) mjurczyk/openvdb contributors. Licensed under the MIT License (see THIRD_PARTY_NOTICES.md).
5
+ // Changes: the composite reads the core renderer's integrated prefix (two taps) through the core WGSL
6
+ // (`vdbFrameSliceCoord`, `vdbFrameIntegrateTaps`, `vdbFrameCompositeColor` by `wgslFn`). Divergences:
7
+ // DIVERGES.md (K6.1 rows).
8
+ /**
9
+ * The proxy material of `VDBFrameRenderer` with `backend: 'core'` (internal, K6.1 A/B): every volume proxy
10
+ * draws it; its fragment is the core composite (`vdbFrameIntegrate`'s maths) over three's
11
+ * `viewportDepthTexture` and `viewportTexture`, sampling the core prefix through a stand-in texture
12
+ * (`core-textures.ts`).
13
+ */
14
+ import * as THREE from "three";
15
+ import { NodeMaterial } from "three/webgpu";
16
+ import * as TSL from "three/tsl";
17
+ import { VDB_FRAME_COMPOSITE_COLOR_FN_WGSL, VDB_FRAME_COMPOSITE_SPECTRAL_FN_WGSL, VDB_FRAME_INTEGRATE_TAPS_WGSL, VDB_FRAME_SLICE_COORD_WGSL, VDB_FRAME_SRGB_EOTF_WGSL, VDB_FRAME_SRGB_OETF_WGSL, } from "../../core/frame/wgsl/integrate.js";
18
+ const { Discard, Fn, If, clamp, float, mix, orthographicDepthToViewZ, perspectiveDepthToViewZ, positionGeometry, screenUV, select, texture3D, uint, uniform, vec2, vec3, vec4, viewportDepthTexture, viewportTexture, wgslFn } = TSL;
19
+ const sliceCoordFn = wgslFn(VDB_FRAME_SLICE_COORD_WGSL);
20
+ const tapsFn = wgslFn(VDB_FRAME_INTEGRATE_TAPS_WGSL);
21
+ const oetfFn = wgslFn(VDB_FRAME_SRGB_OETF_WGSL);
22
+ const eotfFn = wgslFn(VDB_FRAME_SRGB_EOTF_WGSL);
23
+ const compositeFn = wgslFn(VDB_FRAME_COMPOSITE_COLOR_FN_WGSL, [oetfFn, eotfFn]);
24
+ // K6.4: the spectral composite (over the scene colour, per channel)
25
+ const compositeSpectralFn = wgslFn(VDB_FRAME_COMPOSITE_SPECTRAL_FN_WGSL, [oetfFn, eotfFn]);
26
+ /** A 1³ zero placeholder until the first core update binds the prefix. */
27
+ function placeholder() {
28
+ const t = new THREE.Data3DTexture(new Uint16Array(4), 1, 1, 1);
29
+ t.type = THREE.HalfFloatType;
30
+ t.format = THREE.RGBAFormat;
31
+ t.minFilter = t.magFilter = THREE.LinearFilter;
32
+ t.needsUpdate = true;
33
+ return t;
34
+ }
35
+ export class VDBFrameCoreIntegrateMaterial extends NodeMaterial {
36
+ /** The prefix texture node: its `value` is the stand-in of `outputs.froxels.integrated`. */
37
+ prefix = texture3D(placeholder());
38
+ /** K6.4: the alpha prefix (`outputs.froxels.integratedAlpha`: red, blue opacity) of spectral media. */
39
+ alphaPrefix = texture3D(placeholder());
40
+ frameGrid = uniform(new THREE.Vector3(1, 1, 1));
41
+ frameRange = uniform(new THREE.Vector2(0.1, 1.0));
42
+ frameScreenRect = uniform(new THREE.Vector4(-1, -1, 1, 1));
43
+ frameCameraNear = uniform(0.1);
44
+ frameCameraFar = uniform(1000.0);
45
+ frameCameraOrthographic = uniform(0, "int");
46
+ srgbBlending = null;
47
+ srgbClamp = null;
48
+ /** K6.4: spectral media composite themselves over the scene colour (no hardware blending). */
49
+ spectral = false;
50
+ constructor() {
51
+ super();
52
+ this.name = "VDBFrameCoreIntegrateMaterial";
53
+ this.vertexNode = vec4(mix(this.frameScreenRect.xy, this.frameScreenRect.zw, positionGeometry.xy.mul(0.5).add(0.5)), 0.0, 1.0);
54
+ this.setSrgbBlending(true, true);
55
+ this.side = THREE.DoubleSide;
56
+ this.forceSinglePass = true;
57
+ this.transparent = true;
58
+ this.depthTest = false;
59
+ this.depthWrite = false;
60
+ }
61
+ /** The froxel layout of the core outputs (each update). */
62
+ setLayout(layout, camera) {
63
+ this.frameGrid.value.set(layout.width, layout.height, layout.depth);
64
+ this.frameRange.value.set(layout.range[0], layout.range[1]);
65
+ this.frameScreenRect.value.set(...layout.screenRect);
66
+ this.frameCameraNear.value = camera.near;
67
+ this.frameCameraFar.value = camera.far;
68
+ this.frameCameraOrthographic.value = camera.isOrthographicCamera ? 1 : 0;
69
+ }
70
+ /** K6.4: the spectral composite (the alpha prefix, his NoBlending) or the grey one. */
71
+ setSpectral(spectral) {
72
+ if (spectral === this.spectral)
73
+ return;
74
+ this.spectral = spectral;
75
+ this.#rebuild();
76
+ }
77
+ /** As `VDBFrameIntegrateMaterial.setSrgbBlending` (his rules). */
78
+ setSrgbBlending(srgbBlending, srgbClamp) {
79
+ if (srgbBlending === this.srgbBlending && srgbClamp === this.srgbClamp)
80
+ return;
81
+ this.srgbBlending = srgbBlending;
82
+ this.srgbClamp = srgbClamp;
83
+ this.#rebuild();
84
+ }
85
+ #rebuild() {
86
+ const srgbBlending = !!this.srgbBlending;
87
+ this.fragmentNode = this.createFragmentNode();
88
+ this.needsUpdate = true;
89
+ if (srgbBlending || this.spectral) {
90
+ this.blending = THREE.NoBlending;
91
+ }
92
+ else {
93
+ this.blending = THREE.CustomBlending;
94
+ this.blendEquation = THREE.AddEquation;
95
+ this.blendSrc = THREE.OneFactor;
96
+ this.blendDst = THREE.OneMinusSrcAlphaFactor;
97
+ this.blendSrcAlpha = THREE.OneFactor;
98
+ this.blendDstAlpha = THREE.OneMinusSrcAlphaFactor;
99
+ }
100
+ }
101
+ // NOTE Empty depth (no geometry) gives an infinite scene depth (as the TSL integrate pass)
102
+ createSceneDepth() {
103
+ return Fn((_, builder) => {
104
+ const depth = viewportDepthTexture().x;
105
+ const near = this.frameCameraNear;
106
+ const far = this.frameCameraFar;
107
+ const isEmpty = builder.renderer.reversedDepthBuffer ? depth.lessThanEqual(0.0) : depth.greaterThanEqual(1.0);
108
+ const viewZ = select(this.frameCameraOrthographic.equal(1), orthographicDepthToViewZ(depth, near, far), perspectiveDepthToViewZ(depth, near, far));
109
+ return select(isEmpty, float(1e20), viewZ.negate());
110
+ });
111
+ }
112
+ createFragmentNode() {
113
+ const srgb = !!this.srgbBlending;
114
+ const clampColors = !!this.srgbClamp;
115
+ const sceneDepth = this.createSceneDepth();
116
+ if (this.spectral)
117
+ return this.createSpectralFragmentNode(srgb, clampColors, sceneDepth);
118
+ return Fn(() => {
119
+ const grid = this.frameGrid;
120
+ const depth = sceneDepth().toVar();
121
+ const uv = vec2(screenUV.x, float(1.0).sub(screenUV.y));
122
+ const kc = sliceCoordFn({ viewDepth: depth, range: this.frameRange, depth: grid.z }).toVar();
123
+ const xy = clamp(uv.mul(grid.xy), vec2(0.5), grid.xy.sub(0.5)).div(grid.xy).toVar();
124
+ const layers = grid.z.add(1.0);
125
+ const a = this.prefix.sample(vec3(xy, kc.x.add(0.5).div(layers))).level(float(0.0));
126
+ const b = this.prefix.sample(vec3(xy, kc.x.add(1.5).div(layers))).level(float(0.0));
127
+ const r = tapsFn({ a, b, c: kc.y }).toVar();
128
+ If(r.w.greaterThanEqual(1.0), () => {
129
+ Discard();
130
+ });
131
+ const background = srgb ? viewportTexture() : vec4(0.0);
132
+ return compositeFn({ r, sceneColor: background, srgb: uint(srgb ? 1 : 0), clampColors: uint(clampColors ? 1 : 0) });
133
+ })();
134
+ }
135
+ // K6.4 (vdbFrameIntegrate spectral): the two-tap formula for each channel (red and blue opacity from the alpha prefix),
136
+ // then his spectral composite over the scene colour
137
+ createSpectralFragmentNode(srgb, clampColors, sceneDepth) {
138
+ return Fn(() => {
139
+ const grid = this.frameGrid;
140
+ const depth = sceneDepth().toVar();
141
+ const uv = vec2(screenUV.x, float(1.0).sub(screenUV.y));
142
+ const kc = sliceCoordFn({ viewDepth: depth, range: this.frameRange, depth: grid.z }).toVar();
143
+ const xy = clamp(uv.mul(grid.xy), vec2(0.5), grid.xy.sub(0.5)).div(grid.xy).toVar();
144
+ const layers = grid.z.add(1.0);
145
+ const za = vec3(xy, kc.x.add(0.5).div(layers));
146
+ const zb = vec3(xy, kc.x.add(1.5).div(layers));
147
+ const a = this.prefix.sample(za).level(float(0.0)).toVar();
148
+ const b = this.prefix.sample(zb).level(float(0.0)).toVar();
149
+ const aa = this.alphaPrefix.sample(za).level(float(0.0)).toVar();
150
+ const ba = this.alphaPrefix.sample(zb).level(float(0.0)).toVar();
151
+ const r = tapsFn({ a: vec4(a.x, 0.0, 0.0, aa.x), b: vec4(b.x, 0.0, 0.0, ba.x), c: kc.y }).toVar();
152
+ const g = tapsFn({ a: vec4(a.y, 0.0, 0.0, a.w), b: vec4(b.y, 0.0, 0.0, b.w), c: kc.y }).toVar();
153
+ const bl = tapsFn({ a: vec4(a.z, 0.0, 0.0, aa.y), b: vec4(b.z, 0.0, 0.0, ba.y), c: kc.y }).toVar();
154
+ const transmittance = vec3(r.w, g.w, bl.w).toVar();
155
+ If(transmittance.x.greaterThanEqual(1.0).and(transmittance.y.greaterThanEqual(1.0)).and(transmittance.z.greaterThanEqual(1.0)), () => {
156
+ Discard();
157
+ });
158
+ return compositeSpectralFn({ radiance: vec3(r.x, g.x, bl.x), transmittance, sceneColor: viewportTexture(), srgb: uint(srgb ? 1 : 0), clampColors: uint(clampColors ? 1 : 0) });
159
+ })();
160
+ }
161
+ }
162
+ //# sourceMappingURL=core-integrate-material.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"core-integrate-material.js","sourceRoot":"","sources":["../../../src/three/frame/core-integrate-material.ts"],"names":[],"mappings":"AAAA,0EAA0E;AAC1E,2GAA2G;AAC3G,kFAAkF;AAClF,4GAA4G;AAC5G,sGAAsG;AACtG,sGAAsG;AACtG,2BAA2B;AAE3B;;;;;GAKG;AAEH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAC5C,OAAO,KAAK,GAAG,MAAM,WAAW,CAAC;AAEjC,OAAO,EACL,iCAAiC,EACjC,oCAAoC,EACpC,6BAA6B,EAC7B,0BAA0B,EAC1B,wBA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AAE,GAAG,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC,EAAE,GAAG,EAAE,GAAG,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,KAAK,EAAE,CAAC;YACnG,MAAM,aAAa,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,KAAK,EAAE,CAAC;YACnD,EAAE,CAAC,aAAa,CAAC,CAAC,CAAC,gBAAgB,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,aAAa,CAAC,CAAC,CAAC,gBAAgB,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,aAAa,CAAC,CAAC,CAAC,gBAAgB,CAAC,GAAG,CAAC,CAAC,EAAE,GAAG,EAAE;gBACnI,OAAO,EAAE,CAAC;YACZ,CAAC,CAAC,CAAC;YACH,OAAO,mBAAmB,CAAC,EAAE,QAAQ,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,aAAa,EAAE,UAAU,EAAE,eAAe,EAAgB,EAAE,IAAI,EAAE,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,WAAW,EAAE,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;QAC/L,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/FrameIntegrateMaterial.js L33–138 (the proxy quad over the froxel area,\n// sRGB blending and its clamp rule, the scene depth with the empty-depth rule).\n// Copyright (c) mjurczyk/openvdb contributors. Licensed under the MIT License (see THIRD_PARTY_NOTICES.md).\n// Changes: the composite reads the core renderer's integrated prefix (two taps) through the core WGSL\n// (`vdbFrameSliceCoord`, `vdbFrameIntegrateTaps`, `vdbFrameCompositeColor` by `wgslFn`). Divergences:\n// DIVERGES.md (K6.1 rows).\n\n/**\n * The proxy material of `VDBFrameRenderer` with `backend: 'core'` (internal, K6.1 A/B): every volume proxy\n * draws it; its fragment is the core composite (`vdbFrameIntegrate`'s maths) over three's\n * `viewportDepthTexture` and `viewportTexture`, sampling the core prefix through a stand-in texture\n * (`core-textures.ts`).\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 {\n VDB_FRAME_COMPOSITE_COLOR_FN_WGSL,\n VDB_FRAME_COMPOSITE_SPECTRAL_FN_WGSL,\n VDB_FRAME_INTEGRATE_TAPS_WGSL,\n VDB_FRAME_SLICE_COORD_WGSL,\n VDB_FRAME_SRGB_EOTF_WGSL,\n VDB_FRAME_SRGB_OETF_WGSL,\n} from \"../../core/frame/wgsl/integrate.js\";\nimport type { VDBFroxelLayout } from \"../../core/frame/types.js\";\n\nconst { Discard, Fn, If, clamp, float, mix, orthographicDepthToViewZ, perspectiveDepthToViewZ, positionGeometry, screenUV, select, texture3D, uint, uniform, vec2, vec3, vec4, viewportDepthTexture, viewportTexture, wgslFn } = TSL as unknown as Record<string, VDBTslNode>;\n\nconst sliceCoordFn = wgslFn(VDB_FRAME_SLICE_COORD_WGSL);\nconst tapsFn = wgslFn(VDB_FRAME_INTEGRATE_TAPS_WGSL);\nconst oetfFn = wgslFn(VDB_FRAME_SRGB_OETF_WGSL);\nconst eotfFn = wgslFn(VDB_FRAME_SRGB_EOTF_WGSL);\nconst compositeFn = wgslFn(VDB_FRAME_COMPOSITE_COLOR_FN_WGSL, [oetfFn, eotfFn]);\n// K6.4: the spectral composite (over the scene colour, per channel)\nconst compositeSpectralFn = wgslFn(VDB_FRAME_COMPOSITE_SPECTRAL_FN_WGSL, [oetfFn, eotfFn]);\n\n/** A 1³ zero placeholder until the first core update binds the prefix. */\nfunction placeholder(): THREE.Data3DTexture {\n const t = new THREE.Data3DTexture(new Uint16Array(4), 1, 1, 1);\n t.type = THREE.HalfFloatType;\n t.format = THREE.RGBAFormat;\n t.minFilter = t.magFilter = THREE.LinearFilter;\n t.needsUpdate = true;\n return t;\n}\n\nexport class VDBFrameCoreIntegrateMaterial extends NodeMaterial {\n /** The prefix texture node: its `value` is the stand-in of `outputs.froxels.integrated`. */\n readonly prefix: VDBTslNode = texture3D(placeholder());\n /** K6.4: the alpha prefix (`outputs.froxels.integratedAlpha`: red, blue opacity) of spectral media. */\n readonly alphaPrefix: VDBTslNode = texture3D(placeholder());\n readonly frameGrid = uniform(new THREE.Vector3(1, 1, 1));\n readonly frameRange = uniform(new THREE.Vector2(0.1, 1.0));\n readonly frameScreenRect = uniform(new THREE.Vector4(-1, -1, 1, 1));\n readonly frameCameraNear = uniform(0.1);\n readonly frameCameraFar = uniform(1000.0);\n readonly frameCameraOrthographic = uniform(0, \"int\");\n srgbBlending: boolean | null = null;\n srgbClamp: boolean | null = null;\n /** K6.4: spectral media composite themselves over the scene colour (no hardware blending). */\n spectral = false;\n\n constructor() {\n super();\n this.name = \"VDBFrameCoreIntegrateMaterial\";\n this.vertexNode = vec4(mix(this.frameScreenRect.xy, this.frameScreenRect.zw, positionGeometry.xy.mul(0.5).add(0.5)), 0.0, 1.0);\n this.setSrgbBlending(true, true);\n this.side = THREE.DoubleSide;\n this.forceSinglePass = true;\n this.transparent = true;\n this.depthTest = false;\n this.depthWrite = false;\n }\n\n /** The froxel layout of the core outputs (each update). */\n setLayout(layout: VDBFroxelLayout, camera: { near: number; far: number; isOrthographicCamera?: boolean }): void {\n this.frameGrid.value.set(layout.width, layout.height, layout.depth);\n this.frameRange.value.set(layout.range[0], layout.range[1]);\n this.frameScreenRect.value.set(...layout.screenRect);\n this.frameCameraNear.value = camera.near;\n this.frameCameraFar.value = camera.far;\n this.frameCameraOrthographic.value = camera.isOrthographicCamera ? 1 : 0;\n }\n\n /** K6.4: the spectral composite (the alpha prefix, his NoBlending) or the grey one. */\n setSpectral(spectral: boolean): void {\n if (spectral === this.spectral) return;\n this.spectral = spectral;\n this.#rebuild();\n }\n\n /** As `VDBFrameIntegrateMaterial.setSrgbBlending` (his rules). */\n setSrgbBlending(srgbBlending: boolean, srgbClamp: boolean): void {\n if (srgbBlending === this.srgbBlending && srgbClamp === this.srgbClamp) return;\n this.srgbBlending = srgbBlending;\n this.srgbClamp = srgbClamp;\n this.#rebuild();\n }\n\n #rebuild(): void {\n const srgbBlending = !!this.srgbBlending;\n this.fragmentNode = this.createFragmentNode();\n this.needsUpdate = true;\n if (srgbBlending || this.spectral) {\n this.blending = THREE.NoBlending;\n } else {\n this.blending = THREE.CustomBlending;\n this.blendEquation = THREE.AddEquation;\n this.blendSrc = THREE.OneFactor;\n this.blendDst = THREE.OneMinusSrcAlphaFactor;\n this.blendSrcAlpha = THREE.OneFactor;\n this.blendDstAlpha = THREE.OneMinusSrcAlphaFactor;\n }\n }\n\n // NOTE Empty depth (no geometry) gives an infinite scene depth (as the TSL integrate pass)\n private createSceneDepth(): VDBTslNode {\n return Fn((_: unknown, builder: { renderer: { reversedDepthBuffer?: boolean } }) => {\n const depth: VDBTslNode = (viewportDepthTexture() as VDBTslNode).x;\n const near = this.frameCameraNear;\n const far = this.frameCameraFar;\n const isEmpty = builder.renderer.reversedDepthBuffer ? depth.lessThanEqual(0.0) : depth.greaterThanEqual(1.0);\n const viewZ = select(this.frameCameraOrthographic.equal(1), orthographicDepthToViewZ(depth, near, far), perspectiveDepthToViewZ(depth, near, far));\n return select(isEmpty, float(1e20), viewZ.negate());\n });\n }\n\n private createFragmentNode(): VDBTslNode {\n const srgb = !!this.srgbBlending;\n const clampColors = !!this.srgbClamp;\n const sceneDepth = this.createSceneDepth();\n if (this.spectral) return this.createSpectralFragmentNode(srgb, clampColors, sceneDepth);\n return Fn(() => {\n const grid = this.frameGrid;\n const depth = sceneDepth().toVar();\n const uv = vec2(screenUV.x, float(1.0).sub(screenUV.y));\n const kc = sliceCoordFn({ viewDepth: depth, range: this.frameRange, depth: grid.z }).toVar();\n const xy = clamp(uv.mul(grid.xy), vec2(0.5), grid.xy.sub(0.5)).div(grid.xy).toVar();\n const layers = grid.z.add(1.0);\n const a = this.prefix.sample(vec3(xy, kc.x.add(0.5).div(layers))).level(float(0.0));\n const b = this.prefix.sample(vec3(xy, kc.x.add(1.5).div(layers))).level(float(0.0));\n const r = tapsFn({ a, b, c: kc.y }).toVar();\n If(r.w.greaterThanEqual(1.0), () => {\n Discard();\n });\n const background: VDBTslNode = srgb ? (viewportTexture() as VDBTslNode) : vec4(0.0);\n return compositeFn({ r, sceneColor: background, srgb: uint(srgb ? 1 : 0), clampColors: uint(clampColors ? 1 : 0) });\n })();\n }\n\n // K6.4 (vdbFrameIntegrate spectral): the two-tap formula for each channel (red and blue opacity from the alpha prefix),\n // then his spectral composite over the scene colour\n private createSpectralFragmentNode(srgb: boolean, clampColors: boolean, sceneDepth: VDBTslNode): VDBTslNode {\n return Fn(() => {\n const grid = this.frameGrid;\n const depth = sceneDepth().toVar();\n const uv = vec2(screenUV.x, float(1.0).sub(screenUV.y));\n const kc = sliceCoordFn({ viewDepth: depth, range: this.frameRange, depth: grid.z }).toVar();\n const xy = clamp(uv.mul(grid.xy), vec2(0.5), grid.xy.sub(0.5)).div(grid.xy).toVar();\n const layers = grid.z.add(1.0);\n const za = vec3(xy, kc.x.add(0.5).div(layers));\n const zb = vec3(xy, kc.x.add(1.5).div(layers));\n const a = this.prefix.sample(za).level(float(0.0)).toVar();\n const b = this.prefix.sample(zb).level(float(0.0)).toVar();\n const aa = this.alphaPrefix.sample(za).level(float(0.0)).toVar();\n const ba = this.alphaPrefix.sample(zb).level(float(0.0)).toVar();\n const r = tapsFn({ a: vec4(a.x, 0.0, 0.0, aa.x), b: vec4(b.x, 0.0, 0.0, ba.x), c: kc.y }).toVar();\n const g = tapsFn({ a: vec4(a.y, 0.0, 0.0, a.w), b: vec4(b.y, 0.0, 0.0, b.w), c: kc.y }).toVar();\n const bl = tapsFn({ a: vec4(a.z, 0.0, 0.0, aa.y), b: vec4(b.z, 0.0, 0.0, ba.y), c: kc.y }).toVar();\n const transmittance = vec3(r.w, g.w, bl.w).toVar();\n If(transmittance.x.greaterThanEqual(1.0).and(transmittance.y.greaterThanEqual(1.0)).and(transmittance.z.greaterThanEqual(1.0)), () => {\n Discard();\n });\n return compositeSpectralFn({ radiance: vec3(r.x, g.x, bl.x), transmittance, sceneColor: viewportTexture() as VDBTslNode, srgb: uint(srgb ? 1 : 0), clampColors: uint(clampColors ? 1 : 0) });\n })();\n }\n}\n"]}
@@ -0,0 +1,53 @@
1
+ /**
2
+ * K6.5b: three's light shadow maps as the core renderer's occluder maps (mesh → volume shadows, design §3.7). For each
3
+ * directional, spot and point light with `castShadow` (and `renderer.shadowMap.enabled`) whose map three has drawn, the
4
+ * adapter passes the map's depth `GPUTexture` (a `'2d-array'` view: one layer, or the point light's 6 cube faces), the
5
+ * view-projections it was drawn with, `shadow.bias`, the renderer's reversed depth and the filter (`BasicShadowMap`:
6
+ * one texel, else 2 × 2 PCF).
7
+ *
8
+ * **No lag.** three draws a light's map inside its own render, when the first lit material of the frame draws (the
9
+ * light's `ShadowNode.updateBefore`). Before the core update the adapter calls that `updateBefore` itself, with three's
10
+ * frame id, so three draws (and submits) the map first and skips it later in the same frame; the core then reads this
11
+ * frame's map with this frame's matrices. A map three does not redraw this frame (`autoUpdate` off) is read as it is,
12
+ * with the matrices it was drawn with (they stay on the shadow camera), so map and matrices always agree.
13
+ *
14
+ * three r187 internals used, checked by a self-test per backend and map kind (`VDB_ENGINE_MISMATCH` otherwise):
15
+ * 1. `light.shadow.map.depthTexture`'s GPU texture (`backend.get(t).texture`): a depth format with `TEXTURE_BINDING`,
16
+ * 1 layer (directional, spot) or 6 (point, `CubeDepthTexture`);
17
+ * 2. `light.shadow.matrix` is the WebGPU bias matrix × `shadow.camera` projection × view of the last draw
18
+ * (`LightShadow._updateMatrix`); a point light's is the translation to the light of the last draw
19
+ * (`PointShadowNode.renderShadow`), which leaves `shadow.camera` on face 5, and its faces follow three's WebGPU
20
+ * table (checked on face 5);
21
+ * 3. the shared `AnalyticLightNode` of a light (`three-internals.ts` internal 1) has the `ShadowNode` in
22
+ * `shadowNode`, whose `updateBefore(frame)` draws the map once per frame and camera (`_cameraFrameId`), reading
23
+ * `frame.renderer / scene / camera / frameId`.
24
+ * Not supported: logarithmic depth buffers (the maps store log depth; warned, skipped); `CSMShadowNode` (its cascades
25
+ * are lights of their own; not mapped); `shadow.normalBias` (a volume has no normal).
26
+ */
27
+ import * as THREE from "three";
28
+ import type { VDBFrameOccluder } from "../../core/frame/types.js";
29
+ type RendererLike = THREE.EventDispatcher & {
30
+ readonly backend: object;
31
+ shadowMap: {
32
+ enabled: boolean;
33
+ type: THREE.ShadowMapType;
34
+ };
35
+ reversedDepthBuffer?: boolean;
36
+ logarithmicDepthBuffer?: boolean;
37
+ _nodes?: {
38
+ nodeFrame?: {
39
+ frameId?: number;
40
+ renderId?: number;
41
+ };
42
+ };
43
+ };
44
+ /** The occluder inputs of a render (one instance per `VDBFrameRenderer`). */
45
+ export declare class VDBCoreOccluders {
46
+ #private;
47
+ /**
48
+ * The occluder maps of `lights` (three lights in the camera's layers that the core lights; ids = `light.id`) for this
49
+ * render: draws three's pending maps first (no lag), then reads each map that exists.
50
+ */
51
+ input(renderer: RendererLike, scene: THREE.Object3D, camera: THREE.Camera, lights: readonly THREE.Light[]): VDBFrameOccluder[];
52
+ }
53
+ export {};
@@ -0,0 +1,193 @@
1
+ /**
2
+ * K6.5b: three's light shadow maps as the core renderer's occluder maps (mesh → volume shadows, design §3.7). For each
3
+ * directional, spot and point light with `castShadow` (and `renderer.shadowMap.enabled`) whose map three has drawn, the
4
+ * adapter passes the map's depth `GPUTexture` (a `'2d-array'` view: one layer, or the point light's 6 cube faces), the
5
+ * view-projections it was drawn with, `shadow.bias`, the renderer's reversed depth and the filter (`BasicShadowMap`:
6
+ * one texel, else 2 × 2 PCF).
7
+ *
8
+ * **No lag.** three draws a light's map inside its own render, when the first lit material of the frame draws (the
9
+ * light's `ShadowNode.updateBefore`). Before the core update the adapter calls that `updateBefore` itself, with three's
10
+ * frame id, so three draws (and submits) the map first and skips it later in the same frame; the core then reads this
11
+ * frame's map with this frame's matrices. A map three does not redraw this frame (`autoUpdate` off) is read as it is,
12
+ * with the matrices it was drawn with (they stay on the shadow camera), so map and matrices always agree.
13
+ *
14
+ * three r187 internals used, checked by a self-test per backend and map kind (`VDB_ENGINE_MISMATCH` otherwise):
15
+ * 1. `light.shadow.map.depthTexture`'s GPU texture (`backend.get(t).texture`): a depth format with `TEXTURE_BINDING`,
16
+ * 1 layer (directional, spot) or 6 (point, `CubeDepthTexture`);
17
+ * 2. `light.shadow.matrix` is the WebGPU bias matrix × `shadow.camera` projection × view of the last draw
18
+ * (`LightShadow._updateMatrix`); a point light's is the translation to the light of the last draw
19
+ * (`PointShadowNode.renderShadow`), which leaves `shadow.camera` on face 5, and its faces follow three's WebGPU
20
+ * table (checked on face 5);
21
+ * 3. the shared `AnalyticLightNode` of a light (`three-internals.ts` internal 1) has the `ShadowNode` in
22
+ * `shadowNode`, whose `updateBefore(frame)` draws the map once per frame and camera (`_cameraFrameId`), reading
23
+ * `frame.renderer / scene / camera / frameId`.
24
+ * Not supported: logarithmic depth buffers (the maps store log depth; warned, skipped); `CSMShadowNode` (its cascades
25
+ * are lights of their own; not mapped); `shadow.normalBias` (a volume has no normal).
26
+ */
27
+ import * as THREE from "three";
28
+ import { REVISION } from "three";
29
+ import { VDBError } from "../../core/errors.js";
30
+ import { vdbFrameSharedLightNode } from "./three-internals.js";
31
+ /** three r187 PointShadowNode's WebGPU cube faces: directions and ups (`_cubeDirectionsWebGPU`, `_cubeUpsWebGPU`). */
32
+ const CUBE_DIRECTIONS = [new THREE.Vector3(-1, 0, 0), new THREE.Vector3(1, 0, 0), new THREE.Vector3(0, 1, 0), new THREE.Vector3(0, -1, 0), new THREE.Vector3(0, 0, 1), new THREE.Vector3(0, 0, -1)];
33
+ const CUBE_UPS = [new THREE.Vector3(0, 1, 0), new THREE.Vector3(0, 1, 0), new THREE.Vector3(0, 0, -1), new THREE.Vector3(0, 0, 1), new THREE.Vector3(0, 1, 0), new THREE.Vector3(0, 1, 0)];
34
+ /** `LightShadow._updateMatrix`'s WebGPU bias (uv = ndc · ½ + ½, z kept). */
35
+ const WEBGPU_BIAS = new THREE.Matrix4().set(0.5, 0, 0, 0.5, 0, 0.5, 0, 0.5, 0, 0, 1, 0, 0, 0, 0, 1);
36
+ const TEXTURE_BINDING = 0x04;
37
+ const mismatch = (what) => new VDBError("VDB_ENGINE_MISMATCH", `three adapter (core occluder maps): three r${REVISION} ${what}. The frame renderer reads three's light shadow maps through three r187 ` +
38
+ "internals (peer range >=0.187.0 <0.188.0); this three version is unsupported for mesh → volume shadows (set frameRenderer.settings.occlusion = false).");
39
+ const near = (a, b, eps) => {
40
+ for (let i = 0; i < 16; i++)
41
+ if (Math.abs(a[i] - b[i]) > eps * Math.max(1, Math.abs(b[i])))
42
+ return false;
43
+ return true;
44
+ };
45
+ /** Self-test results per backend and kind ('2d' | 'cube' | 'flush'). */
46
+ const selfTested = new WeakMap();
47
+ function check(backend, kind, test) {
48
+ let byKind = selfTested.get(backend);
49
+ if (!byKind)
50
+ selfTested.set(backend, (byKind = new Map()));
51
+ const cached = byKind.get(kind);
52
+ if (cached === true)
53
+ return;
54
+ if (cached)
55
+ throw cached;
56
+ let problem;
57
+ try {
58
+ problem = test();
59
+ }
60
+ catch (e) {
61
+ problem = `failed the occluder self-test (${e instanceof Error ? e.message : String(e)})`;
62
+ }
63
+ const result = problem ? mismatch(problem) : true;
64
+ byKind.set(kind, result);
65
+ if (result !== true)
66
+ throw result;
67
+ }
68
+ /** The occluder inputs of a render (one instance per `VDBFrameRenderer`). */
69
+ export class VDBCoreOccluders {
70
+ #views = new WeakMap();
71
+ #state = new WeakMap();
72
+ #nodes = new WeakMap();
73
+ #camera = new THREE.PerspectiveCamera();
74
+ #warned = new Set();
75
+ /**
76
+ * The occluder maps of `lights` (three lights in the camera's layers that the core lights; ids = `light.id`) for this
77
+ * render: draws three's pending maps first (no lag), then reads each map that exists.
78
+ */
79
+ input(renderer, scene, camera, lights) {
80
+ if (!renderer.shadowMap?.enabled)
81
+ return [];
82
+ if (renderer.logarithmicDepthBuffer) {
83
+ this.#warnOnce("log", "mesh → volume shadows do not read logarithmic-depth shadow maps; occlusion is off.");
84
+ return [];
85
+ }
86
+ const backend = renderer.backend;
87
+ const frameId = renderer._nodes?.nodeFrame?.frameId;
88
+ const out = [];
89
+ for (const object of lights) {
90
+ const light = object;
91
+ if (!light.castShadow || !(light.isDirectionalLight || light.isSpotLight || light.isPointLight))
92
+ continue;
93
+ const shadow = light.shadow;
94
+ if (!shadow)
95
+ continue;
96
+ const state = this.#state.get(light) ?? { revision: 0, frame: -1 };
97
+ this.#state.set(light, state);
98
+ // three draws this frame's map now (if it will at all), so the core reads it in this render
99
+ if (this.#flush(renderer, scene, camera, light, frameId)) {
100
+ if (state.frame !== frameId)
101
+ state.revision++;
102
+ state.frame = frameId ?? -1;
103
+ }
104
+ const depthTexture = shadow.map?.depthTexture;
105
+ if (!depthTexture)
106
+ continue;
107
+ const gpu = backend.get(depthTexture)?.texture;
108
+ if (!gpu)
109
+ continue;
110
+ const point = !!light.isPointLight;
111
+ check(backend, point ? "cube" : "2d", () => {
112
+ if (!String(gpu.format).startsWith("depth"))
113
+ return `stores a light's shadow map as ${gpu.format}, not a depth format`;
114
+ if (!(gpu.usage & TEXTURE_BINDING))
115
+ return "made a shadow map without TEXTURE_BINDING";
116
+ if (gpu.depthOrArrayLayers !== (point ? 6 : 1))
117
+ return `made a ${point ? "point" : "directional / spot"} shadow map with ${gpu.depthOrArrayLayers} layers`;
118
+ return point ? this.#checkCube(light) : this.#check2d(shadow);
119
+ });
120
+ let view = this.#views.get(gpu);
121
+ if (!view)
122
+ this.#views.set(gpu, (view = gpu.createView({ dimension: "2d-array", aspect: "depth-only", label: `vdb occluder ${light.name || light.id}` })));
123
+ out.push({
124
+ light: light.id,
125
+ depth: view,
126
+ viewProjection: point ? this.#faces(light) : [new THREE.Matrix4().multiplyMatrices(shadow.camera.projectionMatrix, shadow.camera.matrixWorldInverse).elements],
127
+ bias: shadow.bias,
128
+ reversedDepth: !!renderer.reversedDepthBuffer,
129
+ filter: renderer.shadowMap.type === THREE.BasicShadowMap ? "nearest" : "bilinear",
130
+ revision: state.revision,
131
+ });
132
+ }
133
+ return out;
134
+ }
135
+ /**
136
+ * Runs the light's `ShadowNode.updateBefore` with three's frame (internal 3): three draws the map now if it would draw
137
+ * it this frame, and not again later. Returns whether the map was drawn this frame for this camera.
138
+ */
139
+ #flush(renderer, scene, camera, light, frameId) {
140
+ let lightNode = this.#nodes.get(light);
141
+ if (lightNode === undefined)
142
+ this.#nodes.set(light, (lightNode = vdbFrameSharedLightNode(light)));
143
+ const shadowNode = lightNode?.shadowNode;
144
+ // No shadow node: no lit material uses the light yet, so three has no map (nothing to read)
145
+ if (!shadowNode)
146
+ return false;
147
+ check(renderer.backend, "flush", () => {
148
+ if (typeof frameId !== "number")
149
+ return "has no renderer._nodes.nodeFrame.frameId";
150
+ if (typeof shadowNode.updateBefore !== "function")
151
+ return "has no ShadowNode.updateBefore";
152
+ if (!(shadowNode._cameraFrameId instanceof WeakMap))
153
+ return "has no ShadowNode._cameraFrameId (its once-per-frame guard)";
154
+ return null;
155
+ });
156
+ shadowNode.updateBefore({ renderer, scene, camera, frameId, renderId: renderer._nodes?.nodeFrame?.renderId });
157
+ return shadowNode._cameraFrameId.get(camera) === frameId;
158
+ }
159
+ /** Internal 2 for a directional or spot map: shadow.matrix = bias × the camera's projection × view. */
160
+ #check2d(shadow) {
161
+ const expected = new THREE.Matrix4().multiplyMatrices(WEBGPU_BIAS, new THREE.Matrix4().multiplyMatrices(shadow.camera.projectionMatrix, shadow.camera.matrixWorldInverse));
162
+ return near(shadow.matrix.elements, expected.elements, 1e-5) ? null : "keeps a shadow.matrix that is not bias × the shadow camera's projection × view (the map's draw state is unknown)";
163
+ }
164
+ /** Internal 2 for a point map: face 5 of the table from the light position of the last draw equals the shadow camera. */
165
+ #checkCube(light) {
166
+ const faces = this.#faceViews(light);
167
+ return near(faces[5].elements, light.shadow.camera.matrixWorldInverse.elements, 1e-5) ? null : "draws point shadow faces another way (face 5 does not match the shadow camera)";
168
+ }
169
+ /** The 6 face views of a point light's last draw (its position from `shadow.matrix`, three's WebGPU table). */
170
+ #faceViews(light) {
171
+ const position = new THREE.Vector3().setFromMatrixPosition(light.shadow.matrix).negate();
172
+ const c = this.#camera;
173
+ return CUBE_DIRECTIONS.map((direction, face) => {
174
+ c.position.copy(position);
175
+ c.up.copy(CUBE_UPS[face]);
176
+ c.lookAt(position.clone().add(direction));
177
+ c.updateMatrixWorld(true);
178
+ return c.matrixWorldInverse.clone();
179
+ });
180
+ }
181
+ /** The 6 face view-projections (one projection: the shadow camera's, as drawn). */
182
+ #faces(light) {
183
+ const projection = light.shadow.camera.projectionMatrix;
184
+ return this.#faceViews(light).map((view) => Float32Array.from(new THREE.Matrix4().multiplyMatrices(projection, view).elements));
185
+ }
186
+ #warnOnce(key, message) {
187
+ if (this.#warned.has(key))
188
+ return;
189
+ this.#warned.add(key);
190
+ console.warn(`@pmndrs/vdb/three: ${message}`);
191
+ }
192
+ }
193
+ //# sourceMappingURL=core-occluders.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"core-occluders.js","sourceRoot":"","sources":["../../../src/three/frame/core-occluders.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AAEH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACjC,OAAO,EAAE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AC;YAC1B,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAE,CAAC,CAAC;YAC3B,CAAC,CAAC,MAAM,CAAC,QAAQ,CAAC,KAAK,EAAE,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC,CAAC;YAC1C,CAAC,CAAC,iBAAiB,CAAC,IAAI,CAAC,CAAC;YAC1B,OAAO,CAAC,CAAC,kBAAkB,CAAC,KAAK,EAAE,CAAC;QACtC,CAAC,CAAC,CAAC;IACL,CAAC;IAED,mFAAmF;IACnF,MAAM,CAAC,KAAuB;QAC5B,MAAM,UAAU,GAAG,KAAK,CAAC,MAAM,CAAC,MAAM,CAAC,gBAAgB,CAAC;QACxD,OAAO,IAAI,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,YAAY,CAAC,IAAI,CAAC,IAAI,KAAK,CAAC,OAAO,EAAE,CAAC,gBAAgB,CAAC,UAAU,EAAE,IAAI,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC;IAClI,CAAC;IAED,SAAS,CAAC,GAAW,EAAE,OAAe;QACpC,IAAI,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC;YAAE,OAAO;QAClC,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;QACtB,OAAO,CAAC,IAAI,CAAC,sBAAsB,OAAO,EAAE,CAAC,CAAC;IAChD,CAAC;CACF","sourcesContent":["/**\n * K6.5b: three's light shadow maps as the core renderer's occluder maps (mesh → volume shadows, design §3.7). For each\n * directional, spot and point light with `castShadow` (and `renderer.shadowMap.enabled`) whose map three has drawn, the\n * adapter passes the map's depth `GPUTexture` (a `'2d-array'` view: one layer, or the point light's 6 cube faces), the\n * view-projections it was drawn with, `shadow.bias`, the renderer's reversed depth and the filter (`BasicShadowMap`:\n * one texel, else 2 × 2 PCF).\n *\n * **No lag.** three draws a light's map inside its own render, when the first lit material of the frame draws (the\n * light's `ShadowNode.updateBefore`). Before the core update the adapter calls that `updateBefore` itself, with three's\n * frame id, so three draws (and submits) the map first and skips it later in the same frame; the core then reads this\n * frame's map with this frame's matrices. A map three does not redraw this frame (`autoUpdate` off) is read as it is,\n * with the matrices it was drawn with (they stay on the shadow camera), so map and matrices always agree.\n *\n * three r187 internals used, checked by a self-test per backend and map kind (`VDB_ENGINE_MISMATCH` otherwise):\n * 1. `light.shadow.map.depthTexture`'s GPU texture (`backend.get(t).texture`): a depth format with `TEXTURE_BINDING`,\n * 1 layer (directional, spot) or 6 (point, `CubeDepthTexture`);\n * 2. `light.shadow.matrix` is the WebGPU bias matrix × `shadow.camera` projection × view of the last draw\n * (`LightShadow._updateMatrix`); a point light's is the translation to the light of the last draw\n * (`PointShadowNode.renderShadow`), which leaves `shadow.camera` on face 5, and its faces follow three's WebGPU\n * table (checked on face 5);\n * 3. the shared `AnalyticLightNode` of a light (`three-internals.ts` internal 1) has the `ShadowNode` in\n * `shadowNode`, whose `updateBefore(frame)` draws the map once per frame and camera (`_cameraFrameId`), reading\n * `frame.renderer / scene / camera / frameId`.\n * Not supported: logarithmic depth buffers (the maps store log depth; warned, skipped); `CSMShadowNode` (its cascades\n * are lights of their own; not mapped); `shadow.normalBias` (a volume has no normal).\n */\n\nimport * as THREE from \"three\";\nimport { REVISION } from \"three\";\nimport { VDBError } from \"../../core/errors.js\";\nimport type { VDBFrameOccluder } from \"../../core/frame/types.js\";\nimport { vdbFrameSharedLightNode } from \"./three-internals.js\";\n\ninterface BackendLike {\n get(object: object): Record<string, unknown>;\n}\ntype RendererLike = THREE.EventDispatcher & {\n readonly backend: object;\n shadowMap: { enabled: boolean; type: THREE.ShadowMapType };\n reversedDepthBuffer?: boolean;\n logarithmicDepthBuffer?: boolean;\n _nodes?: { nodeFrame?: { frameId?: number; renderId?: number } };\n};\ntype ShadowLight = (THREE.DirectionalLight | THREE.SpotLight | THREE.PointLight) & { isDirectionalLight?: boolean; isSpotLight?: boolean; isPointLight?: boolean };\ntype ShadowNodeLike = { updateBefore?: (frame: object) => unknown; _cameraFrameId?: WeakMap<object, number> };\n\n/** three r187 PointShadowNode's WebGPU cube faces: directions and ups (`_cubeDirectionsWebGPU`, `_cubeUpsWebGPU`). */\nconst CUBE_DIRECTIONS = [new THREE.Vector3(-1, 0, 0), new THREE.Vector3(1, 0, 0), new THREE.Vector3(0, 1, 0), new THREE.Vector3(0, -1, 0), new THREE.Vector3(0, 0, 1), new THREE.Vector3(0, 0, -1)];\nconst CUBE_UPS = [new THREE.Vector3(0, 1, 0), new THREE.Vector3(0, 1, 0), new THREE.Vector3(0, 0, -1), new THREE.Vector3(0, 0, 1), new THREE.Vector3(0, 1, 0), new THREE.Vector3(0, 1, 0)];\n/** `LightShadow._updateMatrix`'s WebGPU bias (uv = ndc · ½ + ½, z kept). */\nconst WEBGPU_BIAS = new THREE.Matrix4().set(0.5, 0, 0, 0.5, 0, 0.5, 0, 0.5, 0, 0, 1, 0, 0, 0, 0, 1);\nconst TEXTURE_BINDING = 0x04;\n\nconst mismatch = (what: string): VDBError =>\n new VDBError(\n \"VDB_ENGINE_MISMATCH\",\n `three adapter (core occluder maps): three r${REVISION} ${what}. The frame renderer reads three's light shadow maps through three r187 ` +\n \"internals (peer range >=0.187.0 <0.188.0); this three version is unsupported for mesh → volume shadows (set frameRenderer.settings.occlusion = false).\",\n );\n\nconst near = (a: ArrayLike<number>, b: ArrayLike<number>, eps: number) => {\n for (let i = 0; i < 16; i++) if (Math.abs(a[i]! - b[i]!) > eps * Math.max(1, Math.abs(b[i]!))) return false;\n return true;\n};\n\n/** Self-test results per backend and kind ('2d' | 'cube' | 'flush'). */\nconst selfTested = new WeakMap<object, Map<string, true | VDBError>>();\n\nfunction check(backend: object, kind: string, test: () => string | null): void {\n let byKind = selfTested.get(backend);\n if (!byKind) selfTested.set(backend, (byKind = new Map()));\n const cached = byKind.get(kind);\n if (cached === true) return;\n if (cached) throw cached;\n let problem: string | null;\n try {\n problem = test();\n } catch (e) {\n problem = `failed the occluder self-test (${e instanceof Error ? e.message : String(e)})`;\n }\n const result = problem ? mismatch(problem) : true;\n byKind.set(kind, result);\n if (result !== true) throw result;\n}\n\n/** One light's state across updates: its revision (bumped when three drew the map) and the frame that bumped it. */\ninterface LightState {\n revision: number;\n frame: number;\n}\n\n/** The occluder inputs of a render (one instance per `VDBFrameRenderer`). */\nexport class VDBCoreOccluders {\n readonly #views = new WeakMap<GPUTexture, GPUTextureView>();\n readonly #state = new WeakMap<object, LightState>();\n readonly #nodes = new WeakMap<object, { shadowNode?: unknown } | null>();\n readonly #camera = new THREE.PerspectiveCamera();\n #warned = new Set<string>();\n\n /**\n * The occluder maps of `lights` (three lights in the camera's layers that the core lights; ids = `light.id`) for this\n * render: draws three's pending maps first (no lag), then reads each map that exists.\n */\n input(renderer: RendererLike, scene: THREE.Object3D, camera: THREE.Camera, lights: readonly THREE.Light[]): VDBFrameOccluder[] {\n if (!renderer.shadowMap?.enabled) return [];\n if (renderer.logarithmicDepthBuffer) {\n this.#warnOnce(\"log\", \"mesh → volume shadows do not read logarithmic-depth shadow maps; occlusion is off.\");\n return [];\n }\n const backend = renderer.backend as BackendLike;\n const frameId = renderer._nodes?.nodeFrame?.frameId;\n const out: VDBFrameOccluder[] = [];\n for (const object of lights) {\n const light = object as ShadowLight;\n if (!light.castShadow || !(light.isDirectionalLight || light.isSpotLight || light.isPointLight)) continue;\n const shadow = light.shadow as THREE.LightShadow & { autoUpdate?: boolean; needsUpdate?: boolean };\n if (!shadow) continue;\n const state = this.#state.get(light) ?? { revision: 0, frame: -1 };\n this.#state.set(light, state);\n // three draws this frame's map now (if it will at all), so the core reads it in this render\n if (this.#flush(renderer, scene, camera, light, frameId)) {\n if (state.frame !== frameId) state.revision++;\n state.frame = frameId ?? -1;\n }\n const depthTexture = (shadow.map as (THREE.RenderTarget & { depthTexture?: THREE.Texture | null }) | null)?.depthTexture;\n if (!depthTexture) continue;\n const gpu = backend.get(depthTexture)?.texture as GPUTexture | undefined;\n if (!gpu) continue;\n const point = !!light.isPointLight;\n check(backend, point ? \"cube\" : \"2d\", () => {\n if (!String(gpu.format).startsWith(\"depth\")) return `stores a light's shadow map as ${gpu.format}, not a depth format`;\n if (!(gpu.usage & TEXTURE_BINDING)) return \"made a shadow map without TEXTURE_BINDING\";\n if (gpu.depthOrArrayLayers !== (point ? 6 : 1)) return `made a ${point ? \"point\" : \"directional / spot\"} shadow map with ${gpu.depthOrArrayLayers} layers`;\n return point ? this.#checkCube(light as THREE.PointLight) : this.#check2d(shadow);\n });\n let view = this.#views.get(gpu);\n if (!view) this.#views.set(gpu, (view = gpu.createView({ dimension: \"2d-array\", aspect: \"depth-only\", label: `vdb occluder ${light.name || light.id}` })));\n out.push({\n light: light.id,\n depth: view,\n viewProjection: point ? this.#faces(light as THREE.PointLight) : [new THREE.Matrix4().multiplyMatrices(shadow.camera.projectionMatrix, shadow.camera.matrixWorldInverse).elements],\n bias: shadow.bias,\n reversedDepth: !!renderer.reversedDepthBuffer,\n filter: renderer.shadowMap.type === THREE.BasicShadowMap ? \"nearest\" : \"bilinear\",\n revision: state.revision,\n });\n }\n return out;\n }\n\n /**\n * Runs the light's `ShadowNode.updateBefore` with three's frame (internal 3): three draws the map now if it would draw\n * it this frame, and not again later. Returns whether the map was drawn this frame for this camera.\n */\n #flush(renderer: RendererLike, scene: THREE.Object3D, camera: THREE.Camera, light: ShadowLight, frameId: number | undefined): boolean {\n let lightNode = this.#nodes.get(light);\n if (lightNode === undefined) this.#nodes.set(light, (lightNode = vdbFrameSharedLightNode(light) as { shadowNode?: unknown } | null));\n const shadowNode = lightNode?.shadowNode as ShadowNodeLike | null | undefined;\n // No shadow node: no lit material uses the light yet, so three has no map (nothing to read)\n if (!shadowNode) return false;\n check(renderer.backend, \"flush\", () => {\n if (typeof frameId !== \"number\") return \"has no renderer._nodes.nodeFrame.frameId\";\n if (typeof shadowNode.updateBefore !== \"function\") return \"has no ShadowNode.updateBefore\";\n if (!(shadowNode._cameraFrameId instanceof WeakMap)) return \"has no ShadowNode._cameraFrameId (its once-per-frame guard)\";\n return null;\n });\n shadowNode.updateBefore!({ renderer, scene, camera, frameId, renderId: renderer._nodes?.nodeFrame?.renderId });\n return shadowNode._cameraFrameId!.get(camera) === frameId;\n }\n\n /** Internal 2 for a directional or spot map: shadow.matrix = bias × the camera's projection × view. */\n #check2d(shadow: THREE.LightShadow): string | null {\n const expected = new THREE.Matrix4().multiplyMatrices(WEBGPU_BIAS, new THREE.Matrix4().multiplyMatrices(shadow.camera.projectionMatrix, shadow.camera.matrixWorldInverse));\n return near(shadow.matrix.elements, expected.elements, 1e-5) ? null : \"keeps a shadow.matrix that is not bias × the shadow camera's projection × view (the map's draw state is unknown)\";\n }\n\n /** Internal 2 for a point map: face 5 of the table from the light position of the last draw equals the shadow camera. */\n #checkCube(light: THREE.PointLight): string | null {\n const faces = this.#faceViews(light);\n return near(faces[5]!.elements, light.shadow.camera.matrixWorldInverse.elements, 1e-5) ? null : \"draws point shadow faces another way (face 5 does not match the shadow camera)\";\n }\n\n /** The 6 face views of a point light's last draw (its position from `shadow.matrix`, three's WebGPU table). */\n #faceViews(light: THREE.PointLight): THREE.Matrix4[] {\n const position = new THREE.Vector3().setFromMatrixPosition(light.shadow.matrix).negate();\n const c = this.#camera;\n return CUBE_DIRECTIONS.map((direction, face) => {\n c.position.copy(position);\n c.up.copy(CUBE_UPS[face]!);\n c.lookAt(position.clone().add(direction));\n c.updateMatrixWorld(true);\n return c.matrixWorldInverse.clone();\n });\n }\n\n /** The 6 face view-projections (one projection: the shadow camera's, as drawn). */\n #faces(light: THREE.PointLight): Float32Array[] {\n const projection = light.shadow.camera.projectionMatrix;\n return this.#faceViews(light).map((view) => Float32Array.from(new THREE.Matrix4().multiplyMatrices(projection, view).elements));\n }\n\n #warnOnce(key: string, message: string): void {\n if (this.#warned.has(key)) return;\n this.#warned.add(key);\n console.warn(`@pmndrs/vdb/three: ${message}`);\n }\n}\n"]}
@@ -0,0 +1,34 @@
1
+ /**
2
+ * K6.8a / K6.8b: reading a core uniform struct from a buffer three binds as storage. three r187 binds a buffer it does not
3
+ * own only as storage (`vdbThreeStorageStandIn`, the `VDBGridNode` pattern): a uniform `BufferNode` uploads its own array.
4
+ * So the core buffer (a volume shadow map's `view`, the emission probes' `grid`) is read as `array<vec4u>` and a generated
5
+ * WGSL function unpacks it into the core's struct, field by field from the struct's layout, so a field the core adds is
6
+ * unpacked too. The struct's own WGSL comes with the core's receiver code (`vdbVolumeShadowWgsl()`, `vdbEmissionProbeWgsl()`).
7
+ */
8
+ import { CodeNode, type Node, type NodeBuilder } from "three/webgpu";
9
+ import type { VDBUniformStruct } from "../../core/frame/uniforms.js";
10
+ /** A three storage node (`storage(attribute, 'uvec4', words).toReadOnly()`). */
11
+ export type VDBFrameStorageNode = Node & {
12
+ value: unknown;
13
+ setName(name: string): unknown;
14
+ build(builder: NodeBuilder, output?: string): unknown;
15
+ };
16
+ /**
17
+ * WGSL `fn <fnName>() -> <struct.name>` that unpacks the struct from the `array<vec4u>` binding `ref`. Only 16-byte vector
18
+ * and `mat4x4f` fields unpack (every field of the structs three reads); another type throws.
19
+ */
20
+ export declare function vdbFrameStructLoaderWgsl(struct: VDBUniformStruct, fnName: string, ref: string): string;
21
+ /** `vec4u` words of a struct (its size is a multiple of 16). */
22
+ export declare const vdbFrameStructWords: (struct: VDBUniformStruct) => number;
23
+ /**
24
+ * One binding's loader: a code node over its storage node, generated per shader with the binding's reference (three names
25
+ * the binding per shader). Include it in the `wgslFn` that calls `fnName()`.
26
+ */
27
+ export declare class VDBFrameStructLoaderNode extends CodeNode {
28
+ /** Node-valued property: three sets it up and analyzes it as this node's child (the binding). */
29
+ vdbStructBuffer: VDBFrameStorageNode;
30
+ readonly fnName: string;
31
+ readonly struct: VDBUniformStruct;
32
+ constructor(buffer: VDBFrameStorageNode, struct: VDBUniformStruct, fnName: string);
33
+ generate(builder: NodeBuilder): string;
34
+ }
@@ -0,0 +1,61 @@
1
+ /**
2
+ * K6.8a / K6.8b: reading a core uniform struct from a buffer three binds as storage. three r187 binds a buffer it does not
3
+ * own only as storage (`vdbThreeStorageStandIn`, the `VDBGridNode` pattern): a uniform `BufferNode` uploads its own array.
4
+ * So the core buffer (a volume shadow map's `view`, the emission probes' `grid`) is read as `array<vec4u>` and a generated
5
+ * WGSL function unpacks it into the core's struct, field by field from the struct's layout, so a field the core adds is
6
+ * unpacked too. The struct's own WGSL comes with the core's receiver code (`vdbVolumeShadowWgsl()`, `vdbEmissionProbeWgsl()`).
7
+ */
8
+ import { CodeNode } from "three/webgpu";
9
+ /**
10
+ * WGSL `fn <fnName>() -> <struct.name>` that unpacks the struct from the `array<vec4u>` binding `ref`. Only 16-byte vector
11
+ * and `mat4x4f` fields unpack (every field of the structs three reads); another type throws.
12
+ */
13
+ export function vdbFrameStructLoaderWgsl(struct, fnName, ref) {
14
+ const lines = [`fn ${fnName}() -> ${struct.name} {`, ` var v: ${struct.name};`];
15
+ for (const f of struct.fields.values()) {
16
+ for (let e = 0; e < f.count; e++) {
17
+ const at = (f.offset + e * f.stride) / 16;
18
+ const lhs = f.count > 1 ? `v.${f.name}[${e}]` : `v.${f.name}`;
19
+ let rhs;
20
+ if (f.type === "mat4x4f")
21
+ rhs = `mat4x4f(${[0, 1, 2, 3].map((c) => `bitcast<vec4f>(${ref}[${at + c}])`).join(", ")})`;
22
+ else if (f.type === "vec4f")
23
+ rhs = `bitcast<vec4f>(${ref}[${at}])`;
24
+ else if (f.type === "vec4u")
25
+ rhs = `${ref}[${at}]`;
26
+ else
27
+ throw new Error(`vdbFrameStructLoaderWgsl: ${struct.name}.${f.name} is ${f.type}; only 16-byte vector and mat4x4f fields unpack`);
28
+ lines.push(` ${lhs} = ${rhs};`);
29
+ }
30
+ }
31
+ lines.push(" return v;", "}");
32
+ return lines.join("\n");
33
+ }
34
+ /** `vec4u` words of a struct (its size is a multiple of 16). */
35
+ export const vdbFrameStructWords = (struct) => struct.size / 16;
36
+ /**
37
+ * One binding's loader: a code node over its storage node, generated per shader with the binding's reference (three names
38
+ * the binding per shader). Include it in the `wgslFn` that calls `fnName()`.
39
+ */
40
+ export class VDBFrameStructLoaderNode extends CodeNode {
41
+ /** Node-valued property: three sets it up and analyzes it as this node's child (the binding). */
42
+ vdbStructBuffer;
43
+ fnName;
44
+ struct;
45
+ constructor(buffer, struct, fnName) {
46
+ super("", [], "wgsl");
47
+ this.vdbStructBuffer = buffer;
48
+ this.struct = struct;
49
+ this.fnName = fnName;
50
+ }
51
+ generate(builder) {
52
+ const ref = this.vdbStructBuffer.build(builder, "property");
53
+ if (typeof ref !== "string")
54
+ throw new Error(`VDBFrameStructLoaderNode: three built the ${this.struct.name} storage node to a non-string reference`);
55
+ const text = vdbFrameStructLoaderWgsl(this.struct, this.fnName, ref);
56
+ const nodeCode = builder.getCodeFromNode(this, this.getNodeType(builder));
57
+ nodeCode.code = text;
58
+ return text;
59
+ }
60
+ }
61
+ //# sourceMappingURL=core-structs.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"core-structs.js","sourceRoot":"","sources":["../../../src/three/frame/core-structs.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,QAAQ,EAA+B,MAAM,cAAc,CAAC;AAMrE;;;GAGG;AACH,MAAM,UAAU,wBAAwB,CAAC,MAAwB,EAAE,MAAc,EAAE,GAAW;IAC5F,MAAM,KAAK,GAAG,CAAC,MAAM,MAAM,SAAS,MAAM,CAAC,IAAI,IAAI,EAAE,YAAY,MAAM,CAAC,IAAI,GAAG,CAAC,CAAC;IACjF,KAAK,MAAM,CAAC,IAAI,MAAM,CAAC,MAAM,CAAC,MAAM,EAAE,EAAE,CAAC;QACvC,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,CAAC,EAAE,EAAE,CAAC;YACjC,MAAM,EAAE,GAAG,CAAC,CAAC,CAAC,MAAM,GAAG,CAAC,GAAG,CAAC,CAAC,MAAM,CA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CAAsB;IAC5B,MAAM,CAAS;IACf,MAAM,CAAmB;IAElC,YAAY,MAA2B,EAAE,MAAwB,EAAE,MAAc;QAC/E,KAAK,CAAC,EAAE,EAAE,EAAE,EAAE,MAAM,CAAC,CAAC;QACtB,IAAI,CAAC,eAAe,GAAG,MAAM,CAAC;QAC9B,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;IACvB,CAAC;IAEQ,QAAQ,CAAC,OAAoB;QACpC,MAAM,GAAG,GAAG,IAAI,CAAC,eAAe,CAAC,KAAK,CAAC,OAAO,EAAE,UAAU,CAAC,CAAC;QAC5D,IAAI,OAAO,GAAG,KAAK,QAAQ;YAAE,MAAM,IAAI,KAAK,CAAC,6CAA6C,IAAI,CAAC,MAAM,CAAC,IAAI,yCAAyC,CAAC,CAAC;QACrJ,MAAM,IAAI,GAAG,wBAAwB,CAAC,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;QACrE,MAAM,QAAQ,GAAI,OAAsF,CAAC,eAAe,CAAC,IAAI,EAAE,IAAI,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC,CAAC;QAC1J,QAAQ,CAAC,IAAI,GAAG,IAAI,CAAC;QACrB,OAAO,IAAI,CAAC;IACd,CAAC;CACF","sourcesContent":["/**\n * K6.8a / K6.8b: reading a core uniform struct from a buffer three binds as storage. three r187 binds a buffer it does not\n * own only as storage (`vdbThreeStorageStandIn`, the `VDBGridNode` pattern): a uniform `BufferNode` uploads its own array.\n * So the core buffer (a volume shadow map's `view`, the emission probes' `grid`) is read as `array<vec4u>` and a generated\n * WGSL function unpacks it into the core's struct, field by field from the struct's layout, so a field the core adds is\n * unpacked too. The struct's own WGSL comes with the core's receiver code (`vdbVolumeShadowWgsl()`, `vdbEmissionProbeWgsl()`).\n */\n\nimport { CodeNode, type Node, type NodeBuilder } from \"three/webgpu\";\nimport type { VDBUniformStruct } from \"../../core/frame/uniforms.js\";\n\n/** A three storage node (`storage(attribute, 'uvec4', words).toReadOnly()`). */\nexport type VDBFrameStorageNode = Node & { value: unknown; setName(name: string): unknown; build(builder: NodeBuilder, output?: string): unknown };\n\n/**\n * WGSL `fn <fnName>() -> <struct.name>` that unpacks the struct from the `array<vec4u>` binding `ref`. Only 16-byte vector\n * and `mat4x4f` fields unpack (every field of the structs three reads); another type throws.\n */\nexport function vdbFrameStructLoaderWgsl(struct: VDBUniformStruct, fnName: string, ref: string): string {\n const lines = [`fn ${fnName}() -> ${struct.name} {`, ` var v: ${struct.name};`];\n for (const f of struct.fields.values()) {\n for (let e = 0; e < f.count; e++) {\n const at = (f.offset + e * f.stride) / 16;\n const lhs = f.count > 1 ? `v.${f.name}[${e}]` : `v.${f.name}`;\n let rhs: string;\n if (f.type === \"mat4x4f\") rhs = `mat4x4f(${[0, 1, 2, 3].map((c) => `bitcast<vec4f>(${ref}[${at + c}])`).join(\", \")})`;\n else if (f.type === \"vec4f\") rhs = `bitcast<vec4f>(${ref}[${at}])`;\n else if (f.type === \"vec4u\") rhs = `${ref}[${at}]`;\n else throw new Error(`vdbFrameStructLoaderWgsl: ${struct.name}.${f.name} is ${f.type}; only 16-byte vector and mat4x4f fields unpack`);\n lines.push(` ${lhs} = ${rhs};`);\n }\n }\n lines.push(\" return v;\", \"}\");\n return lines.join(\"\\n\");\n}\n\n/** `vec4u` words of a struct (its size is a multiple of 16). */\nexport const vdbFrameStructWords = (struct: VDBUniformStruct): number => struct.size / 16;\n\n/**\n * One binding's loader: a code node over its storage node, generated per shader with the binding's reference (three names\n * the binding per shader). Include it in the `wgslFn` that calls `fnName()`.\n */\nexport class VDBFrameStructLoaderNode extends CodeNode {\n /** Node-valued property: three sets it up and analyzes it as this node's child (the binding). */\n vdbStructBuffer: VDBFrameStorageNode;\n readonly fnName: string;\n readonly struct: VDBUniformStruct;\n\n constructor(buffer: VDBFrameStorageNode, struct: VDBUniformStruct, fnName: string) {\n super(\"\", [], \"wgsl\");\n this.vdbStructBuffer = buffer;\n this.struct = struct;\n this.fnName = fnName;\n }\n\n override generate(builder: NodeBuilder): string {\n const ref = this.vdbStructBuffer.build(builder, \"property\");\n if (typeof ref !== \"string\") throw new Error(`VDBFrameStructLoaderNode: three built the ${this.struct.name} storage node to a non-string reference`);\n const text = vdbFrameStructLoaderWgsl(this.struct, this.fnName, ref);\n const nodeCode = (builder as unknown as { getCodeFromNode(node: Node, type: string): { code: string } }).getCodeFromNode(this, this.getNodeType(builder));\n nodeCode.code = text;\n return text;\n }\n}\n"]}