@drawcall/lod 0.1.2 → 0.3.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 (358) hide show
  1. package/README.md +13 -70
  2. package/dist/at.d.ts +2 -0
  3. package/dist/at.js +8 -0
  4. package/dist/at.js.map +1 -0
  5. package/dist/bake.d.ts +22 -0
  6. package/dist/bake.js +88 -0
  7. package/dist/bake.js.map +1 -0
  8. package/dist/baked/codec.d.ts +5 -5
  9. package/dist/baked/codec.js +58 -158
  10. package/dist/baked/codec.js.map +1 -1
  11. package/dist/baked/coverage.d.ts +6 -3
  12. package/dist/baked/coverage.js +6 -3
  13. package/dist/baked/coverage.js.map +1 -1
  14. package/dist/baked/fields.d.ts +9 -0
  15. package/dist/baked/fields.js +22 -0
  16. package/dist/baked/fields.js.map +1 -0
  17. package/dist/baked/index.d.ts +16 -6
  18. package/dist/baked/index.js +23 -21
  19. package/dist/baked/index.js.map +1 -1
  20. package/dist/baked/interior/faces.d.ts +4 -3
  21. package/dist/baked/interior/faces.js +13 -10
  22. package/dist/baked/interior/faces.js.map +1 -1
  23. package/dist/baked/interior/material.d.ts +7 -10
  24. package/dist/baked/interior/material.js +29 -36
  25. package/dist/baked/interior/material.js.map +1 -1
  26. package/dist/baked/interior/rooms.js +1 -1
  27. package/dist/baked/interior/rooms.js.map +1 -1
  28. package/dist/baked/low.d.ts +2 -2
  29. package/dist/baked/low.js +9 -8
  30. package/dist/baked/low.js.map +1 -1
  31. package/dist/baked/raster.js +6 -6
  32. package/dist/baked/raster.js.map +1 -1
  33. package/dist/baked/textures.d.ts +17 -0
  34. package/dist/baked/textures.js +95 -0
  35. package/dist/baked/textures.js.map +1 -0
  36. package/dist/baked/transfer.js +19 -18
  37. package/dist/baked/transfer.js.map +1 -1
  38. package/dist/baked/unwrap.js +4 -3
  39. package/dist/baked/unwrap.js.map +1 -1
  40. package/dist/baked/xatlas.js.map +1 -1
  41. package/dist/codec/container.d.ts +8 -0
  42. package/dist/codec/container.js +63 -0
  43. package/dist/codec/container.js.map +1 -0
  44. package/dist/codec/mesh.d.ts +8 -0
  45. package/dist/codec/mesh.js +220 -0
  46. package/dist/codec/mesh.js.map +1 -0
  47. package/dist/dispose.d.ts +11 -4
  48. package/dist/dispose.js +39 -12
  49. package/dist/dispose.js.map +1 -1
  50. package/dist/gpu.d.ts +39 -0
  51. package/dist/gpu.js +41 -0
  52. package/dist/gpu.js.map +1 -0
  53. package/dist/impostor/bake/atlas.d.ts +4 -4
  54. package/dist/impostor/bake/atlas.js +12 -12
  55. package/dist/impostor/bake/atlas.js.map +1 -1
  56. package/dist/impostor/bake/fit.d.ts +8 -0
  57. package/dist/impostor/bake/fit.js +28 -0
  58. package/dist/impostor/bake/fit.js.map +1 -0
  59. package/dist/impostor/bake/index.d.ts +23 -14
  60. package/dist/impostor/bake/index.js +42 -134
  61. package/dist/impostor/bake/index.js.map +1 -1
  62. package/dist/impostor/bake/materials.d.ts +3 -3
  63. package/dist/impostor/bake/materials.js +60 -12
  64. package/dist/impostor/bake/materials.js.map +1 -1
  65. package/dist/impostor/bake/sheet.d.ts +8 -0
  66. package/dist/impostor/bake/sheet.js +90 -0
  67. package/dist/impostor/bake/sheet.js.map +1 -0
  68. package/dist/impostor/bake/source.d.ts +2 -2
  69. package/dist/impostor/bake/source.js +8 -19
  70. package/dist/impostor/bake/source.js.map +1 -1
  71. package/dist/impostor/codec.d.ts +5 -11
  72. package/dist/impostor/codec.js +37 -121
  73. package/dist/impostor/codec.js.map +1 -1
  74. package/dist/impostor/impostor.d.ts +31 -7
  75. package/dist/impostor/impostor.js +21 -6
  76. package/dist/impostor/impostor.js.map +1 -1
  77. package/dist/impostor/ktx2/encode.d.ts +26 -0
  78. package/dist/impostor/ktx2/encode.js +117 -0
  79. package/dist/impostor/ktx2/encode.js.map +1 -0
  80. package/dist/impostor/ktx2/transcode.d.ts +3 -0
  81. package/dist/impostor/ktx2/transcode.js +99 -0
  82. package/dist/impostor/ktx2/transcode.js.map +1 -0
  83. package/dist/impostor/ktx2/uastc.d.ts +7 -0
  84. package/dist/impostor/ktx2/uastc.js +64 -0
  85. package/dist/impostor/ktx2/uastc.js.map +1 -0
  86. package/dist/impostor/ktx2/wasm/encoder.d.ts +4 -0
  87. package/dist/impostor/ktx2/wasm/encoder.js +10 -0
  88. package/dist/impostor/ktx2/wasm/encoder.js.map +1 -0
  89. package/dist/impostor/ktx2/wasm/transcoder.d.ts +3 -0
  90. package/dist/impostor/ktx2/wasm/transcoder.js +9 -0
  91. package/dist/impostor/ktx2/wasm/transcoder.js.map +1 -0
  92. package/dist/impostor/ktx2/worker.d.ts +1 -0
  93. package/dist/impostor/ktx2/worker.js +12 -0
  94. package/dist/impostor/ktx2/worker.js.map +1 -0
  95. package/dist/impostor/mesh/card.d.ts +3 -3
  96. package/dist/impostor/mesh/card.js +11 -8
  97. package/dist/impostor/mesh/card.js.map +1 -1
  98. package/dist/impostor/mesh/index.d.ts +10 -7
  99. package/dist/impostor/mesh/index.js +15 -18
  100. package/dist/impostor/mesh/index.js.map +1 -1
  101. package/dist/impostor/mesh/material.d.ts +24 -13
  102. package/dist/impostor/mesh/material.js +67 -51
  103. package/dist/impostor/mesh/material.js.map +1 -1
  104. package/dist/impostor/mesh/surface.d.ts +20 -16
  105. package/dist/impostor/mesh/surface.js +81 -58
  106. package/dist/impostor/mesh/surface.js.map +1 -1
  107. package/dist/impostor/mesh/textures.d.ts +3 -3
  108. package/dist/impostor/mesh/textures.js +24 -34
  109. package/dist/impostor/mesh/textures.js.map +1 -1
  110. package/dist/impostor/octahedral.d.ts +1 -8
  111. package/dist/impostor/octahedral.js +3 -18
  112. package/dist/impostor/octahedral.js.map +1 -1
  113. package/dist/index.d.ts +16 -10
  114. package/dist/index.js +14 -8
  115. package/dist/index.js.map +1 -1
  116. package/dist/instanced/camera.d.ts +46 -0
  117. package/dist/instanced/camera.js +70 -0
  118. package/dist/instanced/camera.js.map +1 -0
  119. package/dist/instanced/chunk.d.ts +97 -0
  120. package/dist/instanced/chunk.js +156 -0
  121. package/dist/instanced/chunk.js.map +1 -0
  122. package/dist/instanced/chunks.d.ts +60 -0
  123. package/dist/instanced/chunks.js +208 -0
  124. package/dist/instanced/chunks.js.map +1 -0
  125. package/dist/instanced/cull.d.ts +28 -0
  126. package/dist/instanced/cull.js +22 -0
  127. package/dist/instanced/cull.js.map +1 -0
  128. package/dist/instanced/index.d.ts +96 -92
  129. package/dist/instanced/index.js +229 -512
  130. package/dist/instanced/index.js.map +1 -1
  131. package/dist/instanced/key.d.ts +19 -0
  132. package/dist/instanced/key.js +45 -0
  133. package/dist/instanced/key.js.map +1 -0
  134. package/dist/instanced/levels.d.ts +60 -0
  135. package/dist/instanced/levels.js +130 -0
  136. package/dist/instanced/levels.js.map +1 -0
  137. package/dist/instanced/lists.d.ts +70 -0
  138. package/dist/instanced/lists.js +133 -0
  139. package/dist/instanced/lists.js.map +1 -0
  140. package/dist/instanced/measure.d.ts +28 -0
  141. package/dist/instanced/measure.js +203 -0
  142. package/dist/instanced/measure.js.map +1 -0
  143. package/dist/instanced/meshes.d.ts +46 -14
  144. package/dist/instanced/meshes.js +137 -22
  145. package/dist/instanced/meshes.js.map +1 -1
  146. package/dist/instanced/mirror.d.ts +20 -0
  147. package/dist/instanced/mirror.js +37 -0
  148. package/dist/instanced/mirror.js.map +1 -0
  149. package/dist/instanced/pages/buffers.d.ts +37 -0
  150. package/dist/instanced/pages/buffers.js +15 -0
  151. package/dist/instanced/pages/buffers.js.map +1 -0
  152. package/dist/instanced/pages/chunk.d.ts +51 -0
  153. package/dist/instanced/pages/chunk.js +81 -0
  154. package/dist/instanced/pages/chunk.js.map +1 -0
  155. package/dist/instanced/pages/index.d.ts +74 -0
  156. package/dist/instanced/pages/index.js +269 -0
  157. package/dist/instanced/pages/index.js.map +1 -0
  158. package/dist/instanced/pages/passes.d.ts +21 -0
  159. package/dist/instanced/pages/passes.js +52 -0
  160. package/dist/instanced/pages/passes.js.map +1 -0
  161. package/dist/instanced/pages/slots.d.ts +11 -0
  162. package/dist/instanced/pages/slots.js +90 -0
  163. package/dist/instanced/pages/slots.js.map +1 -0
  164. package/dist/instanced/pages/workgroup.d.ts +14 -0
  165. package/dist/instanced/pages/workgroup.js +38 -0
  166. package/dist/instanced/pages/workgroup.js.map +1 -0
  167. package/dist/instanced/raycast.d.ts +15 -0
  168. package/dist/instanced/raycast.js +46 -0
  169. package/dist/instanced/raycast.js.map +1 -0
  170. package/dist/instanced/rows.d.ts +108 -0
  171. package/dist/instanced/rows.js +209 -0
  172. package/dist/instanced/rows.js.map +1 -0
  173. package/dist/instanced/shape.d.ts +25 -0
  174. package/dist/instanced/shape.js +51 -0
  175. package/dist/instanced/shape.js.map +1 -0
  176. package/dist/instanced/sort.d.ts +63 -0
  177. package/dist/instanced/sort.js +162 -0
  178. package/dist/instanced/sort.js.map +1 -0
  179. package/dist/instanced/update.d.ts +30 -0
  180. package/dist/instanced/update.js +207 -0
  181. package/dist/instanced/update.js.map +1 -0
  182. package/dist/levels/bounds.d.ts +21 -0
  183. package/dist/levels/bounds.js +42 -0
  184. package/dist/levels/bounds.js.map +1 -0
  185. package/dist/levels/cameras.d.ts +48 -0
  186. package/dist/levels/cameras.js +122 -0
  187. package/dist/levels/cameras.js.map +1 -0
  188. package/dist/levels/compile/contexts.d.ts +30 -0
  189. package/dist/levels/compile/contexts.js +18 -0
  190. package/dist/levels/compile/contexts.js.map +1 -0
  191. package/dist/levels/compile/index.d.ts +39 -0
  192. package/dist/levels/compile/index.js +185 -0
  193. package/dist/levels/compile/index.js.map +1 -0
  194. package/dist/levels/compile/pipelines.d.ts +26 -0
  195. package/dist/levels/compile/pipelines.js +177 -0
  196. package/dist/levels/compile/pipelines.js.map +1 -0
  197. package/dist/levels/compiles.d.ts +29 -0
  198. package/dist/levels/compiles.js +50 -0
  199. package/dist/levels/compiles.js.map +1 -0
  200. package/dist/levels/draw.d.ts +102 -0
  201. package/dist/levels/draw.js +401 -0
  202. package/dist/levels/draw.js.map +1 -0
  203. package/dist/levels/fade.d.ts +69 -0
  204. package/dist/levels/fade.js +150 -0
  205. package/dist/levels/fade.js.map +1 -0
  206. package/dist/levels/index.d.ts +99 -0
  207. package/dist/levels/index.js +155 -0
  208. package/dist/levels/index.js.map +1 -0
  209. package/dist/levels/item.d.ts +38 -0
  210. package/dist/levels/item.js +97 -0
  211. package/dist/levels/item.js.map +1 -0
  212. package/dist/levels/load.d.ts +31 -0
  213. package/dist/levels/load.js +142 -0
  214. package/dist/levels/load.js.map +1 -0
  215. package/dist/levels/manager.d.ts +159 -0
  216. package/dist/levels/manager.js +339 -0
  217. package/dist/levels/manager.js.map +1 -0
  218. package/dist/{material.js → levels/material.js} +13 -7
  219. package/dist/levels/material.js.map +1 -0
  220. package/dist/levels/renderer.d.ts +29 -0
  221. package/dist/levels/renderer.js +41 -0
  222. package/dist/levels/renderer.js.map +1 -0
  223. package/dist/levels/requests.d.ts +49 -0
  224. package/dist/levels/requests.js +95 -0
  225. package/dist/levels/requests.js.map +1 -0
  226. package/dist/levels/screen.d.ts +14 -0
  227. package/dist/levels/screen.js +21 -0
  228. package/dist/levels/screen.js.map +1 -0
  229. package/dist/levels/wait.d.ts +27 -0
  230. package/dist/levels/wait.js +61 -0
  231. package/dist/levels/wait.js.map +1 -0
  232. package/dist/loader/build.d.ts +10 -0
  233. package/dist/loader/build.js +28 -0
  234. package/dist/loader/build.js.map +1 -0
  235. package/dist/loader/cache.d.ts +12 -15
  236. package/dist/loader/cache.js +64 -33
  237. package/dist/loader/cache.js.map +1 -1
  238. package/dist/loader/context.d.ts +46 -0
  239. package/dist/loader/context.js +91 -0
  240. package/dist/loader/context.js.map +1 -0
  241. package/dist/loader/dependencies.d.ts +32 -0
  242. package/dist/loader/dependencies.js +113 -0
  243. package/dist/loader/dependencies.js.map +1 -0
  244. package/dist/loader/index.d.ts +62 -0
  245. package/dist/loader/index.js +284 -0
  246. package/dist/loader/index.js.map +1 -0
  247. package/dist/loader/level.d.ts +41 -0
  248. package/dist/loader/level.js +140 -0
  249. package/dist/loader/level.js.map +1 -0
  250. package/dist/loader/request.d.ts +87 -0
  251. package/dist/loader/request.js +59 -0
  252. package/dist/loader/request.js.map +1 -0
  253. package/dist/loader/url.d.ts +16 -0
  254. package/dist/loader/url.js +35 -0
  255. package/dist/loader/url.js.map +1 -0
  256. package/dist/lod.d.ts +79 -49
  257. package/dist/lod.js +209 -153
  258. package/dist/lod.js.map +1 -1
  259. package/dist/meshopt.d.ts +6 -0
  260. package/dist/meshopt.js +19 -0
  261. package/dist/meshopt.js.map +1 -0
  262. package/dist/simplify/cards.d.ts +14 -0
  263. package/dist/simplify/cards.js +128 -0
  264. package/dist/simplify/cards.js.map +1 -0
  265. package/dist/{simplify.d.ts → simplify/index.d.ts} +7 -4
  266. package/dist/{simplify.js → simplify/index.js} +42 -22
  267. package/dist/simplify/index.js.map +1 -0
  268. package/dist/{bounds.d.ts → source/detail.d.ts} +4 -13
  269. package/dist/{bounds.js → source/detail.js} +62 -32
  270. package/dist/source/detail.js.map +1 -0
  271. package/dist/source/{error.d.ts → deviation.d.ts} +3 -3
  272. package/dist/source/{error.js → deviation.js} +12 -12
  273. package/dist/source/deviation.js.map +1 -0
  274. package/dist/source/{shading.d.ts → evaluator.d.ts} +10 -10
  275. package/dist/source/{shading.js → evaluator.js} +5 -5
  276. package/dist/source/evaluator.js.map +1 -0
  277. package/dist/source/{trace.d.ts → raycaster.d.ts} +6 -6
  278. package/dist/source/{trace.js → raycaster.js} +8 -8
  279. package/dist/source/raycaster.js.map +1 -0
  280. package/dist/source/{texels.d.ts → sampler.d.ts} +1 -1
  281. package/dist/source/{texels.js → sampler.js} +3 -3
  282. package/dist/source/sampler.js.map +1 -0
  283. package/dist/source/source.d.ts +2 -2
  284. package/dist/source/source.js +2 -2
  285. package/dist/source/source.js.map +1 -1
  286. package/dist/source/surface.js +1 -1
  287. package/dist/source/surface.js.map +1 -1
  288. package/dist/task.d.ts +6 -0
  289. package/dist/{pause.js → task.js} +5 -5
  290. package/dist/task.js.map +1 -0
  291. package/dist/three.d.ts +20 -19
  292. package/dist/three.js +29 -35
  293. package/dist/three.js.map +1 -1
  294. package/dist/tsl.d.ts +10 -14
  295. package/dist/tsl.js +12 -47
  296. package/dist/tsl.js.map +1 -1
  297. package/dist/typegpu.d.ts +37 -0
  298. package/dist/typegpu.js +37 -0
  299. package/dist/typegpu.js.map +1 -0
  300. package/dist/wind/bounds.js +2 -2
  301. package/dist/wind/bounds.js.map +1 -1
  302. package/dist/wind/hooks.d.ts +7 -4
  303. package/dist/wind/hooks.js +5 -2
  304. package/dist/wind/hooks.js.map +1 -1
  305. package/dist/wind/index.d.ts +4 -4
  306. package/dist/wind/index.js +43 -40
  307. package/dist/wind/index.js.map +1 -1
  308. package/dist/wind/sway.d.ts +4 -1
  309. package/dist/wind/sway.js +4 -1
  310. package/dist/wind/sway.js.map +1 -1
  311. package/package.json +24 -8
  312. package/skills/lod/SKILL.md +147 -108
  313. package/dist/bounds.js.map +0 -1
  314. package/dist/fade.d.ts +0 -44
  315. package/dist/fade.js +0 -78
  316. package/dist/fade.js.map +0 -1
  317. package/dist/impostor/cache.d.ts +0 -15
  318. package/dist/impostor/cache.js +0 -44
  319. package/dist/impostor/cache.js.map +0 -1
  320. package/dist/instanced/args.d.ts +0 -20
  321. package/dist/instanced/args.js +0 -77
  322. package/dist/instanced/args.js.map +0 -1
  323. package/dist/instanced/bounds.d.ts +0 -50
  324. package/dist/instanced/bounds.js +0 -271
  325. package/dist/instanced/bounds.js.map +0 -1
  326. package/dist/instanced/dirty.d.ts +0 -12
  327. package/dist/instanced/dirty.js +0 -61
  328. package/dist/instanced/dirty.js.map +0 -1
  329. package/dist/instanced/select.d.ts +0 -84
  330. package/dist/instanced/select.js +0 -264
  331. package/dist/instanced/select.js.map +0 -1
  332. package/dist/lazy.d.ts +0 -64
  333. package/dist/lazy.js +0 -187
  334. package/dist/lazy.js.map +0 -1
  335. package/dist/levels.d.ts +0 -72
  336. package/dist/levels.js +0 -146
  337. package/dist/levels.js.map +0 -1
  338. package/dist/loader/dispose.d.ts +0 -3
  339. package/dist/loader/dispose.js +0 -25
  340. package/dist/loader/dispose.js.map +0 -1
  341. package/dist/loader.d.ts +0 -99
  342. package/dist/loader.js +0 -234
  343. package/dist/loader.js.map +0 -1
  344. package/dist/material.js.map +0 -1
  345. package/dist/pause.d.ts +0 -6
  346. package/dist/pause.js.map +0 -1
  347. package/dist/renderer.d.ts +0 -21
  348. package/dist/renderer.js +0 -83
  349. package/dist/renderer.js.map +0 -1
  350. package/dist/simplify.js.map +0 -1
  351. package/dist/source/error.js.map +0 -1
  352. package/dist/source/shading.js.map +0 -1
  353. package/dist/source/texels.js.map +0 -1
  354. package/dist/source/trace.js.map +0 -1
  355. package/dist/view.d.ts +0 -30
  356. package/dist/view.js +0 -75
  357. package/dist/view.js.map +0 -1
  358. /package/dist/{material.d.ts → levels/material.d.ts} +0 -0
@@ -1,26 +1,27 @@
1
- import { type Object3D } from "three/webgpu";
1
+ import { type Object3D, type Renderer } from "three/webgpu";
2
2
  import { type Impostor, type ImpostorLayout } from "../impostor.js";
3
3
  export interface BakeImpostorOptions {
4
4
  /**
5
- * "full" (default): views from every side, so any orientation works. "hemi": views
5
+ * "full" (default): frames from every side, so any orientation works. "hemi": frames
6
6
  * from the horizon up only, for objects that always stand upright; the same quality
7
7
  * there with about 45% less memory.
8
8
  */
9
9
  layout?: ImpostorLayout;
10
- /** views per atlas side; default 16 for full, 12 for hemi */
10
+ /** frames per atlas side; default 16 for full, 12 for hemi */
11
11
  frames?: number;
12
12
  /**
13
- * pixels per view: the impostor stays sharp up to about this size on screen. Rounded
14
- * down to a power of two so mip levels never mix two views; default 128.
13
+ * pixels per frame: the impostor stays sharp up to about this size on screen. Rounded
14
+ * down to a power of two so mip levels never mix two frames; default 128.
15
15
  */
16
16
  resolution?: number;
17
17
  /**
18
18
  * Largest on-screen height (CSS pixels, as `LodLevel.maxPixels`) the impostor will be
19
19
  * drawn at, when that is above the height where it is sharp (its default maxPixels).
20
20
  * Larger, it shows its top mip magnified, which then reads the source's textures as
21
- * sharp as they are at this height: alpha-tested leaves keep the coverage and colour
22
- * they show up close, not the denser, darker look of their texture's small mips.
23
- * Default: the height where it is sharp.
21
+ * sharp as they are at this height, not with the look of their small mips. Alpha-tested
22
+ * materials are read at full detail at every size, which holds their cut-out's coverage.
23
+ * Default: the height where it is sharp (see `texelPixels`, and `framePixels` for a
24
+ * LodLoader level).
24
25
  */
25
26
  maxPixels?: number;
26
27
  /**
@@ -35,16 +36,24 @@ export interface BakeImpostorOptions {
35
36
  supersample?: number;
36
37
  }
37
38
  /**
38
- * Bake `object` (in its own space, ignoring its own transform) into an impostor. Nested
39
- * LODs are baked at their level 0, an InstancedLod with every instance at its level 0.
40
- * ImpostorMeshes are refused: bake from their source instead.
39
+ * Bake `object` (in its own space, ignoring its own transform) into an impostor, drawing
40
+ * with `renderer`, as three's PMREMGenerator does. Nested LODs are baked at their level 0,
41
+ * an InstancedLod with every instance at its level 0. ImpostorMeshes are refused: bake
42
+ * from their source instead.
43
+ *
44
+ * `renderer` must be one made for bakes: make one with `createBakeRenderer`, as LodLoader
45
+ * does for itself and a .glts script that bakes does too. Such a renderer is initialised,
46
+ * clears to transparent black and only when told to (`autoClear = false`), and has no MRT
47
+ * and no XR session; the bake throws otherwise. Nor may its canvas be a square of a frame's size (resolution ×
48
+ * supersample): three r186 applies a target's viewport only when it differs from the
49
+ * canvas's, and would draw that frame over the whole target. Bakes on one renderer run
50
+ * one at a time.
41
51
  *
42
52
  * Each frame is an orthographic look at the bounding-box centre, rendered once per mip
43
53
  * level at that level's size. The object's materials are rendered unlit into one target
44
54
  * per map: base colour + coverage, object-space normal + depth,
45
55
  * occlusion/roughness/metalness and, if needed, emissive. A material that changes three's
46
56
  * default specular adds the object's mean specular (see `Impostor.specular`).
57
+ * Custom lighting behavior is not baked; the resulting surface is lit at draw time.
47
58
  */
48
- export declare function bakeImpostor(object: Object3D, options?: BakeImpostorOptions): Promise<Impostor>;
49
- /** Loader entry: rooms attached for the close source are absent from distant bakes. */
50
- export declare function bake(object: Object3D, options: BakeImpostorOptions, excluded?: readonly Object3D[]): Promise<Impostor>;
59
+ export declare function bakeImpostor(object: Object3D, renderer: Renderer, options?: BakeImpostorOptions): Promise<Impostor>;
@@ -1,34 +1,40 @@
1
- import { HalfFloatType, Matrix4, NearestFilter, OrthographicCamera, RenderTarget, Scene, Vector3 } from "three/webgpu";
1
+ import { Matrix4, OrthographicCamera, RGBAFormat, Scene, Vector3 } from "three/webgpu";
2
2
  import { uniform } from "three/tsl";
3
- import { MAPS, boundingRadius, texelPixels, validateImpostor } from "../impostor.js";
3
+ import { MAPS, PAD, boundingRadius, texelPixels, validateImpostor } from "../impostor.js";
4
4
  import { frameBasis, frameDirection } from "../octahedral.js";
5
- import { boundingBox, forEachVertex, showDetail } from "../../bounds.js";
6
- import { pause } from "../../pause.js";
7
- import { borrow, readFloats, sharedRenderer } from "../../renderer.js";
8
- import { Atlas } from "./atlas.js";
9
- import { OUTPUTS, swapMaterials } from "./materials.js";
5
+ import { checkBakeRenderer, inTurn } from "../../bake.js";
6
+ import { boundingBox, showDetail } from "../../source/detail.js";
7
+ import { ImpostorAtlasMip } from "./atlas.js";
8
+ import { swapMaterials } from "./materials.js";
9
+ import { bakeMip } from "./sheet.js";
10
10
  import { sourceForBake } from "./source.js";
11
+ import { fittedHalfSize } from "./fit.js";
11
12
  /**
12
- * Empty border around the object in every frame, as a fraction of the frame's half
13
- * size. It keeps mip levels from blending a frame's silhouette into its neighbour.
14
- */
15
- const PAD = 0.06;
16
- /**
17
- * Bake `object` (in its own space, ignoring its own transform) into an impostor. Nested
18
- * LODs are baked at their level 0, an InstancedLod with every instance at its level 0.
19
- * ImpostorMeshes are refused: bake from their source instead.
13
+ * Bake `object` (in its own space, ignoring its own transform) into an impostor, drawing
14
+ * with `renderer`, as three's PMREMGenerator does. Nested LODs are baked at their level 0,
15
+ * an InstancedLod with every instance at its level 0. ImpostorMeshes are refused: bake
16
+ * from their source instead.
17
+ *
18
+ * `renderer` must be one made for bakes: make one with `createBakeRenderer`, as LodLoader
19
+ * does for itself and a .glts script that bakes does too. Such a renderer is initialised,
20
+ * clears to transparent black and only when told to (`autoClear = false`), and has no MRT
21
+ * and no XR session; the bake throws otherwise. Nor may its canvas be a square of a frame's size (resolution ×
22
+ * supersample): three r186 applies a target's viewport only when it differs from the
23
+ * canvas's, and would draw that frame over the whole target. Bakes on one renderer run
24
+ * one at a time.
20
25
  *
21
26
  * Each frame is an orthographic look at the bounding-box centre, rendered once per mip
22
27
  * level at that level's size. The object's materials are rendered unlit into one target
23
28
  * per map: base colour + coverage, object-space normal + depth,
24
29
  * occlusion/roughness/metalness and, if needed, emissive. A material that changes three's
25
30
  * default specular adds the object's mean specular (see `Impostor.specular`).
31
+ * Custom lighting behavior is not baked; the resulting surface is lit at draw time.
26
32
  */
27
- export function bakeImpostor(object, options = {}) {
28
- return bake(object, options);
33
+ export function bakeImpostor(object, renderer, options = {}) {
34
+ return inTurn(renderer, () => bake(object, renderer, options));
29
35
  }
30
- /** Loader entry: rooms attached for the close source are absent from distant bakes. */
31
- export async function bake(object, options, excluded = []) {
36
+ async function bake(object, renderer, options) {
37
+ checkBakeRenderer(renderer, "bakeImpostor");
32
38
  const layout = options.layout ?? "full";
33
39
  const frames = options.frames ?? (layout === "hemi" ? 12 : 16);
34
40
  const resolution = options.resolution ?? 128;
@@ -42,7 +48,7 @@ export async function bake(object, options, excluded = []) {
42
48
  if (options.maxPixels !== undefined && !(options.maxPixels > 0))
43
49
  throw new Error("bakeImpostor: maxPixels must be > 0");
44
50
  const cell = 2 ** Math.floor(Math.log2(resolution));
45
- const source = sourceForBake(object, excluded);
51
+ const source = sourceForBake(object);
46
52
  source.matrix.identity();
47
53
  source.matrix.decompose(source.position, source.quaternion, source.scale);
48
54
  // Bones are descendants, so this also moves them; getVertexPosition reads bone.matrixWorld.
@@ -62,7 +68,8 @@ export async function bake(object, options, excluded = []) {
62
68
  directions.push(frameDirection(layout, frames, col, row));
63
69
  const halfSize = fittedHalfSize(source, centre, directions) * (1 + PAD);
64
70
  const distance = 2 * radius + 1e-3;
65
- // Textures are read at the size of an atlas texel; the top mip's at the size of a pixel at maxPixels.
71
+ // Textures are read at the size of an atlas texel; the top mip's at the size of a pixel at maxPixels. Alpha-tested
72
+ // materials read theirs at full detail (see `swapMaterials`).
66
73
  const sharp = texelPixels({ size: cell * frames, frames, box, halfSize });
67
74
  const textureBias = (m) => Math.log2(supersample) - (m === 0 ? Math.log2(Math.max(1, (options.maxPixels ?? sharp) / sharp)) : 0);
68
75
  const settings = { distance, radius, textureBias: uniform(0) };
@@ -70,24 +77,23 @@ export async function bake(object, options, excluded = []) {
70
77
  const emissive = options.emissive ?? swapped.emits;
71
78
  const maps = emissive ? [...MAPS] : ["base", "normalDepth", "orm"];
72
79
  // Every mip level is rendered, not filtered from the one above: the source does not look
73
- // the same at every size (alpha-tested leaves whose texture mips mix in the dark texels
74
- // around them darken with distance), and filtering would freeze the look of the largest.
75
- const atlases = Array.from({ length: Math.log2(cell) + 1 }, (_, m) => new Atlas(maps, frames, cell >> m, swapped.specular));
76
- const renderer = await sharedRenderer();
80
+ // the same at every size (a texture whose small mips mix in dark texels darkens with
81
+ // distance), and filtering would freeze the look of the largest.
82
+ const atlases = Array.from({ length: Math.log2(cell) + 1 }, (_, m) => new ImpostorAtlasMip(maps, frames, cell >> m, swapped.specular));
77
83
  const scene = new Scene();
78
84
  scene.add(source);
79
85
  const camera = new OrthographicCamera(-halfSize, halfSize, halfSize, -halfSize, 0, 4 * radius + 1e-3);
80
86
  camera.matrixAutoUpdate = false;
81
87
  // Bounds count meshes on every layer, so the bake draws them all.
82
88
  camera.layers.enableAll();
83
- const views = directions.map((n) => {
89
+ const frameCameras = directions.map((n) => {
84
90
  const { tangent: t, bitangent: b } = frameBasis(n);
85
91
  return new Matrix4().set(t[0], b[0], n[0], centre.x + n[0] * distance, t[1], b[1], n[1], centre.y + n[1] * distance, t[2], b[2], n[2], centre.z + n[2] * distance, 0, 0, 0, 1);
86
92
  });
87
93
  try {
88
94
  for (const [m, atlas] of atlases.entries()) {
89
95
  settings.textureBias.value = textureBias(m);
90
- await bakeMip(atlas, supersample, renderer, scene, camera, views);
96
+ await bakeMip(atlas, supersample, renderer, scene, camera, frameCameras);
91
97
  }
92
98
  }
93
99
  finally {
@@ -102,13 +108,16 @@ export async function bake(object, options, excluded = []) {
102
108
  if (sum("turned") > sum("own"))
103
109
  for (const atlas of atlases)
104
110
  atlas.useTurned();
105
- const layers = maps.map((map, i) => atlases.map((atlas) => {
106
- const layer = atlas.layers[i];
107
- if (!layer)
108
- throw new Error(`bakeImpostor: no ${map} layer`);
109
- return layer;
111
+ const layers = maps.map((map, i) => ({
112
+ format: RGBAFormat,
113
+ mipmaps: atlases.map((atlas) => {
114
+ const layer = atlas.layers[i];
115
+ if (!layer)
116
+ throw new Error(`bakeImpostor: no ${map} layer`);
117
+ return layer;
118
+ }),
110
119
  }));
111
- const impostor = { version: 3, layout, frames, size: cell * frames, box, halfSize, maps, layers };
120
+ const impostor = { version: 4, layout, frames, size: cell * frames, box, halfSize, maps, layers };
112
121
  const [top] = atlases;
113
122
  if (!top)
114
123
  throw new Error("bakeImpostor: no mip levels");
@@ -117,105 +126,4 @@ export async function bake(object, options, excluded = []) {
117
126
  validateImpostor(impostor);
118
127
  return impostor;
119
128
  }
120
- /** Edge of the largest target frames render into side by side, which is read back at once. */
121
- const TILE = 1024;
122
- /**
123
- * Colour attachments one pass renders: four half-float targets fill the 32 bytes per
124
- * sample WebGPU guarantees.
125
- */
126
- const PER_PASS = 4;
127
- /**
128
- * Render every frame (`views`: camera matrices, in atlas order) into `atlas`, at its cell
129
- * size × `supersample`. Frames render side by side into tiles of up to TILE square, so
130
- * that each map is read back once per tile, in passes of up to PER_PASS outputs.
131
- */
132
- async function bakeMip(atlas, supersample, renderer, scene, camera, views) {
133
- const { frames, maps } = atlas;
134
- const side = atlas.cell * supersample;
135
- const per = Math.max(1, Math.min(frames, Math.floor(TILE / side)));
136
- const width = per * side;
137
- // one output per map, then the second way to store the normals (see Atlas), then the specular
138
- const names = OUTPUTS.filter((name) => (name === "emissive" ? maps.includes("emissive") : name !== "specular" || atlas.specular));
139
- const passes = Array.from({ length: Math.ceil(names.length / PER_PASS) }, (_, p) => {
140
- const outputs = names.slice(p * PER_PASS, (p + 1) * PER_PASS);
141
- const target = new RenderTarget(width, width, {
142
- count: outputs.length,
143
- type: HalfFloatType,
144
- minFilter: NearestFilter,
145
- magFilter: NearestFilter,
146
- depthBuffer: true,
147
- });
148
- outputs.forEach((name, i) => {
149
- const texture = target.textures[i];
150
- if (!texture)
151
- throw new Error("bakeImpostor: a render target lacks a texture");
152
- texture.name = name;
153
- });
154
- return target;
155
- });
156
- try {
157
- for (let row0 = 0; row0 < frames; row0 += per)
158
- for (let col0 = 0; col0 < frames; col0 += per) {
159
- const tile = [];
160
- for (let row = row0; row < Math.min(row0 + per, frames); row++)
161
- for (let col = col0; col < Math.min(col0 + per, frames); col++)
162
- tile.push({ col, row, x: (col - col0) * side, y: (row - row0) * side });
163
- const placed = tile.map(({ col, row, x, y }) => ({ view: views[row * frames + col], x, y }));
164
- for (const target of passes)
165
- renderTile(renderer, target, scene, camera, placed, side);
166
- const pixels = await Promise.all(passes.flatMap((target) => target.textures.map((_, i) => readFloats(renderer, target, i))));
167
- for (const { col, row, x, y } of tile)
168
- atlas.write(pixels, width, supersample, col, row, x, y);
169
- await pause();
170
- }
171
- }
172
- finally {
173
- for (const target of passes)
174
- target.dispose();
175
- }
176
- }
177
- /** Clear `target` and render each frame's view into its `side` square at (x, y), counted from the bottom left as the atlas is. */
178
- function renderTile(renderer, target, scene, camera, frames, side) {
179
- const restore = borrow(renderer, target);
180
- try {
181
- renderer.clear(true, true, true);
182
- target.scissorTest = true;
183
- for (const { view, x, y } of frames) {
184
- if (!view)
185
- throw new Error("bakeImpostor: a frame has no view");
186
- // WebGPU counts viewport rows from the top; `readFloats` turns the image over.
187
- const top = target.height - y - side;
188
- target.viewport.set(x, top, side, side);
189
- target.scissor.set(x, top, side, side);
190
- camera.matrix.copy(view);
191
- camera.updateMatrixWorld(true);
192
- renderer.render(scene, camera);
193
- }
194
- }
195
- finally {
196
- // The next tile clears it whole.
197
- target.scissorTest = false;
198
- restore();
199
- }
200
- }
201
- /**
202
- * The smallest square half-size that holds the object in every frame: the largest
203
- * extent of any vertex along any frame's image axes. Tighter than the bounding
204
- * sphere, which wastes about a third of every frame on a tree.
205
- */
206
- function fittedHalfSize(source, centre, directions) {
207
- const axes = directions.flatMap((n) => {
208
- const { tangent, bitangent } = frameBasis(n);
209
- return [tangent, bitangent];
210
- });
211
- let half = 0;
212
- forEachVertex(source, (p) => {
213
- p.sub(centre);
214
- for (const a of axes)
215
- half = Math.max(half, Math.abs(p.x * a[0] + p.y * a[1] + p.z * a[2]));
216
- });
217
- if (half === 0)
218
- throw new Error("bakeImpostor: object has no extent (every vertex is at one point)");
219
- return half;
220
- }
221
129
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/impostor/bake/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,OAAO,EAAE,aAAa,EAAE,kBAAkB,EAAE,YAAY,EAAE,KAAK,EAAE,OAAO,EAAgC,MAAM,cAAc,CAAC;AACrJ,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,IAAI,EAAE,cAAc,EAAE,WAAW,EAAE,gBAAgB,EAAwD,MAAM,gBAAgB,CAAC;AAC3I,OAAO,EAAE,UAAU,EAAE,cAAc,EAAa,MAAM,kBAAkB,CAAC;AACzE,OAAO,EAAE,WAAW,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AACzE,OAAO,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAC;AACvC,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,cAA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C,6BAA6B,CAAC,CAAC;IACzD,IAAI,OAAO,CAAC,QAAQ;QAAE,QAAQ,CAAC,QAAQ,GAAG,GAAG,CAAC,YAAY,EAAE,CAAC;IAC7D,gBAAgB,CAAC,QAAQ,CAAC,CAAC;IAC3B,OAAO,QAAQ,CAAC;AAClB,CAAC"}
@@ -4,16 +4,16 @@ export interface BakeSettings {
4
4
  /** the cameras' distance from the bounding box centre, and the bounding radius: the depth encoding */
5
5
  distance: number;
6
6
  radius: number;
7
- /** mip bias of every texture read, per mip level: textures are read at the size of a texel (see `bakeImpostor`) */
7
+ /** mip bias of every texture read but an alpha-tested material's, per mip level: textures are read at the size of a texel (see `bakeImpostor`) */
8
8
  textureBias: Node<"float"> & {
9
9
  value: number;
10
10
  };
11
11
  }
12
12
  /**
13
13
  * The outputs a bake material writes, by name: one per atlas map, then the second way to
14
- * store the normals (see Atlas) and the specular. A render target takes the ones it has
14
+ * store the normals (see ImpostorAtlasMip) and the specular. A render target takes the ones it has
15
15
  * textures of that name for, so every material writes them all and the bake decides,
16
- * once it knows every material, which it keeps.
16
+ * once it knows every material, which it uses.
17
17
  */
18
18
  export declare const OUTPUTS: readonly ["base", "normalDepth", "orm", "emissive", "turned", "specular"];
19
19
  export type Output = (typeof OUTPUTS)[number];
@@ -1,13 +1,14 @@
1
- import { DoubleSide, MeshStandardNodeMaterial, NoBlending } from "three/webgpu";
2
- import { ambientOcclusion, cameraViewMatrix, Fn, clamp, diffuseColor, emissive, faceDirection, float, materialMetalness, materialOpacity, materialRoughness, max, mrt, normalView, normalize, positionView, specularColor, specularF90, step, vec4, } from "three/tsl";
1
+ import { DoubleSide, MeshStandardNodeMaterial, NoBlending, } from "three/webgpu";
2
+ import { ambientOcclusion, cameraViewMatrix, Fn, clamp, context, dFdx, dFdy, diffuseColor, emissive, faceDirection, float, length, log2, materialMetalness, materialOpacity, materialRoughness, max, mrt, normalView, normalize, positionView, positionLocal, specularColor, specularF90, step, uniform, uv, vec2, vec3, vec4, } from "three/tsl";
3
3
  import { isMesh, isNodeMaterial, isPhysical, isStandard, isStandardNode, toNodeMaterial } from "../../three.js";
4
- import { affine, biasedTextures, isNodeOf } from "../../tsl.js";
5
- import { originalOf } from "../../material.js";
4
+ import { affine, isNodeOf } from "../../tsl.js";
5
+ import { placeInstances } from "../../levels/fade.js";
6
+ import { originalOf } from "../../levels/material.js";
6
7
  /**
7
8
  * The outputs a bake material writes, by name: one per atlas map, then the second way to
8
- * store the normals (see Atlas) and the specular. A render target takes the ones it has
9
+ * store the normals (see ImpostorAtlasMip) and the specular. A render target takes the ones it has
9
10
  * textures of that name for, so every material writes them all and the bake decides,
10
- * once it knows every material, which it keeps.
11
+ * once it knows every material, which it uses.
11
12
  */
12
13
  export const OUTPUTS = ["base", "normalDepth", "orm", "emissive", "turned", "specular"];
13
14
  /**
@@ -72,7 +73,7 @@ const STANDARD_KEYS = [
72
73
  "displacementBias",
73
74
  "wireframe",
74
75
  ];
75
- /** Built-in materials whose look the standard keys carry over; others only keep their color/map. */
76
+ /** Built-in materials whose look the standard keys carry over; others carry only their color/map. */
76
77
  const MAPPED = new Set(["MeshBasicMaterial", "MeshLambertMaterial", "MeshPhongMaterial", "MeshToonMaterial", "MeshMatcapMaterial"]);
77
78
  /** A node material that renders like `source`: a copy of a node or standard one, else the standard keys carried over. */
78
79
  function toStandard(source) {
@@ -91,6 +92,15 @@ const scalar = (node, builder) => {
91
92
  };
92
93
  function bakeMaterial(source, settings) {
93
94
  const material = toStandard(source);
95
+ const position = material.positionNode;
96
+ material.positionNode = Fn((builder) => {
97
+ placeInstances(builder);
98
+ if (!position)
99
+ return positionLocal;
100
+ if (!isNodeOf(position, "vec3", builder))
101
+ throw new Error("bakeImpostor: position must build to vec3");
102
+ return position;
103
+ })();
94
104
  // A material that draws no colour has no surface to bake.
95
105
  material.visible = source.visible && source.colorWrite;
96
106
  const emits = material.visible && emitsLight(material);
@@ -98,19 +108,22 @@ function bakeMaterial(source, settings) {
98
108
  // Coverage is the material's alpha where it cuts the surface out: alpha-to-coverage (no
99
109
  // multisampling here, so it would cover the card), or a blended material's texture
100
110
  // alpha. A blended material's uniform opacity (glass) is no hole: it folds into the
101
- // colour, as if the pane were dark and opaque, which keeps its reflection.
111
+ // colour, as if the pane were dark and opaque, which leaves its reflection.
102
112
  const blended = material.transparent;
103
113
  const coverage = blended ? diffuseColor.a.div(max(materialOpacity, 1e-4)) : material.alphaToCoverage ? diffuseColor.a : float(1);
104
114
  const opacity = blended ? materialOpacity : float(1);
105
115
  // Blending would mix the outputs with the cleared background; coverage carries alpha
106
- // instead. Without normal blending three also keeps the alpha (not opaque).
116
+ // instead. Without normal blending three also writes the alpha (not opaque).
107
117
  material.transparent = false;
108
118
  material.blending = NoBlending;
109
119
  material.depthWrite = true;
110
- material.contextNode = biasedTextures(settings.textureBias);
120
+ // A cut-out covers where its alpha passes the test at full detail, and the supersamples average that. Tested at
121
+ // a smaller mip, whose alpha averages the holes in, thin cut-outs such as needles fall below the cutoff and vanish.
122
+ const cutOut = material.alphaTest > 0 || material.alphaTestNode !== null;
123
+ material.contextNode = cutOut ? sharpTextures() : biasedTextures(settings.textureBias);
111
124
  // Two ways to store the normals three shades with, each a normal and the share of the
112
- // surface that shades with it rather than its opposite; the bake keeps the one whose
113
- // normals agree more once averaged (see Atlas):
125
+ // surface that shades with it rather than its opposite; the bake uses the one whose
126
+ // normals agree more once averaged (see ImpostorAtlasMip):
114
127
  // - the surface's own normal and the share whose front faced the camera (on two-sided
115
128
  // surfaces three turns the normal toward the camera; this undoes it). Painted canopy
116
129
  // normals of cut-out foliage agree this way, which three turns inward on every leaf
@@ -153,4 +166,39 @@ function changesSpecular(material) {
153
166
  const { ior, specularIntensity, specularColor: c, specularIntensityMap, specularColorMap } = material;
154
167
  return ior !== 1.5 || specularIntensity !== 1 || c.r !== 1 || c.g !== 1 || c.b !== 1 || specularIntensityMap !== null || specularColorMap !== null;
155
168
  }
169
+ /** The size in texels of a texture's image, or null when it has none to read. */
170
+ function texelsOf(image) {
171
+ if (typeof image !== "object" || image === null || !("width" in image) || !("height" in image))
172
+ return null;
173
+ const { width, height } = image;
174
+ return typeof width === "number" && typeof height === "number" ? [width, height] : null;
175
+ }
176
+ /**
177
+ * A context in which every texture read is `bias` mip levels above the level the
178
+ * hardware would pick: the level from the read's own texel footprint, plus `bias`. Reads
179
+ * with uv of their own making, or with an explicit level or gradients, are left as they are.
180
+ */
181
+ function biasedTextures(bias) {
182
+ return context({
183
+ getTextureLevel: (node) => {
184
+ const texture = node.value;
185
+ const size = texelsOf(texture.image);
186
+ if (node.uvNode || !size)
187
+ return null;
188
+ // The texture's offset, repeat and rotation, as three applies them.
189
+ const at = uniform(texture.matrix).mul(vec3(uv(texture.channel), 1)).xy;
190
+ const texels = at.mul(vec2(size[0], size[1]));
191
+ return log2(max(max(length(dFdx(texels)), length(dFdy(texels))), 1e-6)).add(bias);
192
+ },
193
+ });
194
+ }
195
+ /**
196
+ * A context in which every texture read is at level 0, the full detail. Reads with uv of their own making, or with an
197
+ * explicit level or gradients, are left as they are.
198
+ */
199
+ function sharpTextures() {
200
+ return context({
201
+ getTextureLevel: (node) => (node.uvNode || !texelsOf(node.value.image) ? null : float(0)),
202
+ });
203
+ }
156
204
  //# sourceMappingURL=materials.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"materials.js","sourceRoot":"","sources":["../../../src/impostor/bake/materials.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,wBAAwB,EAAE,UAAU,EAAgF,MAAM,cAAc,CAAC;AAC9J,OAAO,EACL,gBAAgB,EAChB,gBAAgB,EAChB,EAAE,EACF,KAAK,EACL,YAAY,EACZ,QAAQ,EACR,aAAa,EACb,KAAK,EACL,iBAAiB,EACjB,eAAe,EACf,iBAAiB,EACjB,GAAG,EACH,GAAG,EACH,UAAU,EACV,SAAS,EACT,YAAY,EACZ,aAAa,EACb,WAAW,EACX,IAAI,EACJ,IAAI,GACL,MAAM,WAAW,CAAC;AACnB,OAAO,EAAE,M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AAE,EAAE;YACrC,MAAM,OAAO,GAAG,IAAI,CAAC,KAAK,CAAC;YAC3B,MAAM,IAAI,GAAG,QAAQ,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;YACrC,IAAI,IAAI,CAAC,MAAM,IAAI,CAAC,IAAI;gBAAE,OAAO,IAAI,CAAC;YACtC,oEAAoE;YACpE,MAAM,EAAE,GAAG,OAAO,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;YACxE,MAAM,MAAM,GAAG,EAAE,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;YAC9C,OAAO,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,EAAE,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;QACpF,CAAC;KACF,CAAC,CAAC;AACL,CAAC;AAED;;;GAGG;AACH,SAAS,aAAa;IACpB,OAAO,OAAO,CAAC;QACb,eAAe,EAAE,CAAC,IAAiB,EAAE,EAAE,CAAC,CAAC,IAAI,CAAC,MAAM,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;KACvG,CAAC,CAAC;AACL,CAAC"}
@@ -0,0 +1,8 @@
1
+ import { type Matrix4, type OrthographicCamera, type Renderer, type Scene } from "three/webgpu";
2
+ import type { ImpostorAtlasMip } from "./atlas.js";
3
+ /**
4
+ * Render every frame (`frameCameras`: camera matrices, in atlas order) into `atlas`, at its
5
+ * cell size × `supersample`. Frames render side by side into sheets of up to SHEET square,
6
+ * so that each map is read back once per sheet, into targets of up to PER_TARGET outputs.
7
+ */
8
+ export declare function bakeMip(atlas: ImpostorAtlasMip, supersample: number, renderer: Renderer, scene: Scene, camera: OrthographicCamera, frameCameras: Matrix4[]): Promise<void>;
@@ -0,0 +1,90 @@
1
+ import { HalfFloatType, NearestFilter, RenderTarget, Vector2 } from "three/webgpu";
2
+ import { at } from "../../at.js";
3
+ import { readFloats } from "../../bake.js";
4
+ import { nextTask } from "../../task.js";
5
+ import { OUTPUTS } from "./materials.js";
6
+ // Rendering an atlas mip: its frames side by side in sheets, each read back at once.
7
+ /** Edge of the largest target frames render into side by side, a sheet, which is read back at once. */
8
+ const SHEET = 1024;
9
+ /**
10
+ * Colour attachments one target renders: four half-float targets fill the 32 bytes per
11
+ * sample WebGPU guarantees.
12
+ */
13
+ const PER_TARGET = 4;
14
+ /**
15
+ * Render every frame (`frameCameras`: camera matrices, in atlas order) into `atlas`, at its
16
+ * cell size × `supersample`. Frames render side by side into sheets of up to SHEET square,
17
+ * so that each map is read back once per sheet, into targets of up to PER_TARGET outputs.
18
+ */
19
+ export async function bakeMip(atlas, supersample, renderer, scene, camera, frameCameras) {
20
+ const { frames, maps } = atlas;
21
+ const side = atlas.cell * supersample;
22
+ const buffer = renderer.getDrawingBufferSize(new Vector2());
23
+ if (buffer.x === side && buffer.y === side)
24
+ throw new Error(`bakeImpostor: the renderer's canvas is ${side} px square, a frame's size: three would draw that frame over the whole sheet`);
25
+ const per = Math.max(1, Math.min(frames, Math.floor(SHEET / side)));
26
+ const width = per * side;
27
+ // one output per map, then the second way to store the normals (see ImpostorAtlasMip), then the specular
28
+ const names = OUTPUTS.filter((name) => (name === "emissive" ? maps.includes("emissive") : name !== "specular" || atlas.specular));
29
+ const targets = Array.from({ length: Math.ceil(names.length / PER_TARGET) }, (_, p) => {
30
+ const outputs = names.slice(p * PER_TARGET, (p + 1) * PER_TARGET);
31
+ const target = new RenderTarget(width, width, {
32
+ count: outputs.length,
33
+ type: HalfFloatType,
34
+ minFilter: NearestFilter,
35
+ magFilter: NearestFilter,
36
+ depthBuffer: true,
37
+ });
38
+ outputs.forEach((name, i) => {
39
+ const texture = target.textures[i];
40
+ if (!texture)
41
+ throw new Error("bakeImpostor: a render target lacks a texture");
42
+ texture.name = name;
43
+ });
44
+ return target;
45
+ });
46
+ try {
47
+ for (let row0 = 0; row0 < frames; row0 += per)
48
+ for (let col0 = 0; col0 < frames; col0 += per) {
49
+ const sheet = [];
50
+ for (let row = row0; row < Math.min(row0 + per, frames); row++)
51
+ for (let col = col0; col < Math.min(col0 + per, frames); col++)
52
+ sheet.push({ col, row, x: (col - col0) * side, y: (row - row0) * side });
53
+ const placed = sheet.map(({ col, row, x, y }) => ({ matrix: at(frameCameras, row * frames + col), x, y }));
54
+ for (const target of targets)
55
+ renderSheet(renderer, target, scene, camera, placed, side);
56
+ const pixels = await Promise.all(targets.flatMap((target) => target.textures.map((_, i) => readFloats(renderer, target, i))));
57
+ for (const { col, row, x, y } of sheet)
58
+ atlas.write(pixels, width, supersample, col, row, x, y);
59
+ // Yield to the page between sheets, so that a long bake does not freeze it.
60
+ await nextTask();
61
+ }
62
+ }
63
+ finally {
64
+ for (const target of targets)
65
+ target.dispose();
66
+ }
67
+ }
68
+ /**
69
+ * Clear `target` and render each frame, its camera at `matrix`, into its `side` square at (x, y), counted from the
70
+ * bottom left as the atlas is.
71
+ */
72
+ function renderSheet(renderer, target, scene, camera, frames, side) {
73
+ const previous = renderer.getRenderTarget();
74
+ renderer.setRenderTarget(target);
75
+ try {
76
+ renderer.clear(true, true, true);
77
+ for (const { matrix, x, y } of frames) {
78
+ // WebGPU counts viewport rows from the top; `readFloats` turns the image over.
79
+ const top = target.height - y - side;
80
+ target.viewport.set(x, top, side, side);
81
+ camera.matrix.copy(matrix);
82
+ camera.updateMatrixWorld(true);
83
+ renderer.render(scene, camera);
84
+ }
85
+ }
86
+ finally {
87
+ renderer.setRenderTarget(previous);
88
+ }
89
+ }
90
+ //# sourceMappingURL=sheet.js.map