@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":"analytic.js","sourceRoot":"","sources":["../../../src/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* one box or ball).\n *\n * - Beer–Lambert: T = exp(−σ · chord).\n * - Emission only (albedo 0): L = Le · (1 − T) (the renderer's source term σt · Le).\n * - Single scattering of a directional light: L = ∫ σ · albedo · p(cos θ) · E · exp(−σ (t − t₀)) · exp(−σ ℓ(t)) dt\n * over the camera ray's interval, ℓ(t) the distance from the point to the medium's exit toward the light\n * (composite Simpson, n panels).\n * - White furnace: albedo 1 under a uniform environment Lₑ (and no other light): L + T · Lₑ = Lₑ.\n * - K6.R1: single scattering of a point light (three's falloff or none) and with a tabulated phase.\n */\n\nimport { vdbRefDistanceAttenuation, vdbRefInvert4, type VDBRefVec3, type VDBReferenceFalloff, type VDBReferencePhase } from \"./scene.js\";\nimport { vdbRefPhaseTableEval } from \"./tables.js\";\nimport { vdbRefPhase, vdbRefVolumeInterval } from \"./trace.js\";\n\n/** A homogeneous medium in one box or ball. */\nexport interface VDBRefHomogeneous {\n localToWorld: ArrayLike<number>;\n sphere: boolean;\n /** σt per world unit. */\n sigma: number;\n}\n\nconst dot = (a: readonly number[], b: readonly number[]) => a[0]! * b[0]! + a[1]! * b[1]! + a[2]! * b[2]!;\n\n/** The chord [t₀, t₁] of the ray o + t·d (|d| = 1) in the medium, or null. */\nexport function vdbRefChord(m: VDBRefHomogeneous, o: readonly number[], d: readonly number[]): [number, number] | null {\n const [t0, t1] = vdbRefVolumeInterval(vdbRefInvert4(m.localToWorld), m.sphere, o, d, 1e30);\n return t0 < t1 ? [t0, t1] : null;\n}\n\n/** Beer–Lambert transmittance of the ray through the medium. */\nexport function vdbRefBeerLambert(m: VDBRefHomogeneous, o: readonly number[], d: readonly number[]): number {\n const c = vdbRefChord(m, o, d);\n return c ? Math.exp(-m.sigma * (c[1] - c[0])) : 1;\n}\n\n/** Radiance of a purely emitting medium (albedo 0) of emitted radiance Le: Le · (1 − T). */\nexport function vdbRefEmissionOnly(m: VDBRefHomogeneous, o: readonly number[], d: readonly number[], le: VDBRefVec3): VDBRefVec3 {\n const a = 1 - vdbRefBeerLambert(m, o, d);\n return [le[0] * a, le[1] * a, le[2] * a];\n}\n\n/**\n * Single-scattered radiance of a directional light (irradiance `e`, `toLight` unit) along o + t·d (|d| = 1) in a\n * homogeneous medium of scattering albedo `albedo`, phase (g, backG, backWeight); composite Simpson, `n` panels.\n */\nexport function vdbRefSingleScatter(\n m: VDBRefHomogeneous,\n o: readonly number[],\n d: readonly number[],\n toLight: readonly number[],\n e: VDBRefVec3,\n albedo: VDBRefVec3,\n phase: VDBReferencePhase,\n n = 4096,\n): VDBRefVec3 {\n const c = vdbRefChord(m, o, d);\n if (!c) return [0, 0, 0];\n const w2l = vdbRefInvert4(m.localToWorld);\n const pc = phaseOf(phase, dot(d, toLight));\n const f = (t: number) => {\n const x = [o[0]! + t * d[0]!, o[1]! + t * d[1]!, o[2]! + t * d[2]!];\n const [, exit] = vdbRefVolumeInterval(w2l, m.sphere, x, toLight, 1e30);\n const l = Math.max(exit, 0);\n return Math.exp(-m.sigma * (t - c[0])) * Math.exp(-m.sigma * l);\n };\n const steps = n % 2 === 0 ? n : n + 1;\n const h = (c[1] - c[0]) / steps;\n let s = f(c[0]) + f(c[1]);\n for (let i = 1; i < steps; i++) s += (i % 2 ? 4 : 2) * f(c[0] + i * h);\n const integral = (s * h) / 3;\n return [0, 1, 2].map((k) => m.sigma * albedo[k]! * pc[k]! * e[k]! * integral) as VDBRefVec3;\n}\n\n/** The phase per steradian per channel (HG / dual-lobe, or the table). */\nfunction phaseOf(phase: VDBReferencePhase, cosTheta: number): VDBRefVec3 {\n if (phase.table) return vdbRefPhaseTableEval(phase.table, cosTheta);\n const p = vdbRefPhase(cosTheta, phase.g, phase.backG ?? 0, phase.backWeight ?? 0);\n return [p, p, p];\n}\n\n/**\n * K6.R1: single-scattered radiance of a point light (`intensity` at `position`, `falloff` three's attenuation or\n * none) along o + t·d (|d| = 1) in a homogeneous medium; composite Simpson, `n` panels. The light's transmittance\n * is exp(−σ · the part of the segment x → light inside the medium).\n */\nexport function vdbRefSingleScatterPoint(\n m: VDBRefHomogeneous,\n o: readonly number[],\n d: readonly number[],\n light: { position: VDBRefVec3; intensity: VDBRefVec3; falloff?: VDBReferenceFalloff },\n albedo: VDBRefVec3,\n phase: VDBReferencePhase,\n n = 4096,\n): VDBRefVec3 {\n const c = vdbRefChord(m, o, d);\n if (!c) return [0, 0, 0];\n const w2l = vdbRefInvert4(m.localToWorld);\n const f = (t: number): VDBRefVec3 => {\n const x = [o[0]! + t * d[0]!, o[1]! + t * d[1]!, o[2]! + t * d[2]!];\n const to = [light.position[0] - x[0]!, light.position[1] - x[1]!, light.position[2] - x[2]!];\n const dist = Math.hypot(to[0]!, to[1]!, to[2]!);\n const dir = [to[0]! / dist, to[1]! / dist, to[2]! / dist];\n const [t0, t1] = vdbRefVolumeInterval(w2l, m.sphere, x, dir, dist);\n const inside = t0 < t1 ? t1 - t0 : 0;\n const k = (light.falloff ? vdbRefDistanceAttenuation(dist, light.falloff) : 1) * Math.exp(-m.sigma * (t - c[0])) * Math.exp(-m.sigma * inside);\n const p = phaseOf(phase, dot(d, dir));\n return [p[0] * k, p[1] * k, p[2] * k];\n };\n const steps = n % 2 === 0 ? n : n + 1;\n const h = (c[1] - c[0]) / steps;\n const s: VDBRefVec3 = [0, 0, 0];\n for (let i = 0; i <= steps; i++) {\n const w = i === 0 || i === steps ? 1 : i % 2 ? 4 : 2;\n const v = f(c[0] + i * h);\n for (let k = 0; k < 3; k++) s[k] = s[k]! + w * v[k]!;\n }\n return [0, 1, 2].map((k) => (m.sigma * albedo[k]! * light.intensity[k]! * s[k]! * h) / 3) as VDBRefVec3;\n}\n"]}
@@ -0,0 +1,62 @@
1
+ /**
2
+ * K6.R2: importance sampling of the reference's equirect environment map (next-event estimation of the map, combined
3
+ * with the phase-sampled escape by multiple importance sampling; `VDBReferenceSettings.environmentSampling`).
4
+ *
5
+ * The map is read nearest (`vdbRefEnvironmentRadiance`: texel x = ⌊u·W⌋, u = atan2(m.z, m.x)/2π + ½; row y = ⌊(1 − v)·H⌋,
6
+ * v = asin(m.y)/π + ½, m = R·d), so it is piecewise constant over texels, and a texel is uniform in solid angle in
7
+ * (azimuth, sin latitude): its solid angle is Ω = (2π / W)·(s_y − s_{y+1}) with s_y = sin(π(½ − y/H)) the sine of its
8
+ * top edge's latitude. Sampling picks a row from the marginal and a column from the row's conditional distribution of
9
+ * luminance × Ω (piecewise constant, so the texel's probability is P = P(y)·P(x | y)), then a direction uniform in the
10
+ * texel's solid angle: azimuth uniform in the column, sin latitude uniform in the row. The density per steradian is
11
+ * P / Ω, exactly (no sin θ approximation).
12
+ *
13
+ * Everything the sampler reads is in one r32float table the GPU kernel reads too (`core/reference/renderer.ts` uploads
14
+ * `data`): rows 0 … H − 1 the conditional CDFs C_y[0 … W], row H the marginal M[0 … H], row H + 1 cos φ and row H + 2
15
+ * sin φ of the column edges φ_x = 2π(x/W − ½) (x = 0 … W), row H + 3 the row edges s_y (y = 0 … H), row H + 4 each
16
+ * row's texel solid angle Ω_y (from f64 edges: the f32 difference of two edges near a pole loses digits); width
17
+ * max(W, H) + 1. Both sides read these f32 numbers, so the twin and the kernel pick the same texels. The kernel turns
18
+ * the column edge by the in-texel angle with a polynomial (WGSL `sin`/`cos` are only accurate to 2^-11, a third of a
19
+ * 4096-wide map's texel); the twin uses `Math.cos` / `Math.sin`.
20
+ */
21
+ import type { VDBRefVec3, VDBReferenceEquirect } from "./scene.js";
22
+ /** The sampling table of an equirect map ({@link vdbReferenceEnvironmentSampler}). */
23
+ export interface VDBReferenceEnvironmentSampler {
24
+ /** The map's size. */
25
+ width: number;
26
+ height: number;
27
+ /** The table's size: max(W, H) + 1 by H + 5. */
28
+ tableWidth: number;
29
+ tableHeight: number;
30
+ /** r32float rows (see the file comment), x fastest. */
31
+ data: Float32Array;
32
+ /** Σ luminance × Ω over the texels (0: nothing to sample; the map is then gathered by escapes only). */
33
+ total: number;
34
+ }
35
+ /**
36
+ * The sampling table of `map` (cached per map object). Weights: luminance (≥ 0) × the texel's solid angle; a row with
37
+ * no light gets a uniform conditional (never picked: its marginal interval is empty).
38
+ */
39
+ export declare function vdbReferenceEnvironmentSampler(map: VDBReferenceEquirect): VDBReferenceEnvironmentSampler;
40
+ /**
41
+ * The density per steradian of texel (x, y): P(y)·P(x | y) / Ω. The mutation `env-pdf` uses every texel's mean solid
42
+ * angle 4π / (W·H) instead of its own (a forgotten latitude Jacobian).
43
+ */
44
+ export declare function vdbRefEnvTexelPdf(s: VDBReferenceEnvironmentSampler, x: number, y: number, mutate?: string): number;
45
+ /** The texel (x, y) the radiance lookup reads in world direction `d` (`vdbRefEnvironmentRadiance`'s mapping). */
46
+ export declare function vdbRefEnvTexelOf(map: VDBReferenceEquirect, d: readonly number[]): [number, number];
47
+ /** The density per steradian with which {@link vdbRefEnvSample} picks world direction `d` (0 when the sampler is empty). */
48
+ export declare function vdbRefEnvPdf(map: VDBReferenceEquirect, s: VDBReferenceEnvironmentSampler, d: readonly number[], mutate?: string): number;
49
+ /**
50
+ * Sample a world direction from the map with xi ∈ [0, 1)⁴ (row, column, azimuth in the texel, sin latitude in the
51
+ * texel): the direction, the sampled texel's radiance (× `intensity`) and its density per steradian. The estimate
52
+ * uses the SAMPLED texel's radiance and density (the kernel's direction can stray across a texel edge by rounding; the
53
+ * texel is what was sampled).
54
+ */
55
+ export declare function vdbRefEnvSample(map: VDBReferenceEquirect, s: VDBReferenceEnvironmentSampler, xi: readonly number[], mutate?: string): {
56
+ dir: VDBRefVec3;
57
+ radiance: VDBRefVec3;
58
+ pdf: number;
59
+ texel: [number, number];
60
+ };
61
+ /** The power heuristic's weight (β = 2) of a technique with density `p` against one with density `q`: p² / (p² + q²). */
62
+ export declare function vdbRefMisWeight(p: number, q: number): number;
@@ -0,0 +1,154 @@
1
+ /**
2
+ * K6.R2: importance sampling of the reference's equirect environment map (next-event estimation of the map, combined
3
+ * with the phase-sampled escape by multiple importance sampling; `VDBReferenceSettings.environmentSampling`).
4
+ *
5
+ * The map is read nearest (`vdbRefEnvironmentRadiance`: texel x = ⌊u·W⌋, u = atan2(m.z, m.x)/2π + ½; row y = ⌊(1 − v)·H⌋,
6
+ * v = asin(m.y)/π + ½, m = R·d), so it is piecewise constant over texels, and a texel is uniform in solid angle in
7
+ * (azimuth, sin latitude): its solid angle is Ω = (2π / W)·(s_y − s_{y+1}) with s_y = sin(π(½ − y/H)) the sine of its
8
+ * top edge's latitude. Sampling picks a row from the marginal and a column from the row's conditional distribution of
9
+ * luminance × Ω (piecewise constant, so the texel's probability is P = P(y)·P(x | y)), then a direction uniform in the
10
+ * texel's solid angle: azimuth uniform in the column, sin latitude uniform in the row. The density per steradian is
11
+ * P / Ω, exactly (no sin θ approximation).
12
+ *
13
+ * Everything the sampler reads is in one r32float table the GPU kernel reads too (`core/reference/renderer.ts` uploads
14
+ * `data`): rows 0 … H − 1 the conditional CDFs C_y[0 … W], row H the marginal M[0 … H], row H + 1 cos φ and row H + 2
15
+ * sin φ of the column edges φ_x = 2π(x/W − ½) (x = 0 … W), row H + 3 the row edges s_y (y = 0 … H), row H + 4 each
16
+ * row's texel solid angle Ω_y (from f64 edges: the f32 difference of two edges near a pole loses digits); width
17
+ * max(W, H) + 1. Both sides read these f32 numbers, so the twin and the kernel pick the same texels. The kernel turns
18
+ * the column edge by the in-texel angle with a polynomial (WGSL `sin`/`cos` are only accurate to 2^-11, a third of a
19
+ * 4096-wide map's texel); the twin uses `Math.cos` / `Math.sin`.
20
+ */
21
+ const LUMA = [0.2126, 0.7152, 0.0722];
22
+ const cache = new WeakMap();
23
+ /**
24
+ * The sampling table of `map` (cached per map object). Weights: luminance (≥ 0) × the texel's solid angle; a row with
25
+ * no light gets a uniform conditional (never picked: its marginal interval is empty).
26
+ */
27
+ export function vdbReferenceEnvironmentSampler(map) {
28
+ const hit = cache.get(map);
29
+ if (hit)
30
+ return hit;
31
+ const W = map.width;
32
+ const H = map.height;
33
+ const tw = Math.max(W, H) + 1;
34
+ const th = H + 5;
35
+ const data = new Float32Array(tw * th);
36
+ const rowEdge = (y) => (y === 0 ? 1 : y === H ? -1 : Math.sin(Math.PI * (0.5 - y / H)));
37
+ const rowWeight = new Float64Array(H);
38
+ const acc = new Float64Array(W + 1);
39
+ for (let y = 0; y < H; y++) {
40
+ const omega = ((2 * Math.PI) / W) * (rowEdge(y) - rowEdge(y + 1));
41
+ data[(H + 4) * tw + y] = omega;
42
+ acc[0] = 0;
43
+ for (let x = 0; x < W; x++) {
44
+ const k = (y * W + x) * 4;
45
+ const l = Math.max(0, LUMA[0] * map.data[k] + LUMA[1] * map.data[k + 1] + LUMA[2] * map.data[k + 2]);
46
+ acc[x + 1] = acc[x] + l;
47
+ }
48
+ const sum = acc[W];
49
+ rowWeight[y] = sum * omega;
50
+ for (let x = 0; x <= W; x++)
51
+ data[y * tw + x] = sum > 0 ? acc[x] / sum : x / W;
52
+ data[y * tw + W] = 1;
53
+ }
54
+ let total = 0;
55
+ for (let y = 0; y < H; y++)
56
+ total += rowWeight[y];
57
+ let m = 0;
58
+ for (let y = 0; y <= H; y++) {
59
+ data[H * tw + y] = total > 0 ? m / total : y / H;
60
+ if (y < H)
61
+ m += rowWeight[y];
62
+ }
63
+ data[H * tw + H] = 1;
64
+ for (let x = 0; x <= W; x++) {
65
+ const phi = 2 * Math.PI * (x / W - 0.5);
66
+ data[(H + 1) * tw + x] = Math.cos(phi);
67
+ data[(H + 2) * tw + x] = Math.sin(phi);
68
+ }
69
+ for (let y = 0; y <= H; y++)
70
+ data[(H + 3) * tw + y] = rowEdge(y);
71
+ const s = { width: W, height: H, tableWidth: tw, tableHeight: th, data, total };
72
+ cache.set(map, s);
73
+ return s;
74
+ }
75
+ /** The interval j with t[j] ≤ xi < t[j + 1] of the increasing table t[0 … n] (binary search, as the phase table's). */
76
+ function search(data, base, n, xi) {
77
+ let lo = 0;
78
+ let hi = n;
79
+ while (hi - lo > 1) {
80
+ const mid = (lo + hi) >> 1;
81
+ if (data[base + mid] <= xi)
82
+ lo = mid;
83
+ else
84
+ hi = mid;
85
+ }
86
+ return lo;
87
+ }
88
+ /**
89
+ * The density per steradian of texel (x, y): P(y)·P(x | y) / Ω. The mutation `env-pdf` uses every texel's mean solid
90
+ * angle 4π / (W·H) instead of its own (a forgotten latitude Jacobian).
91
+ */
92
+ export function vdbRefEnvTexelPdf(s, x, y, mutate) {
93
+ const { width: W, height: H, tableWidth: tw, data } = s;
94
+ const py = data[H * tw + y + 1] - data[H * tw + y];
95
+ const px = data[y * tw + x + 1] - data[y * tw + x];
96
+ const omega = mutate === "env-pdf" ? (4 * Math.PI) / (W * H) : data[(H + 4) * tw + y];
97
+ return omega > 0 ? (py * px) / omega : 0;
98
+ }
99
+ /** The texel (x, y) the radiance lookup reads in world direction `d` (`vdbRefEnvironmentRadiance`'s mapping). */
100
+ export function vdbRefEnvTexelOf(map, d) {
101
+ const r = map.rotation;
102
+ const m = r ? [r[0] * d[0] + r[1] * d[1] + r[2] * d[2], r[3] * d[0] + r[4] * d[1] + r[5] * d[2], r[6] * d[0] + r[7] * d[1] + r[8] * d[2]] : d;
103
+ const u = Math.atan2(m[2], m[0]) / (2 * Math.PI) + 0.5;
104
+ const v = Math.asin(Math.min(Math.max(m[1], -1), 1)) / Math.PI + 0.5;
105
+ const x = Math.min(Math.max(Math.floor(u * map.width), 0), map.width - 1);
106
+ const y = Math.min(Math.max(Math.floor((1 - v) * map.height), 0), map.height - 1);
107
+ return [x, y];
108
+ }
109
+ /** The density per steradian with which {@link vdbRefEnvSample} picks world direction `d` (0 when the sampler is empty). */
110
+ export function vdbRefEnvPdf(map, s, d, mutate) {
111
+ if (!(s.total > 0))
112
+ return 0;
113
+ const [x, y] = vdbRefEnvTexelOf(map, d);
114
+ return vdbRefEnvTexelPdf(s, x, y, mutate);
115
+ }
116
+ /**
117
+ * Sample a world direction from the map with xi ∈ [0, 1)⁴ (row, column, azimuth in the texel, sin latitude in the
118
+ * texel): the direction, the sampled texel's radiance (× `intensity`) and its density per steradian. The estimate
119
+ * uses the SAMPLED texel's radiance and density (the kernel's direction can stray across a texel edge by rounding; the
120
+ * texel is what was sampled).
121
+ */
122
+ export function vdbRefEnvSample(map, s, xi, mutate) {
123
+ const { width: W, height: H, tableWidth: tw, data } = s;
124
+ const y = search(data, H * tw, H, xi[0]);
125
+ const x = search(data, y * tw, W, xi[1]);
126
+ const a = ((2 * Math.PI) / W) * xi[2];
127
+ const c0 = data[(H + 1) * tw + x];
128
+ const s0 = data[(H + 2) * tw + x];
129
+ const ca = Math.cos(a);
130
+ const sa = Math.sin(a);
131
+ const cphi = c0 * ca - s0 * sa;
132
+ const sphi = s0 * ca + c0 * sa;
133
+ const top = data[(H + 3) * tw + y];
134
+ const bottom = data[(H + 3) * tw + y + 1];
135
+ const my = bottom + (top - bottom) * xi[3];
136
+ const r = Math.sqrt(Math.max(0, 1 - my * my));
137
+ const m = [r * cphi, my, r * sphi];
138
+ const R = map.rotation;
139
+ // d = Rᵀ m (R is orthonormal: the lookup applies m = R d)
140
+ const raw = R ? [R[0] * m[0] + R[3] * m[1] + R[6] * m[2], R[1] * m[0] + R[4] * m[1] + R[7] * m[2], R[2] * m[0] + R[5] * m[1] + R[8] * m[2]] : m;
141
+ // unit length again (the f32 column edges are unit only to f32 rounding)
142
+ const len = Math.hypot(raw[0], raw[1], raw[2]);
143
+ const dir = [raw[0] / len, raw[1] / len, raw[2] / len];
144
+ const k = (y * W + x) * 4;
145
+ const scale = map.intensity ?? 1;
146
+ return { dir, radiance: [map.data[k] * scale, map.data[k + 1] * scale, map.data[k + 2] * scale], pdf: vdbRefEnvTexelPdf(s, x, y, mutate), texel: [x, y] };
147
+ }
148
+ /** The power heuristic's weight (β = 2) of a technique with density `p` against one with density `q`: p² / (p² + q²). */
149
+ export function vdbRefMisWeight(p, q) {
150
+ // as a ratio at most 1e15, so the GPU's f32 never overflows (a forward Mie peak, u → 0; a texel the map never picks)
151
+ const r = q / Math.max(p, q * 1e-15, 1e-30);
152
+ return 1 / (1 + r * r);
153
+ }
154
+ //# sourceMappingURL=environment.js.map
@@ -0,0 +1 @@
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,GAAG,GAAe,CAAC,GAAG,CAAC,CAAC,CAAE,GAAG,GAAG,EAAE,GAAG,CAAC,CAAC,CAAE,GAAG,GAAG,EAAE,GAAG,CAAC,CAAC,CAAE,GAAG,GAAG,CAAC,CAAC;IACtE,MAAM,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC;IAC1B,MAAM,KAAK,GAAG,GAAG,CAAC,SAAS,IAAI,CAAC,CAAC;IACjC,OAAO,EAAE,GAAG,EAAE,QAAQ,EAAE,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,CAAE,GAAG,KAAK,EAAE,GAAG,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,CAAE,GAAG,KAAK,EAAE,GAAG,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,CAAE,GAAG,KAAK,CAAC,EAAE,GAAG,EAAE,iBAAiB,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,MAAM,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC;AAC/J,CAAC;AAED,yHAAyH;AACzH,MAAM,UAAU,eAAe,CAAC,CAAS,EAAE,CAAS;IAClD,qHAAqH;IACrH,MAAM,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC,GAAG,KAAK,EAAE,KAAK,CAAC,CAAC;IAC5C,OAAO,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC;AACzB,CAAC","sourcesContent":["/**\n * K6.R2: importance sampling of the reference's equirect environment map (next-event estimation of the map, combined\n * with the phase-sampled escape by multiple importance sampling; `VDBReferenceSettings.environmentSampling`).\n *\n * The map is read nearest (`vdbRefEnvironmentRadiance`: texel x = ⌊u·W⌋, u = atan2(m.z, m.x)/2π + ½; row y = ⌊(1 − v)·H⌋,\n * v = asin(m.y)/π + ½, m = R·d), so it is piecewise constant over texels, and a texel is uniform in solid angle in\n * (azimuth, sin latitude): its solid angle is Ω = (2π / W)·(s_y − s_{y+1}) with s_y = sin(π(½ − y/H)) the sine of its\n * top edge's latitude. Sampling picks a row from the marginal and a column from the row's conditional distribution of\n * luminance × Ω (piecewise constant, so the texel's probability is P = P(y)·P(x | y)), then a direction uniform in the\n * texel's solid angle: azimuth uniform in the column, sin latitude uniform in the row. The density per steradian is\n * P / Ω, exactly (no sin θ approximation).\n *\n * Everything the sampler reads is in one r32float table the GPU kernel reads too (`core/reference/renderer.ts` uploads\n * `data`): rows 0 … H − 1 the conditional CDFs C_y[0 … W], row H the marginal M[0 … H], row H + 1 cos φ and row H + 2\n * sin φ of the column edges φ_x = 2π(x/W − ½) (x = 0 … W), row H + 3 the row edges s_y (y = 0 … H), row H + 4 each\n * row's texel solid angle Ω_y (from f64 edges: the f32 difference of two edges near a pole loses digits); width\n * max(W, H) + 1. Both sides read these f32 numbers, so the twin and the kernel pick the same texels. The kernel turns\n * the column edge by the in-texel angle with a polynomial (WGSL `sin`/`cos` are only accurate to 2^-11, a third of a\n * 4096-wide map's texel); the twin uses `Math.cos` / `Math.sin`.\n */\n\nimport type { VDBRefVec3, VDBReferenceEquirect } from \"./scene.js\";\n\n/** The sampling table of an equirect map ({@link vdbReferenceEnvironmentSampler}). */\nexport interface VDBReferenceEnvironmentSampler {\n /** The map's size. */\n width: number;\n height: number;\n /** The table's size: max(W, H) + 1 by H + 5. */\n tableWidth: number;\n tableHeight: number;\n /** r32float rows (see the file comment), x fastest. */\n data: Float32Array;\n /** Σ luminance × Ω over the texels (0: nothing to sample; the map is then gathered by escapes only). */\n total: number;\n}\n\nconst LUMA = [0.2126, 0.7152, 0.0722] as const;\nconst cache = new WeakMap<VDBReferenceEquirect, VDBReferenceEnvironmentSampler>();\n\n/**\n * The sampling table of `map` (cached per map object). Weights: luminance (≥ 0) × the texel's solid angle; a row with\n * no light gets a uniform conditional (never picked: its marginal interval is empty).\n */\nexport function vdbReferenceEnvironmentSampler(map: VDBReferenceEquirect): VDBReferenceEnvironmentSampler {\n const hit = cache.get(map);\n if (hit) return hit;\n const W = map.width;\n const H = map.height;\n const tw = Math.max(W, H) + 1;\n const th = H + 5;\n const data = new Float32Array(tw * th);\n const rowEdge = (y: number) => (y === 0 ? 1 : y === H ? -1 : Math.sin(Math.PI * (0.5 - y / H)));\n const rowWeight = new Float64Array(H);\n const acc = new Float64Array(W + 1);\n for (let y = 0; y < H; y++) {\n const omega = ((2 * Math.PI) / W) * (rowEdge(y) - rowEdge(y + 1));\n data[(H + 4) * tw + y] = omega;\n acc[0] = 0;\n for (let x = 0; x < W; x++) {\n const k = (y * W + x) * 4;\n const l = Math.max(0, LUMA[0] * map.data[k]! + LUMA[1] * map.data[k + 1]! + LUMA[2] * map.data[k + 2]!);\n acc[x + 1] = acc[x]! + l;\n }\n const sum = acc[W]!;\n rowWeight[y] = sum * omega;\n for (let x = 0; x <= W; x++) data[y * tw + x] = sum > 0 ? acc[x]! / sum : x / W;\n data[y * tw + W] = 1;\n }\n let total = 0;\n for (let y = 0; y < H; y++) total += rowWeight[y]!;\n let m = 0;\n for (let y = 0; y <= H; y++) {\n data[H * tw + y] = total > 0 ? m / total : y / H;\n if (y < H) m += rowWeight[y]!;\n }\n data[H * tw + H] = 1;\n for (let x = 0; x <= W; x++) {\n const phi = 2 * Math.PI * (x / W - 0.5);\n data[(H + 1) * tw + x] = Math.cos(phi);\n data[(H + 2) * tw + x] = Math.sin(phi);\n }\n for (let y = 0; y <= H; y++) data[(H + 3) * tw + y] = rowEdge(y);\n const s: VDBReferenceEnvironmentSampler = { width: W, height: H, tableWidth: tw, tableHeight: th, data, total };\n cache.set(map, s);\n return s;\n}\n\n/** The interval j with t[j] ≤ xi < t[j + 1] of the increasing table t[0 … n] (binary search, as the phase table's). */\nfunction search(data: Float32Array, base: number, n: number, xi: number): number {\n let lo = 0;\n let hi = n;\n while (hi - lo > 1) {\n const mid = (lo + hi) >> 1;\n if (data[base + mid]! <= xi) lo = mid;\n else hi = mid;\n }\n return lo;\n}\n\n/**\n * The density per steradian of texel (x, y): P(y)·P(x | y) / Ω. The mutation `env-pdf` uses every texel's mean solid\n * angle 4π / (W·H) instead of its own (a forgotten latitude Jacobian).\n */\nexport function vdbRefEnvTexelPdf(s: VDBReferenceEnvironmentSampler, x: number, y: number, mutate?: string): number {\n const { width: W, height: H, tableWidth: tw, data } = s;\n const py = data[H * tw + y + 1]! - data[H * tw + y]!;\n const px = data[y * tw + x + 1]! - data[y * tw + x]!;\n const omega = mutate === \"env-pdf\" ? (4 * Math.PI) / (W * H) : data[(H + 4) * tw + y]!;\n return omega > 0 ? (py * px) / omega : 0;\n}\n\n/** The texel (x, y) the radiance lookup reads in world direction `d` (`vdbRefEnvironmentRadiance`'s mapping). */\nexport function vdbRefEnvTexelOf(map: VDBReferenceEquirect, d: readonly number[]): [number, number] {\n const r = map.rotation;\n const m = r ? [r[0]! * d[0]! + r[1]! * d[1]! + r[2]! * d[2]!, r[3]! * d[0]! + r[4]! * d[1]! + r[5]! * d[2]!, r[6]! * d[0]! + r[7]! * d[1]! + r[8]! * d[2]!] : d;\n const u = Math.atan2(m[2]!, m[0]!) / (2 * Math.PI) + 0.5;\n const v = Math.asin(Math.min(Math.max(m[1]!, -1), 1)) / Math.PI + 0.5;\n const x = Math.min(Math.max(Math.floor(u * map.width), 0), map.width - 1);\n const y = Math.min(Math.max(Math.floor((1 - v) * map.height), 0), map.height - 1);\n return [x, y];\n}\n\n/** The density per steradian with which {@link vdbRefEnvSample} picks world direction `d` (0 when the sampler is empty). */\nexport function vdbRefEnvPdf(map: VDBReferenceEquirect, s: VDBReferenceEnvironmentSampler, d: readonly number[], mutate?: string): number {\n if (!(s.total > 0)) return 0;\n const [x, y] = vdbRefEnvTexelOf(map, d);\n return vdbRefEnvTexelPdf(s, x, y, mutate);\n}\n\n/**\n * Sample a world direction from the map with xi ∈ [0, 1)⁴ (row, column, azimuth in the texel, sin latitude in the\n * texel): the direction, the sampled texel's radiance (× `intensity`) and its density per steradian. The estimate\n * uses the SAMPLED texel's radiance and density (the kernel's direction can stray across a texel edge by rounding; the\n * texel is what was sampled).\n */\nexport function vdbRefEnvSample(map: VDBReferenceEquirect, s: VDBReferenceEnvironmentSampler, xi: readonly number[], mutate?: string): { dir: VDBRefVec3; radiance: VDBRefVec3; pdf: number; texel: [number, number] } {\n const { width: W, height: H, tableWidth: tw, data } = s;\n const y = search(data, H * tw, H, xi[0]!);\n const x = search(data, y * tw, W, xi[1]!);\n const a = ((2 * Math.PI) / W) * xi[2]!;\n const c0 = data[(H + 1) * tw + x]!;\n const s0 = data[(H + 2) * tw + x]!;\n const ca = Math.cos(a);\n const sa = Math.sin(a);\n const cphi = c0 * ca - s0 * sa;\n const sphi = s0 * ca + c0 * sa;\n const top = data[(H + 3) * tw + y]!;\n const bottom = data[(H + 3) * tw + y + 1]!;\n const my = bottom + (top - bottom) * xi[3]!;\n const r = Math.sqrt(Math.max(0, 1 - my * my));\n const m = [r * cphi, my, r * sphi];\n const R = map.rotation;\n // d = Rᵀ m (R is orthonormal: the lookup applies m = R d)\n const raw = R ? [R[0]! * m[0]! + R[3]! * m[1]! + R[6]! * m[2]!, R[1]! * m[0]! + R[4]! * m[1]! + R[7]! * m[2]!, R[2]! * m[0]! + R[5]! * m[1]! + R[8]! * m[2]!] : m;\n // unit length again (the f32 column edges are unit only to f32 rounding)\n const len = Math.hypot(raw[0]!, raw[1]!, raw[2]!);\n const dir: VDBRefVec3 = [raw[0]! / len, raw[1]! / len, raw[2]! / len];\n const k = (y * W + x) * 4;\n const scale = map.intensity ?? 1;\n return { dir, radiance: [map.data[k]! * scale, map.data[k + 1]! * scale, map.data[k + 2]! * scale], pdf: vdbRefEnvTexelPdf(s, x, y, mutate), texel: [x, y] };\n}\n\n/** The power heuristic's weight (β = 2) of a technique with density `p` against one with density `q`: p² / (p² + q²). */\nexport function vdbRefMisWeight(p: number, q: number): number {\n // as a ratio at most 1e15, so the GPU's f32 never overflows (a forward Mie peak, u → 0; a texel the map never picks)\n const r = q / Math.max(p, q * 1e-15, 1e-30);\n return 1 / (1 + r * r);\n}\n"]}
@@ -0,0 +1,12 @@
1
+ /**
2
+ * K6.R: the reference renderer's engine-free half (design K6-core-renderer.md §7.4): the scene description, the
3
+ * random stream it shares with the GPU kernel, the CPU twin (a brute-force volumetric path tracer), the media the
4
+ * twin reads and the analytic cases. Internal (`tools/internal.ts`); no public export.
5
+ */
6
+ export * from "./rng.js";
7
+ export * from "./scene.js";
8
+ export * from "./trace.js";
9
+ export * from "./media.js";
10
+ export * from "./analytic.js";
11
+ export * from "./tables.js";
12
+ export * from "./environment.js";
@@ -0,0 +1,13 @@
1
+ /**
2
+ * K6.R: the reference renderer's engine-free half (design K6-core-renderer.md §7.4): the scene description, the
3
+ * random stream it shares with the GPU kernel, the CPU twin (a brute-force volumetric path tracer), the media the
4
+ * twin reads and the analytic cases. Internal (`tools/internal.ts`); no public export.
5
+ */
6
+ export * from "./rng.js";
7
+ export * from "./scene.js";
8
+ export * from "./trace.js";
9
+ export * from "./media.js";
10
+ export * from "./analytic.js";
11
+ export * from "./tables.js";
12
+ export * from "./environment.js";
13
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/tools/reference/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,cAAc,UAAU,CAAC;AACzB,cAAc,YAAY,CAAC;AAC3B,cAAc,YAAY,CAAC;AAC3B,cAAc,YAAY,CAAC;AAC3B,cAAc,eAAe,CAAC;AAC9B,cAAc,aAAa,CAAC;AAC5B,cAAc,kBAAkB,CAAC","sourcesContent":["/**\n * K6.R: the reference renderer's engine-free half (design K6-core-renderer.md §7.4): the scene description, the\n * random stream it shares with the GPU kernel, the CPU twin (a brute-force volumetric path tracer), the media the\n * twin reads and the analytic cases. Internal (`tools/internal.ts`); no public export.\n */\nexport * from \"./rng.js\";\nexport * from \"./scene.js\";\nexport * from \"./trace.js\";\nexport * from \"./media.js\";\nexport * from \"./analytic.js\";\nexport * from \"./tables.js\";\nexport * from \"./environment.js\";\n"]}
@@ -0,0 +1,14 @@
1
+ /**
2
+ * K6.R: the CPU side of the reference renderer's volume sources ({@link VDBReferenceMediumCpu}): the dense `.wvdb`
3
+ * textures (twin of `vdbDenseSource`: hardware trilinear on the 8-bit texels, `sampleWvdbDenseTexture`), the sparse
4
+ * pool (twin of `vdbSparseSource` at level 0: `tools/frame/sparse.ts`) and a constant medium (analytic tests).
5
+ */
6
+ import { type VDBSparseVolumeCpu } from "../frame/sparse.js";
7
+ import { type WvdbDenseVolume } from "../wvdb/dense.js";
8
+ import type { VDBReferenceMediumCpu } from "./trace.js";
9
+ /** The dense source at level 0: density × mask, the albedo texture's rgb, the emission texture. */
10
+ export declare function vdbReferenceDenseMediumCpu(volume: WvdbDenseVolume): VDBReferenceMediumCpu;
11
+ /** The sparse source at level 0 (one volume of a `vdbSparseSource`, as its CPU twin describes it). */
12
+ export declare function vdbReferenceSparseMediumCpu(vol: VDBSparseVolumeCpu): VDBReferenceMediumCpu;
13
+ /** A constant medium (density `value`, emission channel `emission`), for the analytic tests. */
14
+ export declare function vdbReferenceConstantMediumCpu(value?: number, emission?: number): VDBReferenceMediumCpu;
@@ -0,0 +1,30 @@
1
+ /**
2
+ * K6.R: the CPU side of the reference renderer's volume sources ({@link VDBReferenceMediumCpu}): the dense `.wvdb`
3
+ * textures (twin of `vdbDenseSource`: hardware trilinear on the 8-bit texels, `sampleWvdbDenseTexture`), the sparse
4
+ * pool (twin of `vdbSparseSource` at level 0: `tools/frame/sparse.ts`) and a constant medium (analytic tests).
5
+ */
6
+ import { vdbSparseAlbedoCpu, vdbSparseDensityCpu, vdbSparseDensityStochasticCpu, vdbSparseEmissionCpu, vdbSparseMaskCpu } from "../frame/sparse.js";
7
+ import { sampleWvdbDenseTexture } from "../wvdb/dense.js";
8
+ /** The dense source at level 0: density × mask, the albedo texture's rgb, the emission texture. */
9
+ export function vdbReferenceDenseMediumCpu(volume) {
10
+ const { density, mask, albedo, emission } = volume;
11
+ return {
12
+ density: (uvw) => sampleWvdbDenseTexture(density, uvw, 0) * (mask ? sampleWvdbDenseTexture(mask, uvw, 0) : 1),
13
+ ...(albedo ? { albedo: (uvw) => [0, 1, 2].map((c) => sampleWvdbDenseTexture(albedo, uvw, 0, c)) } : {}),
14
+ ...(emission ? { emission: (uvw) => sampleWvdbDenseTexture(emission, uvw, 0) } : {}),
15
+ };
16
+ }
17
+ /** The sparse source at level 0 (one volume of a `vdbSparseSource`, as its CPU twin describes it). */
18
+ export function vdbReferenceSparseMediumCpu(vol) {
19
+ return {
20
+ density: (uvw) => vdbSparseDensityCpu(vol, uvw, 0).value * vdbSparseMaskCpu(vol, uvw).value,
21
+ densityStochastic: (uvw, xi) => vdbSparseDensityStochasticCpu(vol, uvw, 0, xi).value * vdbSparseMaskCpu(vol, uvw).value,
22
+ ...(vol.albedo ? { albedo: (uvw) => vdbSparseAlbedoCpu(vol, uvw).value } : {}),
23
+ ...(vol.emission ? { emission: (uvw) => vdbSparseEmissionCpu(vol, uvw).value } : {}),
24
+ };
25
+ }
26
+ /** A constant medium (density `value`, emission channel `emission`), for the analytic tests. */
27
+ export function vdbReferenceConstantMediumCpu(value = 1, emission) {
28
+ return { density: () => value, ...(emission !== undefined ? { emission: () => emission } : {}) };
29
+ }
30
+ //# sourceMappingURL=media.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"media.js","sourceRoot":"","sources":["../../../src/tools/reference/media.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,kBAAkB,EAAE,mBAAmB,EAAE,6BAA6B,EAAE,oBAAoB,EAAE,gBAAgB,EAA2B,MAAM,oBAAoB,CAAC;AAC7K,OAAO,EAAE,sBAAsB,EAAwB,MAAM,kBAAkB,CAAC;AAIhF,mGAAmG;AACnG,MAAM,UAAU,0BAA0B,CAAC,MAAuB;IAChE,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,QAA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AAM,EAAE,CAAC,GAAG,EAAE,EAAE,CAAC,kBAAkB,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QAC9E,GAAG,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC,CAAC,EAAE,QAAQ,EAAE,CAAC,GAAG,EAAE,EAAE,CAAC,oBAAoB,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;KACrF,CAAC;AACJ,CAAC;AAED,gGAAgG;AAChG,MAAM,UAAU,6BAA6B,CAAC,KAAK,GAAG,CAAC,EAAE,QAAiB;IACxE,OAAO,EAAE,OAAO,EAAE,GAAG,EAAE,CAAC,KAAK,EAAE,GAAG,CAAC,QAAQ,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,QAAQ,EAAE,GAAG,EAAE,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC;AACnG,CAAC","sourcesContent":["/**\n * K6.R: the CPU side of the reference renderer's volume sources ({@link VDBReferenceMediumCpu}): the dense `.wvdb`\n * textures (twin of `vdbDenseSource`: hardware trilinear on the 8-bit texels, `sampleWvdbDenseTexture`), the sparse\n * pool (twin of `vdbSparseSource` at level 0: `tools/frame/sparse.ts`) and a constant medium (analytic tests).\n */\n\nimport { vdbSparseAlbedoCpu, vdbSparseDensityCpu, vdbSparseDensityStochasticCpu, vdbSparseEmissionCpu, vdbSparseMaskCpu, type VDBSparseVolumeCpu } from \"../frame/sparse.js\";\nimport { sampleWvdbDenseTexture, type WvdbDenseVolume } from \"../wvdb/dense.js\";\nimport type { VDBRefVec3 } from \"./scene.js\";\nimport type { VDBReferenceMediumCpu } from \"./trace.js\";\n\n/** The dense source at level 0: density × mask, the albedo texture's rgb, the emission texture. */\nexport function vdbReferenceDenseMediumCpu(volume: WvdbDenseVolume): VDBReferenceMediumCpu {\n const { density, mask, albedo, emission } = volume;\n return {\n density: (uvw) => sampleWvdbDenseTexture(density, uvw, 0) * (mask ? sampleWvdbDenseTexture(mask, uvw, 0) : 1),\n ...(albedo ? { albedo: (uvw) => [0, 1, 2].map((c) => sampleWvdbDenseTexture(albedo, uvw, 0, c)) as VDBRefVec3 } : {}),\n ...(emission ? { emission: (uvw) => sampleWvdbDenseTexture(emission, uvw, 0) } : {}),\n };\n}\n\n/** The sparse source at level 0 (one volume of a `vdbSparseSource`, as its CPU twin describes it). */\nexport function vdbReferenceSparseMediumCpu(vol: VDBSparseVolumeCpu): VDBReferenceMediumCpu {\n return {\n density: (uvw) => vdbSparseDensityCpu(vol, uvw, 0).value * vdbSparseMaskCpu(vol, uvw).value,\n densityStochastic: (uvw, xi) => vdbSparseDensityStochasticCpu(vol, uvw, 0, xi).value * vdbSparseMaskCpu(vol, uvw).value,\n ...(vol.albedo ? { albedo: (uvw) => vdbSparseAlbedoCpu(vol, uvw).value } : {}),\n ...(vol.emission ? { emission: (uvw) => vdbSparseEmissionCpu(vol, uvw).value } : {}),\n };\n}\n\n/** A constant medium (density `value`, emission channel `emission`), for the analytic tests. */\nexport function vdbReferenceConstantMediumCpu(value = 1, emission?: number): VDBReferenceMediumCpu {\n return { density: () => value, ...(emission !== undefined ? { emission: () => emission } : {}) };\n}\n"]}
@@ -0,0 +1,20 @@
1
+ /**
2
+ * K6.R: the random numbers the reference renderer's GPU kernel and its CPU twin share. A 32-bit LCG with the
3
+ * PCG-RXS-M-XS output permutation (Jarzynski & Olano 2020, "Hash Functions for GPU Rendering", `pcg`), in u32
4
+ * arithmetic only, so the WGSL (`vdbRefRng*` in `core/reference/wgsl.ts`) and this file produce the same bits.
5
+ * Floats take the top 24 bits (`x >>> 8` × 2⁻²⁴): exact in f32, in [0, 1).
6
+ *
7
+ * Seeding: one stream per (seed, sample index, pixel): `state = pcg(pixel + pcg(seed ^ pcg(sampleIndex)))`.
8
+ */
9
+ /** The PCG hash of a u32 (`pcg` of Jarzynski & Olano 2020). */
10
+ export declare function vdbRefPcg(v: number): number;
11
+ /** A random stream; `next()` returns a float in [0, 1) with 24 random bits (exact in f32). */
12
+ export interface VDBRefRng {
13
+ /** The LCG state (u32). */
14
+ state: number;
15
+ /** Draws so far (for tests). */
16
+ draws: number;
17
+ next(): number;
18
+ }
19
+ /** The stream of pixel `pixel` (row-major index), sample `sampleIndex` (batch × spp + s) and `seed`. */
20
+ export declare function vdbRefRng(seed: number, sampleIndex: number, pixel: number): VDBRefRng;
@@ -0,0 +1,30 @@
1
+ /**
2
+ * K6.R: the random numbers the reference renderer's GPU kernel and its CPU twin share. A 32-bit LCG with the
3
+ * PCG-RXS-M-XS output permutation (Jarzynski & Olano 2020, "Hash Functions for GPU Rendering", `pcg`), in u32
4
+ * arithmetic only, so the WGSL (`vdbRefRng*` in `core/reference/wgsl.ts`) and this file produce the same bits.
5
+ * Floats take the top 24 bits (`x >>> 8` × 2⁻²⁴): exact in f32, in [0, 1).
6
+ *
7
+ * Seeding: one stream per (seed, sample index, pixel): `state = pcg(pixel + pcg(seed ^ pcg(sampleIndex)))`.
8
+ */
9
+ /** The PCG hash of a u32 (`pcg` of Jarzynski & Olano 2020). */
10
+ export function vdbRefPcg(v) {
11
+ const s = (Math.imul(v >>> 0, 747796405) + 2891336453) >>> 0;
12
+ const w = Math.imul(((s >>> ((s >>> 28) + 4)) ^ s) >>> 0, 277803737) >>> 0;
13
+ return ((w >>> 22) ^ w) >>> 0;
14
+ }
15
+ /** The stream of pixel `pixel` (row-major index), sample `sampleIndex` (batch × spp + s) and `seed`. */
16
+ export function vdbRefRng(seed, sampleIndex, pixel) {
17
+ const rng = {
18
+ state: vdbRefPcg((pixel + vdbRefPcg((seed ^ vdbRefPcg(sampleIndex >>> 0)) >>> 0)) >>> 0),
19
+ draws: 0,
20
+ next() {
21
+ this.state = (Math.imul(this.state, 747796405) + 2891336453) >>> 0;
22
+ const s = this.state;
23
+ const w = Math.imul(((s >>> ((s >>> 28) + 4)) ^ s) >>> 0, 277803737) >>> 0;
24
+ this.draws++;
25
+ return (((w >>> 22) ^ w) >>> 8) * 5.9604644775390625e-8;
26
+ },
27
+ };
28
+ return rng;
29
+ }
30
+ //# sourceMappingURL=rng.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"rng.js","sourceRoot":"","sources":["../../../src/tools/reference/rng.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,+DAA+D;AAC/D,MAAM,UAAU,SAAS,CAAC,CAAS;IACjC,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,KAAK,CAAC,EAAE,SAAS,CAAC,GAAG,UAAU,CAAC,KAAK,CAAC,CAAC;IAC7D,MAAM,CAAC,GAAG,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,KAAK,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,KAAK,CAAC,EAAE,SAAS,CAAC,KAAK,CAAC,CAAC;IAC3E,OAAO,CAAC,CAAC,CAAC,KAAK,EAAE,CAAC,GAAG,CAAC,CAAC,KAAK,CAAC,CAAC;AAChC,CAAC;AAWD,wGAAwG;AACxG,MAAM,UAAU,SAAS,CAAC,IAAY,EAAE,WAAmB,EAAE,KAAa;IACxE,MAAM,GAAG,GAAc;QACrB,KAAK,EAAE,SAAS,CAAC,CAAC,KAAK,GAAG,SAAS,CAAC,CAAC,IAAI,GAAG,SAAS,CAAC,WAAW,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC;QACxF,KAAK,EAAE,CAAC;QACR,IAAI;YACF,IAAI,CAAC,KAAK,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,EAAE,SAAS,CAAC,GAAG,UAAU,CAAC,KAAK,CAAC,CAAC;YACnE,MAAM,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC;YACrB,MAAM,CAAC,GAAG,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,KAAK,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,KAAK,CAAC,EAAE,SAAS,CAAC,KAAK,CAAC,CAAC;YAC3E,IAAI,CAAC,KAAK,EAAE,CAAC;YACb,OAAO,CAAC,CAAC,CAAC,CAAC,KAAK,EAAE,CAAC,GAAG,CAAC,CAAC,KAAK,CAAC,CAAC,GAAG,qBAAqB,CAAC;QAC1D,CAAC;KACF,CAAC;IACF,OAAO,GAAG,CAAC;AACb,CAAC","sourcesContent":["/**\n * K6.R: the random numbers the reference renderer's GPU kernel and its CPU twin share. A 32-bit LCG with the\n * PCG-RXS-M-XS output permutation (Jarzynski & Olano 2020, \"Hash Functions for GPU Rendering\", `pcg`), in u32\n * arithmetic only, so the WGSL (`vdbRefRng*` in `core/reference/wgsl.ts`) and this file produce the same bits.\n * Floats take the top 24 bits (`x >>> 8` × 2⁻²⁴): exact in f32, in [0, 1).\n *\n * Seeding: one stream per (seed, sample index, pixel): `state = pcg(pixel + pcg(seed ^ pcg(sampleIndex)))`.\n */\n\n/** The PCG hash of a u32 (`pcg` of Jarzynski & Olano 2020). */\nexport function vdbRefPcg(v: number): number {\n const s = (Math.imul(v >>> 0, 747796405) + 2891336453) >>> 0;\n const w = Math.imul(((s >>> ((s >>> 28) + 4)) ^ s) >>> 0, 277803737) >>> 0;\n return ((w >>> 22) ^ w) >>> 0;\n}\n\n/** A random stream; `next()` returns a float in [0, 1) with 24 random bits (exact in f32). */\nexport interface VDBRefRng {\n /** The LCG state (u32). */\n state: number;\n /** Draws so far (for tests). */\n draws: number;\n next(): number;\n}\n\n/** The stream of pixel `pixel` (row-major index), sample `sampleIndex` (batch × spp + s) and `seed`. */\nexport function vdbRefRng(seed: number, sampleIndex: number, pixel: number): VDBRefRng {\n const rng: VDBRefRng = {\n state: vdbRefPcg((pixel + vdbRefPcg((seed ^ vdbRefPcg(sampleIndex >>> 0)) >>> 0)) >>> 0),\n draws: 0,\n next() {\n this.state = (Math.imul(this.state, 747796405) + 2891336453) >>> 0;\n const s = this.state;\n const w = Math.imul(((s >>> ((s >>> 28) + 4)) ^ s) >>> 0, 277803737) >>> 0;\n this.draws++;\n return (((w >>> 22) ^ w) >>> 8) * 5.9604644775390625e-8;\n },\n };\n return rng;\n}\n"]}