@null3d/engine 0.1.0 → 0.1.2

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 (388) hide show
  1. package/dist/wasm/single/null3d.js +10 -8
  2. package/dist/wasm/single/null3d_bg.wasm +0 -0
  3. package/dist/wasm/threaded/null3d.js +10 -8
  4. package/dist/wasm/threaded/null3d_bg.wasm +0 -0
  5. package/docs/api/animation.md +96 -24
  6. package/docs/api/assets.md +99 -29
  7. package/docs/api/cameras.md +38 -7
  8. package/docs/api/controls.md +47 -23
  9. package/docs/api/debug.md +105 -35
  10. package/docs/api/engine.md +108 -32
  11. package/docs/api/feature-draws.md +21 -15
  12. package/docs/api/feature-effects.md +8 -8
  13. package/docs/api/feature-instances.md +68 -17
  14. package/docs/api/features.md +68 -37
  15. package/docs/api/geometry.md +83 -14
  16. package/docs/api/grass.md +55 -13
  17. package/docs/api/impostors.md +92 -50
  18. package/docs/api/input.md +22 -9
  19. package/docs/api/lights.md +67 -16
  20. package/docs/api/lines.md +38 -13
  21. package/docs/api/materials.md +187 -59
  22. package/docs/api/math.md +6 -6
  23. package/docs/api/objects.md +40 -15
  24. package/docs/api/page.md +58 -7
  25. package/docs/api/particles.md +36 -11
  26. package/docs/api/points.md +18 -8
  27. package/docs/api/post.md +57 -23
  28. package/docs/api/quality.md +36 -16
  29. package/docs/api/raycast.md +57 -24
  30. package/docs/api/reference/animation.md +1 -2
  31. package/docs/api/reference/assets.md +7 -4
  32. package/docs/api/reference/cameras.md +3 -2
  33. package/docs/api/reference/controls.md +59 -2
  34. package/docs/api/reference/debug.md +58 -6
  35. package/docs/api/reference/engine.md +40 -10
  36. package/docs/api/reference/feature-draws.md +3 -4
  37. package/docs/api/reference/feature-effects.md +2 -3
  38. package/docs/api/reference/feature-instances.md +5 -4
  39. package/docs/api/reference/features.md +7 -4
  40. package/docs/api/reference/geometry.md +132 -21
  41. package/docs/api/reference/grass.md +62 -2
  42. package/docs/api/reference/impostors.md +120 -16
  43. package/docs/api/reference/input.md +1 -2
  44. package/docs/api/reference/lights.md +4 -3
  45. package/docs/api/reference/lines.md +3 -4
  46. package/docs/api/reference/materials.md +7 -6
  47. package/docs/api/reference/math.md +13 -2
  48. package/docs/api/reference/objects.md +2 -3
  49. package/docs/api/reference/particles.md +31 -6
  50. package/docs/api/reference/points.md +2 -3
  51. package/docs/api/reference/post.md +4 -3
  52. package/docs/api/reference/quality.md +1 -2
  53. package/docs/api/reference/raycast.md +1 -2
  54. package/docs/api/reference/render.md +4 -3
  55. package/docs/api/reference/scene.md +24 -5
  56. package/docs/api/reference/sketch.md +11 -11
  57. package/docs/api/reference/sound.md +33 -2
  58. package/docs/api/reference/splats.md +42 -3
  59. package/docs/api/reference/sprites.md +2 -3
  60. package/docs/api/reference/tasks.md +16 -3
  61. package/docs/api/reference/terrain.md +26 -5
  62. package/docs/api/reference/textures.md +1 -2
  63. package/docs/api/reference/three-compat.md +18 -7
  64. package/docs/api/reference/time.md +1 -2
  65. package/docs/api/reference/ui.md +10 -7
  66. package/docs/api/reference/vertex-draws.md +2 -3
  67. package/docs/api/reference/water.md +78 -5
  68. package/docs/api/reference/wind.md +15 -2
  69. package/docs/api/render.md +67 -25
  70. package/docs/api/scene.md +129 -36
  71. package/docs/api/sketch.md +45 -19
  72. package/docs/api/sound.md +48 -12
  73. package/docs/api/splats.md +42 -15
  74. package/docs/api/sprites.md +8 -6
  75. package/docs/api/tasks.md +31 -22
  76. package/docs/api/terrain.md +44 -12
  77. package/docs/api/textures.md +61 -12
  78. package/docs/api/three-compat.md +15 -7
  79. package/docs/api/time.md +3 -5
  80. package/docs/api/ui.md +18 -10
  81. package/docs/api/vertex-draws.md +13 -12
  82. package/docs/api/water.md +111 -67
  83. package/docs/api/wind.md +61 -15
  84. package/docs/cli/null3d.md +90 -15
  85. package/docs/concepts/architecture.md +69 -23
  86. package/docs/concepts/assets.md +57 -16
  87. package/docs/concepts/backends.md +68 -24
  88. package/docs/concepts/color-management.md +42 -13
  89. package/docs/concepts/culling.md +68 -47
  90. package/docs/concepts/handles.md +14 -5
  91. package/docs/concepts/instances.md +72 -23
  92. package/docs/concepts/large-worlds.md +17 -7
  93. package/docs/concepts/lighting.md +117 -44
  94. package/docs/concepts/lod.md +128 -33
  95. package/docs/concepts/materials.md +43 -12
  96. package/docs/concepts/particle-buffer.md +48 -35
  97. package/docs/concepts/post-processing.md +77 -14
  98. package/docs/concepts/quality-preset-tables.md +3 -2
  99. package/docs/concepts/quality-presets.md +122 -39
  100. package/docs/concepts/render-graph.md +56 -21
  101. package/docs/concepts/render-layers.md +9 -5
  102. package/docs/concepts/shadows.md +96 -25
  103. package/docs/concepts/static-dynamic.md +22 -7
  104. package/docs/cookbook/index.md +163 -119
  105. package/docs/data/threejs-mapping.json +301 -340
  106. package/docs/errors/E1101.md +23 -5
  107. package/docs/errors/E1102.md +11 -3
  108. package/docs/errors/E1103.md +11 -3
  109. package/docs/errors/E1104.md +11 -3
  110. package/docs/errors/E1105.md +13 -5
  111. package/docs/errors/E1106.md +11 -3
  112. package/docs/errors/E1107.md +15 -5
  113. package/docs/errors/E1108.md +11 -3
  114. package/docs/errors/E1109.md +32 -6
  115. package/docs/errors/E1110.md +23 -5
  116. package/docs/errors/E1111.md +11 -3
  117. package/docs/errors/E1112.md +11 -3
  118. package/docs/errors/E1203.md +12 -4
  119. package/docs/errors/E1204.md +11 -3
  120. package/docs/errors/E1205.md +11 -3
  121. package/docs/errors/E1206.md +28 -6
  122. package/docs/errors/E1207.md +11 -3
  123. package/docs/errors/E1208.md +12 -3
  124. package/docs/errors/E1209.md +11 -3
  125. package/docs/errors/E1213.md +27 -5
  126. package/docs/errors/E1214.md +11 -3
  127. package/docs/errors/E1215.md +31 -6
  128. package/docs/errors/E1216.md +31 -6
  129. package/docs/errors/E1217.md +29 -6
  130. package/docs/errors/E1218.md +22 -6
  131. package/docs/errors/E1219.md +11 -3
  132. package/docs/errors/E1220.md +24 -5
  133. package/docs/errors/E1221.md +24 -5
  134. package/docs/errors/E1222.md +11 -3
  135. package/docs/errors/E1223.md +39 -6
  136. package/docs/errors/E1224.md +11 -3
  137. package/docs/errors/E1225.md +11 -3
  138. package/docs/errors/E1301.md +11 -3
  139. package/docs/errors/E1302.md +11 -3
  140. package/docs/errors/E1303.md +11 -3
  141. package/docs/errors/E1304.md +11 -3
  142. package/docs/errors/E1305.md +13 -3
  143. package/docs/errors/E1306.md +11 -3
  144. package/docs/errors/E1307.md +23 -6
  145. package/docs/errors/E1308.md +31 -0
  146. package/docs/errors/E1401.md +11 -3
  147. package/docs/errors/E1402.md +13 -5
  148. package/docs/errors/E1403.md +11 -3
  149. package/docs/errors/E1404.md +13 -3
  150. package/docs/errors/E1405.md +15 -4
  151. package/docs/errors/E1406.md +31 -5
  152. package/docs/errors/E1407.md +11 -3
  153. package/docs/errors/E1408.md +11 -3
  154. package/docs/errors/E1409.md +11 -3
  155. package/docs/errors/E1410.md +13 -5
  156. package/docs/errors/E1411.md +11 -3
  157. package/docs/errors/E1412.md +29 -6
  158. package/docs/errors/E1413.md +11 -3
  159. package/docs/errors/E1414.md +11 -3
  160. package/docs/errors/E1415.md +11 -3
  161. package/docs/errors/E1416.md +27 -6
  162. package/docs/errors/E1417.md +11 -3
  163. package/docs/errors/E1418.md +12 -3
  164. package/docs/errors/E1419.md +13 -5
  165. package/docs/errors/E1420.md +11 -3
  166. package/docs/errors/E1421.md +11 -3
  167. package/docs/errors/E1422.md +12 -3
  168. package/docs/errors/E1423.md +12 -3
  169. package/docs/errors/E1424.md +24 -5
  170. package/docs/errors/E1425.md +11 -3
  171. package/docs/errors/E1426.md +11 -3
  172. package/docs/errors/E1430.md +11 -3
  173. package/docs/errors/E1431.md +11 -3
  174. package/docs/errors/E1432.md +11 -3
  175. package/docs/errors/E1433.md +11 -3
  176. package/docs/errors/E1434.md +15 -6
  177. package/docs/errors/E1435.md +11 -3
  178. package/docs/errors/E1436.md +11 -3
  179. package/docs/errors/E1437.md +14 -6
  180. package/docs/errors/E1501.md +41 -6
  181. package/docs/errors/E1502.md +13 -3
  182. package/docs/errors/E1503.md +11 -3
  183. package/docs/errors/E1504.md +11 -3
  184. package/docs/errors/E1505.md +23 -5
  185. package/docs/errors/E1506.md +11 -3
  186. package/docs/errors/index.md +53 -29
  187. package/docs/getting-started/cdn.md +15 -9
  188. package/docs/getting-started/first-scene.md +20 -12
  189. package/docs/getting-started/hosting.md +113 -63
  190. package/docs/getting-started/install.md +39 -24
  191. package/docs/getting-started/network-use.md +31 -21
  192. package/docs/getting-started/project-structure.md +20 -8
  193. package/docs/getting-started/third-party-notices.md +6 -10
  194. package/docs/guides/accessibility.md +4 -4
  195. package/docs/guides/add-ons.md +83 -13
  196. package/docs/guides/agents.md +13 -14
  197. package/docs/guides/assets-pipeline.md +294 -72
  198. package/docs/guides/audio.md +17 -15
  199. package/docs/guides/baked-light-data.md +44 -23
  200. package/docs/guides/car-paint.md +37 -31
  201. package/docs/guides/content-pages.md +86 -29
  202. package/docs/guides/custom-passes.md +59 -17
  203. package/docs/guides/custom-shaders.md +54 -37
  204. package/docs/guides/debugging.md +31 -41
  205. package/docs/guides/deploying.md +10 -27
  206. package/docs/guides/deterministic-simulation.md +23 -16
  207. package/docs/guides/first-use-shaders.md +83 -45
  208. package/docs/guides/lens-kit.md +29 -26
  209. package/docs/guides/loading-screens.md +74 -30
  210. package/docs/guides/multiple-views.md +22 -11
  211. package/docs/guides/performance.md +188 -37
  212. package/docs/guides/phones.md +71 -19
  213. package/docs/guides/physics.md +6 -10
  214. package/docs/guides/screens.md +41 -29
  215. package/docs/guides/start-time.md +126 -85
  216. package/docs/guides/testing.md +137 -98
  217. package/docs/guides/ui-overlays.md +17 -12
  218. package/docs/guides/video-textures.md +14 -13
  219. package/docs/images/api/animation/character.webp +0 -0
  220. package/docs/images/api/animation/look-at-ring.webp +0 -0
  221. package/docs/images/api/animation/morph-tulips.webp +0 -0
  222. package/docs/images/api/animation/skeleton-lines.webp +0 -0
  223. package/docs/images/api/controls/gizmo-handles.webp +0 -0
  224. package/docs/images/api/controls/walk-and-fly.webp +0 -0
  225. package/docs/images/api/debug/debug-shapes.webp +0 -0
  226. package/docs/images/api/debug/levels-view.webp +0 -0
  227. package/docs/images/api/engine/transparent-canvas.webp +0 -0
  228. package/docs/images/api/feature-draws/feature-draw-clouds.webp +0 -0
  229. package/docs/images/api/feature-instances/compute-instances.webp +0 -0
  230. package/docs/images/api/feature-instances/instances-shadow.webp +0 -0
  231. package/docs/images/api/geometry/extra-shapes.webp +0 -0
  232. package/docs/images/api/geometry/generators.webp +0 -0
  233. package/docs/images/api/geometry/mesh-arrays.webp +0 -0
  234. package/docs/images/api/geometry/vertex-updates.webp +0 -0
  235. package/docs/images/api/grass/grass-grove.webp +0 -0
  236. package/docs/images/api/grass/grass-presets.webp +0 -0
  237. package/docs/images/api/grass/grass-shadow.webp +0 -0
  238. package/docs/images/api/impostors/impostor-handover.webp +0 -0
  239. package/docs/images/api/impostors/impostor-shadow.webp +0 -0
  240. package/docs/images/api/impostors/impostors-forest.webp +0 -0
  241. package/docs/images/api/lights/spot-cookies.webp +0 -0
  242. package/docs/images/api/lines/lines-lit.webp +0 -0
  243. package/docs/images/api/lines/lines-widths.webp +0 -0
  244. package/docs/images/api/materials/coat-and-sheen.webp +0 -0
  245. package/docs/images/api/materials/decals.webp +0 -0
  246. package/docs/images/api/materials/iridescence-and-anisotropy.webp +0 -0
  247. package/docs/images/api/materials/relief.webp +0 -0
  248. package/docs/images/api/materials/shader-inputs.webp +0 -0
  249. package/docs/images/api/materials/standard-grid.webp +0 -0
  250. package/docs/images/api/materials/subsurface.webp +0 -0
  251. package/docs/images/api/materials/translucency.webp +0 -0
  252. package/docs/images/api/objects/objects-turntable.webp +0 -0
  253. package/docs/images/api/particles/campfire.webp +0 -0
  254. package/docs/images/api/points/galaxy.webp +0 -0
  255. package/docs/images/api/reference/textures/texture-wrap.webp +0 -0
  256. package/docs/images/api/render/fullscreen-glow.webp +0 -0
  257. package/docs/images/api/render/reflection-mirror.webp +0 -0
  258. package/docs/images/api/render/security-camera.webp +0 -0
  259. package/docs/images/api/scene/aurora-sky-layer.webp +0 -0
  260. package/docs/images/api/sound/sound-demo.webp +0 -0
  261. package/docs/images/api/splats/splats-demo.webp +0 -0
  262. package/docs/images/api/sprites/sprites-lines.webp +0 -0
  263. package/docs/images/api/terrain/terrain-demo.webp +0 -0
  264. package/docs/images/api/textures/canvas-screen.webp +0 -0
  265. package/docs/images/api/textures/mipmaps.webp +0 -0
  266. package/docs/images/api/vertex-draws/rain.webp +0 -0
  267. package/docs/images/api/water/ocean.webp +0 -0
  268. package/docs/images/api/water/water-demo.webp +0 -0
  269. package/docs/images/api/water/water-rain.webp +0 -0
  270. package/docs/images/api/water/waterfall.webp +0 -0
  271. package/docs/images/concepts/assets/gltf-model.webp +0 -0
  272. package/docs/images/concepts/color-management/tone-mapped.webp +0 -0
  273. package/docs/images/concepts/culling/far-from-origin.webp +0 -0
  274. package/docs/images/concepts/instances/instances.webp +0 -0
  275. package/docs/images/concepts/instances/per-row-colors.webp +0 -0
  276. package/docs/images/concepts/large-worlds/large-world.webp +0 -0
  277. package/docs/images/concepts/lighting/area-lights.webp +0 -0
  278. package/docs/images/concepts/lighting/atmosphere.webp +0 -0
  279. package/docs/images/concepts/lighting/environment.webp +0 -0
  280. package/docs/images/concepts/lighting/light-shafts.webp +0 -0
  281. package/docs/images/concepts/lighting/reflection-probes.webp +0 -0
  282. package/docs/images/concepts/lod/forest.webp +0 -0
  283. package/docs/images/concepts/materials/weighted-transparency.webp +0 -0
  284. package/docs/images/concepts/post-processing/auto-exposure.webp +0 -0
  285. package/docs/images/concepts/post-processing/bounce-light.webp +0 -0
  286. package/docs/images/concepts/post-processing/depth-of-field.webp +0 -0
  287. package/docs/images/concepts/post-processing/post-effects-alley.webp +0 -0
  288. package/docs/images/concepts/post-processing/sharpen.webp +0 -0
  289. package/docs/images/concepts/post-processing/ssr-wet-street.webp +0 -0
  290. package/docs/images/concepts/render-layers/layers-cottages.webp +0 -0
  291. package/docs/images/concepts/shadows/hero-shadow.webp +0 -0
  292. package/docs/images/cookbook/index/picking.webp +0 -0
  293. package/docs/images/cookbook/index/time-of-day.webp +0 -0
  294. package/docs/images/errors/E1431/area-lights-no-tables.webp +0 -0
  295. package/docs/images/guides/custom-passes/reflection-water.webp +0 -0
  296. package/docs/images/guides/deterministic-simulation/replay-demo.webp +0 -0
  297. package/docs/images/guides/multiple-views/split-screen.webp +0 -0
  298. package/docs/images/guides/performance/overdraw-view.webp +0 -0
  299. package/docs/images/guides/testing/hold-mode-frame.webp +0 -0
  300. package/docs/images/index/showcase-island.webp +0 -0
  301. package/docs/images/porting/threejs-shaders/dissolve.webp +0 -0
  302. package/docs/images/shaders/builtins/builtins.webp +0 -0
  303. package/docs/images/shaders/surface-functions/custom-surface.webp +0 -0
  304. package/docs/images/shaders/surface-functions/vertex-offset.webp +0 -0
  305. package/docs/images/shots.json +2231 -0
  306. package/docs/index.md +14 -23
  307. package/docs/moves.json +1 -0
  308. package/docs/nav.json +300 -0
  309. package/docs/pages.md +230 -212
  310. package/docs/porting/react-three-fiber.md +2 -6
  311. package/docs/porting/threejs-loop-and-threads.md +1 -5
  312. package/docs/porting/threejs-mapping.md +1248 -234
  313. package/docs/porting/threejs-materials.md +10 -5
  314. package/docs/porting/threejs-overview.md +26 -6
  315. package/docs/porting/threejs-postprocessing.md +2 -6
  316. package/docs/porting/threejs-shaders.md +16 -14
  317. package/docs/porting/threejs-unsupported.md +6 -6
  318. package/docs/porting/verification.md +0 -4
  319. package/docs/shaders/builtins.md +15 -4
  320. package/docs/shaders/library.md +9 -6
  321. package/docs/shaders/surface-functions.md +51 -16
  322. package/docs/shaders/wgsl-rules.md +12 -5
  323. package/lib/debug/debug.d.ts +2 -2
  324. package/lib/debug/draw.d.ts +2 -2
  325. package/lib/debug/draw.js +8 -4
  326. package/lib/debug/overlay-look.d.ts +6 -0
  327. package/lib/debug/overlay-look.js +29 -7
  328. package/lib/debug/overlay.js +15 -11
  329. package/lib/debug/stats-options.d.ts +13 -0
  330. package/lib/debug/stats-panel.d.ts +21 -6
  331. package/lib/debug/stats-panel.js +80 -13
  332. package/lib/errors/codes.d.ts +17 -3
  333. package/lib/errors/codes.js +116 -105
  334. package/lib/errors/engine-error.js +1 -1
  335. package/lib/errors/fixes.d.ts +1 -0
  336. package/lib/errors/fixes.js +19 -18
  337. package/lib/generated/shader-permutations.d.ts +6 -0
  338. package/lib/generated/shader-permutations.js +6 -0
  339. package/lib/gpu/variants.d.ts +8 -2
  340. package/lib/gpu/variants.js +39 -7
  341. package/lib/gpu/webgl2/programs.js +1 -1
  342. package/lib/gpu/webgpu/pipelines.js +13 -13
  343. package/lib/index.d.ts +1 -1
  344. package/lib/page/capabilities.d.ts +1 -1
  345. package/lib/page/engine.d.ts +29 -7
  346. package/lib/page/engine.js +79 -7
  347. package/lib/page/label-loop.js +9 -4
  348. package/lib/page/stats-switch.js +2 -0
  349. package/lib/page/switches.d.ts +6 -4
  350. package/lib/page/switches.js +20 -4
  351. package/lib/scene/baked-light.d.ts +2 -2
  352. package/lib/scene/fake-call-values.js +2 -2
  353. package/lib/scene/frame-cameras.d.ts +16 -4
  354. package/lib/scene/frame-cameras.js +28 -10
  355. package/lib/scene/gltf.d.ts +1 -1
  356. package/lib/scene/level-rule.d.ts +6 -5
  357. package/lib/scene/level-rule.js +2 -2
  358. package/lib/scene/particles.d.ts +7 -3
  359. package/lib/scene/particles.js +3 -1
  360. package/lib/scene/post.d.ts +3 -2
  361. package/lib/scene/resources.d.ts +15 -9
  362. package/lib/scene/scene.d.ts +18 -2
  363. package/lib/scene/scene.js +47 -5
  364. package/lib/scene/time-of-day.d.ts +10 -5
  365. package/lib/scene/time-of-day.js +11 -7
  366. package/lib/shader-artifact.json +1 -1
  367. package/lib/shared/labels.d.ts +5 -2
  368. package/lib/shared/labels.js +5 -2
  369. package/lib/shared/permutation-words.d.ts +8 -0
  370. package/lib/shared/permutation-words.js +14 -0
  371. package/lib/shared/recording.d.ts +13 -5
  372. package/lib/shared/recording.js +31 -10
  373. package/lib/shared/sketch-data.d.ts +9 -0
  374. package/lib/shared/sketch-data.js +57 -0
  375. package/lib/shared/tier.d.ts +9 -0
  376. package/lib/shared/tier.js +4 -1
  377. package/lib/shared/version.d.ts +1 -1
  378. package/lib/shared/version.js +1 -1
  379. package/lib/sketch/define-sketch.d.ts +16 -7
  380. package/lib/sketch/define-sketch.js +2 -1
  381. package/lib/sketch/runner.d.ts +4 -0
  382. package/lib/sketch/runner.js +5 -0
  383. package/lib/sketch/ui.js +4 -2
  384. package/lib/stats.d.ts +1 -0
  385. package/lib/workers/protocol.d.ts +10 -0
  386. package/lib/workers/render-worker.js +4 -1
  387. package/lib/workers/sketch-worker.js +4 -1
  388. package/package.json +1 -1
@@ -1,15 +1,11 @@
1
1
  ---
2
2
  id: guides/deterministic-simulation
3
3
  title: Using null3D with a deterministic simulation
4
- status: experimental
5
- since: "0.3"
6
4
  summary: "The maths entry a simulation may import; createMath with an exact math library; input, picking and physics that decide a result stay out of the sketch; createEngine's input option; a camera that the player aims from recorded input; a production build of a game's engine files."
7
5
  ---
8
6
 
9
7
  # Using null3D with a deterministic simulation
10
8
 
11
- > Roadmap step 0.3, first released in null3D 0.1.0. The API is experimental, so it can still change between versions.
12
-
13
9
  ```mermaid
14
10
  flowchart LR
15
11
  recorder["A library on the page<br/>records the player's input"] --> simulation["The simulation steps by ticks:<br/>@null3d/engine/math and<br/>createMath on an exact library"]
@@ -53,7 +49,14 @@ export function stepShip(position: number[], heading: number[], thrust: number):
53
49
  }
54
50
  ```
55
51
 
56
- Never import `@null3d/engine` itself in simulation code. Bun 1.4.3 bundles six helpers from it into 9,133 bytes, against 1,202 bytes from the sub-paths. The rest is engine code that the simulation never calls, with a top-level `FinalizationRegistry`, which a replaying engine's scan refuses. A bundler that keeps each re-exported namespace whole brings far more. Bun 1.3.11 does, and its bundle of the same six takes 87,857 bytes, with `Atomics`, `document`, `navigator`, `requestAnimationFrame`, and helpers that call `Math.sin`, `Math.cos`, `Math.acos`, `Math.exp` and `Math.random`.
52
+ Never import `@null3d/engine` itself in simulation code. A bundler that drops unused code still keeps engine code that runs at load, such as a `FinalizationRegistry`. A replay that checks the simulation's bundle for page-only APIs refuses it. A bundler that keeps whole namespaces also brings page APIs, and helpers that call `Math.sin` and `Math.random`.
53
+
54
+ <details>
55
+ <summary>Technical details: measured bundle sizes</summary>
56
+
57
+ Bun 1.4.3 bundles six helpers from the full entry into 9,133 bytes, against 1,202 bytes from the sub-paths. Bun 1.3.11, which keeps whole re-exported namespaces, takes 87,857 bytes for the same six, with `Atomics`, `document`, `navigator`, `requestAnimationFrame`, and helpers that call `Math.sin`, `Math.cos`, `Math.acos`, `Math.exp` and `Math.random`.
58
+
59
+ </details>
57
60
 
58
61
  The maths entry leaves out four groups:
59
62
 
@@ -64,7 +67,7 @@ The maths entry leaves out four groups:
64
67
 
65
68
  ## Angles and exponentials: createMath
66
69
 
67
- `createMath({ sin, cos, acos, exp })` returns the eight helpers that the maths entry leaves out, built on the four functions that you pass. Pass an exact math library's functions, which give the same bits on every JavaScript engine. clockwork2's `dmath` is one:
70
+ `createMath({ sin, cos, acos, exp })` returns the eight helpers that the maths entry leaves out, built on the four functions that you pass. Pass an exact math library's functions, which give the same bits on every JavaScript engine. The `dmath` entry of the [@clockwork2/engine](https://www.npmjs.com/package/@clockwork2/engine) package is one, and the [deterministic simulation demo](https://github.com/null3d-engine/null3d/tree/main/examples/replay) uses it:
68
71
 
69
72
  ```ts
70
73
  // sim/turn.ts: simulation code
@@ -107,7 +110,7 @@ The sketch still draws with the main entry's helpers, which use the browser's `M
107
110
 
108
111
  ## Input that another library records
109
112
 
110
- `createEngine({ input: false })` keeps the engine from listening for input. The engine then adds no listener that takes input: none for pointers, keys, the wheel, focus, the pointer lock or gamepads. It captures no pointer on the canvas, and leaves the canvas's context menu to the browser. It keeps its listeners that take no input, such as the `visibilitychange` that keeps a hidden page's time out of the sketch's steps. [Input off](../api/input.md#input-off) lists them. The library that records the player's input listens alone.
113
+ `createEngine({ input: false })` keeps the engine from listening for input. The engine then adds no listener that takes input: none for pointers, keys, the wheel, focus, the pointer lock or gamepads. [Input off](../api/input.md#input-off) lists them. The library that records the player's input listens alone. The [deterministic simulation demo](https://github.com/null3d-engine/null3d/tree/main/examples/replay) takes its input on the page, and the [input demo](https://github.com/null3d-engine/null3d/tree/main/examples/input) binds an action map to the keyboard and a gamepad.
111
114
 
112
115
  ```ts
113
116
  // page.ts
@@ -130,6 +133,10 @@ The sketch's `ctx.input` then stays at rest. Every key, button and action is up,
130
133
 
131
134
  A game whose result depends on where the player looks records the look as input. An example is a game that scores what the player aims at. The camera is then the simulation's, and the sketch only draws it:
132
135
 
136
+ ![A walled court at dusk with glowing gold orbs, seen from the player's start point in the deterministic simulation demo.](../images/guides/deterministic-simulation/replay-demo.webp)
137
+
138
+ The run's start, built from the seed.
139
+
133
140
  1. The page's input code locks the pointer on the canvas with `canvas.requestPointerLock()`, in a click handler. When a drag also turns the view, ask only on a click that barely moved, since a drag ends in a click too. Read `document.pointerLockElement` at each event, since a press can come before `pointerlockchange` does. Take no pointer capture under the lock: the browser refuses one with an `InvalidStateError`. The engine's own `requestPointerLock()` belongs to its input, and fails with [E1426](../errors/E1426.md) when that is off.
134
141
  2. Each tick, the page records the mouse's movement since the last tick as whole counts, and carries the fraction to the next tick. A browser can report a fraction of a pixel, and the log holds what the simulation reads.
135
142
  3. The simulation turns the counts into a yaw and a pitch, and builds the camera's rotation with `createMath`'s `quat.fromEuler`.
@@ -163,7 +170,9 @@ export function step(state: State, counts: number): void {
163
170
 
164
171
  ## Sending the state to the sketch
165
172
 
166
- The page sends the simulation's state with `engine.postToSketch`. The sketch takes it with `page.onMessage`, as [Messages between the page and the sketch](../api/page.md) shows, and draws it in `onUpdate`. Send only the numbers that the sketch draws, in a small typed array. Send a new array each time: a sketch on the page's thread gets the very array that the page sent. When the sketch runs in a worker, the browser copies each message's data.
173
+ The page sends the simulation's state with `engine.postToSketch`. The sketch takes it with `page.onMessage`, as [Messages between the page and the sketch](../api/page.md) shows, and draws it in `onUpdate`.
174
+
175
+ Send only the numbers that the sketch draws, in a small typed array. Send a new array each time: a sketch on the page's thread gets the very array that the page sent. When the sketch runs in a worker, the browser copies each message's data.
167
176
 
168
177
  Until the first state arrives, as in a held frame, the sketch can draw the run's start. It imports the simulation's start function and builds the first state from the same seed, and it never steps the state.
169
178
 
@@ -209,17 +218,15 @@ export default defineConfig({
209
218
 
210
219
  The game's module then imports `createEngine` and `SKETCH` from the folder's `entry.js`, and passes `SKETCH` as the `sketch` option. The plugin also writes `null3d-files.json`, which lists the files that the start loads and those of each feature, as [Hosting](../getting-started/hosting.md) describes.
211
220
 
212
- The shader modules decide most of the folder's size. Build only the shader permutation words that the game draws with:
213
-
214
- 1. Record the words from a run of the game's page, as [Build only the shader permutations you draw with](assets-pipeline.md#build-only-the-shader-permutations-you-draw-with) shows. Name the game's pages with `--page`, or `--live` for a page that the recorder drives through its states. Record on both GPU paths, and at the low and high presets.
215
- 2. In a checkout of null3D, build the shader modules from the list: `NULL3D_SHADER_PERMUTATIONS=<list> bun run shaders`. The checkout's `packages/engine/src/generated` then holds them.
216
- 3. Build the game with `NULL3D_ENGINE_SHADERS` set to that folder, such as `NULL3D_ENGINE_SHADERS=<checkout>/packages/engine/src/generated bunx vite build`. The plugin then takes the narrowed modules in place of the full set.
221
+ The shader modules decide most of the folder's size. Copy only the builds of the shader permutation words that the game draws with:
217
222
 
218
- A game whose page module another build makes records differently from a sketch page. Its engine starts on a click, so name its page with `--live` and give the recorder the start control: `--click "#play"`. Its files folder is a production build, and a production build ignores `?permutations`, `?gpu` and `?preset`. Record against a development build of that folder (`vite build --mode development`). Then build the narrowed set, and rebuild the folder in production. A real game recorded this way drew with 5 words, and its folder held 300 files and 26 MB. The same folder built with the 172-word example list held 762 files and 226 MB.
223
+ 1. Build a development copy of the folder (`bunx vite build --mode development`). A production build ignores `?permutations`, `?gpu` and `?preset`, so a recording of it holds nothing.
224
+ 2. Record the words from a run of the game's page, as [Build only the shader permutations you draw with](assets-pipeline.md#build-only-the-shader-permutations-you-draw-with) shows. The game's engine starts on a click, so name its page with `--live` and give the recorder the start control. Serve the game with its development folder, and give the recorder its address: `bunx @null3d/cli shaders record --base http://localhost:8080 --live /game.html --click "#play"`.
225
+ 3. Name the list in the engine folder's config, as `null3d({ shaders: { list: 'shader-permutations.txt' } })`, and build the folder in production again. The build copies only the listed builds, from the release asset, and compiles nothing.
219
226
 
220
- The shader modules in a release asset are the full set. A game that builds against that asset and names no list copies every module into its files folder. That can exceed the folder's file and byte limits. Narrow the set first.
227
+ With null3D 0.1.0's shader set, a small scene drew with 6 words. Its build copied 218 shader files and 17 MB, against 7,597 files and 4,115 MB without a list. Build the set again after each engine upgrade.
221
228
 
222
- A small game scene with three lanes and a ship drew with 5 words. Its folder held 297 files and 26,057,130 bytes, 4,737,421 after Brotli. The same folder built with the 172 words of null3D's examples held 759 files and 225,683,678 bytes. The full set of shader modules is 4,117,799,356 bytes. Record again after the game gains a feature that turns on a new word. The engine names a word that the set lacks the first time a pipeline needs it.
229
+ The shader modules in a release asset are the full set. A game that builds against that asset without a list copies every module into its files folder. The build then warns with the size that it copied. That can exceed the folder's file and byte limits. Record again after the game gains a feature that turns on a new word. The engine names a word that the list lacks the first time a pipeline needs it.
223
230
 
224
231
  ## API reference
225
232
 
@@ -1,8 +1,7 @@
1
1
  ---
2
2
  id: guides/first-use-shaders
3
3
  title: Shaders that load on first use
4
- status: generated
5
- since: "0.1"
4
+ generated: true
6
5
  summary: "The features whose shaders download on first use, which createEngine's preload takes."
7
6
  ---
8
7
 
@@ -12,46 +11,85 @@ summary: "The features whose shaders download on first use, which createEngine's
12
11
 
13
12
  Most shaders come with the engine's start. The shaders of each feature below download the first time the sketch uses the feature. `createEngine`'s `preload` option takes these names, and loads their shaders before the first frame.
14
13
 
15
- | Feature | Its shaders download |
16
- | --- | --- |
17
- | `'decals'` | with the first mesh of a decal material (`materials.decal`) |
18
- | `'probe_grid'` | when the sketch first sets a light probe grid (`scene.setLightProbeGrid`) |
19
- | `'sprites'` | with the first sprite batch |
20
- | `'particles'` | with the first particle system (`@null3d/particles`) |
21
- | `'lines'` | with the first line batch |
22
- | `'texcoords'` | only in the engine's own tests, which draw meshes colored by their texture coordinates |
23
- | `'effect_groups'` | the first time custom effects join into one pass, or fold into the final pass. Until its shaders are built, each effect draws a pass of its own |
24
- | `'bloom'` | when `post.set` turns bloom on |
25
- | `'picking'` | with the first `scene.pick()` call, which waits for the shaders |
26
- | `'ao'` | when `post.set` turns ambient occlusion on, or with the first opaque material where the preset draws the screen-space bounce light that reads its steps |
27
- | `'dof'` | when `post.set` turns depth of field on |
28
- | `'subsurface'` | with the first material whose light spreads under its surface (`subsurfaceRadius`). The skin pass and the blur draw its light |
29
- | `'exposure'` | when `post.set` turns automatic exposure on. The camera keeps its own exposure until the meter is built |
30
- | `'fog_volume'` | when `scene.setFog` turns the volumetric fog on. The fog keeps its sun glow until the fog is built |
31
- | `'taa'` | when `post.set` turns the temporal resolve on, a prototype for measuring only (D-206) |
32
- | `'views'` | with the first scene pass. Its texture shows nothing until its shaders are built |
33
- | `'color_copy'` | with the first step that reads the color that the frame before showed: the first material that lets light through, screen-space reflections, or the bounce light that the preset draws, whose file downloads with the first opaque material |
34
- | `'transmission'` | with the first material that lets light through (`transmission`) |
35
- | `'coat_sheen'` | with the first material with a clear coat, a sheen, iridescence or anisotropy |
36
- | `'weighted'` | with the first material of the `'weighted'` blending |
37
- | `'single_layer'` | with MSAA, when the first blended draw of a feature at the `'resolve'` frame point draws. Its surfaces blend in the transparent pass until the layer is built |
38
- | `'moment'` | when the quality setting `momentTransparency` is on and the first blended surface draws. The surfaces draw sorted until the layer and its anti-aliasing are built |
39
- | `'area_lights'` | with the first rectangle or tube light |
40
- | `'translucency'` | with the first material that lets light through a thin surface (`diffuseTransmission`) |
41
- | `'cutout'` | with the first masked object that casts shadows. It casts none until its shaders are built |
42
- | `'cluster_levels'` | with the first frame that draws a tree of cluster patches (`setMeshPatches`), which builds the pass that picks a tree of patches. A scene without a tree downloads none of it, and WebGL2 never builds that pass |
43
- | `'motion'` | when a pass first reads the motion. The motion debug view is such a pass, and it exists in development builds only |
44
- | `'background'` | with the first texture, environment or cube map background |
45
- | `'sky'` | with the first sky background |
46
- | `'clouds'` | with the first sky background with clouds while `cloudSteps` is above 0, as High and Ultra set it, or with the first frame that draws the sky's volumetric cloud tier after `quality.set({ cloudSteps })`. A page that draws the flat layer downloads none of it. The noise field of its march is made in the browser when the tier first draws |
47
- | `'physical_sky'` | with the first physical sky background (`atmosphere`). The view shows the background color until the sky is built |
48
- | `'skinning'` | with the first skinned mesh, or as soon as the sketch reads a glTF file with skins |
49
- | `'morph'` | with the first morphed mesh, or as soon as the sketch reads a glTF file with morph targets. WebGPU morphs in the skinning pass, so there `'morph'` downloads the skinning shaders |
50
- | `'coverage'` | with the first masked material that MSAA smooths with alpha to coverage |
51
- | `'hash'` | with the first material whose alpha mode is `'hash'` |
52
- | `'instance_index'` | only in the engine's own tests, through a test switch of WebGPU's instance data |
53
- | `'row_values'` | with the first instance batch whose rows have colors or values (`colors: true` or `values: true`) |
54
- | `'displacement'` | with the first material with a displacement map, which also loads the builds of parallax. Its mesh draws nothing until they are built |
55
- | `'bump'` | with the first material with a bump map |
56
- | `'lod_fade'` | with the first mesh whose levels of detail fade, or whose distance bands fade. The quality setting `lodFade` turns the bands' fades off on Low, not a level's fade |
57
- | `'occlusion'` | with the first opaque material while GPU occlusion culling runs on WebGPU. Until its shaders are built, the engine draws without it. WebGL2 has no such shaders |
14
+ ## Post-processing
15
+
16
+ | Feature | Its shaders download | Until they are built |
17
+ | --- | --- | --- |
18
+ | `'ao'` | when `post.set` turns ambient occlusion on, or with the first opaque material where the preset draws the screen-space bounce light that reads its steps | |
19
+ | `'bloom'` | when `post.set` turns bloom on | |
20
+ | `'dof'` | when `post.set` turns depth of field on | |
21
+ | `'effect_groups'` | the first time custom effects join into one pass, or fold into the final pass | Until its shaders are built, each effect draws a pass of its own |
22
+ | `'exposure'` | when `post.set` turns automatic exposure on | The camera keeps its own exposure until the meter is built |
23
+ | `'fog_volume'` | when `scene.setFog` turns the volumetric fog on | The fog keeps its sun glow until the fog is built |
24
+ | `'taa'` | only by an internal test option of temporal anti-aliasing, which the public API does not offer | No quality preset turns it on, so a page never downloads these shaders, and preloading `'taa'` only adds to the download |
25
+
26
+ ## Materials
27
+
28
+ | Feature | Its shaders download | Until they are built |
29
+ | --- | --- | --- |
30
+ | `'bump'` | with the first material with a bump map | |
31
+ | `'coat_sheen'` | with the first material with a clear coat, a sheen, iridescence or anisotropy | |
32
+ | `'decals'` | with the first mesh of a decal material (`materials.decal`) | |
33
+ | `'displacement'` | with the first material with a displacement map, which also loads the builds of parallax | Its mesh draws nothing until they are built |
34
+ | `'particles'` | with the first particle system (`@null3d/particles`) | |
35
+ | `'subsurface'` | with the first material whose light spreads under its surface (`subsurfaceRadius`) | The skin pass and the blur draw its light |
36
+
37
+ ## Transparency
38
+
39
+ | Feature | Its shaders download | Until they are built |
40
+ | --- | --- | --- |
41
+ | `'coverage'` | with the first masked material that MSAA smooths with alpha to coverage | |
42
+ | `'cutout'` | with the first masked object that casts shadows | It casts none until its shaders are built |
43
+ | `'hash'` | with the first material whose alpha mode is `'hash'` | |
44
+ | `'moment'` | when the quality setting `momentTransparency` is on and the first blended surface draws | The surfaces draw sorted until the layer and its anti-aliasing are built |
45
+ | `'single_layer'` | with MSAA, when the first blended draw of a feature at the `'resolve'` frame point draws | Its surfaces blend in the transparent pass until the layer is built |
46
+ | `'translucency'` | with the first material that lets light through a thin surface (`diffuseTransmission`) | |
47
+ | `'transmission'` | with the first material that lets light through (`transmission`) | |
48
+ | `'weighted'` | with the first material of the `'weighted'` blending | |
49
+
50
+ ## Lights and shadows
51
+
52
+ | Feature | Its shaders download | Until they are built |
53
+ | --- | --- | --- |
54
+ | `'area_lights'` | with the first rectangle or tube light | |
55
+ | `'occlusion'` | with the first opaque material while GPU occlusion culling runs on WebGPU | Until its shaders are built, the engine draws without it. WebGL2 has no such shaders |
56
+ | `'probe_grid'` | when the sketch first sets a light probe grid (`scene.setLightProbeGrid`) | |
57
+
58
+ ## Sky and background
59
+
60
+ | Feature | Its shaders download | Until they are built |
61
+ | --- | --- | --- |
62
+ | `'background'` | with the first texture, environment or cube map background | |
63
+ | `'clouds'` | with the first sky background with clouds while `cloudSteps` is above 0, as High and Ultra set it, or with the first frame that draws the sky's volumetric cloud tier after `quality.set({ cloudSteps })` | A page that draws the flat layer downloads none of it. The noise field of its march is made in the browser when the tier first draws |
64
+ | `'physical_sky'` | with the first physical sky background (`atmosphere`) | The view shows the background color until the sky is built |
65
+ | `'sky'` | with the first sky background | |
66
+
67
+ ## Meshes and animation
68
+
69
+ | Feature | Its shaders download | Until they are built |
70
+ | --- | --- | --- |
71
+ | `'lines'` | with the first line batch | |
72
+ | `'lod_fade'` | with the first mesh whose levels of detail fade, or whose distance bands fade | The quality setting `lodFade` turns the bands' fades off on Low, not a level's fade |
73
+ | `'morph'` | with the first morphed mesh, or as soon as the sketch reads a glTF file with morph targets | WebGPU morphs in the skinning pass, so there `'morph'` downloads the skinning shaders |
74
+ | `'picking'` | with the first `scene.pick()` call | which waits for the shaders |
75
+ | `'row_values'` | with the first instance batch whose rows have colors or values (`colors: true` or `values: true`) | |
76
+ | `'skinning'` | with the first skinned mesh, or as soon as the sketch reads a glTF file with skins | |
77
+ | `'sprites'` | with the first sprite batch | |
78
+
79
+ ## Engine passes
80
+
81
+ | Feature | Its shaders download | Until they are built |
82
+ | --- | --- | --- |
83
+ | `'cluster_levels'` | with the first frame that draws a tree of cluster patches (`setMeshPatches`), which builds the pass that picks a tree of patches | A scene without a tree downloads none of it, and WebGL2 never builds that pass |
84
+ | `'color_copy'` | with the first step that reads the color that the frame before showed: the first material that lets light through, screen-space reflections, or the bounce light that the preset draws | whose file downloads with the first opaque material |
85
+ | `'motion'` | when a pass first reads the motion | The motion debug view is such a pass, and it exists in development builds only |
86
+ | `'views'` | with the first scene pass | Its texture shows nothing until its shaders are built |
87
+
88
+ ## Engine tests
89
+
90
+ A page never needs these features.
91
+
92
+ | Feature | Its shaders download | Until they are built |
93
+ | --- | --- | --- |
94
+ | `'instance_index'` | only in the engine's own tests, through a test switch of WebGPU's instance data | |
95
+ | `'texcoords'` | only in the engine's own tests, which draw meshes colored by their texture coordinates | |
@@ -1,15 +1,11 @@
1
1
  ---
2
2
  id: guides/lens-kit
3
3
  title: Lens kit
4
- status: experimental
5
- since: "0.3"
6
- summary: "One look for the camera's marks: a grade, a sharpening, a vignette, film grain, color fringes, an anamorphic streak read from bloom, and a speed blur."
4
+ summary: "An example add-on you copy: one look for the camera's marks: a grade, a sharpening, a vignette, film grain, color fringes, an anamorphic streak read from bloom, and a speed blur."
7
5
  ---
8
6
 
9
7
  # Lens kit
10
8
 
11
- > Roadmap step 0.3, first released in null3D 0.1.0. The API is experimental, so it can still change between versions.
12
-
13
9
  The lens kit gives a scene one camera look. It sets the engine's own grade, sharpening and
14
10
  vignette from one object. It draws the camera's smaller marks in a single full-screen effect: film
15
11
  grain, color fringes, an anamorphic streak and a radial speed blur. A mark that a look leaves at 0
@@ -30,21 +26,24 @@ an npm package. Copy the folder into your project and import its entry point.
30
26
  ## Use it
31
27
 
32
28
  ```ts
29
+ import { defineSketch } from '@null3d/engine';
33
30
  import { createLensKit } from './addons/lens-kit';
34
31
 
35
- const lens = createLensKit(ctx, {
36
- sharpen: 0.35,
37
- vignette: { intensity: 0.55, size: 1.05, falloff: 2.2 },
38
- grading: { lift: [-0.02, -0.02, -0.02], gain: [1.05, 1.05, 1.05], saturation: 1.08 },
39
- bloomLevel: 2,
40
- aberration: 0.8,
41
- streak: 0.45,
42
- grain: 0.045,
43
- speedBlur: 0,
32
+ export default defineSketch((ctx) => {
33
+ const lens = createLensKit(ctx, {
34
+ sharpen: 0.35,
35
+ vignette: { intensity: 0.55, size: 1.05, falloff: 2.2 },
36
+ grading: { lift: [-0.02, -0.02, -0.02], gain: [1.05, 1.05, 1.05], saturation: 1.08 },
37
+ bloomLevel: 2,
38
+ aberration: 0.8,
39
+ streak: 0.45,
40
+ grain: 0.045,
41
+ speedBlur: 0,
42
+ });
43
+
44
+ // Later, change part of the look. A value that a call leaves out keeps its own.
45
+ lens.set({ vignette: false });
44
46
  });
45
-
46
- // Later, change part of the look. A value that a call leaves out keeps its own.
47
- lens.set({ vignette: false });
48
47
  ```
49
48
 
50
49
  ## Options
@@ -104,16 +103,18 @@ a look leaves at 0 skips its reads. The fringes take 2, the streak 10 and the sp
104
103
  grain takes none. A look with only the grain therefore pays no neighbor read. A look with every mark
105
104
  at 0, such as one that wants the grade alone, adds no pass at all.
106
105
 
107
- The grade and the vignette run inside the final pass and add no pass of their own. The sharpening at
108
- the whole canvas's render scale adds the first step of the two-step pass, as any `sharpen` value
109
- does. Below the whole canvas's render scale, effects do not join passes, so each draws one.
106
+ The grade and the vignette run inside the final pass and add no pass of their own. The sharpening adds one full-screen pass, about 1 ms at the size below.
107
+
108
+ On a MacBook Pro with an Apple M3 Max, the canvas is 3840 by 2160 CSS pixels with the pixel ratio held at 2. That draws 33 megapixels. There the whole look costs about 3 to 4 ms of GPU time a frame, on WebGPU and in compatibility mode. The cost follows the pixels: a megapixel costs about a tenth of a millisecond. The add-on's README gives the figure at each preset and for each mark.
109
+
110
+ <details>
111
+ <summary>Technical details: how the kit's passes join, and WebGL2</summary>
112
+
113
+ The sharpening reads display color, so it splits the final pass into two steps at every render scale ([Sharpening](../concepts/post-processing.md#sharpening)). Below the whole canvas's render scale, the kit's last effect does not fold into the final pass, so it draws a pass of its own ([Below the whole canvas's render scale](../concepts/post-processing.md#below-the-whole-canvass-render-scale)).
114
+
115
+ WebGL2 keeps no figure for the whole look. Its whole-frame timer reads about 9 ms and varies by about 1 ms between rounds, which hides the look's own cost. The README gives WebGL2 a figure for each mark instead.
110
116
 
111
- On a MacBook Pro with an M3 Max, the canvas is 3840 by 2160 CSS pixels with the pixel ratio held at
112
- 2. That draws 33 megapixels. There the whole look costs about 3 to 4 ms of GPU time a frame, on
113
- WebGPU and in compatibility mode. The cost follows the pixels: a megapixel costs about a tenth of
114
- a millisecond. WebGL2 keeps no figure for the whole look, because its cleared frame moves by more
115
- than the look there. Its marks stand instead. The add-on's README holds the figure at each preset
116
- and for each mark.
117
+ </details>
117
118
 
118
119
  ## Limits
119
120
 
@@ -132,3 +133,5 @@ and for each mark.
132
133
  - [Color grading](../api/post.md): the grading controls that the kit sets.
133
134
  - [The post effects demo](https://github.com/null3d-engine/null3d/tree/main/examples/post-effects): a
134
135
  neon alley whose look comes from the kit.
136
+ - [The Skyway showcase](https://github.com/null3d-engine/null3d/tree/main/examples/showcase/skyway): its
137
+ speed blur follows the hover car's speed.
@@ -1,15 +1,11 @@
1
1
  ---
2
2
  id: guides/loading-screens
3
3
  title: Loading screens and warm-up
4
- status: experimental
5
- since: "0.1"
6
4
  summary: "The download list; preload; onProgress; loads one after another; scene.warmUp; shader files that load up front; the preset check during play or before it; upload budgets; switching presets behind a loading screen."
7
5
  ---
8
6
 
9
7
  # Loading screens and warm-up
10
8
 
11
- > Roadmap step 0.1, first released in null3D 0.1.0. The API is experimental, so it can still change between versions.
12
-
13
9
  ```mermaid
14
10
  flowchart LR
15
11
  start["createEngine starts<br/>the core and the sketch"] --> preload["The sketch's listed files download<br/>while the engine starts"]
@@ -20,11 +16,13 @@ flowchart LR
20
16
  first --> check["The preset check in the first frames of play:<br/>a lighter preset if the GPU is slow,<br/>skipped on a repeat visit"]
21
17
  ```
22
18
 
23
- A loading screen covers the canvas while the engine starts and the sketch loads its files. It stays while the sketch builds its scene and the GPU gets ready to draw it. The page draws the screen in HTML, and the sketch tells it how far loading has come with messages. Then comes warm-up: the GPU builds a pipeline for each kind of object in the scene. When the engine chose the quality preset itself, it then checks that the GPU draws the scene fast enough at that preset. By default it checks in the first moments of play, so the loading screen does not wait for it.
19
+ A loading screen covers the canvas while the engine starts and the sketch loads its files. It stays while the sketch builds its scene and the GPU gets ready to draw it. The page draws the screen in HTML, and the sketch tells it how far loading has come with messages.
20
+
21
+ Then comes warm-up: the GPU builds a pipeline for each kind of object in the scene. When the engine chose the quality preset itself, it then checks that the GPU draws the scene fast enough at that preset. By default it checks in the first moments of play, so the loading screen does not wait for it.
24
22
 
25
23
  ## Report progress from the sketch
26
24
 
27
- The `downloads` option of `defineSketch` names the files that the setup loads. A live start begins to download them as soon as the sketch's module has loaded, often while the engine's core still downloads. The handler of `assets.onProgress` counts them as they arrive, including the bytes that arrived before the setup added it. The setup's loads take the files that arrived or are on their way, so nothing downloads twice.
25
+ The `downloads` option of `defineSketch` names the files that the setup loads. A live start begins to download them as soon as the sketch's module has loaded, often while the engine's core still downloads. The handler of `assets.onProgress` counts them as they arrive, including the bytes that arrived before the setup added it. The setup's loads take the files that arrived or are on their way, so nothing downloads twice. The [glTF model demo](https://github.com/null3d-engine/null3d/tree/main/examples/gltf-model) reports its downloads through the shared loading helper.
28
26
 
29
27
  ```ts
30
28
  // sketch.ts
@@ -54,11 +52,15 @@ export default defineSketch(
54
52
  );
55
53
  ```
56
54
 
57
- List the files in the order that the setup needs them, and name only the files that the first frame waits for. Two listed files download at a time, so the engine's own files, such as the first frame's shaders, still find free connections to the server. A load of a later file moves it to the front of the list. Up to four listed files then download while loads wait for them. [The download list](../api/sketch.md#the-download-list) gives the rules. Start the files that the first frame does not need when the sketch's `engine.firstFrame` resolves. They then leave the network to the first frame's files ([The engine field](../api/sketch.md#the-engine-field)). For a later stage that loads during play, `assets.preload` downloads its files together when the call runs.
55
+ List the files in the order that the setup needs them, and name only the files that the first frame waits for. Two listed files download at a time, so the engine's own files, such as the first frame's shaders, still find free connections to the server. When the setup loads a listed file that has not started, that file goes first. It starts at once, unless four listed files already download. [The download list](../api/sketch.md#the-download-list) gives the rules.
56
+
57
+ Start the files that the first frame does not need when the sketch's `engine.firstFrame` resolves. They then leave the network to the first frame's files ([The engine field](../api/sketch.md#the-engine-field)). For a later stage that loads during play, `assets.preload` downloads its files together when the call runs.
58
58
 
59
59
  A development build watches the setup's loads. It warns once when a load started its download only after another load's file had arrived, while no other file downloaded. The warning names both files. Start both loads before you await either, as `Promise.all` does above, or name both in `downloads`. When the second address comes from the first file's contents, the order is needed: pass `serialLoadWarning: false` to turn the warning off ([Loads one after another](../api/sketch.md#loads-one-after-another)).
60
60
 
61
- The handler gets the bytes downloaded so far and the bytes expected so far. The total is the length of each response that announced one, so it grows as the scene starts more files. A file that fails counts as done, so the bar still reaches its end. The failed load rejects with an error that says what went wrong. [Assets](../api/assets.md) covers the loading calls and their errors.
61
+ The handler gets the bytes downloaded so far and the bytes expected so far. The total is the length of each response that announced one, so it grows as the scene starts more files.
62
+
63
+ A file that fails counts as done, so the bar still reaches its end. The failed load rejects with an error that says what went wrong. [Assets](../api/assets.md) covers the loading calls and their errors.
62
64
 
63
65
  [A fast start](start-time.md) gives what each of these steps saved on a phone's connection.
64
66
 
@@ -66,7 +68,9 @@ The handler gets the bytes downloaded so far and the bytes expected so far. The
66
68
 
67
69
  The page passes `onSketchMessage` to `createEngine`, so it hears the messages that the sketch sends during its setup. It removes the loading screen when `engine.firstFrame` resolves: until the GPU has finished the first frame, the canvas is blank. When the promise rejects, the engine stopped before that frame, and the screen shows the error instead.
68
70
 
69
- A percentage must come from work that is counted. `onProgress` gives the engine core's bytes, measured against the length that the server announced. `assets.onProgress` gives a scene's files the same way. Neither knows how much of the whole start is left. So the page measures each phase on its own, and it names the phase beside its number. Within a phase the percentage never falls. A scene's total grows as it starts more files, so the bytes that arrived can be a smaller share than before. Across the whole start the figure can fall: a counted phase that ends returns the card to the engine's stage, and a later file starts a new measure under the same label.
71
+ A percentage must come from work that is counted. `onProgress` gives the engine core's bytes, measured against the length that the server announced. `assets.onProgress` gives a scene's files the same way. Neither knows how much of the whole start is left.
72
+
73
+ So the page measures each phase on its own, and it names the phase beside its number. Within a phase the bar never falls, even when a scene's total grows as it starts more files. When the label changes, a new measure starts from 0, as `show` does below.
70
74
 
71
75
  ```ts
72
76
  // page.ts
@@ -131,32 +135,34 @@ The engine's benchmark scenes need 2 to 4 pipelines each. In the engine's warm-u
131
135
 
132
136
  On a first visit, the browser compiles every shader. On a repeat visit, it reuses what it compiled before. The S4 benchmark, a town with a shadow-casting sun, was the slowest scene on each device.
133
137
 
134
- A larger scene needs many more pipelines, because each pass, effect and custom material adds its own. A custom material's shader holds the whole lit shading code around its own function, so its pipelines are among the slowest to build. The showcase scenes' first frames build 46 to 63 pipelines on a phone, and 73 to 84 on a MacBook Pro at High. On a phone they take most of the start. They took 1.8 to 5.4 seconds on a Galaxy S25, and 11.8 to 16.5 seconds on an iPhone 17. A Galaxy Tab A9 Plus took up to 23.5 seconds. Safari reused its compiled shaders on a repeat visit. Chrome's own cache of compiled pipelines on Android is too small to keep a scene's worth. There the engine's stored list does the work, as [Repeat visits](#repeat-visits) says. [A fast start](start-time.md#pipelines-on-phones) gives each figure.
138
+ A larger scene needs many more pipelines, because each pass, effect and custom material adds its own. A custom material's shader holds the whole lit shading code around its own function, so its pipelines are among the slowest to build. On a phone, a showcase scene's first frame builds 45 to 63 pipelines, which take most of the start. The build takes a few seconds on a fast phone, and up to about 24 seconds on a slow tablet.
139
+
140
+ Safari reused its compiled shaders on a repeat visit. Chrome's own cache of compiled pipelines on Android is too small to keep a scene's worth. The engine's stored list does the work, as [Repeat visits](#repeat-visits) says. [A fast start](start-time.md#pipelines-on-phones) gives each figure.
135
141
 
136
142
  The engine builds pipelines without blocking any thread:
137
143
 
138
144
  - On WebGPU, the browser builds each pipeline in the background.
139
145
  - On WebGL2, the browser compiles each program in the background where it has the `KHR_parallel_shader_compile` extension. Chrome, Safari and Brave have it on the Mac, and Safari and Brave have it on the iPad. Firefox does not, and neither does Chrome on some Android phones, such as the Galaxy S24+. There, the first draw with a program waits for its compile.
140
146
 
141
- The first frame waits until every pipeline that it needs is built, so it shows the whole scene. After the first frame, the engine draws each frame at once. An object whose pipeline is still building draws nothing until the pipeline is built, and the rest of the scene draws as usual.
147
+ The first frame waits until every pipeline that it needs is built, so it shows the whole scene. After the first frame, the engine draws each frame at once. An object whose pipeline is still building draws nothing until the pipeline is built, and the rest of the scene draws as usual. The engine's own passes give the first frame only the pipelines that it draws with. Their other pipelines build in the background once the first frame shows. An example is the light clustering of a scene without point, spot or area lights ([A fast start](start-time.md#pipelines-on-phones)). A `scene.warmUp()` after the first frame waits for them too.
142
148
 
143
149
  ### Repeat visits
144
150
 
145
- The engine keeps a list of the pipelines that the first frame of each sketch built, in the page's `localStorage`. On the next start in the same browser, the thread that draws builds them as soon as it has its GPU. The engine downloads and the setup runs meanwhile. Without the list, the builds start only when the setup's first frame asks for them. A custom material's pipelines start when the setup creates the material and its shader arrives. The first frame then takes the pipelines that are built, or waits for the rest.
146
-
147
- On a Galaxy Tab A9 Plus in Chrome, the island showcase's repeat visits drew their first frame 8.8 to 11.2 seconds after the setup. Without the list, they took about 23.6 seconds.
148
-
149
- The list applies to a start of the same sketch on the same GPU path, at the same quality preset. A scene that changed since the last start builds some pipelines that no frame takes, and its first frame stores a new list. Hold mode neither reads nor stores a list. The `?builds=fresh` switch makes the first frame start every build itself, as on a first visit.
151
+ The engine keeps a list of the pipelines that the first frame of each sketch built, in the page's `localStorage`. On the next start in the same browser, the thread that draws builds them as soon as it has its GPU. The engine downloads and the setup runs meanwhile. On a slow tablet, the list cut the island showcase's repeat-visit wait by more than half ([A fast start](start-time.md#pipelines-on-phones)). The [Island showcase](https://github.com/null3d-engine/null3d/tree/main/examples/showcase/island) is that scene.
150
152
 
151
153
  ## The first frame
152
154
 
153
- `engine.firstFrame` resolves once the GPU has finished the first frame after the setup, with every pipeline built. It rejects when the engine stops drawing first, with the failure that ended its frames. So a loading screen that waits for it can say why the scene never came. The promise of `createEngine` resolves once the sketch's setup has run. Either can come first. So remove the loading screen only once both have resolved, as the page above does. Neither waits for the preset check, unless the page asks for the check before play, as the next section says.
155
+ `engine.firstFrame` resolves once the GPU has finished the first frame after the setup, with every pipeline built. It rejects when the engine stops drawing first, with the failure that ended its frames. So a loading screen that waits for it can say why the scene never came.
156
+
157
+ The promise of `createEngine` resolves once the sketch's setup has run. Either can come first. So remove the loading screen only once both have resolved, as the page above does. Neither waits for the preset check, unless the page asks for the check before play, as the next section says.
154
158
 
155
159
  A setup function that awaits `scene.warmUp()` after it creates the scene, as the sketch above does, lets the engine build the pipelines while the setup runs. The engine then draws the first frame as soon as they are built.
156
160
 
157
161
  ## The preset check
158
162
 
159
- When the page leaves the quality preset to the engine, the engine checks its choice in the first frames of play. For about three quarters of a second, it measures the frame rate while the sketch plays. The sketch's `onUpdate`, its input and its animations run as usual. Where the GPU cannot hold the [target frame rate](../concepts/quality-presets.md#the-target-frame-rate), the engine lowers the preset and measures again. By default the target is the display's rate, up to 60 frames per second. Once the check has ended, `engine.presetChecked` resolves, and `engine.mode.preset` holds the preset that it chose.
163
+ When the page leaves the quality preset to the engine, the engine checks its choice in the first frames of play. For about three quarters of a second, it measures the frame rate while the sketch plays. The sketch's `onUpdate`, its input and its animations run as usual.
164
+
165
+ Where the GPU cannot hold the [target frame rate](../concepts/quality-presets.md#the-target-frame-rate), the engine lowers the preset and measures again. By default the target is the display's rate, up to 60 frames per second. Once the check has ended, `engine.presetChecked` resolves, and `engine.mode.preset` holds the preset that it chose.
160
166
 
161
167
  So the loading screen goes at the first frame, and a lighter preset applies in front of the viewer. The pixel ratio, the shadows and the anti-aliasing change. The last frame stays on screen while the new preset's pipelines build. A page that would rather hide that change asks for the check before play:
162
168
 
@@ -169,13 +175,28 @@ const engine = await createEngine({
169
175
  });
170
176
  ```
171
177
 
172
- The engine then draws the scene that the setup built, and measures it before the sketch's `onUpdate` runs. The promise of `createEngine` resolves after the check, and the loading screen hides its frames. The viewer waits for them: the check takes most of the start on a tablet. An 11-inch iPad Pro measured this with the check before play. Each benchmark scene and demo showed its first frame about 1 second after the call to `createEngine`. It took about 2 seconds when the check lowered the preset once. During play, the first frame shows as soon as the GPU has drawn it. On a MacBook Pro, the instances demo's loading screen left 0.49 seconds after navigation on a first visit. With the check before play, it left after 1.18 seconds. A phone starts at Low, which has no lighter preset, so the engine skips the check. On a Galaxy S24+, the first frame showed after 0.23 to 0.43 seconds. [Quality presets](../concepts/quality-presets.md#the-preset-check) gives the rules.
178
+ The engine then draws the scene that the setup built, and measures it before the sketch's `onUpdate` runs. The promise of `createEngine` resolves after the check, and the loading screen hides its frames. The viewer waits for them: the check takes most of the start on a tablet. During play, the first frame shows as soon as the GPU has drawn it. A phone starts at Low, which has no lighter preset, so the engine skips the check. [Quality presets](../concepts/quality-presets.md#the-preset-check) gives the rules.
173
179
 
174
- The engine stores the check's result in the page's `localStorage`. A repeat visit in the same browser on the same device takes that result. Its setup runs at the checked preset, and the check does not run. Only the first visit, and the first after a week, runs the check. A viewer who leaves during the check loses none of the presets it measured. The next visit starts at the preset that the check had lowered to, and its check goes on from there. On the iPad, the first frame of a repeat visit showed after 0.25 to 0.52 seconds. [Quality presets](../concepts/quality-presets.md#repeat-visits) says when a stored result applies, and [Caches between visits](../getting-started/hosting.md#caches-between-visits) shows the other caches that a repeat visit uses.
180
+ <details>
181
+ <summary>Technical details: what the check costs on each device</summary>
182
+
183
+ An 11-inch iPad Pro measured this with the check before play. Each benchmark scene and demo showed its first frame about 1 second after the call to `createEngine`. It took about 2 seconds when the check lowered the preset once. On a MacBook Pro, the instances demo's loading screen left 0.49 seconds after navigation on a first visit. With the check before play, it left after 1.18 seconds. On a Galaxy S24+, the first frame showed after 0.23 to 0.43 seconds.
184
+
185
+ On the iPad, the first frame of a repeat visit showed after 0.25 to 0.52 seconds.
186
+
187
+ </details>
188
+
189
+ The engine stores the check's result in the page's `localStorage`. A repeat visit in the same browser on the same device takes that result. Its setup runs at the checked preset, and the check does not run. Only the first visit, and the first after a week, runs the check.
190
+
191
+ A viewer who leaves during the check loses none of the presets it measured. The next visit starts at the preset that the check had lowered to, and its check goes on from there. [Quality presets](../concepts/quality-presets.md#repeat-visits) says when a stored result applies, and [Caches between visits](../getting-started/hosting.md#caches-between-visits) shows the other caches that a repeat visit uses.
175
192
 
176
193
  So build the whole first view in the setup, with its textures. The check measures the scene from its first frame, and waits while textures upload. A sketch whose setup leaves the scene empty gets a preset that the scene may not hold.
177
194
 
195
+ ## Textures after the loading screen
196
+
197
+ A texture returns at once, and its texels go to the GPU over the frames that follow. Each frame uploads no more texel bytes than the quality preset's upload budget, so a scene with many large textures does not stall a frame. Until a texture's texels arrive, its material draws with its color alone. [Textures](../api/textures.md) says how uploads work.
178
198
 
199
+ Keep the textures of the first view small, so the first frames show them. Or wait a few frames before you remove the loading screen.
179
200
 
180
201
  ## A later loading stage
181
202
 
@@ -191,15 +212,35 @@ await scene.warmUp(); // every pipeline that the scene needs is built
191
212
  for (const piece of pieces) piece.setVisible(true);
192
213
  ```
193
214
 
194
- `scene.warmUp()` builds the pipelines of every object in the scene, hidden objects too, and resolves once they are all built. The scene keeps drawing while it waits. An object of a new kind can need more than one pipeline. Where the scene draws the depth prepass, the object also gets a depth pipeline. On a computer's WebGPU at High and Ultra it gets a third, for the occlusion culling's depth pass. So `engine.measure()` can count 2 or 3 pipelines for one new object ([The depth prepass](../concepts/quality-presets.md#the-depth-prepass)). Without a warm-up, each new object appears when its pipeline is built, which can be a few frames after the others.
215
+ `scene.warmUp()` builds the pipelines of every object in the scene, hidden objects too, and resolves once they are all built. The scene keeps drawing while it waits. Without a warm-up, each new object appears when its pipeline is built, which can be a few frames after the others.
216
+
217
+ <details>
218
+ <summary>Technical details: how many pipelines one new object adds</summary>
219
+
220
+ An object of a new kind can need more than one pipeline. Where the scene draws the depth prepass, the object also gets a depth pipeline. On a computer's WebGPU at High and Ultra it gets a third, for the occlusion culling's depth pass. So `engine.measure()` can count 2 or 3 pipelines for one new object ([The depth prepass](../concepts/quality-presets.md#the-depth-prepass)).
221
+
222
+ </details>
195
223
 
196
224
  In hold mode, the engine draws one frame, which waits for its pipelines, so `scene.warmUp()` resolves at once.
197
225
 
226
+ A warm-up shares the GPU with the frames that the scene draws while it waits. So warm up the stages of cheap objects before a heavy stage shows. On a slow GPU, each frame of a heavy stage can take seconds, and every warm-up after it waits that long too.
227
+
228
+ In SwiftShader, a software GPU, a hero object's richer materials warmed up in 1.3 seconds before a city showed. After the city showed, the same warm-up took more than 20 seconds.
229
+
198
230
  ## Loading everything up front
199
231
 
200
232
  Most shaders come with the engine's start. The shaders of a feature that many games leave out download the first time the sketch uses it. So a page that never uses the feature never downloads them. [Shaders that load on first use](first-use-shaders.md) lists every such feature and the moment its shaders download. For example, `'skinning'` downloads with the first skinned mesh, and `'bloom'` when `post.set` turns bloom on.
201
233
 
202
- Each feature has a file for each GPU path and each device's settings. Each such file takes at most 128 KB after Brotli. A WebGL2 file is larger than its WebGPU twin, and many WebGL2 files take more than 32 KB. Shaders that need two such features, such as a skinned mesh with a hashed material, sit in a file of their own. A page downloads it only when it uses both. The engine starts the download as soon as it knows the sketch needs it. A glTF file with skins or morph targets starts it while the engine reads the file, so the download runs beside the texture decode. A model that `assets optimize` wrote carries a list of the features its draws need. The engine asks for those files as it reads the model, so such a model needs no `preload` entry ([The asset pipeline](assets-pipeline.md#the-shader-list)). A new object draws once its pipelines are built, as on any first use. The skinned meshes of a model, and an effect, appear whole in one frame.
234
+ Each feature has a file for each GPU path and each device's settings, and each file takes at most 128 KB after Brotli. Shaders that need two such features, such as a skinned mesh with a hashed material, sit in a file of their own. A page downloads it only when it uses both.
235
+
236
+ A model that `assets optimize` wrote carries a list of the features its draws need. The engine asks for those files as it reads the model, so such a model needs no `preload` entry ([The asset pipeline](assets-pipeline.md#the-shader-list)). A new object draws once its pipelines are built, as on any first use. The skinned meshes of a model, and an effect, appear whole in one frame.
237
+
238
+ <details>
239
+ <summary>Technical details: how the first-use shader files are split</summary>
240
+
241
+ A WebGL2 file is larger than its WebGPU twin, and many WebGL2 files take more than 32 KB. The engine starts the download as soon as it knows the sketch needs it. A glTF file with skins or morph targets starts it while the engine reads the file, so the download runs beside the texture decode.
242
+
243
+ </details>
203
244
 
204
245
  A game that must fetch nothing while it plays lists its features in `createEngine`:
205
246
 
@@ -212,7 +253,16 @@ const engine = await createEngine({
212
253
  });
213
254
  ```
214
255
 
215
- The listed files download beside the engine's own shaders, so the start waits only for the largest file. Their downloads start right after the engine tests the GPU, while the engine's core downloads. The list also loads the file of each pair or group of listed features whose shaders need them together. Their shaders compile before the first frame, as far as the files alone allow. On the Mac, a list of three features added about 70 ms to the start. When the sketch turns a listed feature on during play, the engine downloads nothing. On WebGL2 the feature's first objects then draw at once. On WebGPU a new object's pipeline still needs the scene's targets and its material's state, so it can take a frame to build. Skinned meshes wait for their pipelines in the same way: which ones they need depends on their materials. To build those too before the loading screen goes, create the objects in the setup and `await scene.warmUp()`, as "A later loading stage" shows. The `createEngine` call throws E1421 for a name it does not know.
256
+ The listed files download beside the engine's own shaders, so the start waits only for the largest file. Their downloads start right after the engine tests the GPU, while the engine's core downloads. The list also loads the file of each pair or group of listed features whose shaders need them together. When the sketch turns a listed feature on during play, the engine downloads nothing.
257
+
258
+ <details>
259
+ <summary>Technical details: what a preload list builds before the first frame</summary>
260
+
261
+ Their shaders compile before the first frame, as far as the files alone allow. On the Mac, a list of three features added about 70 ms to the start. On WebGL2 the feature's first objects then draw at once. On WebGPU a new object's pipeline still needs the scene's targets and its material's state, so it can take a frame to build. Skinned meshes wait for their pipelines in the same way: which ones they need depends on their materials.
262
+
263
+ </details>
264
+
265
+ To build those too before the loading screen goes, create the objects in the setup and `await scene.warmUp()`, as [A later loading stage](#a-later-loading-stage) shows. The `createEngine` call throws [E1421](../errors/E1421.md) for a name it does not know.
216
266
 
217
267
  The engine does not put every feature into the start's file. That file would then grow for every page, also for the pages that never use a feature. A list keeps the cost on the games that ask for it.
218
268
 
@@ -229,13 +279,7 @@ page.onMessage(async (name, preset) => {
229
279
  });
230
280
  ```
231
281
 
232
- [Quality API](../api/quality.md#switching-presets) says what the call changes.
233
-
234
- ## Textures after the loading screen
235
-
236
- A texture returns at once, and its texels go to the GPU over the frames that follow. Each frame uploads no more texel bytes than the quality preset's upload budget, so a scene with many large textures does not stall a frame. Until a texture's texels arrive, its material draws with its color alone. [Textures](../api/textures.md) says how uploads work.
237
-
238
- Keep the textures of the first view small, so the first frames show them. Or wait a few frames before you remove the loading screen.
282
+ [Quality API](../api/quality.md#switching-presets) says what the call changes. The [Island](https://github.com/null3d-engine/null3d/tree/main/examples/showcase/island), [Creek](https://github.com/null3d-engine/null3d/tree/main/examples/showcase/creek) and [Skyway](https://github.com/null3d-engine/null3d/tree/main/examples/showcase/skyway) showcases change preset from a Quality menu while the last frame stays on screen.
239
283
 
240
284
  ## Measure the warm-up
241
285