@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 @@
1
+ {"version":3,"file":"level-set-material.js","sourceRoot":"","sources":["../../src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,IAAI,EAAE,IAAI,CAAC,CAAC;IACpC,CAAC;IAED,kFAAkF;IACzE,aAAa,CAAC,OAAiE;QACtF,2BAA2B,CAAC,IAAI,CAAC,CAAC;QAClC,OAAO,KAAK,CAAC,aAAa,CAAC,OAAO,CAAC,CAAC;IACtC,CAAC;CACF","sourcesContent":["/**\n * `VDBLevelSetMaterial`: a NanoVDB level set's zero surface, traced on the GPU\n * on the sparse pool (K3.7, R1 §6 Step 7), as a three r187\n * `MeshStandardNodeMaterial` (lights, shadows, depth, fog: three's own).\n *\n * const grids = new VDBGridNode(renderer, pool, { profile: 'march', helpers: ['levelSet'] });\n * const material = new VDBLevelSetMaterial(renderer, grids, id, { color: 0xffffff, roughness: 0.5 });\n * scene.add(new Mesh(vdbProxyGeometry(pool.info(id), { pad: 1 }), material));\n * // per frame: pool.update(encoder) (or pool.flush()), then grids.update(), then render.\n *\n * The trace, normal and pixel ray are the core's `vdbLevelSetSurface` / `vdbLevelSetViewRay` WGSL\n * (`core/surface/level-set-wgsl.ts`, K6.6), the same functions the raw pass `vdbCreateLevelSetPass`\n * calls; this material adds three's lighting, shadows and depth conventions around them.\n *\n * Portions derived from mjurczyk/openvdb (MIT), commit 75e7345\n * (`src/three-openvdb/levelset/webgpu/LevelSetSurfaceMaterial.js`,\n * `LevelSetSurfaceCore.js`): the back-face proxy box (the camera can be\n * inside), perspective and orthographic rays (so shadow passes work), the mask,\n * depth, received-shadow position and the `setupLighting` override that moves\n * `positionView` to the hit. Copyright (c) mjurczyk/openvdb contributors, MIT\n * (see THIRD_PARTY_NOTICES.md). Changes: the trace is the core's `vdbLevelSetHit` on\n * the sparse tree (HDDA skip, full-resolution trilinear SDF) instead of a\n * sphere trace of a dense 8-bit texture; the ray comes from the pixel through\n * the inverse projection, not from interpolated box positions; the normal is\n * `vdbLevelSetNormal` (central differences at `normalStep` voxels through the\n * grid affine); the proxy is in world space and the grid is placed with\n * `pool.setTransform` (DIVERGES.md).\n *\n * The trace runs in the grid's index space: `o = worldToIndex(ray origin)`,\n * `d = worldToIndexDir(unit world direction)`, so `t` is in world units. The\n * ray is the pixel's (`viewportUV` through `cameraProjectionMatrixInverse`):\n * perspective from `cameraPosition` over `t >= 0`; orthographic from the pixel\n * on the camera plane along the view axis over `t` in `[-1e5, 1e5]`. The mesh\n * must have an identity transform (the pool record holds the grid's\n * placement); give it `vdbProxyGeometry(pool.info(id), { pad: 1 })`, which\n * covers the trilinear support the trace clips to.\n */\n\nimport * as THREE from \"three\";\nimport { MeshStandardNodeMaterial } from \"three/webgpu\";\nimport * as TSL from \"three/tsl\";\nimport { VDBError } from \"../core/errors.js\";\nimport { vdbLevelSetSurfaceWgsl } from \"../core/surface/level-set-wgsl.js\";\nimport { getDevice, type VDBThreeRendererLike } from \"./device.js\";\nimport { VDBGridNode, type VDBTslNode } from \"./grid-node.js\";\nimport type { VDBUintUniform } from \"./material.js\";\n\nconst { Fn, code, float, select, uint, uniform, vec3, vec4, wgslFn, positionLocal, positionView, viewportUV } = TSL as unknown as Record<string, VDBTslNode>;\nconst { materialRoughness } = TSL as unknown as Record<string, VDBTslNode>;\nconst { cameraFar, cameraNear, cameraProjectionMatrix, cameraProjectionMatrixInverse, cameraViewMatrix, cameraWorldMatrix, modelViewMatrix } =\n TSL as unknown as Record<string, VDBTslNode>;\nconst { viewZToOrthographicDepth, viewZToPerspectiveDepth } = TSL as unknown as Record<string, VDBTslNode>;\n\n/** Default compiled cap on the samples one fragment's trace takes (the live `maxSamples` clamps under it). */\nexport const VDB_LEVEL_SET_SAMPLES_CAP = 1024;\n\n/** Parameters of {@link VDBLevelSetMaterial}: three's standard material parameters plus the trace's. */\nexport interface VDBLevelSetMaterialParameters extends THREE.MeshStandardMaterialParameters, VDBLevelSetTraceParameters {}\n\ntype ScalarUniform = ReturnType<typeof TSL.uniform> & { value: number };\n\nconst SURFACE = \"vdbThreeLevelSetSurface\";\n\n/**\n * The material's entry: the core's pixel ray and surface (one call site: compile time, K3.7), packed into a\n * `mat4x4f` for TSL (three's `wgslFn` takes built-in types only): column 0 `(world hit, hit ? 1 : 0)`,\n * column 1 `(world normal, t)`, column 2 `(ndc depth, 0, 0, 0)`.\n */\nfunction surfaceWgsl(cap: number): string {\n return /* wgsl */ `fn ${SURFACE}(grid_id: u32, uv: vec2f, projection_inverse: mat4x4f, camera_world: mat4x4f, view_projection: mat4x4f, orthographic: u32, sdf_to_index: f32, max_samples: f32, normal_step: f32) -> mat4x4f {\n let ray = vdbLevelSetViewRay(uv, projection_inverse, camera_world, orthographic != 0u);\n let s = vdbLevelSetSurface(grid_id, ray, view_projection, sdf_to_index, u32(clamp(max_samples, 1.0, ${cap}.0)), normal_step);\n return mat4x4f(vec4f(s.world, select(0.0, 1.0, s.hit)), vec4f(s.normal, s.t), vec4f(s.ndcDepth, 0.0, 0.0, 0.0), vec4f(0.0));\n}`;\n}\n\n/** One surface `CodeNode` per `VDBGridNode` (included after its module; deduplicated within a shader). */\nconst surfaceCode = new WeakMap<VDBGridNode, VDBTslNode>();\nfunction surfaceCodeOf(grids: VDBGridNode): VDBTslNode {\n let c = surfaceCode.get(grids);\n if (!c) surfaceCode.set(grids, (c = code(vdbLevelSetSurfaceWgsl(), [grids.module])));\n return c;\n}\n\nfunction bad(owner: string, message: string): VDBError {\n return new VDBError(\"VDB_BAD_OPTION\", `${owner}: ${message}`);\n}\n\n/** The trace a level-set material shades: its uniforms and TSL nodes (shared by the standard and physical materials). */\nexport interface VDBLevelSetTrace<TGridId extends number | VDBTslNode = number> {\n readonly grids: VDBGridNode;\n readonly gridId: TGridId extends number ? VDBUintUniform : VDBTslNode;\n readonly sdfToIndex: ScalarUniform;\n readonly maxSamples: ScalarUniform;\n readonly normalStep: ScalarUniform;\n readonly traceSource: string;\n readonly surfaceNode: VDBTslNode;\n readonly traceNode: VDBTslNode;\n readonly hitWorldNode: VDBTslNode;\n readonly hitViewNode: VDBTslNode;\n readonly hitMaskNode: VDBTslNode;\n readonly normalWorldNode: VDBTslNode;\n readonly normalViewNode: VDBTslNode;\n /** G13c: whether the roughness is widened by the traced normal's screen-space variation (compile time). */\n readonly specularAntialiasing: boolean;\n}\n\n/** The trace parameters of {@link VDBLevelSetMaterialParameters} (also taken by `VDBLevelSetPhysicalMaterial`). */\nexport interface VDBLevelSetTraceParameters {\n /**\n * Index voxels per SDF unit. Default: `1 / voxelSize.x` from `grids.pool.info(id)` when the pool\n * has `info` and the id is a number, else 1. A level set stores distances in its own world units,\n * so this is 1 / its NanoVDB voxel size.\n */\n sdfToIndex?: number;\n /** Trilinear samples per fragment trace (live), clamped to `[1, maxSamplesCap]`. Default 512. */\n maxSamples?: number;\n /** Compiled cap on {@link maxSamples}. Default {@link VDB_LEVEL_SET_SAMPLES_CAP}. */\n maxSamplesCap?: number;\n /**\n * Central-difference step of the normal, in index voxels (live). Default 1. `0` (G13c-a): the exact gradient of the\n * trilinear cell the trace hits (the trace's own surface: it never faces away from the ray; discontinuous across cell\n * faces).\n */\n normalStep?: number;\n /**\n * G13c: geometric specular antialiasing on the traced normal (Tokuyoshi and Kaplanyan 2019): the roughness grows\n * with the normal's change across the pixel, so a low-roughness highlight on a sharp crease is spread over the pixel\n * instead of hitting a few pixel centres with extreme values (on the teapot lid at clearcoat roughness 0.04: linear\n * RMS error against a 4x4 supersampled frame 0.157 vs 0.541, largest per-pixel flicker 1.7 vs 143). three's own term\n * (`getGeometryRoughness`) reads the proxy box's flat normal and adds nothing here. Sets `roughnessNode` (and\n * `clearcoatRoughnessNode` on the physical material); compile time. Default false: in a tone-mapped image lit by\n * an environment it measured worse (G13c-a: ACES RMS on the lid 0.0143 vs 0.0085 in demo 13's studio lighting).\n */\n specularAntialiasing?: boolean;\n}\n\n/** Screen-space variance of the pixel filter (Tokuyoshi and Kaplanyan 2019: 0.25, a box of one pixel). */\nexport const VDB_SPECULAR_AA_VARIANCE = 0.25;\n/** Clamp on the added GGX alpha squared (Tokuyoshi and Kaplanyan's kappa, 0.18): bounds the term at silhouettes. */\nexport const VDB_SPECULAR_AA_CLAMP = 0.18;\n\n/**\n * CPU twin of {@link vdbLevelSetSpecularAa}: the perceptual roughness after adding the kernel's variance to GGX\n * alpha squared, from the normal's screen-space differences (`dndx`, `dndy`; view space, per pixel).\n */\nexport function vdbLevelSetSpecularAaCpu(roughness: number, dndx: readonly number[], dndy: readonly number[]): number {\n const dot = (v: readonly number[]) => v[0]! * v[0]! + v[1]! * v[1]! + v[2]! * v[2]!;\n const kernel = Math.min(2 * VDB_SPECULAR_AA_VARIANCE * (dot(dndx) + dot(dndy)), VDB_SPECULAR_AA_CLAMP);\n const a2 = Math.min(1, Math.max(0, roughness ** 4 + kernel));\n return Math.sqrt(Math.sqrt(a2));\n}\n\n/**\n * G13c: `roughness` widened by the traced view normal's screen-space derivatives (see\n * {@link VDBLevelSetTraceParameters.specularAntialiasing}). A miss pixel's normal is replaced by +z so its derivative\n * stays finite; the clamp bounds what a silhouette quad adds.\n */\nexport function vdbLevelSetSpecularAa(roughness: VDBTslNode, trace: Pick<VDBLevelSetTrace<number | VDBTslNode>, \"normalViewNode\" | \"hitMaskNode\">): VDBTslNode {\n const n = select(trace.hitMaskNode, trace.normalViewNode, vec3(0.0, 0.0, 1.0));\n const dx = n.dFdx();\n const dy = n.dFdy();\n const kernel = dx.dot(dx).add(dy.dot(dy)).mul(2 * VDB_SPECULAR_AA_VARIANCE).min(VDB_SPECULAR_AA_CLAMP);\n const r = float(roughness);\n return r.mul(r).mul(r.mul(r)).add(kernel).clamp(0.0, 1.0).sqrt().sqrt();\n}\n\n/**\n * Validates the inputs and builds the trace's uniforms and nodes (G13a: one setup for both level-set materials).\n * `owner` names the class in error messages.\n */\nexport function vdbLevelSetTrace<TGridId extends number | VDBTslNode>(\n owner: string,\n renderer: VDBThreeRendererLike,\n grids: VDBGridNode,\n gridId: TGridId,\n params: VDBLevelSetTraceParameters,\n): VDBLevelSetTrace<TGridId> {\n const { sdfToIndex, maxSamples, maxSamplesCap, normalStep, specularAntialiasing } = params;\n if (!(grids instanceof VDBGridNode)) throw bad(owner, \"grids must be a VDBGridNode.\");\n getDevice(renderer);\n if (grids.renderer !== renderer) {\n throw bad(owner, \"grids was made for another renderer: create one VDBGridNode per renderer.\");\n }\n if (grids.options.profile !== \"march\" || !grids.options.helpers?.includes(\"levelSet\")) {\n throw bad(owner, \"grids needs profile 'march' and the 'levelSet' helper: new VDBGridNode(renderer, pool, { profile: 'march', helpers: ['levelSet'] }).\");\n }\n if (typeof gridId === \"number\") {\n if (!Number.isInteger(gridId) || gridId < 0) throw bad(owner, `gridId must be a non-negative integer, got ${gridId}.`);\n } else if (gridId === null || typeof gridId !== \"object\") {\n throw bad(owner, \"gridId must be a number or a uint TSL node.\");\n }\n const cap = maxSamplesCap ?? VDB_LEVEL_SET_SAMPLES_CAP;\n if (!Number.isInteger(cap) || cap < 1) throw bad(owner, `maxSamplesCap must be an integer >= 1, got ${JSON.stringify(maxSamplesCap)}.`);\n let toIndex = sdfToIndex;\n if (toIndex === undefined) {\n const info = typeof gridId === \"number\" ? (grids.pool as { info?: (id: number) => { voxelSize: readonly number[] } }).info?.(gridId) : undefined;\n toIndex = info ? 1 / info.voxelSize[0]! : 1;\n }\n if (!(Number.isFinite(toIndex) && toIndex > 0)) throw bad(owner, `sdfToIndex must be a positive finite number, got ${toIndex}.`);\n\n const id = (typeof gridId === \"number\" ? uniform(gridId, \"uint\") : gridId) as VDBLevelSetTrace<TGridId>[\"gridId\"];\n const toIndexUniform = uniform(toIndex) as ScalarUniform;\n const samples = uniform(maxSamples ?? 512) as ScalarUniform;\n const step = uniform(normalStep ?? 1) as ScalarUniform;\n const traceSource = surfaceWgsl(cap);\n const surfaceFn = wgslFn(traceSource, [surfaceCodeOf(grids)] as never);\n\n // The pixel's view ray (core vdbLevelSetViewRay): from the fragment's viewport uv through the inverse\n // projection, not from interpolated box positions, whose varying precision moves the ray by ~0.02 px on\n // large faces (V57). Perspective from the camera; orthographic (directional-light shadow maps) from the\n // pixel on the camera plane along the view axis.\n const surfaceNode = Fn((builder: { camera?: { isOrthographicCamera?: boolean } }) =>\n surfaceFn({\n grid_id: id,\n uv: viewportUV,\n projection_inverse: cameraProjectionMatrixInverse,\n camera_world: cameraWorldMatrix,\n view_projection: cameraProjectionMatrix.mul(cameraViewMatrix),\n orthographic: uint(builder.camera?.isOrthographicCamera === true ? 1 : 0),\n sdf_to_index: toIndexUniform,\n max_samples: samples,\n normal_step: step,\n }),\n )\n .once()()\n .toVar(\"vdbThreeLevelSetSurfaceOut\");\n const traceNode = surfaceNode.element(0);\n const hitWorldNode = traceNode.xyz;\n const normalWorldNode = surfaceNode.element(1).xyz;\n return {\n grids,\n gridId: id,\n sdfToIndex: toIndexUniform,\n maxSamples: samples,\n normalStep: step,\n traceSource,\n surfaceNode,\n traceNode,\n hitWorldNode,\n hitMaskNode: traceNode.w.greaterThan(0.5),\n hitViewNode: cameraViewMatrix.mul(vec4(hitWorldNode, 1.0)).xyz.toVar(\"vdbLevelSetHitView\"),\n normalWorldNode,\n normalViewNode: cameraViewMatrix.mul(vec4(normalWorldNode, 0.0)).xyz.normalize(),\n specularAntialiasing: specularAntialiasing ?? false,\n };\n}\n\n/**\n * Puts a trace on a node material: the back-face proxy, the hit mask, the vertex node (so `positionView` is a\n * variable the lighting moves to the hit), the hit's depth, the received-shadow position and the normal.\n */\nexport function vdbApplyLevelSetTrace(material: THREE.Material, trace: VDBLevelSetTrace<number | VDBTslNode>): void {\n const m = material as THREE.Material & Record<string, unknown>;\n m.side = THREE.BackSide;\n m.shadowSide = THREE.BackSide;\n m.maskNode = trace.hitMaskNode;\n // A vertexNode makes the fragment's positionView a variable, which setupLighting moves to the hit.\n m.vertexNode = cameraProjectionMatrix.mul(modelViewMatrix.mul(vec4(positionLocal, 1.0)));\n const hitView = trace.hitViewNode;\n m.depthNode = Fn((builder: { camera?: { isOrthographicCamera?: boolean } }) =>\n builder.camera?.isOrthographicCamera\n ? viewZToOrthographicDepth(hitView.z, cameraNear, cameraFar)\n : viewZToPerspectiveDepth(hitView.z, cameraNear, cameraFar),\n )();\n m.receivedShadowPositionNode = trace.hitWorldNode;\n m.normalNode = trace.normalViewNode;\n if (trace.specularAntialiasing) m.roughnessNode = vdbLevelSetSpecularAa(materialRoughness, trace);\n}\n\n/** Lights read `positionView`: the shading point is the hit, not the box face (both materials' `setupLighting`). */\nexport function vdbLevelSetLightingPosition(trace: VDBLevelSetTrace<number | VDBTslNode>): void {\n positionView.assign(trace.hitViewNode).toStack();\n}\n\n/**\n * A level set's surface on a world-space proxy box (see the file comment).\n * Shades as a `MeshStandardNodeMaterial`: `color`, `roughness`, `metalness`,\n * maps-free; lights and shadows read the hit point.\n *\n * - Exposes the trace as TSL nodes for custom shading or debugging:\n * {@link hitWorldNode}, {@link hitViewNode}, {@link hitMaskNode},\n * {@link normalWorldNode}, {@link normalViewNode} (e.g. `material.colorNode =\n * material.normalViewNode.mul(0.5).add(0.5)` with no lights shows the normals).\n * - Perspective and orthographic cameras (directional-light shadow maps).\n * - Temporal antialiasing and upscalers: three's `velocity` is the proxy box's. Put a\n * `VDBLevelSetVelocityNode` in the pass's MRT instead: it writes the hit's velocity for this material.\n *\n * @typeParam TGridId What the constructor got as the id: a number (default)\n * makes {@link gridId} a `uint` uniform; a node is kept as given.\n */\nexport class VDBLevelSetMaterial<TGridId extends number | VDBTslNode = number> extends MeshStandardNodeMaterial {\n /** Type flag: true. */\n readonly isVDBLevelSetMaterial = true;\n /** The pool node this material reads. */\n declare readonly grids: VDBGridNode;\n /** The grid id: a `uint` uniform for a numeric id (`material.gridId.value = otherId`), else the caller's node. */\n declare readonly gridId: TGridId extends number ? VDBUintUniform : VDBTslNode;\n /** Index voxels per SDF unit (live). */\n declare readonly sdfToIndex: ScalarUniform;\n /** Trilinear samples per trace (live, clamped to the compiled cap). */\n declare readonly maxSamples: ScalarUniform;\n /** Central-difference step of the normal in index voxels (live); 0: the trilinear cell's exact gradient. */\n declare readonly normalStep: ScalarUniform;\n /** The entry's WGSL (for inspection and tests): calls the core's `vdbLevelSetViewRay` and `vdbLevelSetSurface`. */\n declare readonly traceSource: string;\n /** The packed surface (`mat4`, fragment stage): see {@link traceNode}, {@link normalWorldNode}; column 2 `.x` is the NDC depth. */\n declare readonly surfaceNode: VDBTslNode;\n /** `vec4(hit world position, 1)` on a hit, `vec4(0)` on a miss (fragment stage). */\n declare readonly traceNode: VDBTslNode;\n /** The hit in world space (what `VDBLevelSetVelocityNode` reprojects for the MRT `velocity` output). */\n declare readonly hitWorldNode: VDBTslNode;\n /** The hit in view space. */\n declare readonly hitViewNode: VDBTslNode;\n /** True where the ray hit the surface (the material's `maskNode`). */\n declare readonly hitMaskNode: VDBTslNode;\n /** World-space unit normal at the hit. */\n declare readonly normalWorldNode: VDBTslNode;\n /** View-space unit normal at the hit (the material's `normalNode`). */\n declare readonly normalViewNode: VDBTslNode;\n /** Whether `roughnessNode` carries the geometric specular antialiasing (G13c; compile time). */\n declare readonly specularAntialiasing: boolean;\n\n /**\n * @param renderer The initialized `WebGPURenderer` the pool and `grids` live on.\n * @param grids A `VDBGridNode` on this renderer with profile `'march'` and helpers including `'levelSet'`.\n * @param gridId The level set's pool id (a number, made a `uint` uniform) or a `uint` node.\n * @param params three's `MeshStandardMaterialParameters` plus the trace's ({@link VDBLevelSetMaterialParameters}).\n * @throws VDBError `VDB_BAD_OPTION` for a `grids` this material can't use, a bad id or cap;\n * `VDB_UNSUPPORTED_DEVICE` for an uninitialized renderer.\n */\n constructor(renderer: VDBThreeRendererLike, grids: VDBGridNode, gridId: TGridId, params: VDBLevelSetMaterialParameters = {}) {\n const { sdfToIndex: _s, maxSamples: _m, maxSamplesCap: _c, normalStep: _n, specularAntialiasing: _a, ...standard } = params;\n super(standard);\n this.name = \"VDBLevelSetMaterial\";\n Object.assign(this, vdbLevelSetTrace(\"VDBLevelSetMaterial\", renderer, grids, gridId, params));\n vdbApplyLevelSetTrace(this, this);\n }\n\n /** Lights read `positionView`: the shading point is the hit, not the box face. */\n override setupLighting(builder: Parameters<MeshStandardNodeMaterial[\"setupLighting\"]>[0]): ReturnType<MeshStandardNodeMaterial[\"setupLighting\"]> {\n vdbLevelSetLightingPosition(this);\n return super.setupLighting(builder);\n }\n}\n"]}
@@ -0,0 +1,154 @@
1
+ /**
2
+ * `VDBLevelSetPhysicalMaterial` (G13a): the level-set trace of `VDBLevelSetMaterial` on three r187's
3
+ * `MeshPhysicalNodeMaterial`, so a traced surface can be glass (`transmission`, `ior`, `thickness`,
4
+ * `attenuationColor` / `attenuationDistance`, `dispersion`), lacquered (`clearcoat`), sheen or iridescent.
5
+ *
6
+ * const grids = new VDBGridNode(renderer, pool, { profile: 'march', helpers: ['levelSet'] });
7
+ * const glass = new VDBLevelSetPhysicalMaterial(renderer, grids, id, { transmission: 1, ior: 1.5, thickness: 0.3, roughness: 0.05 });
8
+ * scene.add(new Mesh(vdbProxyGeometry(pool.info(id), { pad: 1 }), glass));
9
+ *
10
+ * The trace, mask, depth and normal are `VDBLevelSetMaterial`'s (one setup, `vdbLevelSetTrace`); this class adds
11
+ * three's physical lighting at the hit. Two terms of three's physical model read the proxy box rather than the
12
+ * shading point, and are rewired here:
13
+ * - the clearcoat normal (`clearcoatNormalNode`) is the trace's view normal;
14
+ * - transmission (screen-space refraction) starts its refracted ray at the hit. three's `PhysicalLightingModel`
15
+ * reads `positionWorld`, the proxy's back-face varying, which lies on the same view ray but farther away, so the
16
+ * refracted sample would land too close to the pixel. {@link VDBLevelSetPhysicalLightingModel} builds the
17
+ * same refraction from the hit (`hitWorldNode`) instead.
18
+ *
19
+ * G13c:
20
+ * - `backdrop: 'object'` copies the frame before each glass draw (three copies it once per render), so glass sees the
21
+ * glass drawn before it (three sorts transparent objects back to front): glass behind glass.
22
+ * - With `renderer.shadowMap.transmitted = true` the material casts a coloured shadow: its `castShadowNode` is the
23
+ * light the glass lets through ({@link vdbLevelSetShadowTint}), not black.
24
+ * - The roughness and clearcoat roughness get the trace's geometric specular antialiasing (`specularAntialiasing`).
25
+ *
26
+ * Anisotropy needs mesh tangents and is not supported on a traced surface (it shades with the box's tangents).
27
+ *
28
+ * The refraction below is a port of three.js r187 `src/nodes/functions/PhysicalLightingModel.js`
29
+ * (`getVolumeTransmissionRay`, `applyIorToRoughness`, `getTransmissionSample`, `volumeAttenuation`,
30
+ * `getIBLVolumeRefraction`). Copyright 2010-2026 three.js authors, MIT. Change: the shading position is the
31
+ * trace's hit, and the model matrix is the identity (the proxy mesh has an identity transform, so `thickness` is
32
+ * in world units).
33
+ */
34
+ import * as THREE from "three";
35
+ import { MeshPhysicalNodeMaterial, PhysicalLightingModel } from "three/webgpu";
36
+ import * as TSL from "three/tsl";
37
+ import { type VDBThreeRendererLike } from "./device.js";
38
+ import { VDBGridNode, type VDBTslNode } from "./grid-node.js";
39
+ import { type VDBLevelSetTrace, type VDBLevelSetTraceParameters } from "./level-set-material.js";
40
+ import type { VDBUintUniform } from "./material.js";
41
+ /** Parameters of {@link VDBLevelSetPhysicalMaterial}: three's physical material parameters plus the trace's. */
42
+ export interface VDBLevelSetPhysicalMaterialParameters extends THREE.MeshPhysicalMaterialParameters, VDBLevelSetTraceParameters {
43
+ /**
44
+ * G13c: when the transmission's framebuffer copy is taken (compile time). `'render'` (default, three's rule): once
45
+ * per render, at the first transmissive draw, so glass does not see other glass through itself. `'object'`: before
46
+ * every draw of this material, so a glass piece sees everything drawn before it, other glass included (three sorts
47
+ * transparent objects back to front); one framebuffer copy with mips per glass object per render.
48
+ */
49
+ backdrop?: VDBLevelSetBackdrop;
50
+ }
51
+ /** When a glass level set's transmission copies the frame: see {@link VDBLevelSetPhysicalMaterialParameters.backdrop}. */
52
+ export type VDBLevelSetBackdrop = "render" | "object";
53
+ /** The material properties {@link vdbLevelSetShadowTint} reads (three's `MeshPhysicalMaterial` names). */
54
+ export interface VDBLevelSetShadowTintInputs {
55
+ transmission: number;
56
+ color: {
57
+ r: number;
58
+ g: number;
59
+ b: number;
60
+ };
61
+ ior: number;
62
+ thickness: number;
63
+ attenuationColor: {
64
+ r: number;
65
+ g: number;
66
+ b: number;
67
+ };
68
+ attenuationDistance: number;
69
+ }
70
+ /**
71
+ * G13c: the fraction of light a glass level set lets through, per linear channel, for its transmitted shadow:
72
+ * `transmission · color · (1 − F0)² · attenuation`, with F0 the normal-incidence Fresnel reflectance of `ior` (two
73
+ * interfaces) and Beer's law over `thickness` (`attenuationColor ^ (thickness / attenuationDistance)`, none for a zero
74
+ * or infinite distance, three's rule). An opaque piece (`transmission` 0) gives black, three's opaque shadow. Maps
75
+ * (`transmissionMap`, `thicknessMap`) are not read.
76
+ */
77
+ export declare function vdbLevelSetShadowTint(m: VDBLevelSetShadowTintInputs): [number, number, number];
78
+ type ScalarUniform = ReturnType<typeof TSL.uniform> & {
79
+ value: number;
80
+ };
81
+ /**
82
+ * three's `PhysicalLightingModel` with transmission refracted from the trace's hit (see the file comment). Every
83
+ * other term is three's: `start` runs with transmission off, then sets the backdrop three would.
84
+ */
85
+ export declare class VDBLevelSetPhysicalLightingModel extends PhysicalLightingModel {
86
+ /** The world hit the refraction starts at. */
87
+ readonly hitWorld: VDBTslNode;
88
+ /** When the backdrop is copied (G13c). */
89
+ readonly backdrop: VDBLevelSetBackdrop;
90
+ constructor(hitWorld: VDBTslNode, flags: ConstructorParameters<typeof PhysicalLightingModel>, backdrop?: VDBLevelSetBackdrop);
91
+ start(builder: Parameters<PhysicalLightingModel["start"]>[0]): void;
92
+ }
93
+ /**
94
+ * A level set's surface (as {@link VDBLevelSetMaterial}) shaded by three's physical material: transmission,
95
+ * clearcoat, sheen, iridescence, `ior`, `specularIntensity` (see the file comment).
96
+ *
97
+ * @typeParam TGridId What the constructor got as the id: a number (default) makes {@link gridId} a `uint`
98
+ * uniform; a node is kept as given.
99
+ */
100
+ export declare class VDBLevelSetPhysicalMaterial<TGridId extends number | VDBTslNode = number> extends MeshPhysicalNodeMaterial implements VDBLevelSetTrace<TGridId> {
101
+ /** Type flag: true (a level-set material, as `VDBLevelSetMaterial`). */
102
+ readonly isVDBLevelSetMaterial = true;
103
+ /** Type flag: true. */
104
+ readonly isVDBLevelSetPhysicalMaterial = true;
105
+ /** The pool node this material reads. */
106
+ readonly grids: VDBGridNode;
107
+ /** The grid id: a `uint` uniform for a numeric id (`material.gridId.value = otherId`), else the caller's node. */
108
+ readonly gridId: TGridId extends number ? VDBUintUniform : VDBTslNode;
109
+ /** Index voxels per SDF unit (live). */
110
+ readonly sdfToIndex: ScalarUniform;
111
+ /** Trilinear samples per trace (live, clamped to the compiled cap). */
112
+ readonly maxSamples: ScalarUniform;
113
+ /** Central-difference step of the normal in index voxels (live). */
114
+ readonly normalStep: ScalarUniform;
115
+ /** The entry's WGSL (for inspection and tests). */
116
+ readonly traceSource: string;
117
+ /** The packed surface (`mat4`, fragment stage). */
118
+ readonly surfaceNode: VDBTslNode;
119
+ /** `vec4(hit world position, 1)` on a hit, `vec4(0)` on a miss (fragment stage). */
120
+ readonly traceNode: VDBTslNode;
121
+ /** The hit in world space (where the refraction starts). */
122
+ readonly hitWorldNode: VDBTslNode;
123
+ /** The hit in view space. */
124
+ readonly hitViewNode: VDBTslNode;
125
+ /** True where the ray hit the surface (the material's `maskNode`). */
126
+ readonly hitMaskNode: VDBTslNode;
127
+ /** World-space unit normal at the hit. */
128
+ readonly normalWorldNode: VDBTslNode;
129
+ /** View-space unit normal at the hit (the material's `normalNode` and `clearcoatNormalNode`). */
130
+ readonly normalViewNode: VDBTslNode;
131
+ /** Whether the roughness nodes carry the geometric specular antialiasing (G13c; compile time). */
132
+ readonly specularAntialiasing: boolean;
133
+ /** When the transmission copies the frame (G13c; compile time). */
134
+ readonly backdrop: VDBLevelSetBackdrop;
135
+ /**
136
+ * The transmitted shadow's colour (G13c): {@link vdbLevelSetShadowTint} of this material, refreshed each render. It
137
+ * is the `castShadowNode` (alpha 1) when the renderer's `shadowMap.transmitted` is true and no `castShadowNode` was set.
138
+ */
139
+ readonly shadowTintNode: VDBTslNode;
140
+ /**
141
+ * @param renderer The initialized `WebGPURenderer` the pool and `grids` live on.
142
+ * @param grids A `VDBGridNode` on this renderer with profile `'march'` and helpers including `'levelSet'`.
143
+ * @param gridId The level set's pool id (a number, made a `uint` uniform) or a `uint` node.
144
+ * @param params three's `MeshPhysicalMaterialParameters` plus the trace's ({@link VDBLevelSetPhysicalMaterialParameters}).
145
+ * @throws VDBError `VDB_BAD_OPTION` for a `grids` this material can't use, a bad id or cap;
146
+ * `VDB_UNSUPPORTED_DEVICE` for an uninitialized renderer.
147
+ */
148
+ constructor(renderer: VDBThreeRendererLike, grids: VDBGridNode, gridId: TGridId, params?: VDBLevelSetPhysicalMaterialParameters);
149
+ /** Lights read `positionView`: the shading point is the hit, not the box face. */
150
+ setupLighting(builder: Parameters<MeshPhysicalNodeMaterial["setupLighting"]>[0]): ReturnType<MeshPhysicalNodeMaterial["setupLighting"]>;
151
+ /** three's physical lighting model, with transmission refracted from the hit. */
152
+ setupLightingModel(builder?: unknown): PhysicalLightingModel;
153
+ }
154
+ export {};
@@ -0,0 +1,253 @@
1
+ /**
2
+ * `VDBLevelSetPhysicalMaterial` (G13a): the level-set trace of `VDBLevelSetMaterial` on three r187's
3
+ * `MeshPhysicalNodeMaterial`, so a traced surface can be glass (`transmission`, `ior`, `thickness`,
4
+ * `attenuationColor` / `attenuationDistance`, `dispersion`), lacquered (`clearcoat`), sheen or iridescent.
5
+ *
6
+ * const grids = new VDBGridNode(renderer, pool, { profile: 'march', helpers: ['levelSet'] });
7
+ * const glass = new VDBLevelSetPhysicalMaterial(renderer, grids, id, { transmission: 1, ior: 1.5, thickness: 0.3, roughness: 0.05 });
8
+ * scene.add(new Mesh(vdbProxyGeometry(pool.info(id), { pad: 1 }), glass));
9
+ *
10
+ * The trace, mask, depth and normal are `VDBLevelSetMaterial`'s (one setup, `vdbLevelSetTrace`); this class adds
11
+ * three's physical lighting at the hit. Two terms of three's physical model read the proxy box rather than the
12
+ * shading point, and are rewired here:
13
+ * - the clearcoat normal (`clearcoatNormalNode`) is the trace's view normal;
14
+ * - transmission (screen-space refraction) starts its refracted ray at the hit. three's `PhysicalLightingModel`
15
+ * reads `positionWorld`, the proxy's back-face varying, which lies on the same view ray but farther away, so the
16
+ * refracted sample would land too close to the pixel. {@link VDBLevelSetPhysicalLightingModel} builds the
17
+ * same refraction from the hit (`hitWorldNode`) instead.
18
+ *
19
+ * G13c:
20
+ * - `backdrop: 'object'` copies the frame before each glass draw (three copies it once per render), so glass sees the
21
+ * glass drawn before it (three sorts transparent objects back to front): glass behind glass.
22
+ * - With `renderer.shadowMap.transmitted = true` the material casts a coloured shadow: its `castShadowNode` is the
23
+ * light the glass lets through ({@link vdbLevelSetShadowTint}), not black.
24
+ * - The roughness and clearcoat roughness get the trace's geometric specular antialiasing (`specularAntialiasing`).
25
+ *
26
+ * Anisotropy needs mesh tangents and is not supported on a traced surface (it shades with the box's tangents).
27
+ *
28
+ * The refraction below is a port of three.js r187 `src/nodes/functions/PhysicalLightingModel.js`
29
+ * (`getVolumeTransmissionRay`, `applyIorToRoughness`, `getTransmissionSample`, `volumeAttenuation`,
30
+ * `getIBLVolumeRefraction`). Copyright 2010-2026 three.js authors, MIT. Change: the shading position is the
31
+ * trace's hit, and the model matrix is the identity (the proxy mesh has an identity transform, so `thickness` is
32
+ * in world units).
33
+ */
34
+ import * as THREE from "three";
35
+ import { MeshPhysicalNodeMaterial, NodeUpdateType, PhysicalLightingModel, ViewportTextureNode } from "three/webgpu";
36
+ import * as TSL from "three/tsl";
37
+ import { VDBError } from "../core/errors.js";
38
+ import {} from "./device.js";
39
+ import { VDBGridNode } from "./grid-node.js";
40
+ import { vdbApplyLevelSetTrace, vdbLevelSetLightingPosition, vdbLevelSetSpecularAa, vdbLevelSetTrace, } from "./level-set-material.js";
41
+ const { EnvironmentBRDF, Fn, If, Loop, cameraPosition, cameraProjectionMatrix, cameraViewMatrix, cameraViewport, exp, float, log, log2, mix, normalWorld, refract, screenSize, textureBicubicLevel, vec2, vec3, vec4 } = TSL;
42
+ const { materialClearcoatRoughness, nodeObject, screenUV, uniform } = TSL;
43
+ const { attenuationColor, attenuationDistance, diffuseColor, diffuseContribution, dispersion, ior, roughness, specularColorBlended, specularF90, thickness, transmission, viewportMipTexture } = TSL;
44
+ /**
45
+ * G13c: the fraction of light a glass level set lets through, per linear channel, for its transmitted shadow:
46
+ * `transmission · color · (1 − F0)² · attenuation`, with F0 the normal-incidence Fresnel reflectance of `ior` (two
47
+ * interfaces) and Beer's law over `thickness` (`attenuationColor ^ (thickness / attenuationDistance)`, none for a zero
48
+ * or infinite distance, three's rule). An opaque piece (`transmission` 0) gives black, three's opaque shadow. Maps
49
+ * (`transmissionMap`, `thicknessMap`) are not read.
50
+ */
51
+ export function vdbLevelSetShadowTint(m) {
52
+ const f0 = ((m.ior - 1) / (m.ior + 1)) ** 2;
53
+ const through = Math.max(0, Math.min(1, m.transmission)) * (1 - f0) ** 2;
54
+ const d = m.attenuationDistance;
55
+ const beer = (c) => (d > 0 && Number.isFinite(d) ? Math.max(c, 0) ** (Math.max(m.thickness, 0) / d) : 1);
56
+ return [through * m.color.r * beer(m.attenuationColor.r), through * m.color.g * beer(m.attenuationColor.g), through * m.color.b * beer(m.attenuationColor.b)];
57
+ }
58
+ // --- three r187's screen-space refraction, from the hit (see the file comment) ---------------------------------
59
+ /** The framebuffer copies the refraction samples (three's back-side texture: the material draws back faces), per mode. */
60
+ const backdropTextures = {};
61
+ /** Last (render, object) each per-object copy was taken for: a bicubic sample reads one texture through several nodes. */
62
+ const objectCopies = new WeakMap();
63
+ /**
64
+ * G13c: three's mipmapped viewport texture, copied before every draw (`NodeUpdateType.OBJECT`) instead of once per
65
+ * render. Clones (each `sample()`) share the texture; one copy per draw.
66
+ */
67
+ class VDBObjectBackdropNode extends ViewportTextureNode {
68
+ constructor(uv, level, texture) {
69
+ super(uv, level, texture);
70
+ this.updateBeforeType = NodeUpdateType.OBJECT;
71
+ }
72
+ updateBefore(frame) {
73
+ const texture = this.value;
74
+ const last = objectCopies.get(texture);
75
+ if (last && last.renderId === frame.renderId && last.object === frame.object)
76
+ return undefined;
77
+ objectCopies.set(texture, { renderId: frame.renderId, object: frame.object });
78
+ return super.updateBefore(frame);
79
+ }
80
+ }
81
+ function backdropTextureOf(mode) {
82
+ let node = backdropTextures[mode];
83
+ if (!node) {
84
+ if (mode === "object") {
85
+ const raw = new VDBObjectBackdropNode(screenUV);
86
+ raw.generateMipmaps = true;
87
+ node = nodeObject(raw);
88
+ }
89
+ else
90
+ node = viewportMipTexture();
91
+ backdropTextures[mode] = node;
92
+ }
93
+ return node;
94
+ }
95
+ function transmissionSample(fragCoord, rough, eta, mode) {
96
+ const sample = backdropTextureOf(mode).sample(fragCoord.mul(cameraViewport.zw).add(cameraViewport.xy).div(screenSize));
97
+ // applyIorToRoughness: an ior of 1 gives no microfacet refraction, 1.5 the default amount.
98
+ const lod = log2(cameraViewport.z).mul(rough.mul(eta.mul(2.0).sub(2.0).clamp(0.0, 1.0)));
99
+ return textureBicubicLevel(sample, lod);
100
+ }
101
+ /** Beer's law over the transmission distance; no attenuation for a zero attenuation distance (three's rule). */
102
+ const volumeAttenuation = Fn(([distance, color, attenuationDist]) => {
103
+ const out = vec3(1.0).toVar();
104
+ If(attenuationDist.notEqual(0), () => {
105
+ out.assign(exp(log(color).negate().div(attenuationDist).negate().mul(distance)));
106
+ });
107
+ return out;
108
+ });
109
+ /** Refraction exit point's screen uv (WebGPU y down) for an ior: the hit plus the refracted direction times the thickness. */
110
+ function refractionCoords(position, n, v, eta, thick) {
111
+ const ray = refract(v.negate(), n.normalize(), float(1.0).div(eta)).normalize().mul(thick);
112
+ const ndc = cameraProjectionMatrix.mul(cameraViewMatrix.mul(vec4(position.add(ray), 1.0)));
113
+ const uv = ndc.xy.div(ndc.w).add(1.0).div(2.0);
114
+ return { coords: vec2(uv.x, uv.y.oneMinus()), ray };
115
+ }
116
+ /** three's `getIBLVolumeRefraction` with `position` the hit and an identity model matrix. */
117
+ function volumeRefraction(position, withDispersion, mode) {
118
+ const v = cameraPosition.sub(position).normalize();
119
+ const n = normalWorld;
120
+ let transmitted;
121
+ let transmittance;
122
+ if (withDispersion) {
123
+ transmitted = vec4().toVar();
124
+ transmittance = vec3().toVar();
125
+ const halfSpread = ior.sub(1.0).mul(dispersion.mul(0.025));
126
+ const iors = vec3(ior.sub(halfSpread), ior, ior.add(halfSpread));
127
+ Loop({ start: 0, end: 3 }, ({ i }) => {
128
+ const eta = iors.element(i);
129
+ const { coords, ray } = refractionCoords(position, n, v, eta, thickness);
130
+ const sample = transmissionSample(coords, roughness, eta, mode);
131
+ transmitted.element(i).assign(sample.element(i));
132
+ transmitted.a.addAssign(sample.a);
133
+ transmittance.element(i).assign(diffuseContribution.element(i).mul(volumeAttenuation(ray.length(), attenuationColor, attenuationDistance).element(i)));
134
+ });
135
+ transmitted.a.divAssign(3.0);
136
+ }
137
+ else {
138
+ const { coords, ray } = refractionCoords(position, n, v, ior, thickness);
139
+ transmitted = transmissionSample(coords, roughness, ior, mode);
140
+ transmittance = diffuseContribution.mul(volumeAttenuation(ray.length(), attenuationColor, attenuationDistance));
141
+ }
142
+ const attenuated = transmittance.rgb.mul(transmitted.rgb);
143
+ const F = vec3(EnvironmentBRDF({ dotNV: n.dot(v).clamp(), specularColor: specularColorBlended, specularF90, roughness }));
144
+ const factor = transmittance.r.add(transmittance.g, transmittance.b).div(3.0);
145
+ return vec4(F.oneMinus().mul(attenuated), transmitted.a.oneMinus().mul(factor).oneMinus());
146
+ }
147
+ /**
148
+ * three's `PhysicalLightingModel` with transmission refracted from the trace's hit (see the file comment). Every
149
+ * other term is three's: `start` runs with transmission off, then sets the backdrop three would.
150
+ */
151
+ export class VDBLevelSetPhysicalLightingModel extends PhysicalLightingModel {
152
+ /** The world hit the refraction starts at. */
153
+ hitWorld;
154
+ /** When the backdrop is copied (G13c). */
155
+ backdrop;
156
+ constructor(hitWorld, flags, backdrop = "render") {
157
+ super(...flags);
158
+ this.hitWorld = hitWorld;
159
+ this.backdrop = backdrop;
160
+ }
161
+ start(builder) {
162
+ const self = this;
163
+ const withTransmission = self.transmission;
164
+ self.transmission = false;
165
+ try {
166
+ super.start(builder);
167
+ }
168
+ finally {
169
+ self.transmission = withTransmission;
170
+ }
171
+ if (!withTransmission)
172
+ return;
173
+ const context = builder.context;
174
+ context.backdrop = volumeRefraction(this.hitWorld, self.dispersion, this.backdrop);
175
+ context.backdropAlpha = transmission;
176
+ diffuseColor.a.mulAssign(mix(1, context.backdrop.a, transmission));
177
+ }
178
+ }
179
+ /**
180
+ * A level set's surface (as {@link VDBLevelSetMaterial}) shaded by three's physical material: transmission,
181
+ * clearcoat, sheen, iridescence, `ior`, `specularIntensity` (see the file comment).
182
+ *
183
+ * @typeParam TGridId What the constructor got as the id: a number (default) makes {@link gridId} a `uint`
184
+ * uniform; a node is kept as given.
185
+ */
186
+ export class VDBLevelSetPhysicalMaterial extends MeshPhysicalNodeMaterial {
187
+ /** Type flag: true (a level-set material, as `VDBLevelSetMaterial`). */
188
+ isVDBLevelSetMaterial = true;
189
+ /** Type flag: true. */
190
+ isVDBLevelSetPhysicalMaterial = true;
191
+ /**
192
+ * @param renderer The initialized `WebGPURenderer` the pool and `grids` live on.
193
+ * @param grids A `VDBGridNode` on this renderer with profile `'march'` and helpers including `'levelSet'`.
194
+ * @param gridId The level set's pool id (a number, made a `uint` uniform) or a `uint` node.
195
+ * @param params three's `MeshPhysicalMaterialParameters` plus the trace's ({@link VDBLevelSetPhysicalMaterialParameters}).
196
+ * @throws VDBError `VDB_BAD_OPTION` for a `grids` this material can't use, a bad id or cap;
197
+ * `VDB_UNSUPPORTED_DEVICE` for an uninitialized renderer.
198
+ */
199
+ constructor(renderer, grids, gridId, params = {}) {
200
+ const { sdfToIndex: _s, maxSamples: _m, maxSamplesCap: _c, normalStep: _n, specularAntialiasing: _a, backdrop, ...physical } = params;
201
+ super(physical);
202
+ this.name = "VDBLevelSetPhysicalMaterial";
203
+ if (backdrop !== undefined && backdrop !== "render" && backdrop !== "object") {
204
+ throw new VDBError("VDB_BAD_OPTION", `VDBLevelSetPhysicalMaterial: backdrop must be 'render' or 'object', got ${JSON.stringify(backdrop)}.`);
205
+ }
206
+ Object.assign(this, vdbLevelSetTrace("VDBLevelSetPhysicalMaterial", renderer, grids, gridId, params));
207
+ vdbApplyLevelSetTrace(this, this);
208
+ const self = this;
209
+ self.clearcoatNormalNode = this.normalViewNode;
210
+ if (this.specularAntialiasing)
211
+ self.clearcoatRoughnessNode = vdbLevelSetSpecularAa(materialClearcoatRoughness, this);
212
+ const tint = new THREE.Color();
213
+ const shadowTintNode = uniform(tint).onRenderUpdate(() => tint.setRGB(...vdbLevelSetShadowTint(this)));
214
+ Object.assign(this, { backdrop: backdrop ?? "render", shadowTintNode, vdbRenderer: renderer });
215
+ }
216
+ /** Lights read `positionView`: the shading point is the hit, not the box face. */
217
+ setupLighting(builder) {
218
+ vdbLevelSetLightingPosition(this);
219
+ return super.setupLighting(builder);
220
+ }
221
+ /** three's physical lighting model, with transmission refracted from the hit. */
222
+ setupLightingModel(builder) {
223
+ void builder;
224
+ const m = this;
225
+ return new VDBLevelSetPhysicalLightingModel(this.hitWorldNode, [
226
+ m.useClearcoat,
227
+ m.useSheen,
228
+ m.useIridescence,
229
+ m.useAnisotropy,
230
+ m.useTransmission,
231
+ m.useDispersion,
232
+ m.useRetroreflection,
233
+ m.useDiffuseRoughness,
234
+ ], this.backdrop);
235
+ }
236
+ }
237
+ // `castShadowNode` as an accessor (three's NodeMaterial assigns it in its constructor, so a class field can't be used):
238
+ // the user's node if set, else the transmitted shadow when the renderer's shadow map carries colour (G13c).
239
+ Object.defineProperty(VDBLevelSetPhysicalMaterial.prototype, "castShadowNode", {
240
+ configurable: true,
241
+ get() {
242
+ const self = this;
243
+ if (self.vdbCastShadowNode)
244
+ return self.vdbCastShadowNode;
245
+ if (self.vdbRenderer?.shadowMap?.transmitted !== true || !this.shadowTintNode)
246
+ return null;
247
+ return (self.vdbTransmitted ??= vec4(this.shadowTintNode, 1.0));
248
+ },
249
+ set(value) {
250
+ this.vdbCastShadowNode = value ?? null;
251
+ },
252
+ });
253
+ //# sourceMappingURL=level-set-physical-material.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"level-set-physical-material.js","sourceRoot":"","sources":["../../src/three/level-set-physical-material.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AAEH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,wBAAwB,EAAE,cAAc,EAAE,qBAAqB,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC;AACpH,OAAO,KAAK,GAAG,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAC7C,OAAO,EAA6B,MAAM,aAAa,CAAC;AACxD,OAAO,EAAE,WAAW,EAAmB,MAAM,gBAAgB,CAAC;AAC9D,OAAO,EACL,qBAAqB,EACrB,2BAA2B,EAC3B,qBAAqB,EACrB,gBAAgB,GAGjB,MAAM,yBAAyB,CAAC;AAGjC,MAAM,EAAE,eAAe,EAAE,EAAE,EAAE,EAAE,EAAE,IAAI,EAAE,cAAc,EAAE,sBAAsB,EAAE,gBAAgB,EAAE,cAAc,EAAE,GAAG,EAAE,KAAK,EAAE,GAAG,EAAE,IAAI,EAAE,GAAG,EAAE,WAAW,EAAE,OAAO,EAAE,UAAU,EAAE,mBAAmB,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,GACpN,GAA4C,CAAC;AAC/C,MAAM,EAAE,0BAA0B,EAAE,UAAU,EAAE,QAAQ,EAAE,OAAO,EAAE,GAAG,GAA4C,CAAC;AACnH,MAAM,EAAE,gBAAgB,EAAE,mBAAmB,EAAE,YAAY,EAAE,mBAAmB,EAAE,UAAU,EAAE,GAAG,EAAE,SAAS,EAAE,oBAAoB,EAAE,WAAW,EAAE,SAAS,EAAE,YAAY,EAAE,kBAAkB,EAAE,GAC5L,GAA4C,CAAC;AA0B/C;;;;;;GAMG;AACH,MAAM,UAAU,qBAAqB,CAAC,CAA8B;IAClE,M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,CAAC;IAC3E,CAAC;CACF;AAED,wHAAwH;AACxH,4GAA4G;AAC5G,MAAM,CAAC,cAAc,CAAC,2BAA2B,CAAC,SAAS,EAAE,gBAAgB,EAAE;IAC7E,YAAY,EAAE,IAAI;IAClB,GAAG;QACD,MAAM,IAAI,GAAG,IAAkJ,CAAC;QAChK,IAAI,IAAI,CAAC,iBAAiB;YAAE,OAAO,IAAI,CAAC,iBAAiB,CAAC;QAC1D,IAAI,IAAI,CAAC,WAAW,EAAE,SAAS,EAAE,WAAW,KAAK,IAAI,IAAI,CAAC,IAAI,CAAC,cAAc;YAAE,OAAO,IAAI,CAAC;QAC3F,OAAO,CAAC,IAAI,CAAC,cAAc,KAAK,IAAI,CAAC,IAAI,CAAC,cAAc,EAAE,GAAG,CAAC,CAAC,CAAC;IAClE,CAAC;IACD,GAAG,CAAoC,KAAwB;QAC5D,IAA4D,CAAC,iBAAiB,GAAG,KAAK,IAAI,IAAI,CAAC;IAClG,CAAC;CACF,CAAC,CAAC","sourcesContent":["/**\n * `VDBLevelSetPhysicalMaterial` (G13a): the level-set trace of `VDBLevelSetMaterial` on three r187's\n * `MeshPhysicalNodeMaterial`, so a traced surface can be glass (`transmission`, `ior`, `thickness`,\n * `attenuationColor` / `attenuationDistance`, `dispersion`), lacquered (`clearcoat`), sheen or iridescent.\n *\n * const grids = new VDBGridNode(renderer, pool, { profile: 'march', helpers: ['levelSet'] });\n * const glass = new VDBLevelSetPhysicalMaterial(renderer, grids, id, { transmission: 1, ior: 1.5, thickness: 0.3, roughness: 0.05 });\n * scene.add(new Mesh(vdbProxyGeometry(pool.info(id), { pad: 1 }), glass));\n *\n * The trace, mask, depth and normal are `VDBLevelSetMaterial`'s (one setup, `vdbLevelSetTrace`); this class adds\n * three's physical lighting at the hit. Two terms of three's physical model read the proxy box rather than the\n * shading point, and are rewired here:\n * - the clearcoat normal (`clearcoatNormalNode`) is the trace's view normal;\n * - transmission (screen-space refraction) starts its refracted ray at the hit. three's `PhysicalLightingModel`\n * reads `positionWorld`, the proxy's back-face varying, which lies on the same view ray but farther away, so the\n * refracted sample would land too close to the pixel. {@link VDBLevelSetPhysicalLightingModel} builds the\n * same refraction from the hit (`hitWorldNode`) instead.\n *\n * G13c:\n * - `backdrop: 'object'` copies the frame before each glass draw (three copies it once per render), so glass sees the\n * glass drawn before it (three sorts transparent objects back to front): glass behind glass.\n * - With `renderer.shadowMap.transmitted = true` the material casts a coloured shadow: its `castShadowNode` is the\n * light the glass lets through ({@link vdbLevelSetShadowTint}), not black.\n * - The roughness and clearcoat roughness get the trace's geometric specular antialiasing (`specularAntialiasing`).\n *\n * Anisotropy needs mesh tangents and is not supported on a traced surface (it shades with the box's tangents).\n *\n * The refraction below is a port of three.js r187 `src/nodes/functions/PhysicalLightingModel.js`\n * (`getVolumeTransmissionRay`, `applyIorToRoughness`, `getTransmissionSample`, `volumeAttenuation`,\n * `getIBLVolumeRefraction`). Copyright 2010-2026 three.js authors, MIT. Change: the shading position is the\n * trace's hit, and the model matrix is the identity (the proxy mesh has an identity transform, so `thickness` is\n * in world units).\n */\n\nimport * as THREE from \"three\";\nimport { MeshPhysicalNodeMaterial, NodeUpdateType, PhysicalLightingModel, ViewportTextureNode } from \"three/webgpu\";\nimport * as TSL from \"three/tsl\";\nimport { VDBError } from \"../core/errors.js\";\nimport { type VDBThreeRendererLike } from \"./device.js\";\nimport { VDBGridNode, type VDBTslNode } from \"./grid-node.js\";\nimport {\n vdbApplyLevelSetTrace,\n vdbLevelSetLightingPosition,\n vdbLevelSetSpecularAa,\n vdbLevelSetTrace,\n type VDBLevelSetTrace,\n type VDBLevelSetTraceParameters,\n} from \"./level-set-material.js\";\nimport type { VDBUintUniform } from \"./material.js\";\n\nconst { EnvironmentBRDF, Fn, If, Loop, cameraPosition, cameraProjectionMatrix, cameraViewMatrix, cameraViewport, exp, float, log, log2, mix, normalWorld, refract, screenSize, textureBicubicLevel, vec2, vec3, vec4 } =\n TSL as unknown as Record<string, VDBTslNode>;\nconst { materialClearcoatRoughness, nodeObject, screenUV, uniform } = TSL as unknown as Record<string, VDBTslNode>;\nconst { attenuationColor, attenuationDistance, diffuseColor, diffuseContribution, dispersion, ior, roughness, specularColorBlended, specularF90, thickness, transmission, viewportMipTexture } =\n TSL as unknown as Record<string, VDBTslNode>;\n\n/** Parameters of {@link VDBLevelSetPhysicalMaterial}: three's physical material parameters plus the trace's. */\nexport interface VDBLevelSetPhysicalMaterialParameters extends THREE.MeshPhysicalMaterialParameters, VDBLevelSetTraceParameters {\n /**\n * G13c: when the transmission's framebuffer copy is taken (compile time). `'render'` (default, three's rule): once\n * per render, at the first transmissive draw, so glass does not see other glass through itself. `'object'`: before\n * every draw of this material, so a glass piece sees everything drawn before it, other glass included (three sorts\n * transparent objects back to front); one framebuffer copy with mips per glass object per render.\n */\n backdrop?: VDBLevelSetBackdrop;\n}\n\n/** When a glass level set's transmission copies the frame: see {@link VDBLevelSetPhysicalMaterialParameters.backdrop}. */\nexport type VDBLevelSetBackdrop = \"render\" | \"object\";\n\n/** The material properties {@link vdbLevelSetShadowTint} reads (three's `MeshPhysicalMaterial` names). */\nexport interface VDBLevelSetShadowTintInputs {\n transmission: number;\n color: { r: number; g: number; b: number };\n ior: number;\n thickness: number;\n attenuationColor: { r: number; g: number; b: number };\n attenuationDistance: number;\n}\n\n/**\n * G13c: the fraction of light a glass level set lets through, per linear channel, for its transmitted shadow:\n * `transmission · color · (1 − F0)² · attenuation`, with F0 the normal-incidence Fresnel reflectance of `ior` (two\n * interfaces) and Beer's law over `thickness` (`attenuationColor ^ (thickness / attenuationDistance)`, none for a zero\n * or infinite distance, three's rule). An opaque piece (`transmission` 0) gives black, three's opaque shadow. Maps\n * (`transmissionMap`, `thicknessMap`) are not read.\n */\nexport function vdbLevelSetShadowTint(m: VDBLevelSetShadowTintInputs): [number, number, number] {\n const f0 = ((m.ior - 1) / (m.ior + 1)) ** 2;\n const through = Math.max(0, Math.min(1, m.transmission)) * (1 - f0) ** 2;\n const d = m.attenuationDistance;\n const beer = (c: number) => (d > 0 && Number.isFinite(d) ? Math.max(c, 0) ** (Math.max(m.thickness, 0) / d) : 1);\n return [through * m.color.r * beer(m.attenuationColor.r), through * m.color.g * beer(m.attenuationColor.g), through * m.color.b * beer(m.attenuationColor.b)];\n}\n\ntype ScalarUniform = ReturnType<typeof TSL.uniform> & { value: number };\n\n// --- three r187's screen-space refraction, from the hit (see the file comment) ---------------------------------\n\n/** The framebuffer copies the refraction samples (three's back-side texture: the material draws back faces), per mode. */\nconst backdropTextures: Partial<Record<VDBLevelSetBackdrop, VDBTslNode>> = {};\n\n/** Last (render, object) each per-object copy was taken for: a bicubic sample reads one texture through several nodes. */\nconst objectCopies = new WeakMap<object, { renderId: number; object: unknown }>();\n\ntype ViewportTextureLike = new (uv?: unknown, level?: unknown, texture?: unknown) => {\n updateBeforeType: string;\n generateMipmaps: boolean;\n value: object;\n updateBefore(frame: unknown): unknown;\n};\n\n/**\n * G13c: three's mipmapped viewport texture, copied before every draw (`NodeUpdateType.OBJECT`) instead of once per\n * render. Clones (each `sample()`) share the texture; one copy per draw.\n */\nclass VDBObjectBackdropNode extends (ViewportTextureNode as unknown as ViewportTextureLike) {\n constructor(uv?: unknown, level?: unknown, texture?: unknown) {\n super(uv, level, texture);\n this.updateBeforeType = (NodeUpdateType as unknown as { OBJECT: string }).OBJECT;\n }\n\n override updateBefore(frame: { renderId: number; object: unknown }): unknown {\n const texture = this.value;\n const last = objectCopies.get(texture);\n if (last && last.renderId === frame.renderId && last.object === frame.object) return undefined;\n objectCopies.set(texture, { renderId: frame.renderId, object: frame.object });\n return super.updateBefore(frame);\n }\n}\n\nfunction backdropTextureOf(mode: VDBLevelSetBackdrop): VDBTslNode {\n let node = backdropTextures[mode];\n if (!node) {\n if (mode === \"object\") {\n const raw = new VDBObjectBackdropNode(screenUV);\n raw.generateMipmaps = true;\n node = nodeObject(raw) as VDBTslNode;\n } else node = viewportMipTexture();\n backdropTextures[mode] = node;\n }\n return node!;\n}\n\nfunction transmissionSample(fragCoord: VDBTslNode, rough: VDBTslNode, eta: VDBTslNode, mode: VDBLevelSetBackdrop): VDBTslNode {\n const sample = backdropTextureOf(mode).sample(fragCoord.mul(cameraViewport.zw).add(cameraViewport.xy).div(screenSize));\n // applyIorToRoughness: an ior of 1 gives no microfacet refraction, 1.5 the default amount.\n const lod = log2(cameraViewport.z).mul(rough.mul(eta.mul(2.0).sub(2.0).clamp(0.0, 1.0)));\n return textureBicubicLevel(sample, lod);\n}\n\n/** Beer's law over the transmission distance; no attenuation for a zero attenuation distance (three's rule). */\nconst volumeAttenuation = Fn(([distance, color, attenuationDist]: VDBTslNode[]) => {\n const out = vec3(1.0).toVar();\n If(attenuationDist.notEqual(0), () => {\n out.assign(exp(log(color).negate().div(attenuationDist).negate().mul(distance)));\n });\n return out;\n});\n\n/** Refraction exit point's screen uv (WebGPU y down) for an ior: the hit plus the refracted direction times the thickness. */\nfunction refractionCoords(position: VDBTslNode, n: VDBTslNode, v: VDBTslNode, eta: VDBTslNode, thick: VDBTslNode): { coords: VDBTslNode; ray: VDBTslNode } {\n const ray = refract(v.negate(), n.normalize(), float(1.0).div(eta)).normalize().mul(thick);\n const ndc = cameraProjectionMatrix.mul(cameraViewMatrix.mul(vec4(position.add(ray), 1.0)));\n const uv = ndc.xy.div(ndc.w).add(1.0).div(2.0);\n return { coords: vec2(uv.x, uv.y.oneMinus()), ray };\n}\n\n/** three's `getIBLVolumeRefraction` with `position` the hit and an identity model matrix. */\nfunction volumeRefraction(position: VDBTslNode, withDispersion: boolean, mode: VDBLevelSetBackdrop): VDBTslNode {\n const v = cameraPosition.sub(position).normalize();\n const n = normalWorld;\n let transmitted: VDBTslNode;\n let transmittance: VDBTslNode;\n if (withDispersion) {\n transmitted = vec4().toVar();\n transmittance = vec3().toVar();\n const halfSpread = ior.sub(1.0).mul(dispersion.mul(0.025));\n const iors = vec3(ior.sub(halfSpread), ior, ior.add(halfSpread));\n Loop({ start: 0, end: 3 }, ({ i }: { i: VDBTslNode }) => {\n const eta = iors.element(i);\n const { coords, ray } = refractionCoords(position, n, v, eta, thickness);\n const sample = transmissionSample(coords, roughness, eta, mode);\n transmitted.element(i).assign(sample.element(i));\n transmitted.a.addAssign(sample.a);\n transmittance.element(i).assign(diffuseContribution.element(i).mul(volumeAttenuation(ray.length(), attenuationColor, attenuationDistance).element(i)));\n });\n transmitted.a.divAssign(3.0);\n } else {\n const { coords, ray } = refractionCoords(position, n, v, ior, thickness);\n transmitted = transmissionSample(coords, roughness, ior, mode);\n transmittance = diffuseContribution.mul(volumeAttenuation(ray.length(), attenuationColor, attenuationDistance));\n }\n const attenuated = transmittance.rgb.mul(transmitted.rgb);\n const F = vec3(EnvironmentBRDF({ dotNV: n.dot(v).clamp(), specularColor: specularColorBlended, specularF90, roughness }));\n const factor = transmittance.r.add(transmittance.g, transmittance.b).div(3.0);\n return vec4(F.oneMinus().mul(attenuated), transmitted.a.oneMinus().mul(factor).oneMinus());\n}\n\n/**\n * three's `PhysicalLightingModel` with transmission refracted from the trace's hit (see the file comment). Every\n * other term is three's: `start` runs with transmission off, then sets the backdrop three would.\n */\nexport class VDBLevelSetPhysicalLightingModel extends PhysicalLightingModel {\n /** The world hit the refraction starts at. */\n readonly hitWorld: VDBTslNode;\n /** When the backdrop is copied (G13c). */\n readonly backdrop: VDBLevelSetBackdrop;\n\n constructor(hitWorld: VDBTslNode, flags: ConstructorParameters<typeof PhysicalLightingModel>, backdrop: VDBLevelSetBackdrop = \"render\") {\n super(...flags);\n this.hitWorld = hitWorld;\n this.backdrop = backdrop;\n }\n\n override start(builder: Parameters<PhysicalLightingModel[\"start\"]>[0]): void {\n const self = this as unknown as { transmission: boolean; dispersion: boolean };\n const withTransmission = self.transmission;\n self.transmission = false;\n try {\n super.start(builder);\n } finally {\n self.transmission = withTransmission;\n }\n if (!withTransmission) return;\n const context = (builder as unknown as { context: { backdrop: VDBTslNode; backdropAlpha: VDBTslNode } }).context;\n context.backdrop = volumeRefraction(this.hitWorld, self.dispersion, this.backdrop);\n context.backdropAlpha = transmission;\n diffuseColor.a.mulAssign(mix(1, context.backdrop.a, transmission));\n }\n}\n\n/**\n * A level set's surface (as {@link VDBLevelSetMaterial}) shaded by three's physical material: transmission,\n * clearcoat, sheen, iridescence, `ior`, `specularIntensity` (see the file comment).\n *\n * @typeParam TGridId What the constructor got as the id: a number (default) makes {@link gridId} a `uint`\n * uniform; a node is kept as given.\n */\nexport class VDBLevelSetPhysicalMaterial<TGridId extends number | VDBTslNode = number> extends MeshPhysicalNodeMaterial implements VDBLevelSetTrace<TGridId> {\n /** Type flag: true (a level-set material, as `VDBLevelSetMaterial`). */\n readonly isVDBLevelSetMaterial = true;\n /** Type flag: true. */\n readonly isVDBLevelSetPhysicalMaterial = true;\n /** The pool node this material reads. */\n declare readonly grids: VDBGridNode;\n /** The grid id: a `uint` uniform for a numeric id (`material.gridId.value = otherId`), else the caller's node. */\n declare readonly gridId: TGridId extends number ? VDBUintUniform : VDBTslNode;\n /** Index voxels per SDF unit (live). */\n declare readonly sdfToIndex: ScalarUniform;\n /** Trilinear samples per trace (live, clamped to the compiled cap). */\n declare readonly maxSamples: ScalarUniform;\n /** Central-difference step of the normal in index voxels (live). */\n declare readonly normalStep: ScalarUniform;\n /** The entry's WGSL (for inspection and tests). */\n declare readonly traceSource: string;\n /** The packed surface (`mat4`, fragment stage). */\n declare readonly surfaceNode: VDBTslNode;\n /** `vec4(hit world position, 1)` on a hit, `vec4(0)` on a miss (fragment stage). */\n declare readonly traceNode: VDBTslNode;\n /** The hit in world space (where the refraction starts). */\n declare readonly hitWorldNode: VDBTslNode;\n /** The hit in view space. */\n declare readonly hitViewNode: VDBTslNode;\n /** True where the ray hit the surface (the material's `maskNode`). */\n declare readonly hitMaskNode: VDBTslNode;\n /** World-space unit normal at the hit. */\n declare readonly normalWorldNode: VDBTslNode;\n /** View-space unit normal at the hit (the material's `normalNode` and `clearcoatNormalNode`). */\n declare readonly normalViewNode: VDBTslNode;\n /** Whether the roughness nodes carry the geometric specular antialiasing (G13c; compile time). */\n declare readonly specularAntialiasing: boolean;\n /** When the transmission copies the frame (G13c; compile time). */\n declare readonly backdrop: VDBLevelSetBackdrop;\n /**\n * The transmitted shadow's colour (G13c): {@link vdbLevelSetShadowTint} of this material, refreshed each render. It\n * is the `castShadowNode` (alpha 1) when the renderer's `shadowMap.transmitted` is true and no `castShadowNode` was set.\n */\n declare readonly shadowTintNode: VDBTslNode;\n\n /**\n * @param renderer The initialized `WebGPURenderer` the pool and `grids` live on.\n * @param grids A `VDBGridNode` on this renderer with profile `'march'` and helpers including `'levelSet'`.\n * @param gridId The level set's pool id (a number, made a `uint` uniform) or a `uint` node.\n * @param params three's `MeshPhysicalMaterialParameters` plus the trace's ({@link VDBLevelSetPhysicalMaterialParameters}).\n * @throws VDBError `VDB_BAD_OPTION` for a `grids` this material can't use, a bad id or cap;\n * `VDB_UNSUPPORTED_DEVICE` for an uninitialized renderer.\n */\n constructor(renderer: VDBThreeRendererLike, grids: VDBGridNode, gridId: TGridId, params: VDBLevelSetPhysicalMaterialParameters = {}) {\n const { sdfToIndex: _s, maxSamples: _m, maxSamplesCap: _c, normalStep: _n, specularAntialiasing: _a, backdrop, ...physical } = params;\n super(physical);\n this.name = \"VDBLevelSetPhysicalMaterial\";\n if (backdrop !== undefined && backdrop !== \"render\" && backdrop !== \"object\") {\n throw new VDBError(\"VDB_BAD_OPTION\", `VDBLevelSetPhysicalMaterial: backdrop must be 'render' or 'object', got ${JSON.stringify(backdrop)}.`);\n }\n Object.assign(this, vdbLevelSetTrace(\"VDBLevelSetPhysicalMaterial\", renderer, grids, gridId, params));\n vdbApplyLevelSetTrace(this, this);\n const self = this as unknown as { clearcoatNormalNode: VDBTslNode; clearcoatRoughnessNode: VDBTslNode };\n self.clearcoatNormalNode = this.normalViewNode;\n if (this.specularAntialiasing) self.clearcoatRoughnessNode = vdbLevelSetSpecularAa(materialClearcoatRoughness, this);\n const tint = new THREE.Color();\n const shadowTintNode = (uniform(tint) as VDBTslNode).onRenderUpdate(() => tint.setRGB(...vdbLevelSetShadowTint(this as unknown as VDBLevelSetShadowTintInputs)));\n Object.assign(this, { backdrop: backdrop ?? \"render\", shadowTintNode, vdbRenderer: renderer });\n }\n\n /** Lights read `positionView`: the shading point is the hit, not the box face. */\n override setupLighting(builder: Parameters<MeshPhysicalNodeMaterial[\"setupLighting\"]>[0]): ReturnType<MeshPhysicalNodeMaterial[\"setupLighting\"]> {\n vdbLevelSetLightingPosition(this);\n return super.setupLighting(builder);\n }\n\n /** three's physical lighting model, with transmission refracted from the hit. */\n override setupLightingModel(builder?: unknown): PhysicalLightingModel {\n void builder;\n const m = this as unknown as Record<string, boolean>;\n return new VDBLevelSetPhysicalLightingModel(this.hitWorldNode, [\n m.useClearcoat!,\n m.useSheen!,\n m.useIridescence!,\n m.useAnisotropy!,\n m.useTransmission!,\n m.useDispersion!,\n m.useRetroreflection!,\n m.useDiffuseRoughness!,\n ] as ConstructorParameters<typeof PhysicalLightingModel>, this.backdrop);\n }\n}\n\n// `castShadowNode` as an accessor (three's NodeMaterial assigns it in its constructor, so a class field can't be used):\n// the user's node if set, else the transmitted shadow when the renderer's shadow map carries colour (G13c).\nObject.defineProperty(VDBLevelSetPhysicalMaterial.prototype, \"castShadowNode\", {\n configurable: true,\n get(this: VDBLevelSetPhysicalMaterial): VDBTslNode | null {\n const self = this as unknown as { vdbCastShadowNode?: VDBTslNode | null; vdbTransmitted?: VDBTslNode; vdbRenderer?: { shadowMap?: { transmitted?: boolean } } };\n if (self.vdbCastShadowNode) return self.vdbCastShadowNode;\n if (self.vdbRenderer?.shadowMap?.transmitted !== true || !this.shadowTintNode) return null;\n return (self.vdbTransmitted ??= vec4(this.shadowTintNode, 1.0));\n },\n set(this: VDBLevelSetPhysicalMaterial, value: VDBTslNode | null) {\n (this as unknown as { vdbCastShadowNode: VDBTslNode | null }).vdbCastShadowNode = value ?? null;\n },\n});\n"]}
@@ -0,0 +1,94 @@
1
+ /**
2
+ * `VDBLevelSetVelocityNode`: the screen-space velocity of a traced level set's HIT, for temporal antialiasing and
3
+ * upscalers (G13c-a1b, D42 (3)).
4
+ *
5
+ * A level-set material draws a proxy box and traces the surface inside it. three's `velocity` node reprojects the
6
+ * rasterized vertex position, which is a point on the box, not on the surface: a temporal resolve fed with it fetches
7
+ * its history from the wrong surface point and is worse than no antialiasing (G13c-a1a: ACES error against a 4x4
8
+ * supersampled frame 0.0110, the plain frame 0.0084, with the hit's velocity 0.0048).
9
+ *
10
+ * This node writes the hit's velocity instead, in three's convention (NDC of this frame minus NDC of the previous
11
+ * frame, y up, jitter-free), and three's own `velocity` for every material that has no traced hit. Put ONE node in
12
+ * the MRT of the pass that renders the scene:
13
+ *
14
+ * const hitVelocity = new VDBLevelSetVelocityNode();
15
+ * scenePass.setMRT(mrt({ output, velocity: hitVelocity })); // a RenderPipeline pass (three's TRAA), or
16
+ * renderer.setMRT(mrt({ output, velocity: hitVelocity })); // a render target of your own (an upscaler)
17
+ *
18
+ * Not `material.mrtNode`: three r187 takes a material's `mrtNode` as its whole output in a render into a target that
19
+ * has no MRT (an accumulation pass, a read-back of the same scene).
20
+ *
21
+ * Bookkeeping. "Previous" is the previous render in which this node was drawn with the same camera (three's
22
+ * `renderId`), so it needs no animation loop. Per camera it keeps the jitter-free view-projection; per camera and
23
+ * grid the grid's placement (`pool.setTransform`), so a level set that moves gets its own motion too. The first
24
+ * render after construction or {@link VDBLevelSetVelocityNode.reset} writes zero velocity for level sets.
25
+ */
26
+ import * as THREE from "three";
27
+ import { Node } from "three/webgpu";
28
+ import type { VDBTslNode } from "./grid-node.js";
29
+ type Mat4Uniform = VDBTslNode & {
30
+ value: THREE.Matrix4;
31
+ };
32
+ /**
33
+ * CPU twin of the node's reprojection: the NDC velocity (current − previous, three's convention) of a world-space
34
+ * hit. Matrices are column-major (`Matrix4.elements`): this and the previous frame's jitter-free projection × view,
35
+ * and `motion`, which takes a world position of this frame to the same surface point's world position in the
36
+ * previous frame ({@link vdbLevelSetGridMotion}; identity for a grid that did not move).
37
+ */
38
+ export declare function vdbLevelSetVelocityCpu(hitWorld: ArrayLike<number>, currentViewProjection: ArrayLike<number>, previousViewProjection: ArrayLike<number>, motion?: ArrayLike<number>): [number, number];
39
+ /**
40
+ * The world-space motion of a grid between two frames: `previous indexToWorld ∘ current worldToIndex` (both 3x4,
41
+ * row-major, as `pool.info(id)` reports them), as a column-major 4x4. It takes this frame's world position of a
42
+ * surface point to its world position in the previous frame.
43
+ */
44
+ export declare function vdbLevelSetGridMotion(previousIndexToWorld: ArrayLike<number>, currentWorldToIndex: ArrayLike<number>): number[];
45
+ /**
46
+ * The MRT `velocity` output for scenes with traced level sets: the hit's velocity for `VDBLevelSetMaterial` and
47
+ * `VDBLevelSetPhysicalMaterial` (any material with a `hitWorldNode`), three's `velocity` for every other material.
48
+ * See the file comment for the wiring.
49
+ *
50
+ * - **Convention:** three's: `ndc(current) − ndc(previous)`, x right, y up, in NDC units (2 = the viewport's side).
51
+ * - **Jitter:** the velocity is jitter-free when the projection it uses is. three's TRAA gives its unjittered
52
+ * projection to the `velocity` node; this node reads the same one. A host that jitters the camera itself calls
53
+ * {@link setProjectionMatrix} with the unjittered projection (and with `null` when it stops).
54
+ * - **Moving level sets:** a grid placed with `pool.setTransform` gets the motion of its placement (numeric grid ids
55
+ * only; a material whose `gridId` is a node gets the camera's motion alone). A grid whose image changes
56
+ * (`pool.replace`: a sequence) has no motion vectors: its history is wrong where the surface moved.
57
+ * - **Cuts:** call {@link reset} at a camera cut, after a resize that changes the aspect, and when rendering resumes
58
+ * after frames this node did not draw (and reset the consumer's history too).
59
+ * - **Several materials and grids** share the one node. One node per pass.
60
+ */
61
+ export declare class VDBLevelSetVelocityNode extends Node {
62
+ #private;
63
+ static get type(): string;
64
+ /** Type flag: true. */
65
+ readonly isVDBLevelSetVelocityNode = true;
66
+ /**
67
+ * The jitter-free projection the velocity is computed with, or `null`: three's `velocity` node's override (what
68
+ * three's TRAA sets), else the camera's own projection. Set it with {@link setProjectionMatrix}.
69
+ */
70
+ projectionMatrix: THREE.Matrix4 | null;
71
+ /** This render's jitter-free projection × view (a render-group uniform; written by the node). */
72
+ readonly currentViewProjection: Mat4Uniform;
73
+ /** The previous render's jitter-free projection × view (a render-group uniform; written by the node). */
74
+ readonly previousViewProjection: Mat4Uniform;
75
+ /** Per object: this frame's world position to the previous frame's, for a grid whose placement changed. */
76
+ readonly gridMotion: Mat4Uniform;
77
+ constructor();
78
+ /**
79
+ * Gives the velocity a jitter-free projection (a matrix the host keeps up to date, read at every render), or
80
+ * `null` for the default. The same matrix is given to three's `velocity` node, so the other meshes of the pass
81
+ * stay consistent. Not needed with three's TRAA, which sets three's node itself.
82
+ */
83
+ setProjectionMatrix(projectionMatrix: THREE.Matrix4 | null): void;
84
+ /**
85
+ * Forgets the previous frame: the next render writes zero velocity for level sets (previous = current). For a
86
+ * camera cut, an aspect change, or after renders this node did not draw. Other meshes keep three's bookkeeping.
87
+ */
88
+ reset(): void;
89
+ /** three's per-object update: latches the camera once per render and the grid's motion per object. */
90
+ update(frame: Parameters<Node["update"]>[0]): undefined;
91
+ /** The hit's NDC delta for a material with a traced hit, three's `velocity` otherwise. */
92
+ setup(builder: Parameters<Node["setup"]>[0]): ReturnType<Node["setup"]>;
93
+ }
94
+ export {};