@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: api/textures
3
3
  title: Textures
4
- status: experimental
5
- since: "0.1"
6
4
  summary: "loadTexture options; KTX2 files; fromData; fromImageBitmap; fromCanvas; fromVideo; fromPass."
7
5
  ---
8
6
 
9
7
  # Textures
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. Materials do not sample cube maps. A cube map can be a background: [Assets](assets.md) loads one with `assets.loadCubemap`.
12
-
13
9
  ```mermaid
14
10
  flowchart LR
15
11
  file["An image file"] -->|"assets.loadTexture:<br/>downloaded and decoded<br/>outside the sketch's frames"| image["A decoded image<br/>(ImageBitmap)"]
@@ -80,6 +76,11 @@ const bricks = await assets.loadTexture('/tex/bricks.ktx2', { wrap: 'repeat' });
80
76
  console.log(bricks.format); // 'astc-4x4-unorm' on phones and tablets, 'bc7-rgba-unorm' on most desktop GPUs
81
77
  ```
82
78
 
79
+ The engine picks the best compressed format that the device supports: `texture.format` says which one it got, and `texture.bytes` its GPU memory.
80
+
81
+ <details>
82
+ <summary>Technical details: which compressed format each device gets</summary>
83
+
83
84
  The engine turns the file's data into the first format on its list that the device supports:
84
85
 
85
86
  | Data in the file | Formats, in order |
@@ -92,8 +93,10 @@ The engine turns the file's data into the first format on its list that the devi
92
93
  - Phones and tablets have ASTC and ETC2. Desktop GPUs have BC7, and Macs with Apple chips have all three. A device with none gets `rgba8unorm`.
93
94
  - On WebGL2, a device with BC7 gets `bc7-rgba-unorm` for both kinds of data. Some desktop drivers, such as Mesa on Linux, offer ETC2 and ASTC on GPUs without them. They then decode those textures in software on the page's thread, which stalls the page. WebGPU offers a format only where the GPU has it.
94
95
  - UASTC HDR data holds colors brighter than white, with no alpha. A device with BC formats gets `bc6h-rgb-ufloat`, at 1 byte per texel. Devices without BC formats, such as the iPad and most phones, get `rgb9e5ufloat`: three 9-bit values with a shared exponent, at 4 bytes per texel. That is half the memory of `rgba16float`, and every device filters it. WebGPU and WebGL2 have no ASTC format for HDR data. The texture is always `linear`.
96
+
97
+ </details>
98
+
95
99
  - A texture whose width or height is not a multiple of 4 texels gets `rgba8unorm` too, at 4 to 8 times the memory. HDR data then gets `rgb9e5ufloat`. WebGPU keeps compressed textures in whole blocks of 4 x 4 texels. Development builds warn when a file loads this way. `bunx @null3d/cli assets optimize` writes sides that are whole blocks.
96
- - `texture.format` says which format the device got, and `texture.bytes` its GPU memory.
97
100
 
98
101
  A KTX2 file takes the texture options above, with these differences:
99
102
 
@@ -121,7 +124,11 @@ The image moves to the thread that draws, without a copy, so the sketch can use
121
124
 
122
125
  ## Canvases
123
126
 
124
- `textures.fromCanvas` makes a texture that follows an `OffscreenCanvas` drawn in the sketch, such as a score board, a map or a drawing surface. The canvas's last row goes to v = 0, the bottom of a plane, so the canvas stands upright on a plane as on a page. Its first pixels upload as any image's do.
127
+ `textures.fromCanvas` makes a texture that follows an `OffscreenCanvas` drawn in the sketch, such as a score board, a map or a drawing surface. The canvas's last row goes to v = 0, the bottom of a plane, so the canvas stands upright on a plane as on a page. Its first pixels upload as any image's do. The [screens on a canvas demo](https://github.com/null3d-engine/null3d/tree/main/examples/canvas-screen) paints wall panels and a console this way, each at its own rate.
128
+
129
+ ![A dark wall with three glowing screens that show numbers and bar gauges, and a small console panel with a wave trace below them.](../images/api/textures/canvas-screen.webp)
130
+
131
+ Screens painted on canvases.
125
132
 
126
133
  `texture.refresh(rect)` reads the canvas again. Give it the rectangle that changed, in the canvas's own coordinates. The rectangle starts at the column and row of its top-left texel, counted from the canvas's top-left corner, and gives its width and height. Only that rectangle uploads, in the texture's turn and within the frame's upload budget. The rest of the texture keeps its texels. Without a rectangle, the call reads the whole canvas.
127
134
 
@@ -186,7 +193,7 @@ The video element's own settings, such as its file format and its cross-origin r
186
193
 
187
194
  A texture with `depth` above 1 holds that many layers, up to 256, one after another in `data`. Its layers are a texture array of their own. Materials read its first layer.
188
195
 
189
- Data of the wrong length or type for the size and format throws E1208. Data textures have no mip levels unless `mipmaps` is true.
196
+ Data of the wrong length or type for the size and format throws E1208. Data textures have no mip levels unless `mipmaps` is true. The [security camera demo](https://github.com/null3d-engine/null3d/tree/main/examples/security-camera) makes its ground maps with `textures.fromData`.
190
197
 
191
198
  ## Textures of render passes
192
199
 
@@ -221,11 +228,29 @@ A texture's `width`, `height` and `depth` give its size, and `bytes` its GPU mem
221
228
 
222
229
  Textures of one size, one format and one number of mip levels share a 2D texture array on the GPU. Each texture takes one layer of the array. Materials whose maps are in one array share one bind group when they sample their maps the same way. The GPU then switches textures less often between draws.
223
230
 
224
- An array holds at most 256 layers, the most that an iPad allows, and at most 128 MiB. It starts with room for a few textures, at most 8 MiB of them, and doubles its layers when it is full. The GPU copies the old array into the new one, so the textures that it holds keep their texels. For one frame the GPU holds both, so the cap of 128 MiB keeps that extra memory small. When a size has more textures than an array holds, another array holds the rest. When under a quarter of an array's layers hold textures, the array shrinks, and its textures move to its lowest layers. A texture from data with several layers has an array of its own, with exactly its layers. So does a texture in a compressed format, because WebGPU's compatibility mode cannot copy compressed texels into a larger array. A texture in `rgb9e5ufloat` has one too, because WebGL2 cannot copy that format.
231
+ An array holds at most 256 layers, the most that an iPad allows, and at most 128 MiB. When a size has more textures than an array holds, another array holds the rest.
232
+
233
+ <details>
234
+ <summary>Technical details: how texture arrays grow and shrink</summary>
235
+
236
+ An array starts with room for a few textures, at most 8 MiB of them, and doubles its layers when it is full. The GPU copies the old array into the new one, so the textures that it holds keep their texels. For one frame the GPU holds both, so the cap of 128 MiB keeps that extra memory small. When under a quarter of an array's layers hold textures, the array shrinks, and its textures move to its lowest layers.
237
+
238
+ A texture from data with several layers has an array of its own, with exactly its layers. So does a texture in a compressed format, because WebGPU's compatibility mode cannot copy compressed texels into a larger array. A texture in `rgb9e5ufloat` has one too, because WebGL2 cannot copy that format.
239
+
240
+ </details>
225
241
 
226
242
  Textures of many different sizes need many arrays. Give the textures of a scene a few common sizes where you can, such as 512 x 512 and 1024 x 1024. An update with an image of another size moves the texture to the array of that size.
227
243
 
228
- WebGL2 promises each shader stage only 16 textures, so on WebGL2 the maps of one standard material share at most six. Maps in one array that sample the same way share one of the six. So a material whose color maps have one size and whose data maps have one size takes two. Each compressed map takes one of its own. Past six, a material draws without the maps that change its look least. It drops its specular intensity map first, then its specular color map, then its light map. A material that lets light through keeps its transmission map in the specular intensity map's place and its thickness map in the specular color map's, so they drop in that same order. A glTF material needs more than six only when its seven maps all differ in size, format or sampling.
244
+ On WebGL2, one standard material samples its maps through at most six texture units. Maps in one array that sample the same way share one unit, and each compressed map takes a unit of its own. A glTF material needs more than six only when its seven maps all differ in size, format or sampling. Past six, the material draws without the maps that change its look least.
245
+
246
+ <details>
247
+ <summary>Technical details: which maps WebGL2 drops first</summary>
248
+
249
+ WebGL2 promises each shader stage only 16 textures, so on WebGL2 the maps of one standard material share at most six. A material whose color maps have one size and whose data maps have one size takes two units. Past six, a material draws without the maps that change its look least.
250
+
251
+ It drops its specular intensity map first, then its specular color map, then its light map. A material that lets light through keeps its transmission map in the specular intensity map's place and its thickness map in the specular color map's, so they drop in that same order.
252
+
253
+ </details>
229
254
 
230
255
  A texture can be at most 4096 texels wide and tall, the most that every WebGPU device allows. On a WebGL2 device that allows less, the device's own limit applies: at least 2048 texels. `textures.maxSize` gives the limit, and a larger image throws E1208.
231
256
 
@@ -233,7 +258,9 @@ A texture can be at most 4096 texels wide and tall, the most that every WebGPU d
233
258
 
234
259
  An image decodes off the main thread into an `ImageBitmap`, and then moves to the thread that draws without a copy. In the default pipelined mode, that thread is the render worker. Data goes into the engine's memory, which that thread reads.
235
260
 
236
- The engine spreads uploads over frames, so loading many textures does not make one frame slow. Each frame uploads no more texel bytes than the upload budget, the `uploadBytesPerFrame` setting of the [quality preset](../concepts/quality-presets.md#the-settings-of-each-preset). A large texture goes up in bands of rows, one band per frame. Textures upload in the order that they got their texels. The engine frees its copy of data once the upload is done. Texels from a KTX2 file go into the engine's memory as data does. They go up in bands of rows of blocks, each mip level in turn.
261
+ The engine spreads uploads over frames, so loading many textures does not make one frame slow. Each frame uploads no more texel bytes than the upload budget, the `uploadBytesPerFrame` setting of the [quality preset](../concepts/quality-presets.md#the-settings-of-each-preset). A large texture goes up in bands of rows, one band per frame. Textures upload in the order that they got their texels.
262
+
263
+ The engine frees its copy of data once the upload is done. Texels from a KTX2 file go into the engine's memory as data does. They go up in bands of rows of blocks, each mip level in turn.
237
264
 
238
265
  Until its texels are on the GPU, a texture draws as if the material had no map. A material then shows its base color alone.
239
266
 
@@ -241,6 +268,10 @@ Until its texels are on the GPU, a texture draws as if the material had no map.
241
268
 
242
269
  Mip levels are smaller copies of a texture. The GPU reads them where the texture covers few pixels on screen, so distant textures do not shimmer. The engine makes each texture's mip levels on the GPU, after its texels upload. Each level is the average of the level above it, in linear color. Textures in `rgba16float` have no mip levels. A texture from a KTX2 file has the mip levels of its file.
243
270
 
271
+ ![A checkerboard drawn smaller and smaller: with mip levels the small copies fade to gray, without them they break into stray texels. Below, two receding floors; the right one uses anisotropic filtering and stays sharp further away.](../images/api/textures/mipmaps.webp)
272
+
273
+ Mip levels and anisotropic filtering.
274
+
244
275
  ## Sampling
245
276
 
246
277
  Each texture has its own sampler settings, from its options:
@@ -249,13 +280,29 @@ Each texture has its own sampler settings, from its options:
249
280
  - The filter of magnified texels, of minified texels and between mip levels: linear or nearest. It is linear by default.
250
281
  - Anisotropic filtering, which keeps a texture sharp on a surface seen at a slant, such as a floor. It reaches at most 16 samples, or the quality preset's cap (`maxAnisotropy`) when that is lower. A nearest filter turns it off. It is off by default.
251
282
 
283
+ ![A grid of texture samples. The bottom row applies repeat, clamp and mirror wrap to the same picture, then shows nearest and linear filters.](../images/api/reference/textures/texture-wrap.webp)
284
+
285
+ Wrap modes and the other texture checks.
286
+
287
+ Materials do not sample cube maps. A cube map can be a background: [Assets](assets.md) loads one with `assets.loadCubemap`.
288
+
252
289
  ## Color spaces
253
290
 
254
291
  Color maps, such as the base color of a surface, store sRGB colors. The GPU turns their texels into linear values as it samples them, so lighting works in linear color. Data maps, such as normal, roughness and metalness maps, store linear values, which the GPU reads as they are. Choose with the `colorSpace` option. [Color management](../concepts/color-management.md) explains the engine's color spaces.
255
292
 
256
293
  ## GPU memory
257
294
 
258
- A texture takes the GPU memory of its layers, with every mip level. The mip levels add a third to the image: a texture of 1024 x 1024 texels, at 4 bytes each, takes about 5.3 MiB. An `rgba16float` texel takes 8 bytes. A compressed texel takes 1 byte, or half a byte in `etc2-rgb8unorm`. An `rgb9e5ufloat` texel takes 4 bytes. The same texture from a KTX2 file then takes about 1.3 MiB or 0.7 MiB. An array also holds its free layers. The count in `textures.memoryBytes` holds them too. It also holds an array's old GPU texture after the array grows or shrinks, until the next frame frees it.
295
+ A texture takes the GPU memory of its layers, with every mip level.
296
+
297
+ | Format | Bytes per texel |
298
+ | --- | --- |
299
+ | `rgba8unorm` | 4 |
300
+ | `rgba16float` | 8 |
301
+ | `rgb9e5ufloat` | 4 |
302
+ | Compressed | 1 |
303
+ | `etc2-rgb8unorm` | 0.5 |
304
+
305
+ The mip levels add a third to the image: a texture of 1024 x 1024 texels, at 4 bytes each, takes about 5.3 MiB. The same texture from a KTX2 file then takes about 1.3 MiB or 0.7 MiB. An array also holds its free layers. The count in `textures.memoryBytes` holds them too. It also holds an array's old GPU texture after the array grows or shrinks, until the next frame frees it.
259
306
 
260
307
  The quality preset's texture memory budget, `textureMemoryMiB`, caps the GPU memory of every texture. Past it, the engine drops the largest mip levels of textures from files, and loads them again when room returns. Each texture's `droppedLevels` gives the levels that it lost, from 0 to 3. Its `width` and `height` keep its own size, and its `bytes` give the memory that it takes now. [Quality presets](../concepts/quality-presets.md#texture-memory) explains the order of the drops.
261
308
 
@@ -265,7 +312,9 @@ WebGPU and WebGL2 store, upload and sample textures the same way, and make the s
265
312
 
266
313
  ## When the browser takes the GPU away
267
314
 
268
- When the browser takes the GPU away, the engine starts a new device and uploads the texels that it still holds. A texture from a file loads its file again. On a phone or a tablet the engine also keeps its copy of an image or of data after their upload, so the texture draws with its map again. The `keepTextureCopies` option of `createEngine` turns that on or off on any device ([Page API](engine.md#options)). Keeping the copies costs about one more copy of each image in memory. Where the engine keeps no copy, a texture whose texels it released draws without its map until the texture gets an update.
315
+ When the browser takes the GPU away, the engine starts a new device and uploads the texels that it still holds. A texture from a file loads its file again. On a phone or a tablet the engine also keeps its copy of an image or of data after their upload, so the texture draws with its map again.
316
+
317
+ The `keepTextureCopies` option of `createEngine` turns that on or off on any device ([Page API](engine.md#options)). Keeping the copies costs about one more copy of each image in memory. Where the engine keeps no copy, a texture whose texels it released draws without its map until the texture gets an update.
269
318
 
270
319
  ## API reference
271
320
 
@@ -1,14 +1,10 @@
1
1
  ---
2
2
  id: api/three-compat
3
- title: three.js compatibility (@null3d/three-compat)
4
- status: experimental
5
- since: "0.3"
6
- summary: "Reinhard and Cineon tone curves for post.set, and an outline with three.js OutlinePass's glow, pulse and blurred edge."
3
+ title: three.js looks (@null3d/three-compat)
4
+ summary: "Reinhard and Cineon tone curves for post.set, and an outline with three.js OutlinePass's glow, pulse and blurred edge. It runs no three.js code."
7
5
  ---
8
6
 
9
- # three.js compatibility (@null3d/three-compat)
10
-
11
- > Roadmap step 0.3, first released in null3D 0.1.0. The API is experimental, so it can still change between versions.
7
+ # three.js looks (@null3d/three-compat)
12
8
 
13
9
  ```mermaid
14
10
  flowchart LR
@@ -21,6 +17,18 @@ flowchart LR
21
17
 
22
18
  The engine's core holds the looks that most scenes use. This add-on holds the few three.js looks that a port asks for. They are Reinhard's and Cineon's tone curves, and the soft outline of three.js's `OutlinePass`, with its glow, its pulse and its blurred edge. It uses only the engine's public API.
23
19
 
20
+ ## What it is not
21
+
22
+ The add-on is not a compatibility layer. It holds the two tone curves and the outline, and nothing more. It does not run three.js code, and it takes no three.js scene, object, material, shader or pass.
23
+
24
+ A port of a three.js scene is a rewrite in null3D's own API, with or without this add-on:
25
+
26
+ - The scene code moves into a sketch, which runs in a worker. Objects are handles with setters, and many similar objects are rows of a batch that typed arrays fill.
27
+ - GLSL becomes WGSL. A `ShaderMaterial` or an `onBeforeCompile` patch becomes a surface function, an unlit function or a vertex offset ([Porting shaders](../porting/threejs-shaders.md)).
28
+ - An `EffectComposer` chain becomes `post.set` settings, with `post.addEffect` for each custom pass ([Porting post-processing](../porting/threejs-postprocessing.md)).
29
+
30
+ [Porting from three.js](../porting/threejs-overview.md#a-port-is-a-rewrite) gives the workflow and the limits that a port meets.
31
+
24
32
  Install it beside the engine:
25
33
 
26
34
  ```sh
package/docs/api/time.md CHANGED
@@ -1,15 +1,11 @@
1
1
  ---
2
2
  id: api/time
3
3
  title: Time
4
- status: experimental
5
- since: "0.1"
6
4
  summary: "dt, time.now, fixed steps."
7
5
  ---
8
6
 
9
7
  # Time
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
  The engine calls the sketch's `onUpdate` callback once per frame. Its argument, `dt`, is the frame's step: the time in seconds since the sketch's previous frame. The `time` object in the sketch's context holds the sketch time, the frame's step and the frame number. Simulation that must step the same at every frame rate runs in fixed steps instead, in `onFixedUpdate`.
14
10
 
15
11
  Sketch time is the sum of every frame's step. Time while the engine is paused or the page is hidden does not count, so the sketch never jumps over a pause.
@@ -62,7 +58,7 @@ In hold mode, the first frame gets 0 and each later frame gets 1/60 second. The
62
58
  | `time.now` | Sketch time in seconds: the sum of every frame's step. It is 0 during the setup function. |
63
59
  | `time.dt` | The frame's step in seconds: the `dt` that `onUpdate` and `onLateUpdate` get. It is 0 during the setup function. |
64
60
  | `time.frame` | The frame number: 0 during the setup function, 1 in the first frame, and one more in each frame after it. |
65
- | `time.held` | True while hold mode steps to its held frame, and false otherwise. Work on a cadence reads it to draw in every frame, so a held frame never lands between two of its draws. |
61
+ | `time.held` | True while hold mode steps to its held frame, and false otherwise. Work on a cadence reads it to draw in every frame, so a held frame never lands between two of its draws. Unlike `engine.held`, it is false in the setup function and in a replay. |
66
62
  | `time.drawn` | False in a step of hold mode whose frame the GPU never draws, and true in every other frame. Hold mode draws only the frames at the end of its hold. Work that a frame's GPU passes pay for, such as a solver's runs for the time that passed, waits for a frame that draws, so the held frame carries the whole hold's work once. |
67
63
 
68
64
  The engine updates the fields at the start of each frame, before it calls `onFixedUpdate`, so `time.now` already includes the frame's step. The fields keep their values until the next frame, in every callback. In hold mode, `time.now` in the last frame is the held time exactly.
@@ -128,6 +124,8 @@ A fixed factor per frame, such as `current += (goal - current) * 0.1`, moves fas
128
124
  - [Page API: createEngine](engine.md): `setPaused`, `detach` and `attach`, which pause and resume the sketch's frames.
129
125
  - [Math helpers](math.md): `math.damp`, `math.lerp` and `vec3.lerp`.
130
126
  - [Testing your sketch](../guides/testing.md): hold mode's fixed steps.
127
+ - [Hold mode](https://github.com/null3d-engine/null3d/tree/main/examples/hold-mode): a held frame that every run draws the same.
128
+ - [Easing at any frame rate](https://github.com/null3d-engine/null3d/tree/main/examples/math): 300 drones that follow a lamp at their own lag and speed.
131
129
 
132
130
  ## API reference
133
131
 
package/docs/api/ui.md CHANGED
@@ -1,14 +1,10 @@
1
1
  ---
2
2
  id: api/ui
3
- title: UI overlays and labels
4
- status: experimental
5
- since: "0.2"
3
+ title: Labels that follow objects
6
4
  summary: "ui.trackLabel in the sketch; engine.labels.bind on the page."
7
5
  ---
8
6
 
9
- # UI overlays and labels
10
-
11
- > Roadmap step 0.2, first released in null3D 0.1.0. The API is experimental, so it can still change between versions.
7
+ # Labels that follow objects
12
8
 
13
9
  A label is an HTML element that follows a scene object, such as a name tag or a health bar above a unit. The sketch tracks a label on an object under an id, and the page binds an element to the same id. The engine then moves the element over the object in every frame on screen. No message goes between the sketch and the page per frame.
14
10
 
@@ -78,7 +74,14 @@ The engine holds 4,096 labels at once by default, and 256 labels that are planes
78
74
 
79
75
  `engine.labels.bind(id, element)` binds an element to the label with the same id. The sketch can track the label before or after the bind. The element stays hidden until the label's first frame reaches the screen. The code that moves the elements downloads with the first bind, so a page without labels never downloads it.
80
76
 
81
- The engine places the element's center over the label, through its CSS `transform`. It also sets the element's `position` to `absolute` at the top left of its container. So put the elements in a container that covers the canvas exactly, as the example above does. Give the container `pointer-events: none`, so the canvas still gets the pointer. The elements of labels flat on the screen stack in the order of the page, whatever their distance to the camera. The engine owns the element's `transform`. To anchor another point of the element on the label, offset the content inside the element with CSS.
77
+ The engine places the element's center over the label through its CSS `transform`, and sets its `position` to `absolute` at the top left of its container. So:
78
+
79
+ - Put the elements in a container that covers the canvas exactly, as the example above does.
80
+ - Give the container `pointer-events: none`, so the canvas still gets the pointer.
81
+ - Do not set the element's `transform`: the engine owns it.
82
+ - To anchor another point of the element on the label, offset the content inside the element with CSS.
83
+
84
+ The elements of labels flat on the screen stack in the order of the page, whatever their distance to the camera.
82
85
 
83
86
  The engine sets `visibility: hidden` on the element while:
84
87
 
@@ -114,15 +117,20 @@ What the page does for such a label:
114
117
 
115
118
  ## Which frame the labels follow
116
119
 
117
- The engine draws a frame on one thread while the sketch computes the next one on another. A label placed from the sketch's current camera would run ahead of the image during a fast camera move.
120
+ The engine draws a frame on one thread while the sketch computes the next one on another. A label placed from the sketch's current camera would run ahead of the image during a fast camera move. So the sketch places every label with the camera of each frame, as part of the frame's work.
118
121
 
119
- So the sketch places every label with the camera of each frame, as part of the frame's work. The thread that draws keeps the places of the frame it shows, and the page moves the elements to them. Each element therefore sits over its object in the frame on screen, in every thread mode. Where the page itself draws, it moves the elements right after it draws each frame, in the same update of the page.
122
+ The thread that draws keeps the places of the frame it shows, and the page moves the elements to them. Each element therefore sits over its object in the frame on screen, in every thread mode. Where the page itself draws, it moves the elements right after it draws each frame, in the same update of the page.
123
+
124
+ <details>
125
+ <summary>Technical details: how labels stay in step with the frame</summary>
120
126
 
121
127
  The page writes a screen label's element only when the label moved by half a CSS pixel or more, or when it shows or hides. It writes a 3D element's transform only when its matrix changed. It reads every label before it writes any style, so the browser runs no layout between them. While no element is bound, the labels cost the page nothing.
122
128
 
129
+ </details>
130
+
123
131
  ## Related pages
124
132
 
125
- - [UI, HTML overlays and labels](../guides/ui-overlays.md): HTML UI around the canvas, and labels in a full app.
133
+ - [HTML UI around the scene](../guides/ui-overlays.md): HTML UI around the canvas, and labels in a full app.
126
134
  - [Cameras](cameras.md): `worldToScreen` places a single point on the canvas.
127
135
  - [Engine](engine.md): `createEngine` and its label options.
128
136
  - [Sketch](sketch.md): the sketch's context, which holds `ui`.
@@ -1,30 +1,30 @@
1
1
  ---
2
2
  id: api/vertex-draws
3
3
  title: Draws from a vertex count
4
- status: experimental
5
- since: "0.2"
6
4
  summary: "scene.createVertexDraw: a custom material and a vertex count with no mesh data, the vertex and instance index in the shader, a bounds sphere, and helpers that wrap positions around the camera."
7
5
  ---
8
6
 
9
7
  # Draws from a vertex count
10
8
 
11
- > Roadmap step 0.2, 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
- shader["Your WGSL<br/>@builtin(vertex_index)<br/>@builtin(instance_index)"] --> call["scene.createVertexDraw"]
16
- counts["vertices: 6<br/>instances: 50,000"] --> call
17
- bounds["bounds: a sphere"] --> call
18
- call --> object["A scene object<br/>place, layers, culling sphere"]
11
+ shader["Your WGSL<br/>@builtin(vertex_index)<br/>@builtin(instance_index)"] --> create["scene.createVertexDraw"]
12
+ counts["vertices: 6<br/>instances: 50,000"] --> create
13
+ bounds["bounds: a sphere"] --> create
14
+ create --> object["A scene object<br/>place, layers, culling sphere"]
19
15
  object --> list["The frame's draw list<br/>one draw, no buffers"]
20
16
  ```
21
17
 
22
18
  A draw from a vertex count has a material and two numbers instead of a mesh. The numbers say how many vertices make one shape, and how many copies of the shape to draw. The shader makes every vertex itself, from the vertex index and the instance index. So the draw needs no vertex buffer, no index buffer and no per-instance data. A frame uploads nothing for it, whatever the number of copies.
23
19
 
24
- Use it for rain, streaks, sparks, card effects and shapes that a formula makes. You cannot change the shape per copy or hit-test it, and the whole draw sorts as one object in the transparent pass.
20
+ Use it for rain, streaks, sparks, card effects and shapes that a formula makes. Every copy has the same vertex count and no data of its own: the shader makes each one from its index. You cannot hit-test the shapes, and the whole draw sorts as one object in the transparent pass.
25
21
 
26
22
  ## Rain around the camera
27
23
 
24
+ ![Thousands of thin rain streaks fall through a dark night street with one distant lamp.](../images/api/vertex-draws/rain.webp)
25
+
26
+ Fifty thousand rain streaks from one vertex draw.
27
+
28
28
  ```ts
29
29
  import { defineSketch } from '@null3d/engine';
30
30
 
@@ -107,7 +107,7 @@ A draw's WGSL declares no texture, and the engine writes no values for a `struct
107
107
  draw.setCounts(6, 80_000);
108
108
  ```
109
109
 
110
- A frame reads the counts from engine memory, so a change uploads nothing.
110
+ A frame reads the counts from engine memory, so a change uploads nothing. A scene holds up to 256 vertex draws, and one more throws E1108.
111
111
 
112
112
  ## The bounds
113
113
 
@@ -147,7 +147,7 @@ A copy that leaves one side of the box comes back on the other side. The field t
147
147
 
148
148
  - A draw sorts as one object. Per-copy sorting is not available: give several draws when copies must sort against each other.
149
149
  - A draw casts no shadow and receives none.
150
- - A raycast tests the small triangle that the engine keeps for the draw's object. It does not test the shapes that the shader makes, so do not use a draw to hit-test.
150
+ - Raycasts and picks never hit a vertex draw, so do not use one to hit-test.
151
151
  - The pick pass and the depth prepass draw no vertex draw, so it is no occluder.
152
152
  - A draw has one shape and one material. For add-on draws with a feature description, use [scene.addFeatureDraw](feature-draws.md).
153
153
 
@@ -155,12 +155,13 @@ A copy that leaves one side of the box comes back on the other side. The field t
155
155
 
156
156
  | Code | Cause |
157
157
  | --- | --- |
158
- | E1108 | A count that is not a whole number from 1 up, a sphere radius that is not above 0, or more draws than the scene holds |
158
+ | E1108 | A count that is not a whole number from 1 up, a sphere radius that is not above 0, or more than 256 draws in a scene |
159
159
  | E1215 | WGSL that the plugin did not compile, or one whose `@vertex` entry point is not the draw shader's |
160
160
  | E1217 | An alpha mode other than `blend`, or the weighted blending |
161
161
 
162
162
  ## Related pages
163
163
 
164
+ - [The rain demo](https://github.com/null3d-engine/null3d/tree/main/examples/rain): 50,000 rain streaks from one draw with a vertex count and no mesh data.
164
165
  - [Custom shaders](../guides/custom-shaders.md): the WGSL that the plugin compiles, and full shaders.
165
166
  - [Built-in shader inputs](../shaders/builtins.md): `frame`, `camera` and `object`, which `fill_builtins` fills.
166
167
  - [Shader library and imports](../shaders/library.md): `null3d::wrap` and the other modules.