@null3d/engine 0.1.0 → 0.1.1

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 (381) 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 +39 -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 +65 -25
  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/E1401.md +11 -3
  146. package/docs/errors/E1402.md +13 -5
  147. package/docs/errors/E1403.md +11 -3
  148. package/docs/errors/E1404.md +13 -3
  149. package/docs/errors/E1405.md +15 -4
  150. package/docs/errors/E1406.md +31 -5
  151. package/docs/errors/E1407.md +11 -3
  152. package/docs/errors/E1408.md +11 -3
  153. package/docs/errors/E1409.md +11 -3
  154. package/docs/errors/E1410.md +13 -5
  155. package/docs/errors/E1411.md +11 -3
  156. package/docs/errors/E1412.md +29 -6
  157. package/docs/errors/E1413.md +11 -3
  158. package/docs/errors/E1414.md +11 -3
  159. package/docs/errors/E1415.md +11 -3
  160. package/docs/errors/E1416.md +27 -6
  161. package/docs/errors/E1417.md +11 -3
  162. package/docs/errors/E1418.md +12 -3
  163. package/docs/errors/E1419.md +13 -5
  164. package/docs/errors/E1420.md +11 -3
  165. package/docs/errors/E1421.md +11 -3
  166. package/docs/errors/E1422.md +12 -3
  167. package/docs/errors/E1423.md +12 -3
  168. package/docs/errors/E1424.md +24 -5
  169. package/docs/errors/E1425.md +11 -3
  170. package/docs/errors/E1426.md +11 -3
  171. package/docs/errors/E1430.md +11 -3
  172. package/docs/errors/E1431.md +11 -3
  173. package/docs/errors/E1432.md +11 -3
  174. package/docs/errors/E1433.md +11 -3
  175. package/docs/errors/E1434.md +15 -6
  176. package/docs/errors/E1435.md +11 -3
  177. package/docs/errors/E1436.md +11 -3
  178. package/docs/errors/E1437.md +14 -6
  179. package/docs/errors/E1501.md +41 -6
  180. package/docs/errors/E1502.md +13 -3
  181. package/docs/errors/E1503.md +11 -3
  182. package/docs/errors/E1504.md +11 -3
  183. package/docs/errors/E1505.md +23 -5
  184. package/docs/errors/E1506.md +11 -3
  185. package/docs/errors/index.md +52 -29
  186. package/docs/getting-started/cdn.md +15 -9
  187. package/docs/getting-started/first-scene.md +20 -12
  188. package/docs/getting-started/hosting.md +111 -63
  189. package/docs/getting-started/install.md +39 -24
  190. package/docs/getting-started/network-use.md +31 -21
  191. package/docs/getting-started/project-structure.md +20 -8
  192. package/docs/getting-started/third-party-notices.md +6 -10
  193. package/docs/guides/accessibility.md +4 -4
  194. package/docs/guides/add-ons.md +83 -13
  195. package/docs/guides/agents.md +2 -6
  196. package/docs/guides/assets-pipeline.md +248 -72
  197. package/docs/guides/audio.md +17 -15
  198. package/docs/guides/baked-light-data.md +44 -23
  199. package/docs/guides/car-paint.md +37 -31
  200. package/docs/guides/content-pages.md +53 -29
  201. package/docs/guides/custom-passes.md +59 -17
  202. package/docs/guides/custom-shaders.md +54 -37
  203. package/docs/guides/debugging.md +31 -41
  204. package/docs/guides/deploying.md +6 -27
  205. package/docs/guides/deterministic-simulation.md +23 -16
  206. package/docs/guides/first-use-shaders.md +83 -45
  207. package/docs/guides/lens-kit.md +29 -26
  208. package/docs/guides/loading-screens.md +70 -30
  209. package/docs/guides/multiple-views.md +22 -11
  210. package/docs/guides/performance.md +188 -37
  211. package/docs/guides/phones.md +71 -19
  212. package/docs/guides/physics.md +6 -10
  213. package/docs/guides/screens.md +41 -29
  214. package/docs/guides/start-time.md +120 -85
  215. package/docs/guides/testing.md +137 -98
  216. package/docs/guides/ui-overlays.md +17 -12
  217. package/docs/guides/video-textures.md +14 -13
  218. package/docs/images/api/animation/character.webp +0 -0
  219. package/docs/images/api/animation/look-at-ring.webp +0 -0
  220. package/docs/images/api/animation/morph-tulips.webp +0 -0
  221. package/docs/images/api/animation/skeleton-lines.webp +0 -0
  222. package/docs/images/api/controls/gizmo-handles.webp +0 -0
  223. package/docs/images/api/controls/walk-and-fly.webp +0 -0
  224. package/docs/images/api/debug/debug-shapes.webp +0 -0
  225. package/docs/images/api/debug/levels-view.webp +0 -0
  226. package/docs/images/api/engine/transparent-canvas.webp +0 -0
  227. package/docs/images/api/feature-draws/feature-draw-clouds.webp +0 -0
  228. package/docs/images/api/feature-instances/compute-instances.webp +0 -0
  229. package/docs/images/api/feature-instances/instances-shadow.webp +0 -0
  230. package/docs/images/api/geometry/extra-shapes.webp +0 -0
  231. package/docs/images/api/geometry/generators.webp +0 -0
  232. package/docs/images/api/geometry/mesh-arrays.webp +0 -0
  233. package/docs/images/api/geometry/vertex-updates.webp +0 -0
  234. package/docs/images/api/grass/grass-grove.webp +0 -0
  235. package/docs/images/api/grass/grass-presets.webp +0 -0
  236. package/docs/images/api/grass/grass-shadow.webp +0 -0
  237. package/docs/images/api/impostors/impostor-handover.webp +0 -0
  238. package/docs/images/api/impostors/impostor-shadow.webp +0 -0
  239. package/docs/images/api/impostors/impostors-forest.webp +0 -0
  240. package/docs/images/api/lights/spot-cookies.webp +0 -0
  241. package/docs/images/api/lines/lines-lit.webp +0 -0
  242. package/docs/images/api/lines/lines-widths.webp +0 -0
  243. package/docs/images/api/materials/coat-and-sheen.webp +0 -0
  244. package/docs/images/api/materials/decals.webp +0 -0
  245. package/docs/images/api/materials/iridescence-and-anisotropy.webp +0 -0
  246. package/docs/images/api/materials/relief.webp +0 -0
  247. package/docs/images/api/materials/shader-inputs.webp +0 -0
  248. package/docs/images/api/materials/standard-grid.webp +0 -0
  249. package/docs/images/api/materials/subsurface.webp +0 -0
  250. package/docs/images/api/materials/translucency.webp +0 -0
  251. package/docs/images/api/objects/objects-turntable.webp +0 -0
  252. package/docs/images/api/particles/campfire.webp +0 -0
  253. package/docs/images/api/points/galaxy.webp +0 -0
  254. package/docs/images/api/reference/textures/texture-wrap.webp +0 -0
  255. package/docs/images/api/render/fullscreen-glow.webp +0 -0
  256. package/docs/images/api/render/reflection-mirror.webp +0 -0
  257. package/docs/images/api/render/security-camera.webp +0 -0
  258. package/docs/images/api/scene/aurora-sky-layer.webp +0 -0
  259. package/docs/images/api/sound/sound-demo.webp +0 -0
  260. package/docs/images/api/splats/splats-demo.webp +0 -0
  261. package/docs/images/api/sprites/sprites-lines.webp +0 -0
  262. package/docs/images/api/terrain/terrain-demo.webp +0 -0
  263. package/docs/images/api/textures/canvas-screen.webp +0 -0
  264. package/docs/images/api/textures/mipmaps.webp +0 -0
  265. package/docs/images/api/vertex-draws/rain.webp +0 -0
  266. package/docs/images/api/water/ocean.webp +0 -0
  267. package/docs/images/api/water/water-demo.webp +0 -0
  268. package/docs/images/api/water/water-rain.webp +0 -0
  269. package/docs/images/api/water/waterfall.webp +0 -0
  270. package/docs/images/concepts/assets/gltf-model.webp +0 -0
  271. package/docs/images/concepts/color-management/tone-mapped.webp +0 -0
  272. package/docs/images/concepts/culling/far-from-origin.webp +0 -0
  273. package/docs/images/concepts/instances/instances.webp +0 -0
  274. package/docs/images/concepts/instances/per-row-colors.webp +0 -0
  275. package/docs/images/concepts/large-worlds/large-world.webp +0 -0
  276. package/docs/images/concepts/lighting/area-lights.webp +0 -0
  277. package/docs/images/concepts/lighting/atmosphere.webp +0 -0
  278. package/docs/images/concepts/lighting/environment.webp +0 -0
  279. package/docs/images/concepts/lighting/light-shafts.webp +0 -0
  280. package/docs/images/concepts/lighting/reflection-probes.webp +0 -0
  281. package/docs/images/concepts/lod/forest.webp +0 -0
  282. package/docs/images/concepts/materials/weighted-transparency.webp +0 -0
  283. package/docs/images/concepts/post-processing/auto-exposure.webp +0 -0
  284. package/docs/images/concepts/post-processing/bounce-light.webp +0 -0
  285. package/docs/images/concepts/post-processing/depth-of-field.webp +0 -0
  286. package/docs/images/concepts/post-processing/post-effects-alley.webp +0 -0
  287. package/docs/images/concepts/post-processing/sharpen.webp +0 -0
  288. package/docs/images/concepts/post-processing/ssr-wet-street.webp +0 -0
  289. package/docs/images/concepts/render-layers/layers-cottages.webp +0 -0
  290. package/docs/images/concepts/shadows/hero-shadow.webp +0 -0
  291. package/docs/images/cookbook/index/picking.webp +0 -0
  292. package/docs/images/cookbook/index/time-of-day.webp +0 -0
  293. package/docs/images/errors/E1431/area-lights-no-tables.webp +0 -0
  294. package/docs/images/guides/custom-passes/reflection-water.webp +0 -0
  295. package/docs/images/guides/deterministic-simulation/replay-demo.webp +0 -0
  296. package/docs/images/guides/multiple-views/split-screen.webp +0 -0
  297. package/docs/images/guides/performance/overdraw-view.webp +0 -0
  298. package/docs/images/guides/testing/hold-mode-frame.webp +0 -0
  299. package/docs/images/index/showcase-island.webp +0 -0
  300. package/docs/images/porting/threejs-shaders/dissolve.webp +0 -0
  301. package/docs/images/shaders/builtins/builtins.webp +0 -0
  302. package/docs/images/shaders/surface-functions/custom-surface.webp +0 -0
  303. package/docs/images/shaders/surface-functions/vertex-offset.webp +0 -0
  304. package/docs/images/shots.json +2231 -0
  305. package/docs/index.md +14 -23
  306. package/docs/moves.json +1 -0
  307. package/docs/nav.json +300 -0
  308. package/docs/pages.md +230 -212
  309. package/docs/porting/react-three-fiber.md +2 -6
  310. package/docs/porting/threejs-loop-and-threads.md +1 -5
  311. package/docs/porting/threejs-mapping.md +1248 -234
  312. package/docs/porting/threejs-materials.md +10 -5
  313. package/docs/porting/threejs-overview.md +26 -6
  314. package/docs/porting/threejs-postprocessing.md +2 -6
  315. package/docs/porting/threejs-shaders.md +16 -14
  316. package/docs/porting/threejs-unsupported.md +6 -6
  317. package/docs/porting/verification.md +0 -4
  318. package/docs/shaders/builtins.md +15 -4
  319. package/docs/shaders/library.md +9 -6
  320. package/docs/shaders/surface-functions.md +51 -16
  321. package/docs/shaders/wgsl-rules.md +12 -5
  322. package/lib/debug/debug.d.ts +2 -2
  323. package/lib/debug/draw.d.ts +2 -2
  324. package/lib/debug/draw.js +8 -4
  325. package/lib/debug/overlay-look.d.ts +6 -0
  326. package/lib/debug/overlay-look.js +29 -7
  327. package/lib/debug/overlay.js +15 -11
  328. package/lib/debug/stats-options.d.ts +13 -0
  329. package/lib/debug/stats-panel.d.ts +21 -6
  330. package/lib/debug/stats-panel.js +80 -13
  331. package/lib/errors/codes.d.ts +17 -3
  332. package/lib/errors/codes.js +111 -105
  333. package/lib/errors/fixes.js +18 -18
  334. package/lib/gpu/variants.d.ts +8 -2
  335. package/lib/gpu/variants.js +39 -7
  336. package/lib/gpu/webgl2/programs.js +1 -1
  337. package/lib/gpu/webgpu/pipelines.js +13 -13
  338. package/lib/index.d.ts +1 -1
  339. package/lib/page/capabilities.d.ts +1 -1
  340. package/lib/page/engine.d.ts +14 -5
  341. package/lib/page/engine.js +18 -2
  342. package/lib/page/label-loop.js +9 -4
  343. package/lib/page/stats-switch.js +2 -0
  344. package/lib/page/switches.d.ts +6 -4
  345. package/lib/page/switches.js +20 -4
  346. package/lib/scene/baked-light.d.ts +2 -2
  347. package/lib/scene/fake-call-values.js +2 -2
  348. package/lib/scene/frame-cameras.d.ts +16 -4
  349. package/lib/scene/frame-cameras.js +28 -10
  350. package/lib/scene/gltf.d.ts +1 -1
  351. package/lib/scene/level-rule.d.ts +6 -5
  352. package/lib/scene/level-rule.js +2 -2
  353. package/lib/scene/particles.d.ts +7 -3
  354. package/lib/scene/particles.js +3 -1
  355. package/lib/scene/post.d.ts +3 -2
  356. package/lib/scene/resources.d.ts +15 -9
  357. package/lib/scene/scene.d.ts +18 -2
  358. package/lib/scene/scene.js +47 -5
  359. package/lib/scene/time-of-day.d.ts +10 -5
  360. package/lib/scene/time-of-day.js +11 -7
  361. package/lib/shader-artifact.json +1 -1
  362. package/lib/shared/labels.d.ts +5 -2
  363. package/lib/shared/labels.js +5 -2
  364. package/lib/shared/permutation-words.d.ts +2 -0
  365. package/lib/shared/permutation-words.js +8 -0
  366. package/lib/shared/recording.d.ts +13 -5
  367. package/lib/shared/recording.js +31 -10
  368. package/lib/shared/sketch-data.d.ts +9 -0
  369. package/lib/shared/sketch-data.js +57 -0
  370. package/lib/shared/version.d.ts +1 -1
  371. package/lib/shared/version.js +1 -1
  372. package/lib/sketch/define-sketch.d.ts +16 -7
  373. package/lib/sketch/define-sketch.js +2 -1
  374. package/lib/sketch/runner.d.ts +4 -0
  375. package/lib/sketch/runner.js +5 -0
  376. package/lib/sketch/ui.js +4 -2
  377. package/lib/stats.d.ts +1 -0
  378. package/lib/workers/protocol.d.ts +10 -0
  379. package/lib/workers/render-worker.js +4 -1
  380. package/lib/workers/sketch-worker.js +4 -1
  381. package/package.json +1 -1
@@ -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.
179
+
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>
173
188
 
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.
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,7 +212,14 @@ 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
 
@@ -199,7 +227,16 @@ In hold mode, the engine draws one frame, which waits for its pipelines, so `sce
199
227
 
200
228
  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
229
 
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.
230
+ 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.
231
+
232
+ 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.
233
+
234
+ <details>
235
+ <summary>Technical details: how the first-use shader files are split</summary>
236
+
237
+ 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.
238
+
239
+ </details>
203
240
 
204
241
  A game that must fetch nothing while it plays lists its features in `createEngine`:
205
242
 
@@ -212,7 +249,16 @@ const engine = await createEngine({
212
249
  });
213
250
  ```
214
251
 
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.
252
+ 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.
253
+
254
+ <details>
255
+ <summary>Technical details: what a preload list builds before the first frame</summary>
256
+
257
+ 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.
258
+
259
+ </details>
260
+
261
+ 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
262
 
217
263
  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
264
 
@@ -229,13 +275,7 @@ page.onMessage(async (name, preset) => {
229
275
  });
230
276
  ```
231
277
 
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.
278
+ [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
279
 
240
280
  ## Measure the warm-up
241
281
 
@@ -1,16 +1,12 @@
1
1
  ---
2
2
  id: guides/multiple-views
3
3
  title: Multiple views
4
- status: experimental
5
- since: "0.3"
6
4
  summary: "Split screens and picture in picture with scene.createView: a camera and a rectangle of the canvas, drawn after the camera's view in the same frame; per-view culling; the cost of each view."
7
5
  ---
8
6
 
9
7
  # Multiple views
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
- A view draws the scene again from another camera, into a rectangle of the canvas, in the same frame as the camera's view. Use it for a split screen, a picture in picture, a rear-view mirror or a tactical inset. Two kinds of work are different:
9
+ A view draws the scene again from another camera, into a rectangle of the canvas, in the same frame as the camera's view. Use it for a split screen, a picture in picture, a rear-view mirror or a tactical inset. A view is not a render pass:
14
10
 
15
11
  - A **view** draws into the canvas, so the user sees it in place. `scene.createView` makes one.
16
12
  - A **pass** draws into a texture, which a material shows in the world, as a minimap on a screen does. [render.addPass](custom-passes.md#render-to-a-texture) makes one.
@@ -36,6 +32,10 @@ export default defineSketch(({ scene }) => {
36
32
 
37
33
  The camera's view draws the whole canvas first, and each view covers its rectangle afterwards. The camera's aspect ratio is the canvas's, so a half of its image is a crop of a wider view. For two half-width cameras, add a view for each half:
38
34
 
35
+ ![One canvas split into a high wide view and a low view among standing stones.](../images/guides/multiple-views/split-screen.webp)
36
+
37
+ Two cameras in one frame.
38
+
39
39
  ```ts
40
40
  const left = scene.createPerspectiveCamera({ fov: 50, position: [-4, 2, 6], target: [0, 1, 0] });
41
41
  const right = scene.createPerspectiveCamera({ fov: 50, position: [4, 2, 6], target: [0, 1, 0] });
@@ -99,20 +99,30 @@ A view's calls use the view's camera of the frame that last ran, with its lens a
99
99
 
100
100
  Each view culls the scene once more and draws it once more, at its rectangle's pixels. A picture in picture at a tenth of the canvas costs about a tenth of a scene draw. The camera's view always draws first, so a split screen of two halves costs the camera's draw and two view draws.
101
101
 
102
- The shadows cost nothing more: a view draws the sun's cascades and the point and spot lights' shadows that the camera's view made, as a scene pass does. The view draws the background, the environment's light, the material fog and the lights it sees. Its objects take no ambient occlusion or screen-space reflections, which shade the camera's view. The camera's volumetric fog and outline are added to the whole image after the views draw, so they also reach a view's rectangle.
102
+ The shadows cost nothing more: a view reuses the sun's cascades and the point and spot lights' shadows that the camera's view made.
103
103
 
104
- A view has a depth target of the canvas's size, made once in a frame and shared with the other views when their turns do not overlap. The rectangle follows the render scale, as the camera's view does, so a lower scale lowers a view's cost with the rest of the image.
104
+ The rectangle follows the render scale, as the camera's view does, so a lower scale lowers a view's cost with the rest of the image. No preset switches views off or lowers their count. On a phone, keep a picture in picture small: each view costs what its rectangle costs on the preset that the device runs, as [Quality presets](../concepts/quality-presets.md) describes.
105
105
 
106
- Both GPU paths draw views, in every thread mode. The scene culling runs on the GPU on WebGPU and on the job workers on WebGL2, as it does for the camera. On the 8-bit path a view writes display color into the camera's image, and the resolve pass or the final pass draws it to the canvas; the picture looks the same as on the HDR path, with no bloom, as the 8-bit path has none.
106
+ ## What a view draws and its limits
107
107
 
108
- No preset switches views off or lowers their count. On a phone, keep a picture in picture small: each view costs what its rectangle costs on the preset that the device runs, as [Quality presets](../concepts/quality-presets.md) describes.
108
+ Views draw on both GPU paths, in every thread mode.
109
109
 
110
- ## What a view leaves out
110
+ - A view draws: the shadows of the camera's view, the background, the environment's light, the material fog and the lights it sees. The camera's volumetric fog and outline are added to the whole image after the views draw, so they also reach a view's rectangle.
111
+ - A view leaves out: ambient occlusion and screen-space reflections, which shade only the camera's view, and any object whose material shows a render pass's texture.
111
112
 
112
- A view draws no object whose material shows a render pass's texture, since a pass cannot read a target that another pass draws into. Keep such objects in the camera's view, or show the pass's texture on a screen in the world instead.
113
+ A pass cannot read a target that another pass draws into, so keep such objects in the camera's view, or show the pass's texture on a screen in the world instead.
113
114
 
114
115
  A scene and its passes share 32 views, the camera's included. Reflection probes take six while they capture. `scene.createView` throws E1501 when no view is free, and the same error names the limit when a frame draws too many.
115
116
 
117
+ <details>
118
+ <summary>Technical details: how views draw on each GPU path</summary>
119
+
120
+ A view has a depth target of the canvas's size. The engine makes it once in a frame and shares it with the other views when their turns do not overlap. The scene culling runs on the GPU on WebGPU and on the job workers on WebGL2, as it does for the camera.
121
+
122
+ On the 8-bit path a view writes display color into the camera's image. The resolve pass or the final pass draws it to the canvas. The picture looks the same as on the HDR path, with no bloom, as the 8-bit path has none.
123
+
124
+ </details>
125
+
116
126
  ## Related pages
117
127
 
118
128
  - [Scene](../api/scene.md#multiple-views): `createView`, `setCamera`, `setRect` and `destroy`.
@@ -120,3 +130,4 @@ A scene and its passes share 32 views, the camera's included. Reflection probes
120
130
  - [Custom passes and render targets](custom-passes.md#render-to-a-texture): a camera's view in a texture that a material shows.
121
131
  - [The render graph](../concepts/render-graph.md): how the engine plans and orders what it draws.
122
132
  - [Performance](performance.md): the frame budget and the render scale.
133
+ - [A picture in picture](https://github.com/null3d-engine/null3d/tree/main/examples/multiple-views): one scene from a high, wide camera and a low one, split across the canvas or in an inset.