@driftengine/core 4.4.2 → 4.6.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 (339) hide show
  1. package/CHANGELOG.json +97 -0
  2. package/README.md +1 -1
  3. package/dist/geometry/boxCsg.d.ts +28 -0
  4. package/dist/geometry/boxCsg.js +139 -0
  5. package/dist/geometry/csg.d.ts +36 -0
  6. package/dist/geometry/csg.js +329 -0
  7. package/dist/geometry/meshBuilder.js +13 -0
  8. package/dist/geometry/meshConcat.js +1 -0
  9. package/dist/geometry/pixelFont.js +2 -0
  10. package/dist/geometry/solid.d.ts +61 -0
  11. package/dist/geometry/solid.js +152 -0
  12. package/dist/geometry/solidFlat.d.ts +35 -0
  13. package/dist/geometry/solidFlat.js +428 -0
  14. package/dist/geometry/solidHarness.d.ts +19 -0
  15. package/dist/geometry/solidHarness.js +66 -0
  16. package/dist/geometry/solidNormals.d.ts +17 -0
  17. package/dist/geometry/solidNormals.js +86 -0
  18. package/dist/geometry/solidRound.d.ts +41 -0
  19. package/dist/geometry/solidRound.js +323 -0
  20. package/dist/geometry/solidWriter.d.ts +16 -0
  21. package/dist/geometry/solidWriter.js +42 -0
  22. package/dist/index.d.ts +28 -3
  23. package/dist/index.js +20 -1
  24. package/dist/render/backend/api.d.ts +34 -14
  25. package/dist/render/backend/drawFog.d.ts +26 -0
  26. package/dist/render/backend/drawFog.js +30 -0
  27. package/dist/render/backend/materialChanges.d.ts +2 -1
  28. package/dist/render/backend/materialChanges.js +6 -1
  29. package/dist/render/backend/webgl2/glassTintPrograms.d.ts +13 -0
  30. package/dist/render/backend/webgl2/glassTintPrograms.js +38 -0
  31. package/dist/render/backend/webgl2/instanced.d.ts +24 -5
  32. package/dist/render/backend/webgl2/instanced.js +72 -15
  33. package/dist/render/backend/webgl2/renderer.d.ts +201 -16
  34. package/dist/render/backend/webgl2/renderer.js +596 -224
  35. package/dist/render/backend/webgpu/buffers.d.ts +29 -1
  36. package/dist/render/backend/webgpu/buffers.js +61 -4
  37. package/dist/render/backend/webgpu/depthPass.d.ts +1 -1
  38. package/dist/render/backend/webgpu/depthPass.js +7 -2
  39. package/dist/render/backend/webgpu/drawCommand.d.ts +5 -0
  40. package/dist/render/backend/webgpu/drawCommand.js +1 -0
  41. package/dist/render/backend/webgpu/flatPass.d.ts +6 -1
  42. package/dist/render/backend/webgpu/flatPass.js +57 -9
  43. package/dist/render/backend/webgpu/glassTintPass.d.ts +28 -0
  44. package/dist/render/backend/webgpu/glassTintPass.js +206 -0
  45. package/dist/render/backend/webgpu/gpuDrivenPass.d.ts +60 -1
  46. package/dist/render/backend/webgpu/gpuDrivenPass.js +305 -5
  47. package/dist/render/backend/webgpu/instanceCullPass.d.ts +34 -0
  48. package/dist/render/backend/webgpu/instanceCullPass.js +144 -0
  49. package/dist/render/backend/webgpu/instanced.d.ts +23 -2
  50. package/dist/render/backend/webgpu/instanced.js +41 -4
  51. package/dist/render/backend/webgpu/latePass.d.ts +30 -0
  52. package/dist/render/backend/webgpu/latePass.js +140 -0
  53. package/dist/render/backend/webgpu/lightVolumePass.js +5 -1
  54. package/dist/render/backend/webgpu/motionPass.d.ts +95 -0
  55. package/dist/render/backend/webgpu/motionPass.js +491 -0
  56. package/dist/render/backend/webgpu/pipelineCache.d.ts +10 -1
  57. package/dist/render/backend/webgpu/pipelineCache.js +11 -1
  58. package/dist/render/backend/webgpu/pointGlassTintPass.d.ts +32 -0
  59. package/dist/render/backend/webgpu/pointGlassTintPass.js +193 -0
  60. package/dist/render/backend/webgpu/pointShadowPass.d.ts +35 -6
  61. package/dist/render/backend/webgpu/pointShadowPass.js +105 -20
  62. package/dist/render/backend/webgpu/postPass.d.ts +3 -13
  63. package/dist/render/backend/webgpu/renderer.d.ts +271 -64
  64. package/dist/render/backend/webgpu/renderer.js +1395 -580
  65. package/dist/render/backend/webgpu/scatterPass.js +2 -1
  66. package/dist/render/backend/webgpu/sdfTextPass.js +6 -1
  67. package/dist/render/backend/webgpu/shaders/instanceCull.wgsl.d.ts +18 -0
  68. package/dist/render/backend/webgpu/shaders/instanceCull.wgsl.js +59 -0
  69. package/dist/render/backend/webgpu/skinPaletteRing.d.ts +4 -0
  70. package/dist/render/backend/webgpu/skinPaletteRing.js +4 -0
  71. package/dist/render/backend/webgpu/snapshotMips.d.ts +29 -0
  72. package/dist/render/backend/webgpu/snapshotMips.js +52 -0
  73. package/dist/render/backend/webgpu/surfaceTexturePass.d.ts +22 -3
  74. package/dist/render/backend/webgpu/surfaceTexturePass.js +78 -39
  75. package/dist/render/driftLight/bake.d.ts +7 -0
  76. package/dist/render/driftLight/bake.js +61 -56
  77. package/dist/render/driftLight/denseField.d.ts +46 -0
  78. package/dist/render/driftLight/denseField.js +109 -0
  79. package/dist/render/driftLight/lightField.d.ts +10 -5
  80. package/dist/render/driftLight/lightField.js +25 -19
  81. package/dist/render/driftLight/presence.d.ts +50 -0
  82. package/dist/render/driftLight/presence.js +43 -0
  83. package/dist/render/driftLight/uniforms.d.ts +3 -3
  84. package/dist/render/driftLight/uniforms.js +5 -6
  85. package/dist/render/driftLight/worldLightField.d.ts +41 -0
  86. package/dist/render/driftLight/worldLightField.js +66 -0
  87. package/dist/render/fixtureAtlas.d.ts +20 -0
  88. package/dist/render/fixtureAtlas.js +49 -0
  89. package/dist/render/glass.d.ts +45 -0
  90. package/dist/render/glass.js +39 -0
  91. package/dist/render/glassCasters.d.ts +40 -0
  92. package/dist/render/glassCasters.js +84 -0
  93. package/dist/render/glassShadow.d.ts +78 -0
  94. package/dist/render/glassShadow.js +125 -0
  95. package/dist/render/globalMediumPass.d.ts +2 -3
  96. package/dist/render/globalMediumPass.js +2 -8
  97. package/dist/render/gpudriven/lit.d.ts +12 -0
  98. package/dist/render/gpudriven/lit.js +23 -0
  99. package/dist/render/gpudriven/materialTable.d.ts +15 -5
  100. package/dist/render/gpudriven/materialTable.js +26 -6
  101. package/dist/render/gpudriven/pipeline.d.ts +1 -1
  102. package/dist/render/gpudriven/pipeline.js +4 -3
  103. package/dist/render/gpudriven/sunGlass.d.ts +35 -0
  104. package/dist/render/gpudriven/sunGlass.js +89 -0
  105. package/dist/render/instanceCull.d.ts +63 -0
  106. package/dist/render/instanceCull.js +160 -0
  107. package/dist/render/instances.d.ts +15 -0
  108. package/dist/render/lightBudget.d.ts +36 -35
  109. package/dist/render/lightBudget.js +38 -37
  110. package/dist/render/lightGrid.d.ts +42 -0
  111. package/dist/render/lightGrid.js +87 -0
  112. package/dist/render/mesh.d.ts +18 -24
  113. package/dist/render/mesh.js +51 -68
  114. package/dist/render/occlusion.d.ts +10 -0
  115. package/dist/render/occlusion.js +36 -7
  116. package/dist/render/pointGlassTint.d.ts +59 -0
  117. package/dist/render/pointGlassTint.js +198 -0
  118. package/dist/render/pointLightSelection.d.ts +7 -0
  119. package/dist/render/pointLightSelection.js +29 -4
  120. package/dist/render/pointShadowArray.d.ts +56 -3
  121. package/dist/render/pointShadowArray.js +127 -16
  122. package/dist/render/pointShadowMap.d.ts +23 -1
  123. package/dist/render/pointShadowMap.js +27 -1
  124. package/dist/render/rainField.d.ts +13 -0
  125. package/dist/render/rainField.js +27 -5
  126. package/dist/render/recon/changeFrames.d.ts +15 -0
  127. package/dist/render/recon/changeFrames.js +21 -0
  128. package/dist/render/recon/lateDepth.d.ts +11 -0
  129. package/dist/render/recon/lateDepth.js +70 -0
  130. package/dist/render/recon/lateRouting.d.ts +14 -0
  131. package/dist/render/recon/lateRouting.js +18 -0
  132. package/dist/render/recon/mover.d.ts +57 -0
  133. package/dist/render/recon/mover.js +86 -0
  134. package/dist/render/recon/resolve.d.ts +34 -4
  135. package/dist/render/recon/resolve.js +161 -20
  136. package/dist/render/renderQuality.d.ts +35 -0
  137. package/dist/render/renderQuality.js +7 -0
  138. package/dist/render/rendererHarness.js +16 -0
  139. package/dist/render/sceneTarget.d.ts +9 -1
  140. package/dist/render/sceneTarget.js +60 -12
  141. package/dist/render/shaders/depth.d.ts +16 -1
  142. package/dist/render/shaders/depth.js +94 -15
  143. package/dist/render/shaders/flat/directionalShadow.js +91 -6
  144. package/dist/render/shaders/flat/driftLight.d.ts +1 -1
  145. package/dist/render/shaders/flat/driftLight.js +32 -7
  146. package/dist/render/shaders/flat/glassTint.d.ts +6 -0
  147. package/dist/render/shaders/flat/glassTint.js +25 -0
  148. package/dist/render/shaders/flat/index.d.ts +13 -0
  149. package/dist/render/shaders/flat/index.js +9 -3
  150. package/dist/render/shaders/flat/lampGlass.d.ts +1 -0
  151. package/dist/render/shaders/flat/lampGlass.js +183 -0
  152. package/dist/render/shaders/flat/main.d.ts +1 -1
  153. package/dist/render/shaders/flat/main.js +190 -38
  154. package/dist/render/shaders/flat/pointShadow.d.ts +1 -1
  155. package/dist/render/shaders/flat/pointShadow.js +2 -0
  156. package/dist/render/shaders/flat/preamble.js +96 -26
  157. package/dist/render/shaders/flat/surfaceEffects.d.ts +29 -0
  158. package/dist/render/shaders/flat/surfaceEffects.js +152 -0
  159. package/dist/render/shaders/generated/depth.wgsl.d.ts +230 -7
  160. package/dist/render/shaders/generated/depth.wgsl.js +230 -7
  161. package/dist/render/shaders/generated/flat.wgsl.d.ts +1644 -1596
  162. package/dist/render/shaders/generated/flat.wgsl.js +1683 -1621
  163. package/dist/render/shaders/generated/globalMedium.wgsl.d.ts +3 -13
  164. package/dist/render/shaders/generated/globalMedium.wgsl.js +3 -13
  165. package/dist/render/shaders/generated/lightVolume.wgsl.d.ts +3 -13
  166. package/dist/render/shaders/generated/lightVolume.wgsl.js +21 -17
  167. package/dist/render/shaders/generated/octahedralResolve.wgsl.d.ts +29 -0
  168. package/dist/render/shaders/generated/octahedralResolve.wgsl.js +29 -0
  169. package/dist/render/shaders/generated/rush.wgsl.d.ts +21 -16
  170. package/dist/render/shaders/generated/rush.wgsl.js +21 -16
  171. package/dist/render/shaders/generated/sdfText.wgsl.d.ts +2 -2
  172. package/dist/render/shaders/generated/sdfText.wgsl.js +2 -2
  173. package/dist/render/shaders/generated/text.wgsl.d.ts +1 -1
  174. package/dist/render/shaders/generated/text.wgsl.js +1 -1
  175. package/dist/render/shaders/gi/driftLight.wgsl.d.ts +1 -1
  176. package/dist/render/shaders/gi/driftLight.wgsl.js +27 -4
  177. package/dist/render/shaders/globalMedium.js +6 -6
  178. package/dist/render/shaders/gpudriven/blendRaster.wgsl.d.ts +7 -0
  179. package/dist/render/shaders/gpudriven/blendRaster.wgsl.js +86 -1
  180. package/dist/render/shaders/gpudriven/cull.wgsl.d.ts +1 -1
  181. package/dist/render/shaders/gpudriven/cull.wgsl.js +11 -2
  182. package/dist/render/shaders/gpudriven/materialTable.wgsl.d.ts +1 -1
  183. package/dist/render/shaders/gpudriven/materialTable.wgsl.js +3 -1
  184. package/dist/render/shaders/gpudriven/shade.wgsl.js +50 -1
  185. package/dist/render/shaders/gpudriven/sunGlass.wgsl.d.ts +9 -0
  186. package/dist/render/shaders/gpudriven/sunGlass.wgsl.js +133 -0
  187. package/dist/render/shaders/lightVolume.js +6 -6
  188. package/dist/render/shaders/octahedralResolve.d.ts +8 -0
  189. package/dist/render/shaders/octahedralResolve.js +48 -17
  190. package/dist/render/shaders/recon/lateDepth.wgsl.d.ts +1 -0
  191. package/dist/render/shaders/recon/lateDepth.wgsl.js +69 -0
  192. package/dist/render/shaders/recon/motion.wgsl.d.ts +1 -1
  193. package/dist/render/shaders/recon/motion.wgsl.js +84 -0
  194. package/dist/render/shaders/recon/resolve.wgsl.d.ts +8 -7
  195. package/dist/render/shaders/recon/resolve.wgsl.js +161 -27
  196. package/dist/render/shaders/rush.js +11 -1
  197. package/dist/render/shaders/sdfText.d.ts +1 -1
  198. package/dist/render/shaders/sdfText.js +3 -2
  199. package/dist/render/shaders/text.d.ts +1 -1
  200. package/dist/render/shaders/text.js +18 -9
  201. package/dist/render/shadowCasters.d.ts +20 -1
  202. package/dist/render/shadowCasters.js +15 -1
  203. package/dist/render/shadowMap.d.ts +54 -5
  204. package/dist/render/shadowMap.js +190 -36
  205. package/dist/render/sunGlassTint.d.ts +25 -0
  206. package/dist/render/sunGlassTint.js +79 -0
  207. package/dist/render/surfaceEffects.d.ts +83 -0
  208. package/dist/render/surfaceEffects.js +75 -0
  209. package/dist/render/surfaceScene.d.ts +8 -0
  210. package/dist/render/surfaceScene.js +8 -0
  211. package/dist/render/surfaceTexture.d.ts +18 -2
  212. package/dist/render/surfaceTexture.js +68 -15
  213. package/dist/render/temporalAa.d.ts +25 -6
  214. package/dist/render/temporalAa.js +45 -15
  215. package/dist/render/textureSource.d.ts +30 -0
  216. package/dist/render/textureSource.js +53 -0
  217. package/dist/render/translucentQueue.d.ts +6 -0
  218. package/dist/render/translucentQueue.js +15 -1
  219. package/dist/render/vertexDefaults.js +2 -0
  220. package/dist/world/hlod.d.ts +104 -0
  221. package/dist/world/hlod.js +214 -0
  222. package/package.json +6 -6
  223. package/src/geometry/boxCsg.ts +186 -0
  224. package/src/geometry/csg.ts +384 -0
  225. package/src/geometry/meshBuilder.ts +15 -0
  226. package/src/geometry/meshConcat.ts +1 -0
  227. package/src/geometry/pixelFont.ts +2 -0
  228. package/src/geometry/solid.ts +189 -0
  229. package/src/geometry/solidFlat.ts +522 -0
  230. package/src/geometry/solidHarness.ts +83 -0
  231. package/src/geometry/solidNormals.ts +103 -0
  232. package/src/geometry/solidRound.ts +443 -0
  233. package/src/geometry/solidWriter.ts +58 -0
  234. package/src/index.ts +61 -1
  235. package/src/render/backend/api.ts +36 -11
  236. package/src/render/backend/drawFog.ts +31 -0
  237. package/src/render/backend/materialChanges.ts +9 -2
  238. package/src/render/backend/webgl2/glassTintPrograms.ts +58 -0
  239. package/src/render/backend/webgl2/instanced.ts +80 -14
  240. package/src/render/backend/webgl2/renderer.ts +700 -250
  241. package/src/render/backend/webgpu/buffers.ts +92 -5
  242. package/src/render/backend/webgpu/depthPass.ts +7 -2
  243. package/src/render/backend/webgpu/drawCommand.ts +6 -0
  244. package/src/render/backend/webgpu/flatPass.ts +62 -11
  245. package/src/render/backend/webgpu/glassTintPass.ts +245 -0
  246. package/src/render/backend/webgpu/gpuDrivenPass.ts +349 -5
  247. package/src/render/backend/webgpu/instanceCullPass.ts +165 -0
  248. package/src/render/backend/webgpu/instanced.ts +42 -4
  249. package/src/render/backend/webgpu/latePass.ts +161 -0
  250. package/src/render/backend/webgpu/lightVolumePass.ts +5 -1
  251. package/src/render/backend/webgpu/motionPass.ts +535 -0
  252. package/src/render/backend/webgpu/pipelineCache.ts +12 -1
  253. package/src/render/backend/webgpu/pointGlassTintPass.ts +233 -0
  254. package/src/render/backend/webgpu/pointShadowPass.ts +158 -26
  255. package/src/render/backend/webgpu/renderer.ts +1671 -670
  256. package/src/render/backend/webgpu/scatterPass.ts +2 -1
  257. package/src/render/backend/webgpu/sdfTextPass.ts +6 -1
  258. package/src/render/backend/webgpu/shaders/instanceCull.wgsl.ts +61 -0
  259. package/src/render/backend/webgpu/skinPaletteRing.ts +4 -0
  260. package/src/render/backend/webgpu/snapshotMips.ts +80 -0
  261. package/src/render/backend/webgpu/surfaceTexturePass.ts +91 -51
  262. package/src/render/driftLight/bake.ts +85 -62
  263. package/src/render/driftLight/denseField.ts +149 -0
  264. package/src/render/driftLight/lightField.ts +33 -18
  265. package/src/render/driftLight/presence.ts +69 -0
  266. package/src/render/driftLight/uniforms.ts +8 -9
  267. package/src/render/driftLight/worldLightField.ts +83 -0
  268. package/src/render/fixtureAtlas.ts +63 -0
  269. package/src/render/glass.ts +74 -0
  270. package/src/render/glassCasters.ts +164 -0
  271. package/src/render/glassShadow.ts +153 -0
  272. package/src/render/globalMediumPass.ts +4 -11
  273. package/src/render/gpudriven/lit.ts +31 -0
  274. package/src/render/gpudriven/materialTable.ts +28 -6
  275. package/src/render/gpudriven/pipeline.ts +4 -3
  276. package/src/render/gpudriven/sunGlass.ts +117 -0
  277. package/src/render/instanceCull.ts +205 -0
  278. package/src/render/instances.ts +16 -0
  279. package/src/render/lightBudget.ts +41 -38
  280. package/src/render/lightGrid.ts +130 -0
  281. package/src/render/mesh.ts +59 -72
  282. package/src/render/occlusion.ts +51 -7
  283. package/src/render/pointGlassTint.ts +250 -0
  284. package/src/render/pointLightSelection.ts +72 -4
  285. package/src/render/pointShadowArray.ts +188 -22
  286. package/src/render/pointShadowMap.ts +41 -0
  287. package/src/render/rainField.ts +39 -5
  288. package/src/render/recon/changeFrames.ts +24 -0
  289. package/src/render/recon/lateDepth.ts +83 -0
  290. package/src/render/recon/lateRouting.ts +29 -0
  291. package/src/render/recon/mover.ts +118 -0
  292. package/src/render/recon/resolve.ts +206 -20
  293. package/src/render/renderQuality.ts +47 -0
  294. package/src/render/rendererHarness.ts +16 -0
  295. package/src/render/sceneTarget.ts +62 -11
  296. package/src/render/shaders/depth.ts +118 -15
  297. package/src/render/shaders/flat/directionalShadow.ts +97 -6
  298. package/src/render/shaders/flat/driftLight.ts +32 -7
  299. package/src/render/shaders/flat/glassTint.ts +25 -0
  300. package/src/render/shaders/flat/index.ts +22 -3
  301. package/src/render/shaders/flat/lampGlass.ts +185 -0
  302. package/src/render/shaders/flat/main.ts +190 -38
  303. package/src/render/shaders/flat/pointShadow.ts +2 -0
  304. package/src/render/shaders/flat/preamble.ts +96 -26
  305. package/src/render/shaders/flat/surfaceEffects.ts +152 -0
  306. package/src/render/shaders/generated/depth.wgsl.ts +237 -7
  307. package/src/render/shaders/generated/flat.wgsl.ts +1685 -1621
  308. package/src/render/shaders/generated/globalMedium.wgsl.ts +3 -13
  309. package/src/render/shaders/generated/lightVolume.wgsl.ts +23 -17
  310. package/src/render/shaders/generated/octahedralResolve.wgsl.ts +30 -0
  311. package/src/render/shaders/generated/rush.wgsl.ts +21 -16
  312. package/src/render/shaders/generated/sdfText.wgsl.ts +2 -2
  313. package/src/render/shaders/generated/text.wgsl.ts +1 -1
  314. package/src/render/shaders/gi/driftLight.wgsl.ts +27 -4
  315. package/src/render/shaders/globalMedium.ts +6 -6
  316. package/src/render/shaders/gpudriven/blendRaster.wgsl.ts +88 -1
  317. package/src/render/shaders/gpudriven/cull.wgsl.ts +11 -2
  318. package/src/render/shaders/gpudriven/materialTable.wgsl.ts +3 -1
  319. package/src/render/shaders/gpudriven/shade.wgsl.ts +50 -1
  320. package/src/render/shaders/gpudriven/sunGlass.wgsl.ts +139 -0
  321. package/src/render/shaders/lightVolume.ts +6 -6
  322. package/src/render/shaders/octahedralResolve.ts +50 -17
  323. package/src/render/shaders/recon/lateDepth.wgsl.ts +72 -0
  324. package/src/render/shaders/recon/motion.wgsl.ts +84 -0
  325. package/src/render/shaders/recon/resolve.wgsl.ts +161 -27
  326. package/src/render/shaders/rush.ts +11 -1
  327. package/src/render/shaders/sdfText.ts +3 -2
  328. package/src/render/shaders/text.ts +18 -9
  329. package/src/render/shadowCasters.ts +28 -1
  330. package/src/render/shadowMap.ts +231 -37
  331. package/src/render/sunGlassTint.ts +86 -0
  332. package/src/render/surfaceEffects.ts +132 -0
  333. package/src/render/surfaceScene.ts +16 -0
  334. package/src/render/surfaceTexture.ts +110 -19
  335. package/src/render/temporalAa.ts +78 -14
  336. package/src/render/textureSource.ts +72 -0
  337. package/src/render/translucentQueue.ts +20 -1
  338. package/src/render/vertexDefaults.ts +2 -0
  339. package/src/world/hlod.ts +290 -0
@@ -1,4 +1,6 @@
1
1
  import { FrameBudget } from '../budget.ts';
2
+ import type { Mover } from '../../recon/mover.ts';
3
+ import type { GlassOptions } from '../../glass.ts';
2
4
  import type { ReadonlyMat4 } from 'gl-matrix';
3
5
  import type { Camera } from '../../camera.ts';
4
6
  import type { PickHit, PickableSource } from '../../pickable.ts';
@@ -13,6 +15,9 @@ import { GpuTimer } from '../../gpuTimer.ts';
13
15
  import type { ColourGradeLut } from '../../colourGrade.ts';
14
16
  import { LightField } from '../../driftLight/lightField.ts';
15
17
  import type { LightFieldOptions, LightFieldSource } from '../../driftLight/lightField.ts';
18
+ import type { DenseLightVolume } from '../../driftLight/denseField.ts';
19
+ import { WorldLightField } from '../../driftLight/worldLightField.ts';
20
+ import type { WorldLightFieldOptions } from '../../driftLight/worldLightField.ts';
16
21
  /**
17
22
  * How far the rush's outermost tap reaches at full strength, in UV.
18
23
  *
@@ -69,7 +74,7 @@ import type { WindStreakOptions } from '../../windStreakRenderer.ts';
69
74
  import type { WindField } from '../../windField.ts';
70
75
  import type { FlockParams } from '../../flockRenderer.ts';
71
76
  import { InstancedBatch } from './instanced.ts';
72
- import type { MeshInstances } from '../../instances.ts';
77
+ import type { InstancedOptions, MeshInstances } from '../../instances.ts';
73
78
  /** Reused each frame: which shader light slot each bound cubemap serves. */
74
79
  export type { ShadowCasterSink, ShadowCasters } from '../../shadowCasters.ts';
75
80
  /** Lighting and atmosphere for a frame. The game decides what goes in it. */
@@ -106,6 +111,29 @@ export interface Environment extends Atmosphere {
106
111
  * how strongly.
107
112
  */
108
113
  nightFactor: number;
114
+ /**
115
+ * Seconds on the caller's clock, for the surfaces that animate — a sign's pulse, a ticker's
116
+ * scroll, a flipbook. The caller's rather than a clock read here, so a held clock holds every
117
+ * surface still and a replay replays them. 0 unless stated.
118
+ */
119
+ surfaceTime?: number;
120
+ /**
121
+ * How wet the world is, 0 to 1: upward surfaces darken and polish, except materials that say
122
+ * they stay dry. The scene-wide counterpart of `drawFilm`, which stays for a puddle. 0 unless
123
+ * stated.
124
+ */
125
+ wetness?: number;
126
+ /**
127
+ * The share of facade windows lit, 0 to 1, which a scene sets from its time of day. Windows switch
128
+ * on in steps by a per-window hash, so a rising share lights more windows rather than brightening
129
+ * the ones already lit. 0 unless stated.
130
+ */
131
+ litWindows?: number;
132
+ /**
133
+ * The share of windows that stay lit however late it gets, 0 to 1, so the small hours are not a
134
+ * dark city. 0 unless stated.
135
+ */
136
+ lateWindows?: number;
109
137
  /**
110
138
  * Emission that only shows where the dominant light does not reach, 0 and off by default.
111
139
  *
@@ -439,6 +467,31 @@ export interface LightVolumeDrawOptions {
439
467
  * boolean is refused everywhere else in this file.
440
468
  */
441
469
  export interface TranslucentMeshOptions {
470
+ /**
471
+ * Add this surface's light to what is behind it instead of covering it: a glow, a beam, a pool
472
+ * of light under a lamp. Its colour times its opacity is added and nothing is darkened, so black
473
+ * is invisible and overlapping glows brighten — which is why such surfaces are authored nearly
474
+ * black where they fade. **Order does not matter** to a sum, so an additive draw is never held
475
+ * for the order-independent pass; it is drawn where it is asked for. Write depth off with it
476
+ * (`depthWrite: false`) or a glow hides the glows behind it.
477
+ */
478
+ /**
479
+ * Drawn into the picture a reconstruction resolves, rather than after it. For a surface that
480
+ * moves with what it lies on — a glow on a wall, a pane in a window — whose one motion is that
481
+ * surface's, so the resolve can carry it with the surface.
482
+ *
483
+ * **Late is the default, and it is right for anything else.** A translucent surface writes no
484
+ * depth the motion pass could test and may move apart from what shows through it — a caption
485
+ * over a moving car — so a history can only smear it; after the upscale it is sharp and has none.
486
+ * **What late gives up** is the edge: drawn unjittered against a depth the jittered render
487
+ * covered, it meets a silhouette the render drew differently every frame, and a glow along an
488
+ * edge is let through on one frame and not the next. Reconstructed, it is resolved with the edge.
489
+ *
490
+ * Only a reconstructing frame draws anything late, so this changes nothing on WebGL2 or with
491
+ * `reconstruction` off. An order-independent blended set replays where it replays.
492
+ */
493
+ readonly reconstructed?: boolean;
494
+ readonly additive?: boolean;
442
495
  /**
443
496
  * `false` draws the mesh exactly its own vertex colour times its own texture, with no
444
497
  * ambient, sun, point lights, specular, reflectivity, grain or emissive touching it —
@@ -521,6 +574,13 @@ export interface TranslucentMeshOptions {
521
574
  * clear, and it is the whole difference between this and a flat tint.
522
575
  */
523
576
  readonly thicknessM?: number;
577
+ /**
578
+ * Glass: the pane shows what is behind it, by how much it lets through and how little it reflects
579
+ * at the view angle, blurred by how frosted it is, tinted, and glowing with the lights behind it.
580
+ * It keeps its own lighting and highlight, which `refraction` alone replaces. Absent, or letting
581
+ * nothing through, is not glass. See `glass.ts`; `refraction` still bends what a pane shows.
582
+ */
583
+ readonly glass?: GlassOptions;
524
584
  /**
525
585
  * Whether this draw writes depth. `true`, which is what it has always done, unless a caller
526
586
  * says otherwise.
@@ -819,6 +879,8 @@ export declare class WebGL2Renderer implements RendererApi {
819
879
  /** Whether a palette is currently chosen. Distinct from whether one was ever uploaded. */
820
880
  private skinPaletteSet;
821
881
  private readonly emptyTexture2D;
882
+ /** One glass resolution reused by every draw, so a pane allocates nothing. See `glass.ts`. */
883
+ private readonly glassScratch;
822
884
  /** DriftLight's stand-ins while no field is whole: no brick anywhere, and no light. */
823
885
  private readonly emptyDriftIndex;
824
886
  private readonly emptyDriftAtlas;
@@ -870,6 +932,11 @@ export declare class WebGL2Renderer implements RendererApi {
870
932
  private oitActive;
871
933
  /** True while the queue is being replayed, so a replayed draw does not record itself again. */
872
934
  private oitReplaying;
935
+ /** `uSurfaceScene`, resolved once a pass. See `surfaceScene.ts`. */
936
+ private readonly surfaceScene;
937
+ /** The two halves of `uWriteMode`, kept here because a `vec2` is written whole. */
938
+ private oitWeight;
939
+ private ditherFade;
873
940
  /** Said once, not per frame, where the context cannot give the float target the sum needs. */
874
941
  private oitRefused;
875
942
  /** Said once for the whole renderer. See `refuseOitMultisampled`. */
@@ -952,6 +1019,8 @@ export declare class WebGL2Renderer implements RendererApi {
952
1019
  private readonly taaDepthToViewZ;
953
1020
  private readonly aoInvProjection;
954
1021
  private readonly aoProjScale;
1022
+ /** Where this frame's jitter put the occlusion, in the composite's uv. See `uAoOffset`. */
1023
+ private readonly aoOffset;
955
1024
  /**
956
1025
  * Whether this frame has already been resolved to the canvas.
957
1026
  *
@@ -1008,9 +1077,8 @@ export declare class WebGL2Renderer implements RendererApi {
1008
1077
  private readonly depthInstancedCutoutUniforms;
1009
1078
  private readonly scatterDepthProgram;
1010
1079
  private readonly scatterDepthUniforms;
1011
- private readonly shadowMap;
1012
- private readonly peeledShadowMap;
1013
- private readonly dynamicShadowMap;
1080
+ /** The sun's static, moving and peeled maps, as layers of one array. See `shadowMap.ts`. */
1081
+ private readonly sunShadows;
1014
1082
  private readonly pointShadows;
1015
1083
  /**
1016
1084
  * The layers a world's casting rectangles hold, above the point pool in the same array.
@@ -1044,12 +1112,15 @@ export declare class WebGL2Renderer implements RendererApi {
1044
1112
  * world. See `prepareStaticPointShadows`.
1045
1113
  */
1046
1114
  private pointShadowArray;
1047
- /** The photometric atlas, allocated on first use. See `setIesProfiles`. */
1048
- private iesTexture;
1049
- /** Rows in that atlas. One until a consumer loads a profile, which is the row of ones. */
1115
+ /** The fixture atlas — cookies over profiles — allocated on first use. See `fixtureAtlas.ts`. */
1116
+ private fixtureTexture;
1117
+ /** The profiles as packed, kept so a new set of cookies can rebuild the atlas around them. */
1118
+ private iesAtlas;
1119
+ /** The cookie images, kept so a new set of profiles can rebuild the atlas around them. */
1120
+ private cookieImages;
1121
+ /** Rows of profile in the atlas. One until a consumer loads a profile, which is the row of ones. */
1050
1122
  private iesRows;
1051
- private cookieTexture;
1052
- /** Tiles in the cookie atlas. 0 is the white placeholder and the whole off path. */
1123
+ /** Cookie tiles in the atlas. 0 is none, and the whole off path. */
1053
1124
  private cookieTiles;
1054
1125
  /** Horizontal planes each profile occupies. 1 unless something asymmetric was loaded. */
1055
1126
  private iesPlanes;
@@ -1181,7 +1252,7 @@ export declare class WebGL2Renderer implements RendererApi {
1181
1252
  /** Non-zero while the drawing buffer is pinned; see `lockDrawingBuffer`. */
1182
1253
  private lockedWidth;
1183
1254
  private lockedHeight;
1184
- private activeShadowMap;
1255
+ private activeSunLayer;
1185
1256
  private reflectionPassActive;
1186
1257
  private reflectionReadyThisFrame;
1187
1258
  private reflectionAtmosphereY;
@@ -1203,7 +1274,7 @@ export declare class WebGL2Renderer implements RendererApi {
1203
1274
  *
1204
1275
  * **Not whether the map exists.** That was the test here, on the belief that a GL texture is
1205
1276
  * born reading as the far plane; it is born zeroed, and a scene that built the layer and never
1206
- * peeled it sampled an occluder at the light. `ShadowMap` now clears itself at birth, so an
1277
+ * peeled it sampled an occluder at the light. `SunShadowArray` clears itself at birth, so an
1207
1278
  * unfilled layer would read as lit either way — this is what keeps the two backends one
1208
1279
  * decision, and a frame that does not peel from paying a fetch per tap for nothing.
1209
1280
  */
@@ -1229,6 +1300,21 @@ export declare class WebGL2Renderer implements RendererApi {
1229
1300
  * Built once at construction, arrow properties closing over `this`: a sink created
1230
1301
  * per pass would allocate six objects per light per frame.
1231
1302
  */
1303
+ /** What the sun's light keeps through glass, made the first time glass casts: `sunGlassTint.ts`. */
1304
+ private sunGlassTint;
1305
+ /** The five programs a pane casts its colour through, compiled the first time glass casts. */
1306
+ private glassTintPrograms;
1307
+ /** True while the glass list is replayed into the glass depth layer through `casterSink`. */
1308
+ private drawingGlassDepth;
1309
+ /** How many times a shadow array grew its glass layers: once per family, and never again. */
1310
+ private sunGlassRebuilds;
1311
+ /** The light a tint pass is drawn for, and one pane's colour and clarity: uploaded per entry. */
1312
+ private readonly glassLight;
1313
+ private readonly glassPane;
1314
+ /** The glass the open shadow pass was offered, kept for its own passes: `glassCasters.ts`. */
1315
+ private readonly glassCasters;
1316
+ /** One resolution every glass caster is read through, so recording one allocates nothing. */
1317
+ private readonly glassCasterScratch;
1232
1318
  private readonly casterSink;
1233
1319
  /**
1234
1320
  * What a cutout depth draw needs beyond the plain one: the pass's matrix and peel, the material's
@@ -1236,6 +1322,13 @@ export declare class WebGL2Renderer implements RendererApi {
1236
1322
  */
1237
1323
  private bindCutoutDepth;
1238
1324
  private readonly drawPointShadowFace;
1325
+ /**
1326
+ * A lamp's glass, after each face's opaque depth: `PointShadowMap.bake` asks and binds, this
1327
+ * draws, through the same sinks the sun's glass takes and in the face's own matrix.
1328
+ */
1329
+ private readonly pointGlassDraw;
1330
+ /** The glass hook a bake is handed: none at all when glass shadows are off. */
1331
+ private get pointGlass();
1239
1332
  /**
1240
1333
  * Viewport in CSS pixels rather than device pixels.
1241
1334
  *
@@ -1326,6 +1419,11 @@ export declare class WebGL2Renderer implements RendererApi {
1326
1419
  * other half of the same question.
1327
1420
  */
1328
1421
  occluded(bounds: Bounds, model: ReadonlyMat4): boolean;
1422
+ /**
1423
+ * Whether a world-space box is wholly behind the declared occluders — the tighter question for
1424
+ * something that is a box, such as a region. False with no occlusion buffer. See `occluded`.
1425
+ */
1426
+ occludedBox(min: ArrayLike<number>, max: ArrayLike<number>): boolean;
1329
1427
  private readonly passes;
1330
1428
  /** Built once so invoking somebody else's pass allocates nothing. See `PassDefinition.draw`. */
1331
1429
  /**
@@ -1441,7 +1539,17 @@ export declare class WebGL2Renderer implements RendererApi {
1441
1539
  */
1442
1540
  setSpotCookies(images: readonly TexImageSource[]): void;
1443
1541
  setIesProfiles(profiles: readonly PhotometricProfile[]): void;
1444
- /** Bind the atlas and say how many rows it has. Always, for the reason `bindClusters` gives. */
1542
+ /**
1543
+ * The fixture atlas from the profiles and cookies in hand: the profiles' rows at the bottom, the
1544
+ * cookies' tiles on top, one `RGBA16F` texture. See `fixtureAtlas.ts` for the layout.
1545
+ *
1546
+ * **Half float, matching what the other backend must use**: a 32-bit float texture is not
1547
+ * filterable in core WebGPU, and both tables are curves and images that want linear filtering.
1548
+ * Linear and clamped: a profile is sampled between two angles, and a cookie's own inset is what
1549
+ * keeps a tile from its neighbour — clamping alone cannot, the seam being interior to the row.
1550
+ */
1551
+ private buildFixtureAtlas;
1552
+ /** Bind the fixture atlas and say what is in it. Always, for the reason `bindClusters` gives. */
1445
1553
  private bindIesAtlas;
1446
1554
  private bindClusters;
1447
1555
  /**
@@ -1601,6 +1709,13 @@ export declare class WebGL2Renderer implements RendererApi {
1601
1709
  * the consumer's decision. What it gains is a GPU object with sane sampler state.
1602
1710
  */
1603
1711
  createSurfaceTexture(source: TexImageSource, options?: SurfaceTextureOptions): SurfaceTexture;
1712
+ /**
1713
+ * Upload several images of one size as the layers of one array, for a merged mesh that names a
1714
+ * layer per vertex (`MeshData.layers`). One material binding then covers every image, which is
1715
+ * what makes a block wearing forty facades one draw. Every layer must be the same size, and the
1716
+ * refusal names the first that is not.
1717
+ */
1718
+ createSurfaceTextureArray(sources: readonly TexImageSource[], options?: SurfaceTextureOptions): SurfaceTexture;
1604
1719
  /**
1605
1720
  * Replace a surface texture's pixels, keeping the GPU object and its sampler state.
1606
1721
  *
@@ -1730,6 +1845,29 @@ export declare class WebGL2Renderer implements RendererApi {
1730
1845
  */
1731
1846
  setEnvironmentAmbient(_amount: number): void;
1732
1847
  setSurfaceGrain(amount: number): void;
1848
+ /**
1849
+ * One float of material state, into every flat program.
1850
+ *
1851
+ * **Every one, for `setMaterial`'s reason**: an instanced or skinned draw runs a program of its
1852
+ * own and is entitled to the material its caller set before it. These setters wrote the plain
1853
+ * program alone until 2026-09-30, so on this backend a batch drew with the pass defaults — grain
1854
+ * full, no reflection, no relief — while the other backend, whose material block every variant
1855
+ * reads, drew what was asked.
1856
+ */
1857
+ private writeFlatFloat;
1858
+ /**
1859
+ * How much of the surfaces drawn next survives a screen-door dither, for crossfading two levels
1860
+ * of detail of one thing.
1861
+ *
1862
+ * 0 is off and is what `bindMeshPass` restores. A positive amount keeps that share of the
1863
+ * pattern's cells, a negative one keeps the complement, so the level fading in drawn at `t` and
1864
+ * the one fading out at `-t` cover every pixel exactly once — no hole, no pixel drawn twice.
1865
+ * Material state like `setSurfaceGrain`; instanced draws read it too, and shadow casters, which
1866
+ * are a pass of their own, do not. See `uDither` in `flat/preamble.ts` for what it costs.
1867
+ */
1868
+ setDitherFade(amount: number): void;
1869
+ /** `uWriteMode`: the order-independent weight and the dither, which share one uniform row. */
1870
+ private writeMode;
1733
1871
  /**
1734
1872
  * How strong the microscopic relief on the surfaces drawn next is, and how coarse.
1735
1873
  *
@@ -1820,7 +1958,7 @@ export declare class WebGL2Renderer implements RendererApi {
1820
1958
  * One batch per mesh: the attributes bind to the mesh's own vertex array, of which a mesh has
1821
1959
  * one. `Mesh.attachInstances` is what refuses a second, and says why.
1822
1960
  */
1823
- createInstanced(mesh: Mesh, capacity: number): InstancedBatch;
1961
+ createInstanced(mesh: Mesh, capacity: number, options?: InstancedOptions): InstancedBatch;
1824
1962
  /** Push placement and colour. Only the live prefix. */
1825
1963
  uploadInstanced(batch: InstancedBatch, data: MeshInstances): void;
1826
1964
  /** Draw every live instance, opaque. */
@@ -1843,6 +1981,21 @@ export declare class WebGL2Renderer implements RendererApi {
1843
1981
  * consumer's, which is also where the placements are.
1844
1982
  */
1845
1983
  private submitInstanced;
1984
+ /**
1985
+ * Bind what a translucent draw shows through it: the frame's copy, refraction's bend and absorption,
1986
+ * and glass. Returns whether the copy is bound, and so whether `unbindSeeThrough` owes it back.
1987
+ *
1988
+ * **A glass draw takes the copy even when it does not bend**, since a pane shows what is behind it
1989
+ * either way, and asks for the copy's mip chain, which a frosted pane reads blurred. A null copy
1990
+ * leaves both off, so the pane shades as ordinary translucency rather than sampling black.
1991
+ *
1992
+ * **Refused inside a probe's face or a mirror**, as WebGPU's `takeRefractSnapshot` refuses: the
1993
+ * copy is of the frame drawn to the screen, so a pane there would show the wrong picture, and
1994
+ * taking it mid-bake is how a probe's next face came to be attached to the scene's framebuffer.
1995
+ */
1996
+ private bindSeeThrough;
1997
+ /** Put back what `bindSeeThrough` bound: the binding outlives its frame (the 2026-08-27 rule). */
1998
+ private unbindSeeThrough;
1846
1999
  disposeMesh(mesh: Mesh): void;
1847
2000
  /**
1848
2001
  * Release a resource this renderer created, for every kind that needs the context back.
@@ -2329,6 +2482,25 @@ export declare class WebGL2Renderer implements RendererApi {
2329
2482
  */
2330
2483
  drawSceneCasters(casters: ShadowCasters): void;
2331
2484
  drawShadowCasters(casters: ShadowCasters): void;
2485
+ /**
2486
+ * Draw the pass's glass twice: where the nearest pane is, and what the panes let through.
2487
+ *
2488
+ * After the opaque casters, in the pass's own light matrix. A layer that has held glass is
2489
+ * redrawn even when this pass offered none, so glass that has gone takes its colour with it. The
2490
+ * first glass grows the array (`SunShadowArray.growForGlass`) and makes the tint target.
2491
+ */
2492
+ private flushSunGlass;
2493
+ /** The glass list into the glass depth layer: `casterSink` itself, with glass let through. */
2494
+ private readonly glassDepthSink;
2495
+ /** One pane's tint uniforms, and its cutout where it has one. */
2496
+ private bindGlassTint;
2497
+ /**
2498
+ * The glass list into the tint layer, through the tint programs, **culling nothing**: a light
2499
+ * crosses a pane whichever way the pane faces, and a closed glass object has two surfaces on a
2500
+ * ray, so every one counts. What that asks of a model is that a pane be one surface — two-sided
2501
+ * glass says so with `doubleSided`, and a second copy of its triangles is a second pane.
2502
+ */
2503
+ private readonly glassTintSink;
2332
2504
  endShadowPass(): void;
2333
2505
  /**
2334
2506
  * The lit program, built at the largest light budget this device will actually link.
@@ -2586,6 +2758,10 @@ export declare class WebGL2Renderer implements RendererApi {
2586
2758
  *
2587
2759
  * What it gives up is one frame of history: the frame after a cut has no blur and no temporal
2588
2760
  * blend, as the first frame of a session has none. Nothing else is reset.
2761
+ *
2762
+ * **A reconstructing renderer depends on it**: its history is the last shot's, and without this
2763
+ * call a cut blends that shot into the first frames of the next. Nothing detects a cut on the
2764
+ * caller's behalf, deliberately — a fast pan and a cut look alike from here.
2589
2765
  */
2590
2766
  cameraCut(): void;
2591
2767
  /**
@@ -2981,6 +3157,14 @@ export declare class WebGL2Renderer implements RendererApi {
2981
3157
  * the volume is summed into the frame once every brick has landed.
2982
3158
  */
2983
3159
  createLightField(lights: readonly LightFieldSource[], options?: Omit<LightFieldOptions, 'falloff'>): LightField;
3160
+ /**
3161
+ * Hand a world's DriftLight volume to the renderer: every fixed light of a city, summed offline by
3162
+ * `bakeDenseField`, standing in past the frame's exact choice. Replaces any field made before, of
3163
+ * either kind; the scene calls `field.follow(buffer.complete, ...)` each frame as it would for
3164
+ * `createLightField`, and marks the lights the volume summed `inLightField` so none is counted
3165
+ * twice. See `driftLight/worldLightField.ts`.
3166
+ */
3167
+ createWorldLightField(volume: DenseLightVolume, options?: WorldLightFieldOptions): WorldLightField;
2984
3168
  /** Let go of the field and its volumes; the scene's lights are all exact again. */
2985
3169
  disposeLightField(): void;
2986
3170
  private forgetLightFieldVolumes;
@@ -3050,13 +3234,14 @@ export declare class WebGL2Renderer implements RendererApi {
3050
3234
  */
3051
3235
  tint?: Vec3 | null,
3052
3236
  /**
3053
- * Where the mesh was last frame, which this backend takes and ignores.
3237
+ * Where the mesh was last frame — a `Mover` or a matrix — which this backend takes and ignores.
3054
3238
  *
3055
3239
  * Accepted rather than absent so that one scene draws through both renderers unchanged — the
3056
3240
  * parity rule this repository is built on. Reconstruction is WebGPU's, having no compute stage
3057
- * here, so there is no motion target for this to be written into.
3241
+ * here, so there is no motion target for this to be written into, and a mover passed here is
3242
+ * neither read nor advanced.
3058
3243
  */
3059
- _previousModel?: ReadonlyMat4 | null): void;
3244
+ _previousModel?: ReadonlyMat4 | Mover | null): void;
3060
3245
  /**
3061
3246
  * Draw a mesh you can see through, in the same material as everything else by default.
3062
3247
  *