@driftengine/core 3.62.0 → 4.0.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 (428) hide show
  1. package/CHANGELOG.json +122 -0
  2. package/NOTICE +20 -0
  3. package/README.md +1 -1
  4. package/dist/core/loop.js +18 -2
  5. package/dist/core/storage.js +5 -0
  6. package/dist/geometry/meshBuilder.d.ts +1 -1
  7. package/dist/geometry/meshBuilder.js +6 -2
  8. package/dist/index.d.ts +70 -4
  9. package/dist/index.js +123 -2
  10. package/dist/input/input.js +6 -1
  11. package/dist/math/exact.d.ts +13 -3
  12. package/dist/math/exact.js +68 -3
  13. package/dist/math/frustum.d.ts +17 -2
  14. package/dist/math/frustum.js +24 -0
  15. package/dist/render/backend/api.d.ts +34 -1
  16. package/dist/render/backend/api.js +22 -1
  17. package/dist/render/backend/budget.d.ts +7 -6
  18. package/dist/render/backend/budget.js +7 -6
  19. package/dist/render/backend/createRenderer.d.ts +57 -0
  20. package/dist/render/backend/createRenderer.js +51 -2
  21. package/dist/render/backend/materialChanges.d.ts +41 -0
  22. package/dist/render/backend/materialChanges.js +38 -0
  23. package/dist/render/backend/select.js +8 -0
  24. package/dist/render/backend/webgl2/renderer.d.ts +80 -1
  25. package/dist/render/backend/webgl2/renderer.js +208 -10
  26. package/dist/render/backend/webgpu/buffers.d.ts +20 -1
  27. package/dist/render/backend/webgpu/buffers.js +116 -58
  28. package/dist/render/backend/webgpu/fieldCompose.d.ts +156 -0
  29. package/dist/render/backend/webgpu/fieldCompose.js +396 -0
  30. package/dist/render/backend/webgpu/giFieldPass.d.ts +66 -0
  31. package/dist/render/backend/webgpu/giFieldPass.js +137 -0
  32. package/dist/render/backend/webgpu/gpuDrivenPass.d.ts +728 -0
  33. package/dist/render/backend/webgpu/gpuDrivenPass.js +2473 -0
  34. package/dist/render/backend/webgpu/linePass.d.ts +4 -14
  35. package/dist/render/backend/webgpu/linePass.js +4 -33
  36. package/dist/render/backend/webgpu/probeBake.d.ts +148 -0
  37. package/dist/render/backend/webgpu/probeBake.js +493 -0
  38. package/dist/render/backend/webgpu/renderer.d.ts +379 -24
  39. package/dist/render/backend/webgpu/renderer.js +1369 -76
  40. package/dist/render/backend/webgpu/scatterPass.js +15 -1
  41. package/dist/render/backend/webgpu/surfaceTexturePass.d.ts +47 -14
  42. package/dist/render/backend/webgpu/surfaceTexturePass.js +128 -80
  43. package/dist/render/causticsRenderer.d.ts +3 -1
  44. package/dist/render/causticsRenderer.js +4 -1
  45. package/dist/render/depthConvention.d.ts +12 -0
  46. package/dist/render/depthConvention.js +14 -0
  47. package/dist/render/deviceFeatures.d.ts +32 -0
  48. package/dist/render/deviceFeatures.js +41 -0
  49. package/dist/render/fog.d.ts +79 -0
  50. package/dist/render/fog.js +138 -0
  51. package/dist/render/frame/alias.d.ts +30 -0
  52. package/dist/render/frame/alias.js +61 -0
  53. package/dist/render/frame/deps.d.ts +37 -0
  54. package/dist/render/frame/deps.js +122 -0
  55. package/dist/render/frame/flushGraph.d.ts +43 -0
  56. package/dist/render/frame/flushGraph.js +84 -0
  57. package/dist/render/frame/graphSchedule.d.ts +49 -0
  58. package/dist/render/frame/graphSchedule.js +120 -0
  59. package/dist/render/frame/index.d.ts +15 -0
  60. package/dist/render/frame/index.js +8 -0
  61. package/dist/render/frame/lifetime.d.ts +24 -0
  62. package/dist/render/frame/lifetime.js +36 -0
  63. package/dist/render/frame/passTimings.d.ts +42 -0
  64. package/dist/render/frame/passTimings.js +38 -0
  65. package/dist/render/frame/validate.d.ts +15 -0
  66. package/dist/render/frame/validate.js +22 -0
  67. package/dist/render/frame/virtual.d.ts +44 -0
  68. package/dist/render/frame/virtual.js +61 -0
  69. package/dist/render/gi/chain.d.ts +82 -0
  70. package/dist/render/gi/chain.js +135 -0
  71. package/dist/render/gi/denoise.d.ts +114 -0
  72. package/dist/render/gi/denoise.js +169 -0
  73. package/dist/render/gi/fieldScene.d.ts +125 -0
  74. package/dist/render/gi/fieldScene.js +219 -0
  75. package/dist/render/gi/globalField.d.ts +157 -0
  76. package/dist/render/gi/globalField.js +373 -0
  77. package/dist/render/gi/probeGridFit.d.ts +24 -0
  78. package/dist/render/gi/probeGridFit.js +71 -0
  79. package/dist/render/gi/probeTrace.d.ts +82 -0
  80. package/dist/render/gi/probeTrace.js +128 -0
  81. package/dist/render/gi/probeVolume.d.ts +136 -0
  82. package/dist/render/gi/probeVolume.js +191 -0
  83. package/dist/render/gi/reflection.d.ts +73 -0
  84. package/dist/render/gi/reflection.js +109 -0
  85. package/dist/render/gi/traceField.d.ts +91 -0
  86. package/dist/render/gi/traceField.js +129 -0
  87. package/dist/render/gi/traceScreen.d.ts +68 -0
  88. package/dist/render/gi/traceScreen.js +82 -0
  89. package/dist/render/gpuScene.d.ts +38 -0
  90. package/dist/render/gpuScene.js +41 -0
  91. package/dist/render/gpudriven/alphaTest.d.ts +28 -0
  92. package/dist/render/gpudriven/alphaTest.js +32 -0
  93. package/dist/render/gpudriven/clusterUpload.d.ts +59 -0
  94. package/dist/render/gpudriven/clusterUpload.js +75 -0
  95. package/dist/render/gpudriven/clusterWorld.d.ts +57 -0
  96. package/dist/render/gpudriven/clusterWorld.js +155 -0
  97. package/dist/render/gpudriven/compact.d.ts +51 -0
  98. package/dist/render/gpudriven/compact.js +68 -0
  99. package/dist/render/gpudriven/cullClusters.d.ts +129 -0
  100. package/dist/render/gpudriven/cullClusters.js +237 -0
  101. package/dist/render/gpudriven/decodeTables.d.ts +64 -0
  102. package/dist/render/gpudriven/decodeTables.js +219 -0
  103. package/dist/render/gpudriven/frustum.d.ts +25 -0
  104. package/dist/render/gpudriven/frustum.js +59 -0
  105. package/dist/render/gpudriven/geometryHarness.d.ts +15 -0
  106. package/dist/render/gpudriven/geometryHarness.js +31 -0
  107. package/dist/render/gpudriven/hzb.d.ts +60 -0
  108. package/dist/render/gpudriven/hzb.js +97 -0
  109. package/dist/render/gpudriven/ibl.d.ts +85 -0
  110. package/dist/render/gpudriven/ibl.js +129 -0
  111. package/dist/render/gpudriven/indirect.d.ts +67 -0
  112. package/dist/render/gpudriven/indirect.js +77 -0
  113. package/dist/render/gpudriven/instances.d.ts +43 -0
  114. package/dist/render/gpudriven/instances.js +172 -0
  115. package/dist/render/gpudriven/lit.d.ts +165 -0
  116. package/dist/render/gpudriven/lit.js +165 -0
  117. package/dist/render/gpudriven/lodCut.d.ts +28 -0
  118. package/dist/render/gpudriven/lodCut.js +38 -0
  119. package/dist/render/gpudriven/materialBin.d.ts +60 -0
  120. package/dist/render/gpudriven/materialBin.js +108 -0
  121. package/dist/render/gpudriven/materialTable.d.ts +88 -0
  122. package/dist/render/gpudriven/materialTable.js +115 -0
  123. package/dist/render/gpudriven/pipeline.d.ts +135 -0
  124. package/dist/render/gpudriven/pipeline.js +237 -0
  125. package/dist/render/gpudriven/rangeAlloc.d.ts +50 -0
  126. package/dist/render/gpudriven/rangeAlloc.js +112 -0
  127. package/dist/render/gpudriven/sceneUpload.d.ts +96 -0
  128. package/dist/render/gpudriven/sceneUpload.js +115 -0
  129. package/dist/render/gpudriven/shadeBins.d.ts +92 -0
  130. package/dist/render/gpudriven/shadeBins.js +182 -0
  131. package/dist/render/gpudriven/shadow.d.ts +136 -0
  132. package/dist/render/gpudriven/shadow.js +224 -0
  133. package/dist/render/gpudriven/shadowCamera.d.ts +87 -0
  134. package/dist/render/gpudriven/shadowCamera.js +345 -0
  135. package/dist/render/gpudriven/streamScene.d.ts +194 -0
  136. package/dist/render/gpudriven/streamScene.js +459 -0
  137. package/dist/render/gpudriven/surfaceFrame.d.ts +25 -0
  138. package/dist/render/gpudriven/surfaceFrame.js +51 -0
  139. package/dist/render/gpudriven/twoPhase.d.ts +122 -0
  140. package/dist/render/gpudriven/twoPhase.js +160 -0
  141. package/dist/render/gpudriven/visbuffer.d.ts +25 -0
  142. package/dist/render/gpudriven/visbuffer.js +37 -0
  143. package/dist/render/halfFloat.d.ts +10 -0
  144. package/dist/render/halfFloat.js +23 -4
  145. package/dist/render/inference/attentionTiled.d.ts +27 -0
  146. package/dist/render/inference/attentionTiled.js +117 -0
  147. package/dist/render/inference/denseKernels.d.ts +29 -0
  148. package/dist/render/inference/denseKernels.js +312 -0
  149. package/dist/render/inference/device.d.ts +21 -0
  150. package/dist/render/inference/device.js +32 -0
  151. package/dist/render/inference/deviceGraph.d.ts +34 -0
  152. package/dist/render/inference/deviceGraph.js +17 -0
  153. package/dist/render/inference/fuse.d.ts +15 -0
  154. package/dist/render/inference/fuse.js +37 -0
  155. package/dist/render/inference/kernelKit.d.ts +52 -0
  156. package/dist/render/inference/kernelKit.js +70 -0
  157. package/dist/render/inference/kernels.d.ts +3 -0
  158. package/dist/render/inference/kernels.js +11 -0
  159. package/dist/render/inference/plan.d.ts +13 -0
  160. package/dist/render/inference/plan.js +18 -0
  161. package/dist/render/inference/reuse.d.ts +39 -0
  162. package/dist/render/inference/reuse.js +65 -0
  163. package/dist/render/inference/runner.d.ts +31 -0
  164. package/dist/render/inference/runner.js +175 -0
  165. package/dist/render/inference/schedule.d.ts +39 -0
  166. package/dist/render/inference/schedule.js +59 -0
  167. package/dist/render/inference/shapeKernels.d.ts +10 -0
  168. package/dist/render/inference/shapeKernels.js +80 -0
  169. package/dist/render/inference/spatialKernels.d.ts +21 -0
  170. package/dist/render/inference/spatialKernels.js +179 -0
  171. package/dist/render/inference/splatRaster.wgsl.d.ts +75 -0
  172. package/dist/render/inference/splatRaster.wgsl.js +337 -0
  173. package/dist/render/inference/splatTiles.d.ts +79 -0
  174. package/dist/render/inference/splatTiles.js +161 -0
  175. package/dist/render/lineBatch.d.ts +2 -5
  176. package/dist/render/lineBatch.js +4 -24
  177. package/dist/render/mesh.d.ts +4 -0
  178. package/dist/render/mesh.js +45 -1
  179. package/dist/render/pass.d.ts +145 -8
  180. package/dist/render/prefilterEnvMap.d.ts +22 -0
  181. package/dist/render/prefilterEnvMap.js +31 -0
  182. package/dist/render/readback.d.ts +30 -0
  183. package/dist/render/readback.js +47 -0
  184. package/dist/render/recon/clamp.d.ts +36 -0
  185. package/dist/render/recon/clamp.js +92 -0
  186. package/dist/render/recon/disocclusion.d.ts +60 -0
  187. package/dist/render/recon/disocclusion.js +109 -0
  188. package/dist/render/recon/frameGen.d.ts +81 -0
  189. package/dist/render/recon/frameGen.js +150 -0
  190. package/dist/render/recon/frameSizes.d.ts +34 -0
  191. package/dist/render/recon/frameSizes.js +58 -0
  192. package/dist/render/recon/jitter.d.ts +60 -0
  193. package/dist/render/recon/jitter.js +118 -0
  194. package/dist/render/recon/motionVectors.d.ts +55 -0
  195. package/dist/render/recon/motionVectors.js +107 -0
  196. package/dist/render/recon/reproject.d.ts +41 -0
  197. package/dist/render/recon/reproject.js +131 -0
  198. package/dist/render/recon/resolve.d.ts +90 -0
  199. package/dist/render/recon/resolve.js +313 -0
  200. package/dist/render/recon/tier.d.ts +24 -0
  201. package/dist/render/recon/tier.js +8 -0
  202. package/dist/render/reflectionProbe.d.ts +26 -0
  203. package/dist/render/reflectionProbe.js +33 -0
  204. package/dist/render/renderQuality.d.ts +69 -0
  205. package/dist/render/renderQuality.js +22 -0
  206. package/dist/render/screenSpaceReflection.d.ts +23 -0
  207. package/dist/render/screenSpaceReflection.js +22 -3
  208. package/dist/render/sdfFont.js +2 -0
  209. package/dist/render/segmentQuads.d.ts +13 -0
  210. package/dist/render/segmentQuads.js +32 -0
  211. package/dist/render/shaders/flat/lobes.d.ts +27 -0
  212. package/dist/render/shaders/flat/lobes.js +33 -3
  213. package/dist/render/shaders/flat/preamble.d.ts +7 -0
  214. package/dist/render/shaders/flat/preamble.js +24 -1
  215. package/dist/render/shaders/flat/probeGrid.d.ts +1 -1
  216. package/dist/render/shaders/flat/probeGrid.js +71 -2
  217. package/dist/render/shaders/generated/flat.wgsl.d.ts +48 -8
  218. package/dist/render/shaders/generated/flat.wgsl.js +64 -24
  219. package/dist/render/shaders/gi/composeField.wgsl.d.ts +56 -0
  220. package/dist/render/shaders/gi/composeField.wgsl.js +231 -0
  221. package/dist/render/shaders/gi/marchField.wgsl.d.ts +30 -0
  222. package/dist/render/shaders/gi/marchField.wgsl.js +141 -0
  223. package/dist/render/shaders/gi/probeBake.wgsl.d.ts +113 -0
  224. package/dist/render/shaders/gi/probeBake.wgsl.js +635 -0
  225. package/dist/render/shaders/gi/probeTrace.wgsl.d.ts +72 -0
  226. package/dist/render/shaders/gi/probeTrace.wgsl.js +261 -0
  227. package/dist/render/shaders/gi/probeVolume.wgsl.d.ts +49 -0
  228. package/dist/render/shaders/gi/probeVolume.wgsl.js +242 -0
  229. package/dist/render/shaders/gi/sampleField.wgsl.d.ts +32 -0
  230. package/dist/render/shaders/gi/sampleField.wgsl.js +134 -0
  231. package/dist/render/shaders/gpudriven/blendRaster.wgsl.d.ts +26 -0
  232. package/dist/render/shaders/gpudriven/blendRaster.wgsl.js +339 -0
  233. package/dist/render/shaders/gpudriven/compact.wgsl.d.ts +29 -0
  234. package/dist/render/shaders/gpudriven/compact.wgsl.js +58 -0
  235. package/dist/render/shaders/gpudriven/cull.wgsl.d.ts +90 -0
  236. package/dist/render/shaders/gpudriven/cull.wgsl.js +423 -0
  237. package/dist/render/shaders/gpudriven/decode.wgsl.d.ts +72 -0
  238. package/dist/render/shaders/gpudriven/decode.wgsl.js +349 -0
  239. package/dist/render/shaders/gpudriven/environment.wgsl.d.ts +44 -0
  240. package/dist/render/shaders/gpudriven/environment.wgsl.js +137 -0
  241. package/dist/render/shaders/gpudriven/fog.wgsl.d.ts +28 -0
  242. package/dist/render/shaders/gpudriven/fog.wgsl.js +107 -0
  243. package/dist/render/shaders/gpudriven/frameBlock.wgsl.d.ts +13 -0
  244. package/dist/render/shaders/gpudriven/frameBlock.wgsl.js +62 -0
  245. package/dist/render/shaders/gpudriven/materialBin.wgsl.d.ts +51 -0
  246. package/dist/render/shaders/gpudriven/materialBin.wgsl.js +112 -0
  247. package/dist/render/shaders/gpudriven/materialTable.wgsl.d.ts +25 -0
  248. package/dist/render/shaders/gpudriven/materialTable.wgsl.js +43 -0
  249. package/dist/render/shaders/gpudriven/meshTransform.wgsl.d.ts +18 -0
  250. package/dist/render/shaders/gpudriven/meshTransform.wgsl.js +37 -0
  251. package/dist/render/shaders/gpudriven/present.wgsl.d.ts +43 -0
  252. package/dist/render/shaders/gpudriven/present.wgsl.js +127 -0
  253. package/dist/render/shaders/gpudriven/shade.wgsl.d.ts +127 -0
  254. package/dist/render/shaders/gpudriven/shade.wgsl.js +874 -0
  255. package/dist/render/shaders/gpudriven/shadow.wgsl.d.ts +44 -0
  256. package/dist/render/shaders/gpudriven/shadow.wgsl.js +308 -0
  257. package/dist/render/shaders/gpudriven/visbufferRaster.wgsl.d.ts +28 -0
  258. package/dist/render/shaders/gpudriven/visbufferRaster.wgsl.js +245 -0
  259. package/dist/render/shaders/network.wgsl.d.ts +101 -0
  260. package/dist/render/shaders/network.wgsl.js +206 -0
  261. package/dist/render/shaders/recon/motion.wgsl.d.ts +44 -0
  262. package/dist/render/shaders/recon/motion.wgsl.js +96 -0
  263. package/dist/render/shaders/recon/resolve.wgsl.d.ts +51 -0
  264. package/dist/render/shaders/recon/resolve.wgsl.js +733 -0
  265. package/dist/render/temporalAa.js +8 -33
  266. package/dist/render/textLayout.js +12 -6
  267. package/dist/render/textRenderer.d.ts +3 -1
  268. package/dist/render/textRenderer.js +4 -1
  269. package/dist/render/translucentQueue.d.ts +6 -0
  270. package/dist/render/translucentQueue.js +11 -0
  271. package/dist/render/windStreakRenderer.d.ts +2 -1
  272. package/dist/render/windStreakRenderer.js +3 -1
  273. package/dist/world/cell.d.ts +63 -0
  274. package/dist/world/cell.js +181 -0
  275. package/dist/world/cellStream.d.ts +103 -0
  276. package/dist/world/cellStream.js +198 -0
  277. package/dist/world/freeze.d.ts +81 -0
  278. package/dist/world/freeze.js +114 -0
  279. package/dist/world/rebase.d.ts +29 -0
  280. package/dist/world/rebase.js +41 -0
  281. package/package.json +8 -3
  282. package/scripts/frames.mjs +92 -0
  283. package/scripts/gpuCompute.mjs +323 -0
  284. package/scripts/png.d.mts +16 -0
  285. package/scripts/png.mjs +25 -0
  286. package/src/core/loop.ts +19 -2
  287. package/src/core/storage.ts +5 -0
  288. package/src/geometry/meshBuilder.ts +5 -1
  289. package/src/index.ts +261 -4
  290. package/src/input/input.ts +6 -1
  291. package/src/math/exact.ts +69 -3
  292. package/src/math/frustum.ts +52 -3
  293. package/src/render/backend/api.ts +42 -1
  294. package/src/render/backend/budget.ts +7 -6
  295. package/src/render/backend/createRenderer.ts +92 -3
  296. package/src/render/backend/materialChanges.ts +54 -0
  297. package/src/render/backend/select.ts +8 -0
  298. package/src/render/backend/webgl2/renderer.ts +211 -9
  299. package/src/render/backend/webgpu/buffers.ts +182 -69
  300. package/src/render/backend/webgpu/fieldCompose.ts +482 -0
  301. package/src/render/backend/webgpu/giFieldPass.ts +200 -0
  302. package/src/render/backend/webgpu/gpuDrivenPass.ts +2993 -0
  303. package/src/render/backend/webgpu/linePass.ts +4 -39
  304. package/src/render/backend/webgpu/probeBake.ts +588 -0
  305. package/src/render/backend/webgpu/renderer.ts +1481 -76
  306. package/src/render/backend/webgpu/scatterPass.ts +15 -1
  307. package/src/render/backend/webgpu/surfaceTexturePass.ts +158 -88
  308. package/src/render/causticsRenderer.ts +5 -2
  309. package/src/render/depthConvention.ts +15 -0
  310. package/src/render/deviceFeatures.ts +77 -0
  311. package/src/render/fog.ts +185 -0
  312. package/src/render/frame/alias.ts +97 -0
  313. package/src/render/frame/deps.ts +155 -0
  314. package/src/render/frame/flushGraph.ts +135 -0
  315. package/src/render/frame/graphSchedule.ts +170 -0
  316. package/src/render/frame/index.ts +52 -0
  317. package/src/render/frame/lifetime.ts +61 -0
  318. package/src/render/frame/passTimings.ts +69 -0
  319. package/src/render/frame/validate.ts +40 -0
  320. package/src/render/frame/virtual.ts +91 -0
  321. package/src/render/gi/chain.ts +225 -0
  322. package/src/render/gi/denoise.ts +276 -0
  323. package/src/render/gi/fieldScene.ts +264 -0
  324. package/src/render/gi/globalField.ts +543 -0
  325. package/src/render/gi/probeGridFit.ts +89 -0
  326. package/src/render/gi/probeTrace.ts +143 -0
  327. package/src/render/gi/probeVolume.ts +288 -0
  328. package/src/render/gi/reflection.ts +163 -0
  329. package/src/render/gi/traceField.ts +223 -0
  330. package/src/render/gi/traceScreen.ts +106 -0
  331. package/src/render/gpuScene.ts +80 -0
  332. package/src/render/gpudriven/alphaTest.ts +33 -0
  333. package/src/render/gpudriven/clusterUpload.ts +123 -0
  334. package/src/render/gpudriven/clusterWorld.ts +239 -0
  335. package/src/render/gpudriven/compact.ts +80 -0
  336. package/src/render/gpudriven/cullClusters.ts +333 -0
  337. package/src/render/gpudriven/decodeTables.ts +332 -0
  338. package/src/render/gpudriven/frustum.ts +70 -0
  339. package/src/render/gpudriven/geometryHarness.ts +51 -0
  340. package/src/render/gpudriven/hzb.ts +113 -0
  341. package/src/render/gpudriven/ibl.ts +147 -0
  342. package/src/render/gpudriven/indirect.ts +89 -0
  343. package/src/render/gpudriven/instances.ts +234 -0
  344. package/src/render/gpudriven/lit.ts +329 -0
  345. package/src/render/gpudriven/lodCut.ts +62 -0
  346. package/src/render/gpudriven/materialBin.ts +131 -0
  347. package/src/render/gpudriven/materialTable.ts +164 -0
  348. package/src/render/gpudriven/pipeline.ts +336 -0
  349. package/src/render/gpudriven/rangeAlloc.ts +122 -0
  350. package/src/render/gpudriven/sceneUpload.ts +173 -0
  351. package/src/render/gpudriven/shadeBins.ts +222 -0
  352. package/src/render/gpudriven/shadow.ts +285 -0
  353. package/src/render/gpudriven/shadowCamera.ts +406 -0
  354. package/src/render/gpudriven/streamScene.ts +575 -0
  355. package/src/render/gpudriven/surfaceFrame.ts +68 -0
  356. package/src/render/gpudriven/twoPhase.ts +214 -0
  357. package/src/render/gpudriven/visbuffer.ts +41 -0
  358. package/src/render/halfFloat.ts +22 -4
  359. package/src/render/inference/attentionTiled.ts +132 -0
  360. package/src/render/inference/denseKernels.ts +369 -0
  361. package/src/render/inference/device.ts +44 -0
  362. package/src/render/inference/deviceGraph.ts +39 -0
  363. package/src/render/inference/fuse.ts +47 -0
  364. package/src/render/inference/kernelKit.ts +120 -0
  365. package/src/render/inference/kernels.ts +18 -0
  366. package/src/render/inference/plan.ts +26 -0
  367. package/src/render/inference/reuse.ts +79 -0
  368. package/src/render/inference/runner.ts +204 -0
  369. package/src/render/inference/schedule.ts +80 -0
  370. package/src/render/inference/shapeKernels.ts +112 -0
  371. package/src/render/inference/spatialKernels.ts +220 -0
  372. package/src/render/inference/splatRaster.wgsl.ts +348 -0
  373. package/src/render/inference/splatTiles.ts +186 -0
  374. package/src/render/lineBatch.ts +4 -24
  375. package/src/render/mesh.ts +46 -1
  376. package/src/render/pass.ts +155 -10
  377. package/src/render/prefilterEnvMap.ts +33 -0
  378. package/src/render/readback.ts +73 -0
  379. package/src/render/recon/clamp.ts +113 -0
  380. package/src/render/recon/disocclusion.ts +143 -0
  381. package/src/render/recon/frameGen.ts +191 -0
  382. package/src/render/recon/frameSizes.ts +64 -0
  383. package/src/render/recon/jitter.ts +126 -0
  384. package/src/render/recon/motionVectors.ts +138 -0
  385. package/src/render/recon/reproject.ts +179 -0
  386. package/src/render/recon/resolve.ts +444 -0
  387. package/src/render/recon/tier.ts +31 -0
  388. package/src/render/reflectionProbe.ts +34 -0
  389. package/src/render/renderQuality.ts +87 -0
  390. package/src/render/screenSpaceReflection.ts +37 -3
  391. package/src/render/sdfFont.ts +2 -0
  392. package/src/render/segmentQuads.ts +39 -0
  393. package/src/render/shaders/flat/lobes.ts +35 -3
  394. package/src/render/shaders/flat/preamble.ts +25 -1
  395. package/src/render/shaders/flat/probeGrid.ts +77 -2
  396. package/src/render/shaders/generated/flat.wgsl.ts +64 -24
  397. package/src/render/shaders/gi/composeField.wgsl.ts +239 -0
  398. package/src/render/shaders/gi/marchField.wgsl.ts +146 -0
  399. package/src/render/shaders/gi/probeBake.wgsl.ts +649 -0
  400. package/src/render/shaders/gi/probeTrace.wgsl.ts +269 -0
  401. package/src/render/shaders/gi/probeVolume.wgsl.ts +246 -0
  402. package/src/render/shaders/gi/sampleField.wgsl.ts +140 -0
  403. package/src/render/shaders/gpudriven/blendRaster.wgsl.ts +343 -0
  404. package/src/render/shaders/gpudriven/compact.wgsl.ts +59 -0
  405. package/src/render/shaders/gpudriven/cull.wgsl.ts +433 -0
  406. package/src/render/shaders/gpudriven/decode.wgsl.ts +373 -0
  407. package/src/render/shaders/gpudriven/environment.wgsl.ts +141 -0
  408. package/src/render/shaders/gpudriven/fog.wgsl.ts +110 -0
  409. package/src/render/shaders/gpudriven/frameBlock.wgsl.ts +62 -0
  410. package/src/render/shaders/gpudriven/materialBin.wgsl.ts +116 -0
  411. package/src/render/shaders/gpudriven/materialTable.wgsl.ts +46 -0
  412. package/src/render/shaders/gpudriven/meshTransform.wgsl.ts +37 -0
  413. package/src/render/shaders/gpudriven/present.wgsl.ts +129 -0
  414. package/src/render/shaders/gpudriven/shade.wgsl.ts +884 -0
  415. package/src/render/shaders/gpudriven/shadow.wgsl.ts +322 -0
  416. package/src/render/shaders/gpudriven/visbufferRaster.wgsl.ts +251 -0
  417. package/src/render/shaders/network.wgsl.ts +238 -0
  418. package/src/render/shaders/recon/motion.wgsl.ts +101 -0
  419. package/src/render/shaders/recon/resolve.wgsl.ts +741 -0
  420. package/src/render/temporalAa.ts +9 -33
  421. package/src/render/textLayout.ts +12 -6
  422. package/src/render/textRenderer.ts +5 -2
  423. package/src/render/translucentQueue.ts +11 -0
  424. package/src/render/windStreakRenderer.ts +4 -2
  425. package/src/world/cell.ts +231 -0
  426. package/src/world/cellStream.ts +278 -0
  427. package/src/world/freeze.ts +157 -0
  428. package/src/world/rebase.ts +56 -0
@@ -46,6 +46,8 @@ import { type GpuFlock } from './flockPass.ts';
46
46
  import { type GpuBolts } from './boltPass.ts';
47
47
  import { type GpuLines } from './linePass.ts';
48
48
  import { FrameBudget } from '../budget.ts';
49
+ import type { ComposedField } from './fieldCompose.ts';
50
+ import type { FieldSource } from '../../gi/globalField.ts';
49
51
  import type { ReflectiveSurface } from '../../screenSpaceReflection.ts';
50
52
  import type { DecalProjector } from '../../decalProjector.ts';
51
53
  import type { Bounds } from '../../../math/bounds.ts';
@@ -55,25 +57,6 @@ import { GpuInstancedBatch } from './instanced.ts';
55
57
  import type { MeshInstances } from '../../instances.ts';
56
58
  /** Which directional shadow map a pass is filling, matching `renderer.ts`. */
57
59
  type ShadowLayer = 'static' | 'static-peel' | 'dynamic';
58
- /**
59
- * The WebGPU backend.
60
- *
61
- * **`RendererApi`, in full, with no `Partial` and no cast.** It implemented
62
- * `Partial<RendererApi>` for as long as its passes were being written, and the `Partial` was
63
- * the schedule: every member still missing was a row of work, and `createRenderer` needed a
64
- * cast to hand an incomplete backend back behind the complete surface.
65
- *
66
- * That is over. The derived type now does the job it exists for — add a method to `Renderer`
67
- * and this class stops compiling until it has one too, which is the compile-time form of the
68
- * failure the 2026-08-02 design spec named as the real risk: a fallback that rots because only
69
- * the developer's own backend is ever exercised.
70
- *
71
- * **Present is not the same as honoured, and the reverse is a trap of its own.** `setBloom`,
72
- * `setSpeedRush` and `setCameraMotionBlur` warned that the composite did not exist here, which
73
- * was true when they were written and stopped being true when it landed — so the backend spent
74
- * a while telling consumers that working effects did nothing. All three are read by
75
- * `composite()` now, and each has been compared against WebGL2 on `demo/dev/probe.html`.
76
- */
77
60
  export declare class WebGPURenderer implements RendererApi {
78
61
  /**
79
62
  * Real timestamp queries, where the adapter offers them.
@@ -217,8 +200,8 @@ export declare class WebGPURenderer implements RendererApi {
217
200
  private readonly perFrameStaging;
218
201
  private readonly perFrameFloats;
219
202
  private readonly perFrameInts;
220
- /** The slot the open material occupies, or -1 when the next draw must take a new one. */
221
- private materialSlot;
203
+ /** The slot the open material occupies, and whether the next draw must take a new one. */
204
+ private readonly materials;
222
205
  /**
223
206
  * What this frame asked for against the ceilings above, reported rather than only warned about.
224
207
  *
@@ -252,6 +235,7 @@ export declare class WebGPURenderer implements RendererApi {
252
235
  private readonly textBudget;
253
236
  private readonly sdfTextBudget;
254
237
  private readonly lineBudget;
238
+ private readonly panelBudget;
255
239
  /**
256
240
  * What the frame just drawn asked for, and what it was refused.
257
241
  *
@@ -270,6 +254,12 @@ export declare class WebGPURenderer implements RendererApi {
270
254
  * scatter, plumes and text reached it long before the draw ring was full.
271
255
  */
272
256
  private replayScratch;
257
+ /**
258
+ * The identifier graph's working set, where `quality.identifierGraph` asks for it and not
259
+ * otherwise: a renderer scheduling by masks carries none of it. Sized with the arena, and grown
260
+ * by `scheduleFlush` the way the arena grows.
261
+ */
262
+ private readonly flushSchedule;
273
263
  private readonly scheduledPasses;
274
264
  private readonly commands;
275
265
  /** Guards `ensurePass` against re-entering the flush that is already running. */
@@ -499,6 +489,26 @@ export declare class WebGPURenderer implements RendererApi {
499
489
  private bloomGroups;
500
490
  private frameWidth;
501
491
  private frameHeight;
492
+ /**
493
+ * What the scene is drawn at, which is the drawing buffer unless a reconstruction is enlarging it.
494
+ *
495
+ * **Everything before the resolve is this size and everything after it is the drawing buffer's.**
496
+ * The scene colour and its multisampled twin, the depth, the refraction snapshot, the resolved
497
+ * depth, the occlusion pair, the medium, the translucent buffers, the reflection march, the
498
+ * decals, the temporal history and the frame pass's own viewport are all before it; the composite
499
+ * and the overlay are after it, and they are what the viewer's pixels are counted in.
500
+ *
501
+ * **The composite is what enlarges the picture, and it does so by existing.** It draws a
502
+ * full-screen triangle into the swap chain sampling the scene by `uv` through a linear sampler, so
503
+ * a smaller scene target is magnified by that sample and nothing else changes — which is why this
504
+ * needs `screenEffects` and is refused without it: with no composite the world draws straight into
505
+ * the swap chain and there is nothing to enlarge from.
506
+ *
507
+ * Equal to the drawing buffer whenever `quality.reconstruction` is 0, which is the default, and
508
+ * `recon/frameSizes.ts` is the one place the two are related.
509
+ */
510
+ private renderWidth;
511
+ private renderHeight;
502
512
  /** The view-projection this frame was drawn with, for the reprojection motion blur needs. */
503
513
  private readonly previousViewProj;
504
514
  private readonly reprojection;
@@ -592,6 +602,94 @@ export declare class WebGPURenderer implements RendererApi {
592
602
  private temporalJitterX;
593
603
  private temporalJitterY;
594
604
  private temporalJittering;
605
+ /**
606
+ * Whether this frame is being reconstructed, settled once in `bindMeshPass`.
607
+ *
608
+ * It is not `quality.reconstruction > 0` on its own: a mirror pass is skipped for the same reason
609
+ * the temporal jitter skips one — a reflection is not the picture the history holds — and without
610
+ * a composite there is nothing to enlarge the render from.
611
+ */
612
+ private reconstructing;
613
+ /** Said once rather than every frame, as the translucent set's own refusal is. */
614
+ private reconMultisampleSaid;
615
+ private reconFrameIndex;
616
+ private readonly reconJitter;
617
+ private readonly reconPreviousJitter;
618
+ /**
619
+ * `reconJitter` as a fraction of the clip square, which is what a contributed pass is handed.
620
+ * See `PrepareContext.jitter`; zero on a frame that is not reconstructed.
621
+ */
622
+ private readonly passJitter;
623
+ /**
624
+ * The reconstruction's own targets, allocated only while a consumer asks for one.
625
+ *
626
+ * **Two histories rather than one**, for the reason the temporal resolve keeps two: a dispatch
627
+ * cannot read the texture it is writing. The shown picture is a third, because the history holds
628
+ * the *unsharpened* result — sharpening into the history would sharpen a sharpened picture every
629
+ * frame, which is the halo the reference's own clamp exists to prevent, compounded.
630
+ *
631
+ * The motion target is render size and carries a drawn object's own motion where something wrote
632
+ * one. **Nothing writes it yet**, so it is cleared every frame and every pixel takes the camera's
633
+ * motion, which the resolve derives from the depth and the reprojection. Static geometry is
634
+ * exact that way and a moving object ghosts until the motion pass lands.
635
+ */
636
+ private reconHistories;
637
+ private reconHistoryViews;
638
+ private reconWrite;
639
+ private reconHasHistory;
640
+ private reconShown;
641
+ private reconShownView;
642
+ private reconMotion;
643
+ private reconMotionView;
644
+ private reconPreviousDepth;
645
+ private reconPreviousDepthView;
646
+ private reconParams;
647
+ private readonly reconStaging;
648
+ private readonly reconFloats;
649
+ private readonly reconInts;
650
+ private reconLayout;
651
+ private reconResolvePipeline;
652
+ private reconSharpenPipeline;
653
+ private reconGroups;
654
+ private reconSharpenGroups;
655
+ private reconRushGroup;
656
+ /**
657
+ * What the motion pass will draw, recorded by `drawMesh` and spent once a frame.
658
+ *
659
+ * A parallel array of meshes and one flat matrix buffer rather than an array of objects, because
660
+ * this is written on the frame's hot path and the house rule about allocating there binds it: the
661
+ * matrices are copied into a buffer that only ever grows, and the count is what resets.
662
+ */
663
+ private readonly motionMeshes;
664
+ private motionMatrices;
665
+ private motionCount;
666
+ private motionLayout;
667
+ /**
668
+ * One pipeline per vertex stride, because a stride is a property of the *mesh*.
669
+ *
670
+ * Which optional attributes a mesh supplied decides how far apart its positions are, and this
671
+ * pass reads nothing but positions — so two meshes drawn by the same shader still need two
672
+ * vertex layouts. A map rather than a cache key on the pipeline cache: there is one shader here
673
+ * and a handful of strides in any scene.
674
+ */
675
+ private readonly motionPipelines;
676
+ private motionModule;
677
+ private motionPipelineLayout;
678
+ private motionFrameBuffer;
679
+ private motionDrawBuffer;
680
+ private motionDrawCapacity;
681
+ private motionGroup;
682
+ private readonly motionFrameStaging;
683
+ private motionDrawStaging;
684
+ /** The scene's own clip transform with the generated shaders' y negation folded in. */
685
+ private readonly motionRaster;
686
+ private reconSizeKey;
687
+ /** Last frame's raw view-projection and its inverse, and the two eyes. */
688
+ private readonly reconPreviousRawViewProj;
689
+ private readonly reconInverseViewProj;
690
+ private readonly reconPreviousInverseViewProj;
691
+ private readonly reconEye;
692
+ private readonly reconPreviousEye;
595
693
  private temporalHistoryUsable;
596
694
  private readonly aoStaging;
597
695
  private readonly aoFloats;
@@ -628,6 +726,20 @@ export declare class WebGPURenderer implements RendererApi {
628
726
  private readonly postDepthSampler;
629
727
  /** Whether the profile asked for a composite at all. Everything below is null when it did not. */
630
728
  private get hasComposite();
729
+ /**
730
+ * Whether this renderer is set up to reconstruct, asked in one place by everything that cares.
731
+ *
732
+ * **One condition and not three**, which §3 row 132 is the lesson of: the frame's flag, the size
733
+ * the targets are built at and the size the world is drawn at all turn on the same question, and
734
+ * three copies of it are three lines no test can fail — each covering the others, so breaking any
735
+ * one of them changes nothing anybody can see.
736
+ *
737
+ * A composite, because the composite is what enlarges the render; one sample, because the motion
738
+ * pass draws against the depth the scene left and every attachment in a pass must agree about its
739
+ * sample count — `RECONSTRUCTION_MULTISAMPLE_REFUSAL` says the rest. Whether a *frame* is
740
+ * reconstructed adds one more question, the mirror's, and that one belongs to the frame.
741
+ */
742
+ private get reconstructionWanted();
631
743
  /** What a frame pass writes into: the scene target where there is one, the swap chain else. */
632
744
  /**
633
745
  * This frame's swap-chain view, taken on first use rather than at `beginFrame`.
@@ -715,6 +827,31 @@ export declare class WebGPURenderer implements RendererApi {
715
827
  * the frame has drawn, so it cannot run until the opaque world is finished. See `DecalQueue`.
716
828
  */
717
829
  private readonly decalQueue;
830
+ /** The fields this frame declared, composed at `endFrame`. See `addDistanceField`. */
831
+ private readonly distanceFields;
832
+ /**
833
+ * The composition of them, built at the first frame that has both the flag and a field.
834
+ *
835
+ * **Not at construction**, because it is 1.4 MB of device buffers and a compute pipeline, and a
836
+ * profile with `indirectLight` on is entitled to declare no fields at all — a scene that lights
837
+ * itself entirely from a baked probe grid, for one. Nothing is allocated until something would
838
+ * be composed.
839
+ */
840
+ private fieldComposer;
841
+ /**
842
+ * The probes' own bake, built at the first frame that has the flag, a field and an array.
843
+ *
844
+ * Not at construction, for `fieldComposer`'s reason: it is two compute pipelines, a render
845
+ * pipeline and a handful of buffers, and a profile with the flag on may never declare a field.
846
+ */
847
+ private probeBaker;
848
+ /** Which array the baker's views were built against, so a replacement is noticed. */
849
+ private bakerArray;
850
+ /** Reused, because deriving a grid from the declared fields runs in the frame path. */
851
+ private readonly fieldBoundsMin;
852
+ private readonly fieldBoundsMax;
853
+ /** Said once rather than every frame, as the other refusals are. */
854
+ private indirectGridRefused;
718
855
  private decalLayout;
719
856
  private decalUniforms;
720
857
  private readonly decalStaging;
@@ -750,7 +887,10 @@ export declare class WebGPURenderer implements RendererApi {
750
887
  private readonly decalScissorRect;
751
888
  private oitResolveLayout;
752
889
  private oitResolveGroup;
753
- /** Reused, because the frame loop may not allocate. Mirrors the WebGL2 backend's own. */
890
+ /**
891
+ * Reused, because the frame loop may not allocate. Mirrors the WebGL2 backend's own, which it
892
+ * had stopped doing: the other one carried a pane's refraction and this one did not.
893
+ */
754
894
  private readonly oitReplayOptions;
755
895
  private reflectionPassActive;
756
896
  /** Said once: a mirror asked for outside a frame is a call-order fault, not a device limit. */
@@ -874,8 +1014,23 @@ export declare class WebGPURenderer implements RendererApi {
874
1014
  /** Repeats across the mesh's own UV range. Per draw, because `uUvScale` is a vertex uniform. */
875
1015
  private readonly uvScale;
876
1016
  createSurfaceTexture(source: TexImageSource, options?: SurfaceTextureOptions): GpuSurfaceTexture;
1017
+ /**
1018
+ * GPU textures an `updateSurfaceTexture` replaced, destroyed when the next frame begins.
1019
+ *
1020
+ * Not at once, because a draw recorded earlier in the frame the update landed in may still read
1021
+ * one, and a destroyed texture in a submit loses the whole command buffer. Every encoder a frame
1022
+ * opens is submitted by the time the next one begins.
1023
+ */
1024
+ private readonly retiredTextures;
877
1025
  updateSurfaceTexture(texture: GpuSurfaceTexture, source: TexImageSource): void;
878
1026
  disposeSurfaceTexture(texture: GpuSurfaceTexture): void;
1027
+ /**
1028
+ * Drop every bind group that may hold `texture`'s view, and rebuild the ones bound now.
1029
+ *
1030
+ * For a texture going away and for one whose view has been replaced, which are the same problem:
1031
+ * a group holding the old view hands a destroyed texture to the next draw that asks.
1032
+ */
1033
+ private forgetBindingsOf;
879
1034
  /**
880
1035
  * Choose the surface texture the following `drawMesh` calls sample, or null for none.
881
1036
  *
@@ -965,6 +1120,8 @@ export declare class WebGPURenderer implements RendererApi {
965
1120
  * that order, which is the shape of failure the 2026-08-13 rule is about.
966
1121
  */
967
1122
  fillPanel(rect: InsetRect, color: Vec3, alpha: number): void;
1123
+ /** Said once rather than every frame, for the reason `warnedFull` gives. */
1124
+ private warnedPanelsFull;
968
1125
  /** A 3D text object. See `textPass.ts`; the layout it holds is shared with WebGL2. */
969
1126
  createText(): GpuText;
970
1127
  setText(text: GpuText, content: string): void;
@@ -1560,6 +1717,32 @@ export declare class WebGPURenderer implements RendererApi {
1560
1717
  get aspect(): number;
1561
1718
  /** The canvas being drawn into, for a consumer that needs to measure or place against it. */
1562
1719
  get canvas(): HTMLCanvasElement;
1720
+ /**
1721
+ * The size the world is drawn at this frame, which is **not** the canvas when a reconstruction
1722
+ * is enlarging it.
1723
+ *
1724
+ * **A contributed pass that fills a target of its own must size it from here.** The GPU-driven
1725
+ * rig sized its own targets from `canvas.width` and drew a full drawing-buffer picture into a
1726
+ * scene target two thirds as wide: the frame pass clipped it to the top-left corner and the
1727
+ * composite magnified that corner back over the screen, which is a plausible-looking picture of
1728
+ * the wrong part of the world. The device raises nothing — a viewport smaller than the thing
1729
+ * drawn is legal — so there is no failure to see, only a scene that has moved.
1730
+ *
1731
+ * Valid from `beginFrame`; before the first frame it is the canvas, which is what a pass sizing
1732
+ * itself at registration wants.
1733
+ */
1734
+ get sceneWidth(): number;
1735
+ get sceneHeight(): number;
1736
+ /**
1737
+ * The render size this frame will use, computed rather than remembered.
1738
+ *
1739
+ * **Computed, because a pass asks before the frame it is asking about.** `GpuDrivenPass.resize`
1740
+ * runs before `beginFrame` — that is when `prepare` records the pipeline — so a stored field
1741
+ * would answer with the previous frame's size, which is right every frame but the one where it
1742
+ * changed. The first frame after a reconstruction is switched on is exactly the frame that
1743
+ * matters.
1744
+ */
1745
+ private sceneSize;
1563
1746
  /**
1564
1747
  * Whether the device has gone.
1565
1748
  *
@@ -1763,7 +1946,9 @@ export declare class WebGPURenderer implements RendererApi {
1763
1946
  * surfaces should win got the answer on WebGL2 and a per-pixel coin toss here — with nothing
1764
1947
  * failing and nothing in the parity ledger saying so.
1765
1948
  */
1766
- drawMesh(mesh: GpuMesh, model: ArrayLike<number>, depthLayer?: number, tint?: Vec3 | null): void;
1949
+ drawMesh(mesh: GpuMesh, model: ArrayLike<number>, depthLayer?: number, tint?: Vec3 | null,
1950
+ /** Where it was last frame. See `RendererApi.drawMesh`, and `runMotion` for what reads it. */
1951
+ previousModel?: ArrayLike<number> | null): void;
1767
1952
  /**
1768
1953
  * Draw a mesh that lets the world through, at `opacity`.
1769
1954
  *
@@ -2165,6 +2350,64 @@ export declare class WebGPURenderer implements RendererApi {
2165
2350
  */
2166
2351
  private postField;
2167
2352
  /** Sample zero of the depth, into something the generated shaders can sample. */
2353
+ /**
2354
+ * Allocate what a reconstruction needs, and release it when nobody is asking.
2355
+ *
2356
+ * Sized by a key rather than by comparing four numbers, because three of the six targets are the
2357
+ * output's size and three are the render's, and a comparison that checked one pair would rebuild
2358
+ * half of them on a resize and keep the other half at the old size — which the device accepts,
2359
+ * a bind group holding views of two different sizes being perfectly legal, and which draws a
2360
+ * picture with a piece of it at the wrong scale.
2361
+ */
2362
+ private ensureReconstruction;
2363
+ /**
2364
+ * The two dispatches, over one explicit layout.
2365
+ *
2366
+ * **Explicit and not `layout: 'auto'`**, which §3 row 51 is about: an inferred layout names only
2367
+ * the bindings its own entry point reads, and these two read different subsets of one module —
2368
+ * the sharpen touches nothing but the history and the target. Two inferred layouts cannot share
2369
+ * a bind group, and building two groups over the same resources is two things to keep in step.
2370
+ */
2371
+ private buildReconPipelines;
2372
+ /**
2373
+ * The four groups, one a direction of the ping-pong and one a dispatch.
2374
+ *
2375
+ * The resolve reads history `1 - write` and writes history `write`; the sharpen reads history
2376
+ * `write` and writes the shown picture. A group holds the views it was built with, so this is
2377
+ * called whenever any of them is replaced.
2378
+ */
2379
+ private rebuildReconGroups;
2380
+ /**
2381
+ * Remember that this mesh moved, so the motion pass can draw where it was.
2382
+ *
2383
+ * Silent unless a reconstruction is running: a scene that always states its previous transforms
2384
+ * — which is the right thing for a scene to do, the alternative being to know what the renderer
2385
+ * is configured as — must cost nothing at all when nobody is going to read them.
2386
+ */
2387
+ private recordMotion;
2388
+ /**
2389
+ * The pipeline the motion pass draws with, built once.
2390
+ *
2391
+ * **The position buffer alone**, because that is all the shader reads and a mesh keeps one buffer
2392
+ * an attribute — so this binds buffer zero and nothing else, whatever else the mesh carries.
2393
+ */
2394
+ private buildMotionPipeline;
2395
+ /** The pipeline for one vertex stride, built on first sight of it. */
2396
+ private motionPipelineFor;
2397
+ /**
2398
+ * Where every mover was last frame, into the motion target.
2399
+ *
2400
+ * **After everything that draws and before the resolve reads it.** The frame's depth has to be
2401
+ * finished for the equality test to mean anything, and the resolve is what consumes the result.
2402
+ */
2403
+ private runMotion;
2404
+ /**
2405
+ * DriftTR tier 0: the jittered render at the render size into the picture at the output size.
2406
+ *
2407
+ * `recon/resolve.ts` is the reference this is held to and `scripts/recon-parity.mjs` compares the
2408
+ * two; nothing here decides anything the reference does not.
2409
+ */
2410
+ private runReconstruction;
2168
2411
  private resolveDepth;
2169
2412
  /**
2170
2413
  * Occlusion from the depth the resolve produced, then a blur across it.
@@ -2543,6 +2786,81 @@ export declare class WebGPURenderer implements RendererApi {
2543
2786
  * visible, which is a hole in the world. `OcclusionBuffer` carries the rest of the reasoning.
2544
2787
  */
2545
2788
  addOccluder(min: ArrayLike<number>, max: ArrayLike<number>, model: ReadonlyMat4): void;
2789
+ /**
2790
+ * Declare a baked distance field that indirect light may be traced against.
2791
+ *
2792
+ * **The seam is `addOccluder`'s, and for `addOccluder`'s reason.** A distance field is the shape
2793
+ * of a thing it is safe to be *traced against*, and only a consumer knows which of its objects
2794
+ * that is true of — the walls and the terrain, not the leaves, not the water, not the thing it
2795
+ * is about to delete. A renderer that derived the field from whatever was drawn would trace
2796
+ * against the foliage and light the room with a hedge.
2797
+ *
2798
+ * **Declared anywhere in the frame and composed at its end**, which is the one window where
2799
+ * every declaration is in and the encoder has no render pass open. Cleared at `beginFrame` with
2800
+ * the decal and reflection queues, so a consumer redeclares every frame and a field it stops
2801
+ * declaring stops lighting.
2802
+ *
2803
+ * The field is in the model matrix's own space and the matrix must carry uniform scale only —
2804
+ * `composeGlobalField` gives the reason: a distance is not preserved by a non-uniform scale, and
2805
+ * the factor to correct by depends on the direction to the nearest surface, which is exactly
2806
+ * what a distance field does not record.
2807
+ *
2808
+ * **`albedo` is what colour this placement's surface is, and it decides what the bounce carries.**
2809
+ * What leaves a surface is the light arriving times its albedo, so a ray that lands on a wall
2810
+ * and does not know its colour returns the same answer for a red wall and a white one — measured
2811
+ * on `demo/dev/bounce.html` before this argument existed. It is a placement's rather than a
2812
+ * field's, because the same baked shape is placed many times and two pillars cut from one mould
2813
+ * may be painted differently. White where it is left out, so every existing caller is unchanged.
2814
+ */
2815
+ addDistanceField(field: FieldSource, model: ReadonlyMat4, albedo?: ArrayLike<number>): void;
2816
+ /** Forget the fields declared this frame, for a consumer that rebuilds its list mid-frame. */
2817
+ clearDistanceFields(): void;
2818
+ /**
2819
+ * Compose what the frame declared, or nothing at all.
2820
+ *
2821
+ * **Nothing at all is the ordinary case and must cost nothing.** `quality.indirectLight` is off
2822
+ * by default and a frame that declared no fields has nothing to compose, so both are answered
2823
+ * before the composer exists — which is what keeps the eighteen scenes byte-identical with the
2824
+ * flag off rather than merely close.
2825
+ */
2826
+ private runIndirectLight;
2827
+ private composeDistanceField;
2828
+ /** The world field this frame composed, or null where none was. For a pass that marches it. */
2829
+ get distanceField(): ComposedField | null;
2830
+ /**
2831
+ * Refresh this frame's share of the probe grid from the world field, or do nothing at all.
2832
+ *
2833
+ * **Doing nothing is the ordinary case and must cost nothing**, which is why every condition is
2834
+ * answered before the baker exists: a frame may have composed no field — including a frame that
2835
+ * declared none after a frame that did, where the composer exists and holds nothing — and a
2836
+ * profile may have asked for no probe array. With either false this returns having allocated
2837
+ * nothing and recorded nothing, which is what keeps the scenes byte-identical.
2838
+ *
2839
+ * **The grid is the declared one, or one fitted to the fields themselves.** A consumer that
2840
+ * placed its probes always wins. One that did not gets a grid around whatever it said its light
2841
+ * may be traced against — which is the right extent rather than a convenient one, because a grid
2842
+ * sized to everything drawn would spend its probes on the inside of the sky.
2843
+ */
2844
+ private bakeIndirectProbes;
2845
+ /** The declared grid, or one fitted to this frame's fields, or null where neither is possible. */
2846
+ private indirectGrid;
2847
+ /**
2848
+ * The device milliseconds the last composed field took, or null where nothing measured it.
2849
+ *
2850
+ * One frame behind, because a timestamp is read back and a readback that blocked would be the
2851
+ * measurement changing what it measures. Null also where no field has ever been composed, and
2852
+ * where the device was not asked for `timestamp-query`.
2853
+ */
2854
+ get distanceFieldMs(): number | null;
2855
+ /**
2856
+ * The device milliseconds the last traced probe refresh took, or null where nothing measured it.
2857
+ *
2858
+ * **A refresh rather than a grid**, which is `PROBES_PER_FRAME` probes and is what a frame
2859
+ * actually pays. One frame behind, for the reason `distanceFieldMs` gives.
2860
+ */
2861
+ get indirectBakeMs(): number | null;
2862
+ /** Ask for the last frame's figures, once the frame that recorded them has been submitted. */
2863
+ readDistanceFieldTimings(): void;
2546
2864
  /**
2547
2865
  * Whether a mesh is entirely behind the occluders declared this frame.
2548
2866
  *
@@ -2592,6 +2910,28 @@ export declare class WebGPURenderer implements RendererApi {
2592
2910
  private preparingPasses;
2593
2911
  /** Mutated in place, because `beginFrame` is a per-frame path. See `PassDefinition.prepare`. */
2594
2912
  private readonly prepareContext;
2913
+ /**
2914
+ * The object handed to a pass as `PrepareContext.environment`, rebuilt only when it changes.
2915
+ *
2916
+ * **Mutated in place for the reason the context above is**: this runs once a frame for every
2917
+ * registered pass, and the house rule about per-frame allocation binds the seam as much as the
2918
+ * verbs. The view is the only field that can change identity, and it changes when the grid's
2919
+ * layer count does.
2920
+ */
2921
+ private readonly passEnvironment;
2922
+ /**
2923
+ * The frame's reconstruction jitter: one step of the sequence a frame, taken before any pass
2924
+ * prepares.
2925
+ *
2926
+ * **Here and not in `bindMeshPass`, for two reasons that were both defects.** A registered pass
2927
+ * prepares at `beginFrame`, before any mesh pass is bound, so a jitter chosen there could not
2928
+ * reach it — and the GPU-driven pipeline draws its whole world in `prepare`, unjittered, into a
2929
+ * resolve that un-jitters everything. And a frame that bound its mesh pass twice took two steps
2930
+ * of the sequence and resolved against the second.
2931
+ *
2932
+ * The sizes are the frame's by now: `ensureReconstruction` has run.
2933
+ */
2934
+ private settleReconJitter;
2595
2935
  /**
2596
2936
  * Give every pass that owns a target its chance to fill it, before the frame's own opens.
2597
2937
  *
@@ -2929,7 +3269,22 @@ export declare class WebGPURenderer implements RendererApi {
2929
3269
  private get probeMaxLod();
2930
3270
  /** Whether every layer of the grid has been convolved. See `probeFilled`. */
2931
3271
  private get probeBaked();
2932
- /** Record that one layer now holds a convolution, without counting a rebake twice. */
3272
+ /**
3273
+ * Record that one layer now holds a convolution, without counting a rebake twice.
3274
+ *
3275
+ * **And rebuild the flat groups on the last one**, which is the third time this backend has paid
3276
+ * for a bind group holding whatever texture existed when it was built. `flatTextures` resolves
3277
+ * `uEnvironment` to a one-texel **white** stand-in while `probeBaked` is false, so a grid filled
3278
+ * by the trace rather than by `bakeProbeGrid` — which runs before any frame and therefore before
3279
+ * any group — leaves every flat group holding that white for the life of the renderer. The
3280
+ * uniform beside it flips to "use the grid" and the grid the shader reads is pure white.
3281
+ *
3282
+ * Measured on `demo/dev/bounce.html?seed=0`: every surface came back at exactly its own albedo
3283
+ * times 255, with the sun switched off and the trace pinned to a constant. It had been recorded
3284
+ * as undefined memory in the probe array; it is a deliberate white texture, read on purpose.
3285
+ * The refraction snapshot's own note two hundred lines below says the same thing about the same
3286
+ * mistake, and `setProbeGrid` says it about the array being replaced.
3287
+ */
2933
3288
  private markProbeFilled;
2934
3289
  /**
2935
3290
  * The array every probe is a layer of, sized for a grid.