@null3d/engine 0.0.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 (517) hide show
  1. package/README.md +109 -0
  2. package/THIRD-PARTY-NOTICES.txt +0 -1
  3. package/dist/wasm/single/null3d.js +25 -10
  4. package/dist/wasm/single/null3d_bg.wasm +0 -0
  5. package/dist/wasm/threaded/null3d.js +25 -10
  6. package/dist/wasm/threaded/null3d_bg.wasm +0 -0
  7. package/docs/api/animation.md +114 -86
  8. package/docs/api/assets.md +135 -49
  9. package/docs/api/cameras.md +45 -12
  10. package/docs/api/controls.md +88 -62
  11. package/docs/api/debug.md +116 -41
  12. package/docs/api/engine.md +117 -35
  13. package/docs/api/feature-draws.md +23 -17
  14. package/docs/api/feature-effects.md +11 -11
  15. package/docs/api/feature-instances.md +70 -19
  16. package/docs/api/features.md +77 -47
  17. package/docs/api/geometry.md +132 -82
  18. package/docs/api/grass.md +55 -13
  19. package/docs/api/impostors.md +175 -22
  20. package/docs/api/input.md +24 -18
  21. package/docs/api/lights.md +78 -51
  22. package/docs/api/lines.md +41 -33
  23. package/docs/api/materials.md +248 -121
  24. package/docs/api/math.md +12 -13
  25. package/docs/api/objects.md +47 -22
  26. package/docs/api/page.md +58 -7
  27. package/docs/api/particles.md +33 -20
  28. package/docs/api/points.md +19 -31
  29. package/docs/api/post.md +75 -42
  30. package/docs/api/quality.md +42 -17
  31. package/docs/api/raycast.md +65 -51
  32. package/docs/api/reference/animation.md +10 -11
  33. package/docs/api/reference/assets.md +25 -22
  34. package/docs/api/reference/cameras.md +8 -4
  35. package/docs/api/reference/controls.md +134 -25
  36. package/docs/api/reference/debug.md +81 -14
  37. package/docs/api/reference/engine.md +58 -17
  38. package/docs/api/reference/feature-draws.md +3 -4
  39. package/docs/api/reference/feature-effects.md +2 -3
  40. package/docs/api/reference/feature-instances.md +5 -4
  41. package/docs/api/reference/features.md +7 -4
  42. package/docs/api/reference/geometry.md +287 -97
  43. package/docs/api/reference/grass.md +63 -3
  44. package/docs/api/reference/impostors.md +208 -13
  45. package/docs/api/reference/input.md +4 -5
  46. package/docs/api/reference/lights.md +13 -12
  47. package/docs/api/reference/lines.md +10 -11
  48. package/docs/api/reference/materials.md +54 -53
  49. package/docs/api/reference/math.md +35 -24
  50. package/docs/api/reference/objects.md +11 -12
  51. package/docs/api/reference/particles.md +31 -6
  52. package/docs/api/reference/points.md +6 -7
  53. package/docs/api/reference/post.md +21 -20
  54. package/docs/api/reference/quality.md +8 -5
  55. package/docs/api/reference/raycast.md +7 -8
  56. package/docs/api/reference/render.md +5 -4
  57. package/docs/api/reference/scene.md +52 -30
  58. package/docs/api/reference/sketch.md +15 -11
  59. package/docs/api/reference/sound.md +234 -0
  60. package/docs/api/reference/splats.md +42 -3
  61. package/docs/api/reference/sprites.md +7 -8
  62. package/docs/api/reference/tasks.md +16 -3
  63. package/docs/api/reference/terrain.md +27 -5
  64. package/docs/api/reference/textures.md +5 -6
  65. package/docs/api/reference/three-compat.md +18 -7
  66. package/docs/api/reference/time.md +1 -2
  67. package/docs/api/reference/ui.md +12 -9
  68. package/docs/api/reference/vertex-draws.md +5 -6
  69. package/docs/api/reference/water.md +153 -9
  70. package/docs/api/reference/wind.md +17 -4
  71. package/docs/api/render.md +73 -29
  72. package/docs/api/scene.md +164 -60
  73. package/docs/api/sketch.md +102 -15
  74. package/docs/api/sound.md +205 -0
  75. package/docs/api/splats.md +46 -12
  76. package/docs/api/sprites.md +10 -24
  77. package/docs/api/tasks.md +33 -24
  78. package/docs/api/terrain.md +42 -22
  79. package/docs/api/textures.md +68 -19
  80. package/docs/api/three-compat.md +15 -7
  81. package/docs/api/time.md +3 -5
  82. package/docs/api/ui.md +19 -23
  83. package/docs/api/vertex-draws.md +13 -12
  84. package/docs/api/water.md +262 -35
  85. package/docs/api/wind.md +63 -17
  86. package/docs/cli/null3d.md +177 -27
  87. package/docs/concepts/architecture.md +73 -27
  88. package/docs/concepts/assets.md +57 -33
  89. package/docs/concepts/backends.md +69 -27
  90. package/docs/concepts/color-management.md +54 -36
  91. package/docs/concepts/culling.md +68 -47
  92. package/docs/concepts/handles.md +14 -5
  93. package/docs/concepts/instances.md +74 -25
  94. package/docs/concepts/large-worlds.md +18 -8
  95. package/docs/concepts/lighting.md +155 -87
  96. package/docs/concepts/lod.md +126 -44
  97. package/docs/concepts/materials.md +58 -27
  98. package/docs/concepts/particle-buffer.md +48 -35
  99. package/docs/concepts/post-processing.md +84 -43
  100. package/docs/concepts/quality-preset-tables.md +56 -52
  101. package/docs/concepts/quality-presets.md +164 -52
  102. package/docs/concepts/render-graph.md +69 -29
  103. package/docs/concepts/render-layers.md +11 -21
  104. package/docs/concepts/shadows.md +105 -52
  105. package/docs/concepts/static-dynamic.md +22 -7
  106. package/docs/cookbook/index.md +164 -120
  107. package/docs/data/threejs-mapping.json +362 -367
  108. package/docs/errors/E1101.md +23 -5
  109. package/docs/errors/E1102.md +11 -3
  110. package/docs/errors/E1103.md +11 -3
  111. package/docs/errors/E1104.md +11 -3
  112. package/docs/errors/E1105.md +13 -5
  113. package/docs/errors/E1106.md +11 -3
  114. package/docs/errors/E1107.md +15 -5
  115. package/docs/errors/E1108.md +11 -3
  116. package/docs/errors/E1109.md +32 -6
  117. package/docs/errors/E1110.md +23 -5
  118. package/docs/errors/E1111.md +11 -3
  119. package/docs/errors/E1112.md +11 -3
  120. package/docs/errors/E1203.md +12 -4
  121. package/docs/errors/E1204.md +11 -3
  122. package/docs/errors/E1205.md +11 -3
  123. package/docs/errors/E1206.md +28 -6
  124. package/docs/errors/E1207.md +11 -3
  125. package/docs/errors/E1208.md +12 -3
  126. package/docs/errors/E1209.md +11 -3
  127. package/docs/errors/E1213.md +27 -5
  128. package/docs/errors/E1214.md +14 -6
  129. package/docs/errors/E1215.md +31 -6
  130. package/docs/errors/E1216.md +31 -6
  131. package/docs/errors/E1217.md +29 -6
  132. package/docs/errors/E1218.md +22 -6
  133. package/docs/errors/E1219.md +11 -3
  134. package/docs/errors/E1220.md +24 -5
  135. package/docs/errors/E1221.md +24 -5
  136. package/docs/errors/E1222.md +11 -3
  137. package/docs/errors/E1223.md +39 -6
  138. package/docs/errors/E1224.md +11 -3
  139. package/docs/errors/E1225.md +11 -3
  140. package/docs/errors/E1301.md +11 -3
  141. package/docs/errors/E1302.md +11 -3
  142. package/docs/errors/E1303.md +11 -3
  143. package/docs/errors/E1304.md +11 -3
  144. package/docs/errors/E1305.md +13 -3
  145. package/docs/errors/E1306.md +11 -3
  146. package/docs/errors/E1307.md +40 -0
  147. package/docs/errors/E1401.md +11 -3
  148. package/docs/errors/E1402.md +13 -5
  149. package/docs/errors/E1403.md +11 -3
  150. package/docs/errors/E1404.md +13 -3
  151. package/docs/errors/E1405.md +15 -4
  152. package/docs/errors/E1406.md +31 -5
  153. package/docs/errors/E1407.md +11 -3
  154. package/docs/errors/E1408.md +11 -3
  155. package/docs/errors/E1409.md +11 -3
  156. package/docs/errors/E1410.md +13 -5
  157. package/docs/errors/E1411.md +11 -3
  158. package/docs/errors/E1412.md +29 -6
  159. package/docs/errors/E1413.md +11 -3
  160. package/docs/errors/E1414.md +11 -3
  161. package/docs/errors/E1415.md +11 -3
  162. package/docs/errors/E1416.md +27 -6
  163. package/docs/errors/E1417.md +11 -3
  164. package/docs/errors/E1418.md +12 -3
  165. package/docs/errors/E1419.md +13 -5
  166. package/docs/errors/E1420.md +14 -6
  167. package/docs/errors/E1421.md +11 -3
  168. package/docs/errors/E1422.md +12 -3
  169. package/docs/errors/E1423.md +12 -3
  170. package/docs/errors/E1424.md +24 -5
  171. package/docs/errors/E1425.md +11 -3
  172. package/docs/errors/E1426.md +11 -3
  173. package/docs/errors/E1430.md +11 -3
  174. package/docs/errors/E1431.md +11 -3
  175. package/docs/errors/E1432.md +11 -3
  176. package/docs/errors/E1433.md +11 -3
  177. package/docs/errors/E1434.md +15 -6
  178. package/docs/errors/E1435.md +11 -3
  179. package/docs/errors/E1436.md +11 -3
  180. package/docs/errors/E1437.md +14 -6
  181. package/docs/errors/E1501.md +41 -6
  182. package/docs/errors/E1502.md +13 -3
  183. package/docs/errors/E1503.md +11 -3
  184. package/docs/errors/E1504.md +11 -3
  185. package/docs/errors/E1505.md +23 -5
  186. package/docs/errors/E1506.md +11 -3
  187. package/docs/errors/index.md +54 -30
  188. package/docs/getting-started/cdn.md +32 -10
  189. package/docs/getting-started/first-scene.md +21 -13
  190. package/docs/getting-started/hosting.md +152 -63
  191. package/docs/getting-started/install.md +44 -28
  192. package/docs/getting-started/network-use.md +33 -15
  193. package/docs/getting-started/project-structure.md +33 -12
  194. package/docs/getting-started/third-party-notices.md +12 -14
  195. package/docs/guides/accessibility.md +5 -5
  196. package/docs/guides/add-ons.md +86 -15
  197. package/docs/guides/agents.md +16 -9
  198. package/docs/guides/assets-pipeline.md +259 -82
  199. package/docs/guides/audio.md +115 -128
  200. package/docs/guides/baked-light-data.md +44 -23
  201. package/docs/guides/car-paint.md +38 -32
  202. package/docs/guides/content-pages.md +63 -35
  203. package/docs/guides/custom-passes.md +65 -22
  204. package/docs/guides/custom-shaders.md +59 -39
  205. package/docs/guides/debugging.md +74 -10
  206. package/docs/guides/deploying.md +85 -6
  207. package/docs/guides/deterministic-simulation.md +24 -17
  208. package/docs/guides/first-use-shaders.md +83 -45
  209. package/docs/guides/lens-kit.md +29 -26
  210. package/docs/guides/loading-screens.md +132 -47
  211. package/docs/guides/multiple-views.md +63 -13
  212. package/docs/guides/performance.md +192 -38
  213. package/docs/guides/phones.md +78 -15
  214. package/docs/guides/physics.md +7 -11
  215. package/docs/guides/screens.md +47 -33
  216. package/docs/guides/start-time.md +363 -0
  217. package/docs/guides/testing.md +152 -95
  218. package/docs/guides/ui-overlays.md +19 -14
  219. package/docs/guides/video-textures.md +14 -13
  220. package/docs/images/api/animation/character.webp +0 -0
  221. package/docs/images/api/animation/look-at-ring.webp +0 -0
  222. package/docs/images/api/animation/morph-tulips.webp +0 -0
  223. package/docs/images/api/animation/skeleton-lines.webp +0 -0
  224. package/docs/images/api/controls/gizmo-handles.webp +0 -0
  225. package/docs/images/api/controls/walk-and-fly.webp +0 -0
  226. package/docs/images/api/debug/debug-shapes.webp +0 -0
  227. package/docs/images/api/debug/levels-view.webp +0 -0
  228. package/docs/images/api/engine/transparent-canvas.webp +0 -0
  229. package/docs/images/api/feature-draws/feature-draw-clouds.webp +0 -0
  230. package/docs/images/api/feature-instances/compute-instances.webp +0 -0
  231. package/docs/images/api/feature-instances/instances-shadow.webp +0 -0
  232. package/docs/images/api/geometry/extra-shapes.webp +0 -0
  233. package/docs/images/api/geometry/generators.webp +0 -0
  234. package/docs/images/api/geometry/mesh-arrays.webp +0 -0
  235. package/docs/images/api/geometry/vertex-updates.webp +0 -0
  236. package/docs/images/api/grass/grass-grove.webp +0 -0
  237. package/docs/images/api/grass/grass-presets.webp +0 -0
  238. package/docs/images/api/grass/grass-shadow.webp +0 -0
  239. package/docs/images/api/impostors/impostor-handover.webp +0 -0
  240. package/docs/images/api/impostors/impostor-shadow.webp +0 -0
  241. package/docs/images/api/impostors/impostors-forest.webp +0 -0
  242. package/docs/images/api/lights/spot-cookies.webp +0 -0
  243. package/docs/images/api/lines/lines-lit.webp +0 -0
  244. package/docs/images/api/lines/lines-widths.webp +0 -0
  245. package/docs/images/api/materials/coat-and-sheen.webp +0 -0
  246. package/docs/images/api/materials/decals.webp +0 -0
  247. package/docs/images/api/materials/iridescence-and-anisotropy.webp +0 -0
  248. package/docs/images/api/materials/relief.webp +0 -0
  249. package/docs/images/api/materials/shader-inputs.webp +0 -0
  250. package/docs/images/api/materials/standard-grid.webp +0 -0
  251. package/docs/images/api/materials/subsurface.webp +0 -0
  252. package/docs/images/api/materials/translucency.webp +0 -0
  253. package/docs/images/api/objects/objects-turntable.webp +0 -0
  254. package/docs/images/api/particles/campfire.webp +0 -0
  255. package/docs/images/api/points/galaxy.webp +0 -0
  256. package/docs/images/api/reference/textures/texture-wrap.webp +0 -0
  257. package/docs/images/api/render/fullscreen-glow.webp +0 -0
  258. package/docs/images/api/render/reflection-mirror.webp +0 -0
  259. package/docs/images/api/render/security-camera.webp +0 -0
  260. package/docs/images/api/scene/aurora-sky-layer.webp +0 -0
  261. package/docs/images/api/sound/sound-demo.webp +0 -0
  262. package/docs/images/api/splats/splats-demo.webp +0 -0
  263. package/docs/images/api/sprites/sprites-lines.webp +0 -0
  264. package/docs/images/api/terrain/terrain-demo.webp +0 -0
  265. package/docs/images/api/textures/canvas-screen.webp +0 -0
  266. package/docs/images/api/textures/mipmaps.webp +0 -0
  267. package/docs/images/api/vertex-draws/rain.webp +0 -0
  268. package/docs/images/api/water/ocean.webp +0 -0
  269. package/docs/images/api/water/water-demo.webp +0 -0
  270. package/docs/images/api/water/water-rain.webp +0 -0
  271. package/docs/images/api/water/waterfall.webp +0 -0
  272. package/docs/images/concepts/assets/gltf-model.webp +0 -0
  273. package/docs/images/concepts/color-management/tone-mapped.webp +0 -0
  274. package/docs/images/concepts/culling/far-from-origin.webp +0 -0
  275. package/docs/images/concepts/instances/instances.webp +0 -0
  276. package/docs/images/concepts/instances/per-row-colors.webp +0 -0
  277. package/docs/images/concepts/large-worlds/large-world.webp +0 -0
  278. package/docs/images/concepts/lighting/area-lights.webp +0 -0
  279. package/docs/images/concepts/lighting/atmosphere.webp +0 -0
  280. package/docs/images/concepts/lighting/environment.webp +0 -0
  281. package/docs/images/concepts/lighting/light-shafts.webp +0 -0
  282. package/docs/images/concepts/lighting/reflection-probes.webp +0 -0
  283. package/docs/images/concepts/lod/forest.webp +0 -0
  284. package/docs/images/concepts/materials/weighted-transparency.webp +0 -0
  285. package/docs/images/concepts/post-processing/auto-exposure.webp +0 -0
  286. package/docs/images/concepts/post-processing/bounce-light.webp +0 -0
  287. package/docs/images/concepts/post-processing/depth-of-field.webp +0 -0
  288. package/docs/images/concepts/post-processing/post-effects-alley.webp +0 -0
  289. package/docs/images/concepts/post-processing/sharpen.webp +0 -0
  290. package/docs/images/concepts/post-processing/ssr-wet-street.webp +0 -0
  291. package/docs/images/concepts/render-layers/layers-cottages.webp +0 -0
  292. package/docs/images/concepts/shadows/hero-shadow.webp +0 -0
  293. package/docs/images/cookbook/index/picking.webp +0 -0
  294. package/docs/images/cookbook/index/time-of-day.webp +0 -0
  295. package/docs/images/errors/E1431/area-lights-no-tables.webp +0 -0
  296. package/docs/images/guides/custom-passes/reflection-water.webp +0 -0
  297. package/docs/images/guides/deterministic-simulation/replay-demo.webp +0 -0
  298. package/docs/images/guides/multiple-views/split-screen.webp +0 -0
  299. package/docs/images/guides/performance/overdraw-view.webp +0 -0
  300. package/docs/images/guides/testing/hold-mode-frame.webp +0 -0
  301. package/docs/images/index/showcase-island.webp +0 -0
  302. package/docs/images/porting/threejs-shaders/dissolve.webp +0 -0
  303. package/docs/images/shaders/builtins/builtins.webp +0 -0
  304. package/docs/images/shaders/surface-functions/custom-surface.webp +0 -0
  305. package/docs/images/shaders/surface-functions/vertex-offset.webp +0 -0
  306. package/docs/images/shots.json +2231 -0
  307. package/docs/index.md +18 -23
  308. package/docs/moves.json +1 -0
  309. package/docs/nav.json +300 -0
  310. package/docs/pages.md +230 -209
  311. package/docs/porting/react-three-fiber.md +225 -6
  312. package/docs/porting/threejs-loop-and-threads.md +217 -7
  313. package/docs/porting/threejs-mapping.md +1249 -233
  314. package/docs/porting/threejs-materials.md +218 -6
  315. package/docs/porting/threejs-overview.md +240 -7
  316. package/docs/porting/threejs-postprocessing.md +4 -8
  317. package/docs/porting/threejs-shaders.md +301 -6
  318. package/docs/porting/threejs-unsupported.md +83 -7
  319. package/docs/porting/verification.md +178 -6
  320. package/docs/shaders/builtins.md +15 -4
  321. package/docs/shaders/library.md +72 -45
  322. package/docs/shaders/surface-functions.md +59 -23
  323. package/docs/shaders/wgsl-rules.md +12 -5
  324. package/lib/debug/channel.d.ts +103 -0
  325. package/lib/debug/channel.js +269 -0
  326. package/lib/debug/debug.d.ts +11 -9
  327. package/lib/debug/draw.d.ts +11 -2
  328. package/lib/debug/draw.js +57 -6
  329. package/lib/debug/inspector.d.ts +60 -0
  330. package/lib/debug/inspector.js +475 -0
  331. package/lib/debug/overlay-look.d.ts +6 -0
  332. package/lib/debug/overlay-look.js +29 -7
  333. package/lib/debug/overlay.js +15 -11
  334. package/lib/debug/stats-options.d.ts +13 -0
  335. package/lib/debug/stats-panel.d.ts +22 -7
  336. package/lib/debug/stats-panel.js +80 -13
  337. package/lib/debug/stats.d.ts +2 -3
  338. package/lib/errors/codes.d.ts +17 -3
  339. package/lib/errors/codes.js +117 -105
  340. package/lib/errors/engine-error.js +25 -10
  341. package/lib/errors/fixes.d.ts +1 -0
  342. package/lib/errors/fixes.js +20 -19
  343. package/lib/generated/core.d.ts +1 -1
  344. package/lib/generated/core.js +1 -1
  345. package/lib/gpu/early-builds.d.ts +68 -0
  346. package/lib/gpu/early-builds.js +158 -0
  347. package/lib/gpu/pipeline-name.d.ts +6 -0
  348. package/lib/gpu/pipeline-name.js +23 -0
  349. package/lib/gpu/variants.d.ts +8 -2
  350. package/lib/gpu/variants.js +39 -7
  351. package/lib/gpu/webgl2/backend.d.ts +63 -2
  352. package/lib/gpu/webgl2/backend.js +226 -8
  353. package/lib/gpu/webgl2/programs.d.ts +18 -0
  354. package/lib/gpu/webgl2/programs.js +5 -2
  355. package/lib/gpu/webgpu/backend.d.ts +89 -2
  356. package/lib/gpu/webgpu/backend.js +255 -8
  357. package/lib/gpu/webgpu/pipelines.d.ts +13 -0
  358. package/lib/gpu/webgpu/pipelines.js +28 -14
  359. package/lib/index.d.ts +7 -5
  360. package/lib/index.js +3 -2
  361. package/lib/math/color.d.ts +5 -5
  362. package/lib/math/color.js +5 -5
  363. package/lib/math/mat4.d.ts +6 -12
  364. package/lib/math/mat4.js +6 -12
  365. package/lib/math/namespaces/quat.d.ts +3 -3
  366. package/lib/math/namespaces/quat.js +3 -3
  367. package/lib/math/quat.d.ts +8 -12
  368. package/lib/math/quat.js +8 -12
  369. package/lib/math/random.d.ts +2 -3
  370. package/lib/math/random.js +2 -3
  371. package/lib/math/types.d.ts +4 -4
  372. package/lib/math/vec3.d.ts +3 -6
  373. package/lib/math/vec3.js +3 -6
  374. package/lib/page/capabilities.d.ts +8 -8
  375. package/lib/page/capabilities.js +39 -25
  376. package/lib/page/check-store.d.ts +14 -2
  377. package/lib/page/check-store.js +34 -11
  378. package/lib/page/engine.d.ts +117 -31
  379. package/lib/page/engine.js +438 -99
  380. package/lib/page/first-frame.d.ts +16 -0
  381. package/lib/page/first-frame.js +35 -0
  382. package/lib/page/frame-stats.d.ts +34 -1
  383. package/lib/page/frame-stats.js +15 -0
  384. package/lib/page/label-loop.d.ts +7 -3
  385. package/lib/page/label-loop.js +26 -14
  386. package/lib/page/labels.d.ts +3 -3
  387. package/lib/page/pipeline-store.d.ts +25 -0
  388. package/lib/page/pipeline-store.js +84 -0
  389. package/lib/page/start-marker.d.ts +4 -1
  390. package/lib/page/start-marker.js +5 -2
  391. package/lib/page/stats-switch.js +2 -0
  392. package/lib/page/switches.d.ts +38 -6
  393. package/lib/page/switches.js +29 -5
  394. package/lib/quality/check.d.ts +24 -3
  395. package/lib/quality/check.js +21 -7
  396. package/lib/quality/chooser.d.ts +6 -0
  397. package/lib/quality/chooser.js +8 -0
  398. package/lib/quality/governor.d.ts +98 -6
  399. package/lib/quality/governor.js +250 -20
  400. package/lib/quality/preset-docs.d.ts +16 -1
  401. package/lib/quality/preset-docs.js +3 -0
  402. package/lib/quality/presets.d.ts +84 -7
  403. package/lib/quality/presets.js +94 -2
  404. package/lib/render/draw.d.ts +3 -2
  405. package/lib/render/draw.js +15 -5
  406. package/lib/render/load-draw.d.ts +7 -5
  407. package/lib/render/load-draw.js +7 -5
  408. package/lib/render/loss.d.ts +28 -10
  409. package/lib/render/loss.js +50 -22
  410. package/lib/render/recovery.d.ts +20 -0
  411. package/lib/render/recovery.js +44 -4
  412. package/lib/render/renderer.d.ts +85 -9
  413. package/lib/render/renderer.js +181 -42
  414. package/lib/render/scene-renderer.d.ts +19 -1
  415. package/lib/render/scene-renderer.js +25 -1
  416. package/lib/render/webgl2-renderers.js +8 -5
  417. package/lib/render/webgpu-renderers.js +5 -4
  418. package/lib/scene/animation.d.ts +28 -32
  419. package/lib/scene/animation.js +12 -15
  420. package/lib/scene/assets.d.ts +61 -86
  421. package/lib/scene/assets.js +103 -236
  422. package/lib/scene/background.d.ts +14 -18
  423. package/lib/scene/background.js +5 -2
  424. package/lib/scene/baked-light.d.ts +2 -2
  425. package/lib/scene/color.d.ts +3 -3
  426. package/lib/scene/downloads.d.ts +2 -0
  427. package/lib/scene/downloads.js +371 -0
  428. package/lib/scene/environment.d.ts +7 -7
  429. package/lib/scene/environment.js +1 -1
  430. package/lib/scene/fake-call-values.js +3 -3
  431. package/lib/scene/fog.d.ts +11 -4
  432. package/lib/scene/fog.js +8 -2
  433. package/lib/scene/frame-cameras.d.ts +35 -4
  434. package/lib/scene/frame-cameras.js +86 -10
  435. package/lib/scene/gltf.d.ts +33 -3
  436. package/lib/scene/gltf.js +78 -49
  437. package/lib/scene/grading.d.ts +2 -2
  438. package/lib/scene/grading.js +3 -3
  439. package/lib/scene/ktx2.d.ts +9 -1
  440. package/lib/scene/ktx2.js +3 -2
  441. package/lib/scene/level-rule.d.ts +121 -0
  442. package/lib/scene/level-rule.js +130 -0
  443. package/lib/scene/lines.d.ts +13 -17
  444. package/lib/scene/lines.js +3 -3
  445. package/lib/scene/lut.d.ts +1 -2
  446. package/lib/scene/lut.js +1 -2
  447. package/lib/scene/particles.d.ts +7 -3
  448. package/lib/scene/particles.js +3 -1
  449. package/lib/scene/picks.d.ts +2 -2
  450. package/lib/scene/pointer-events.d.ts +4 -7
  451. package/lib/scene/post.d.ts +39 -43
  452. package/lib/scene/post.js +4 -1
  453. package/lib/scene/prefab.d.ts +7 -8
  454. package/lib/scene/prefab.js +7 -8
  455. package/lib/scene/property-animation.d.ts +1 -1
  456. package/lib/scene/property-animation.js +1 -1
  457. package/lib/scene/queries.d.ts +7 -13
  458. package/lib/scene/resources.d.ts +238 -261
  459. package/lib/scene/resources.js +179 -81
  460. package/lib/scene/scene.d.ts +167 -120
  461. package/lib/scene/scene.js +243 -103
  462. package/lib/scene/serial-loads.d.ts +29 -0
  463. package/lib/scene/serial-loads.js +68 -0
  464. package/lib/scene/shader-preloads.d.ts +34 -0
  465. package/lib/scene/shader-preloads.js +38 -0
  466. package/lib/scene/sprites.d.ts +14 -17
  467. package/lib/scene/sprites.js +5 -6
  468. package/lib/scene/textures.d.ts +11 -12
  469. package/lib/scene/textures.js +9 -10
  470. package/lib/scene/time-of-day.d.ts +11 -7
  471. package/lib/scene/time-of-day.js +11 -8
  472. package/lib/scene/vertex-draws.d.ts +5 -4
  473. package/lib/scene/vertex-draws.js +7 -5
  474. package/lib/shader-artifact.json +1 -0
  475. package/lib/shared/core.d.ts +5 -0
  476. package/lib/shared/core.js +1 -0
  477. package/lib/shared/import-once.d.ts +6 -0
  478. package/lib/shared/import-once.js +19 -0
  479. package/lib/shared/labels.d.ts +5 -2
  480. package/lib/shared/labels.js +5 -2
  481. package/lib/shared/metrics.d.ts +38 -0
  482. package/lib/shared/metrics.js +62 -1
  483. package/lib/shared/permutation-words.d.ts +2 -0
  484. package/lib/shared/permutation-words.js +8 -0
  485. package/lib/shared/recording.d.ts +13 -5
  486. package/lib/shared/recording.js +31 -10
  487. package/lib/shared/run-task.js +7 -1
  488. package/lib/shared/sketch-data.d.ts +9 -0
  489. package/lib/shared/sketch-data.js +57 -0
  490. package/lib/shared/task-pending.d.ts +12 -0
  491. package/lib/shared/task-pending.js +61 -1
  492. package/lib/shared/tasks.js +79 -32
  493. package/lib/shared/version.d.ts +17 -1
  494. package/lib/shared/version.js +19 -1
  495. package/lib/shared/wasm.d.ts +12 -4
  496. package/lib/shared/wasm.js +50 -27
  497. package/lib/shared/worker-start.d.ts +7 -0
  498. package/lib/shared/worker-start.js +27 -0
  499. package/lib/sketch/define-sketch.d.ts +51 -7
  500. package/lib/sketch/define-sketch.js +2 -1
  501. package/lib/sketch/input.d.ts +2 -2
  502. package/lib/sketch/preset-check.d.ts +20 -6
  503. package/lib/sketch/preset-check.js +42 -17
  504. package/lib/sketch/quality.d.ts +69 -11
  505. package/lib/sketch/quality.js +54 -13
  506. package/lib/sketch/runner.d.ts +80 -9
  507. package/lib/sketch/runner.js +390 -52
  508. package/lib/sketch/ui.d.ts +5 -8
  509. package/lib/sketch/ui.js +4 -2
  510. package/lib/stats.d.ts +1 -0
  511. package/lib/workers/probe-worker.d.ts +5 -0
  512. package/lib/workers/probe-worker.js +13 -4
  513. package/lib/workers/protocol.d.ts +71 -13
  514. package/lib/workers/protocol.js +4 -0
  515. package/lib/workers/render-worker.js +29 -5
  516. package/lib/workers/sketch-worker.js +108 -16
  517. package/package.json +2 -2
@@ -1,15 +1,11 @@
1
1
  ---
2
2
  id: concepts/backends
3
3
  title: GPU tiers and backends
4
- status: experimental
5
- since: "0.1"
6
4
  summary: "WebGPU core, compatibility mode and WebGL2; color, anti-aliasing and depth on each tier; capability flags; the portable budget; never branching on GPU names."
7
5
  ---
8
6
 
9
7
  # GPU tiers and backends
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 TD
15
11
  start["Page loads: the engine runs feature tests"] --> adapter{"Does the browser give<br/>a WebGPU adapter?"}
@@ -18,7 +14,11 @@ flowchart TD
18
14
  adapter -- "no" --> gl["WebGL2"]
19
15
  ```
20
16
 
21
- null3D draws with WebGPU where the browser offers it, and with WebGL2 everywhere else. The same sketch code runs on both, with no backend checks in it. The engine picks the tier once, at startup, from feature tests. It tests the thread that will draw: where a worker draws, the engine picks the best tier that the worker can use. Where no worker can draw, the page draws in pipelined mode, even when the page asks for low latency ([Architecture](architecture.md#where-the-sketch-runs)). After two starts in a row that crashed the tab on WebGPU, the engine starts on WebGL2. A page that names a GPU path keeps it ([Quality presets](quality-presets.md#starts-that-crashed-the-tab)).
17
+ null3D draws with WebGPU where the browser offers it, and with WebGL2 everywhere else. The same sketch code runs on both, with no backend checks in it. So one sketch works in every current browser on computers, tablets and phones.
18
+
19
+ The engine picks the tier once, at startup, from feature tests. It tests the thread that will draw: where a worker draws, the engine picks the best tier that the worker can use. Where no worker can draw, the page draws in pipelined mode, even when the page asks for low latency ([Architecture](architecture.md#where-the-sketch-runs)). After two starts in a row that crashed the tab on WebGPU, the engine starts on WebGL2. A page that names a GPU path keeps it ([Quality presets](quality-presets.md#starts-that-crashed-the-tab)).
20
+
21
+ Other pages call the tier the GPU path. `engine.capabilities.tier` says which one the engine started on.
22
22
 
23
23
  ## The three tiers
24
24
 
@@ -32,9 +32,18 @@ Browser support changes often, so this table can go out of date. At run time, th
32
32
 
33
33
  ## How each path draws
34
34
 
35
- On WebGPU, the GPU culls the scene itself. The engine records one draw for each group of objects that share a pipeline, a mesh and a material, and replays these draws every frame. The GPU fills in each draw's count. The CPU's cost per frame grows with the number of those groups, and stays almost flat as the object count grows. A start-up measurement can pick a direct-draw path instead, where the job workers cull on the CPU and each bucket draws directly ([Culling](culling.md#how-each-path-culls)).
35
+ On WebGPU, the GPU culls the scene itself. The engine records one draw for each group of objects that share a pipeline, a mesh and a material, and replays these draws every frame. The GPU fills in each draw's count. The CPU's cost per frame grows with the number of those groups, and stays almost flat as the object count grows. A start-up measurement can pick a direct-draw path instead. There the job workers cull on the CPU, and each group draws with the count they found ([Culling](culling.md#how-each-path-culls)).
36
+
37
+ On WebGL2 there are no compute shaders, so the job workers cull on the CPU ([Culling](culling.md#how-each-path-culls)). Where the browser has the `WEBGL_multi_draw` extension, one call draws each group with the same shading, texture maps and mesh buffer. Firefox lacks the extension, so there each group takes one call.
38
+
39
+ <details>
40
+ <summary>Technical details: how WebGL2 uploads a frame</summary>
41
+
42
+ The job workers group the visible objects the same way as on WebGPU. Each object's matrix sits in a data texture on the GPU, which a frame updates only where matrices changed. Dynamic instance batches write theirs each frame into the next of three textures. So a frame never writes a texture that the GPU may still read.
36
43
 
37
- On WebGL2 there are no compute shaders, so the job workers cull in parallel on the CPU and group the visible objects the same way. Each object's matrix sits in a data texture on the GPU, which a frame updates only where matrices changed. Dynamic instance batches write theirs each frame into the next of three textures. A frame then never writes a texture that the GPU may still read. Each frame lists the visible objects, 4 bytes each, and uploads the list only when it changed. The `visibleEntries` figure of `engine.measure` counts the entries of each frame's list. A static instance batch that has stopped changing is culled in groups of 64 nearby rows, with one test and one list entry per group. A group partly in view draws all its rows, and the GPU clips the ones outside. On both paths, a scene spread over several grid cells skips the still objects of the cells out of view first ([Culling](culling.md)). Where the browser has the `WEBGL_multi_draw` extension, one call draws every group with the same shading, the same texture maps and the same mesh buffer. Firefox lacks the extension, so there each group takes one call.
44
+ Each frame lists the visible objects, 4 bytes each, and uploads the list only when it changed. The `visibleEntries` figure of `engine.measure` counts the entries of each frame's list. A static instance batch that has stopped changing is culled in groups of 64 nearby rows, with one test and one list entry per group. A group partly in view draws all its rows, and the GPU clips the ones outside. On both paths, a scene spread over several grid cells skips the still objects of the cells out of view first ([Culling](culling.md)).
45
+
46
+ </details>
38
47
 
39
48
  Every feature works on both paths, or its page describes its WebGL2 fallback. The page downloads only the renderers and the shaders of the path that it draws with. Other work differs by path too:
40
49
 
@@ -46,7 +55,7 @@ Every feature works on both paths, or its page describes its WebGL2 fallback. Th
46
55
  | [Skinning](../api/animation.md#skinned-meshes) | The vertex shader of each pass that draws the mesh, with copies of one mesh and material in one instanced draw | The same |
47
56
  | [Morph targets](../api/animation.md#morph-targets) | The skinning pass, once per frame, with every weight | The vertex shader of each pass, with the preset's count of each object's largest weights. Its shaders load with the first morphed mesh |
48
57
  | The [depth prepass](quality-presets.md#the-depth-prepass) | Off on every preset. Drawn when `depthPrepass` is on, with a shader that computes positions only | On for every preset, as it restores early rejection of hidden pixels on Apple GPUs. Drawn with each material's own vertex shader |
49
- | [Occlusion culling](culling.md#gpu-occlusion-culling-on-webgpu) | On the GPU, in two phases, when `gpuOcclusion` is on | Not on the GPU |
58
+ | [Occlusion culling](culling.md#gpu-occlusion-culling-on-webgpu) | On the GPU, in two phases, when `gpuOcclusion` is on | On the job workers, against marked blockers, when `softwareOcclusion` is on ([Culling](culling.md#software-occlusion-culling-on-webgl2)) |
50
59
  | GPU time in `engine.measure` | Where the device has timestamp queries | Not measured |
51
60
 
52
61
  Shadows, skinned and morphed meshes, debug views and custom materials draw the same on both paths. The one exception: on WebGL2, a custom material draws a morphed mesh in its shape at rest. A debug view's wireframe draws an edge list of each mesh, because neither API fills triangles as lines.
@@ -57,7 +66,9 @@ WebGL2 and WebGPU's compatibility mode run at most the Medium [quality preset](q
57
66
 
58
67
  ## Color and anti-aliasing on each tier
59
68
 
60
- The anti-aliasing mode smooths the jagged edges of objects. The quality preset picks it: FXAA on Low, and MSAA from Medium up. The `antialias` option of `createEngine` replaces the preset's mode. The mode stays fixed while the engine runs, because the scene's targets and pipelines depend on it. One exception: when the start-up preset check lowers the preset, the demo draws with the lower preset's mode. The engine moves the canvas to a lighter mode for that, and never under the viewer's own preset change.
69
+ The anti-aliasing mode smooths the jagged edges of objects. The quality preset picks it: FXAA on Low, and MSAA from Medium up. The `antialias` option of `createEngine` replaces the preset's mode. The mode stays fixed while the engine runs, because the scene's targets and pipelines depend on it.
70
+
71
+ Two cases move it. When the start-up preset check lowers the preset, the engine draws with the lower preset's mode. In compatibility mode with MSAA, the first effect that needs HDR color moves the engine to FXAA ([The post-processing chain](post-processing.md#effects-on-devices-without-hdr-color)). A sketch's own preset change never moves it.
61
72
 
62
73
  | Mode | How the frame draws it |
63
74
  | --- | --- |
@@ -65,21 +76,28 @@ The anti-aliasing mode smooths the jagged edges of objects. The quality preset p
65
76
  | `fxaa` | The opaque pass draws one sample per pixel. The final pass finds edges by their contrast, and blends each pixel on an edge with its neighbors along the edge. It needs less memory and bandwidth than MSAA, and blurs thin lines a little. |
66
77
  | `none` | The opaque pass draws one sample per pixel, and nothing smooths the edges. |
67
78
 
68
- The moment transparency layer draws its surfaces at one sample per pixel, whatever the mode. While a sketch turns `momentTransparency` on, SMAA 1x smooths the layer's edges under the share that its moments cover, and MSAA's samples keep smoothing the opaque geometry around them. SMAA reads the color, so it works on every tier and replaces no other mode. It runs only under that share, so it does not soften edges that MSAA already smoothed.
79
+ The moment transparency layer draws its surfaces at one sample per pixel, whatever the mode. While a sketch turns `momentTransparency` on, SMAA 1x smooths the layer's edges under the share that its moments cover. MSAA's samples keep smoothing the opaque geometry around them. SMAA reads the color, so it works on every tier and replaces no other mode. It runs only under that share, so it does not soften edges that MSAA already smoothed.
69
80
 
70
81
  The scene's color target differs from tier to tier:
71
82
 
72
83
  | Tier | Scene color | How it reaches the canvas |
73
84
  | --- | --- | --- |
74
85
  | WebGPU core | `rg11b10ufloat` where the device can draw into it and the canvas is opaque; `rgba16float` elsewhere | The final pass applies the exposure and the tone mapping, encodes sRGB and dithers, into the canvas. With MSAA, the render pass first averages the samples into a texture. |
75
- | WebGPU compatibility mode | With MSAA, 8 bits per channel. With FXAA or none, as on core WebGPU. | With MSAA, each shader tone maps and encodes its own result. The render pass averages the samples into the canvas, or into a texture that the final pass copies while the render scale can drop below 1. With FXAA or none, as on core WebGPU. |
86
+ | WebGPU compatibility mode | With MSAA, 8 bits per channel. With FXAA or none, as on core WebGPU. | With MSAA, each shader tone maps and encodes its own result. The render pass averages the samples into the canvas, or into a texture that the final pass copies while the render scale can drop below 1 or an effect needs the final pass. With FXAA or none, as on core WebGPU. |
76
87
  | WebGL2 | `RGBA16F` where the float target test passes; 8 bits per channel elsewhere. With `?scene-format=rg11b10`, `R11F_G11F_B10F` where the canvas is opaque and that format passes the test too | As on core WebGPU with the float target. Without it, each shader tone maps its own result. MSAA then averages the samples as in compatibility mode. With FXAA or none, the final pass reads the color as it is, and FXAA smooths its edges. |
77
88
 
78
- On every tier, the final pass also scales the image up to the canvas when the [render scale](quality-presets.md#dynamic-resolution) is below 1. It blends the nearest four pixels, and skips FXAA there, because the scaling softens edges already. WebGL2 and compatibility mode run Low or Medium, whose lowest render scale is below 1, so there the final pass usually runs.
89
+ Where the render scale can drop below 1, the final pass runs in two steps. It scales the image up with GSR 1 ([The post-processing chain](post-processing.md#below-the-whole-canvass-render-scale)). WebGL2 and compatibility mode run Low or Medium, whose render scale can drop below 1, so there the final pass usually runs.
90
+
91
+ High dynamic range (HDR) color keeps light brighter than white until the tone mapping. It needs a float target that the GPU can draw into, with 4 samples for MSAA. Compatibility mode allows no MSAA on 16-bit float targets, so there MSAA takes the 8-bit path, and FXAA and none keep HDR color.
92
+
93
+ <details>
94
+ <summary>Technical details: the float target test on WebGL2</summary>
95
+
96
+ Some WebGL2 devices draw into no float target at all. On WebGL2, `engine.report.webgl2.floatRenderTargets` gives the result of the engine's test for `RGBA16F`, `RGBA32F` and `R11F_G11F_B10F`. The target must be complete and keep values above 1. For MSAA it must also take 4 samples.
79
97
 
80
- High dynamic range (HDR) color keeps light brighter than white until the tone mapping. It needs a float target that the GPU can draw into, with 4 samples for MSAA. Compatibility mode allows no MSAA on 16-bit float targets, so there MSAA takes the 8-bit path, and FXAA and none keep HDR color. Some WebGL2 devices draw into no float target at all. On WebGL2, `engine.report.webgl2.floatRenderTargets` gives the result of the engine's test for `RGBA16F`, `RGBA32F` and `R11F_G11F_B10F`. The target must be complete and keep values above 1. For MSAA it must also take 4 samples.
98
+ </details>
81
99
 
82
- `engine.capabilities.hdr` says which path the engine started on. Bloom moves compatibility mode to HDR color with FXAA when a sketch turns it on ([the post-processing chain](post-processing.md#effects-on-devices-without-hdr-color)). Both paths show the same colors. Edges differ a little, because the 8-bit path averages MSAA's samples after the tone mapping. FXAA compares and blends colors as the tone mapping would show them on both paths, so bright edges stay smooth. [Color management](color-management.md) describes the conversions and the tone mapping.
100
+ Both paths show the same colors. Edges differ a little, because the 8-bit path averages MSAA's samples after the tone mapping. FXAA compares and blends colors as the tone mapping would show them on both paths, so bright edges stay smooth ([Color management](color-management.md#the-8-bit-path)).
83
101
 
84
102
  Phone GPUs draw in tiles, and each write of a tile back to memory costs time and power. So each render pass discards the targets that no later pass reads: the depth, and with MSAA the samples once they are averaged. Chrome 146 and later also offer transient attachments. Where the browser has them, those targets take that usage, so they can stay in the GPU's tile memory. `engine.report.webgpu.transientAttachments` says whether the browser has them. On WebGL2 the engine tells the driver the same with `invalidateFramebuffer`.
85
103
 
@@ -93,7 +111,9 @@ The engine draws reversed depth: the near plane stores 1 and the far plane store
93
111
  | WebGL2 with the `EXT_clip_control` extension | Reversed, in a 32-bit float buffer | Out to 10 km |
94
112
  | WebGL2 without it | Reversed, in WebGL2's range from -1 to 1 | Out to about 250 m |
95
113
 
96
- WebGL2 maps depth into a range from -1 to 1, which loses most of the precision that reversed depth gives. The `EXT_clip_control` extension sets the range from 0 to 1, as on WebGPU. In the engine's tests, Chrome, Safari and Brave have it on a MacBook Pro. So do Chrome on a Galaxy S24+, and Safari and Brave on an iPad Pro. Firefox on macOS does not. Without the extension, the engine keeps reversed depth in the range from -1 to 1. In every browser tested, that fought in fewer pixels than standard depth.
114
+ WebGL2 maps depth into a range from -1 to 1, which loses most of the precision that reversed depth gives. The `EXT_clip_control` extension sets the range from 0 to 1, as on WebGPU.
115
+
116
+ In the engine's tests, Chrome, Safari and Brave have it on a MacBook Pro. So do Chrome on a Galaxy S24+, and Safari and Brave on an iPad Pro. Firefox on macOS does not. Without the extension, the engine keeps reversed depth in the range from -1 to 1. In every browser tested, that fought in fewer pixels than standard depth.
97
117
 
98
118
  The distances come from the engine's depth precision test on a MacBook Pro, with the camera's near plane at 0.1 m. The field `engine.capabilities.depth` says which depth the device draws: `reversed`, or `reversed-gl` on WebGL2 without the extension. In both, depth textures such as [shadow maps](shadows.md) hold the same values as on WebGPU. Shaders that read depth then work the same on every tier. The `?depth=standard` switch below gives a third value, `standard`.
99
119
 
@@ -115,9 +135,11 @@ The `features` field lists the WebGPU adapter's optional features. On WebGL2 it
115
135
  - rendering into 16-bit and 32-bit float textures, and into the packed `R11F_G11F_B10F` format, on WebGL2 (`engine.report.webgl2.floatRenderTargets`)
116
136
  - transient attachments on WebGPU (`engine.report.webgpu.transientAttachments`)
117
137
 
118
- On an Apple GPU in WebKit, the engine also measures whether direct draws are faster than its indirect draws. WebKit is the engine of Safari and of every browser on iPhone and iPad. It checks each indirect draw at a fixed cost, which direct draws do not pay. That is not a capability flag. The `directDraws` field reports the choice, and it is false on WebGL2, which always draws directly. The `drawPath` field says why the engine took its path. On other devices it is `not-apple-gpu-in-webkit`, since they skip the measurement.
138
+ On an Apple GPU in WebKit, the engine also measures whether direct draws are faster than its indirect draws. WebKit is the engine of Safari and of every browser on iPhone and iPad. It checks each indirect draw at a fixed cost, which direct draws do not pay.
139
+
140
+ That is not a capability flag. The `directDraws` field reports the choice, and it is false on WebGL2, which always draws directly. The `drawPath` field says why the engine took its path. On other devices it is `not-apple-gpu-in-webkit`, since they skip the measurement.
119
141
 
120
- Where float targets take the anti-aliasing mode, the scene draws high dynamic range color, and the final pass tone maps it. That holds on core WebGPU and on WebGL2 devices that pass the float target test. It holds in compatibility mode with FXAA or none too. `hdr` says whether the engine took that path. [Color management](color-management.md) covers the 8-bit path of the other devices.
142
+ `hdr` says whether the engine took the HDR path ([Color and anti-aliasing on each tier](#color-and-anti-aliasing-on-each-tier)).
121
143
 
122
144
  Code that uses an optional feature checks this object first. A sketch reads the same values in its context, as `ctx.engine.capabilities`.
123
145
 
@@ -127,7 +149,7 @@ The WebGPU path stays inside WebGPU's default limits, and inside compatibility m
127
149
 
128
150
  | Limit | Budget |
129
151
  | --- | --- |
130
- | Bind groups | 4 (the engine uses 2) |
152
+ | Bind groups | 4 (the engine uses all 4) |
131
153
  | Compute threads per workgroup | 128 |
132
154
  | Uniform binding size | 16 KB |
133
155
  | Color attachments | 4 |
@@ -141,7 +163,9 @@ The storage binding is the one limit the engine raises past this budget. When a
141
163
 
142
164
  On WebGPU, development builds warn once when a scene passes 2,097,152, because a device with the default limits refuses that scene.
143
165
 
144
- On WebGL2 the limit follows the largest texture the device allows. Each object's matrix takes 3 texels of a data texture, 512 matrices to a texel row. That is 2,097,152 objects and instance rows at 4,096 pixels, and 8,388,608 at 16,384. Larger textures hold no more, because the list of visible objects can name at most 8,388,608. WebGL2 promises at least 2,048 pixels, which holds 1,048,576. `engine.capabilities.maxInstances` gives the number on WebGL2 too. On WebGL2, development builds warn once when a scene passes 1,048,576, because a device with the smallest textures refuses that scene.
166
+ On WebGL2 the limit follows the largest texture the device allows. Each object's matrix takes 3 texels of a data texture, 512 matrices to a texel row. That is 2,097,152 objects and instance rows at 4,096 pixels, and 8,388,608 at 16,384. Larger textures hold no more, because the list of visible objects can name at most 8,388,608. WebGL2 promises at least 2,048 pixels, which holds 1,048,576.
167
+
168
+ `engine.capabilities.maxInstances` gives the number on WebGL2 too. On WebGL2, development builds warn once when a scene passes 1,048,576, because a device with the smallest textures refuses that scene.
145
169
 
146
170
  Engine memory holds the rows too. A page with worker threads gives the engine 1 GiB by default, which holds about 5 million instance rows. The `memory` option of `createEngine` raises the maximum to as much as 4 GiB ([Page API](../api/engine.md#memory)). A call that needs more memory than the engine can get fails with E1109.
147
171
 
@@ -159,21 +183,30 @@ Some laptops have a separate graphics chip next to the one built into the proces
159
183
 
160
184
  ## Choosing a tier for testing
161
185
 
162
- `createEngine({ gpu: 'webgl2' })` forces a tier, and so do the URL switches `?gpu=webgpu`, `?gpu=compat` and `?gpu=webgl2`. A device can then test every path it supports. Use them for testing only; in production, let the engine choose.
186
+ `createEngine({ gpu: 'webgl2' })` forces a tier, and so do the URL switches `?gpu=webgpu`, `?gpu=compat` and `?gpu=webgl2`. A device can then test every path it supports. Use them for testing only; in production, let the engine choose. The [Testing guide](../guides/testing.md#switches-for-tests) lists many of the switches.
163
187
 
164
- On WebGL2, uploads read straight from the engine's shared memory. A browser that refuses to read shared memory gets a copy of each upload instead. The switch `?uploads=copy` makes the engine copy everywhere, so one device can test both routes.
188
+ Other switches make one device test the paths of other devices. They cover copied uploads, shader compiles without the parallel compile extension, the 8-bit color path, each WebGL2 depth mode and each compressed texture family. The engine reads them in development builds, or in a production build with the Vite plugin's `urlSwitches` option on.
165
189
 
166
- On WebGL2, the engine compiles shader programs in the background where the browser has the `KHR_parallel_shader_compile` extension. The switch `?compile=wait` makes it wait for each compile at the program's first draw instead, as a browser without the extension does.
190
+ On WebGL2, uploads read straight from the engine's shared memory. A browser that refuses to read shared memory gets a copy of each upload instead.
167
191
 
168
- The switch `?half=on` makes the scene shaders do their color math at half precision, where the device can. It is off by default, and serves measurements. The switch `?hdr=off` makes the engine draw the 8-bit color path on a device that draws HDR color, so one device can test both. The switch `?scene-format=` picks the HDR scene color's format where the device can draw it. The value `rg11b10` takes the packed small float format of 4 bytes a pixel, and `rgba16f` takes 16-bit floats of 8 bytes. The small format keeps 6 bits of mantissa in red and green and 5 in blue, against 10 in a 16-bit float. On WebGL2 it serves measurements of its cost and of banding in dark gradients. Without the switch, WebGL2 keeps `RGBA16F`: on the phones measured, the small format drew no faster. The switch `?prepass=on` or `?prepass=off` turns the depth prepass on or off, and `?occlusion=on` or `?occlusion=off` turns GPU occlusion culling on or off.
192
+ The switch `?depth=` forces a WebGL2 depth mode: `reversed`, `reversed-gl` or `standard`, where the near plane stores 0 and the far plane 1. A browser without `EXT_clip_control` cannot draw `reversed`, so it draws its own mode instead. Shadow maps hold the same depth values as on WebGPU in `reversed` and `reversed-gl`. In `standard` they would hold them the other way around, so WebGL2 draws no shadows in that mode.
169
193
 
170
- The switch `?depth=` forces a WebGL2 depth mode: `reversed`, `reversed-gl` or `standard`, which draws depth as three.js's WebGL renderer does by default. A browser without `EXT_clip_control` cannot draw `reversed`, so it draws its own mode instead. Shadow maps hold the same depth values as on WebGPU in `reversed` and `reversed-gl`. In `standard` they would hold them the other way around, so WebGL2 draws no shadows in that mode.
194
+ <details>
195
+ <summary>Technical details: the packed scene color format</summary>
171
196
 
172
- KTX2 textures take the compressed format of the first family that the device has: ASTC, BC7 or ETC2 by the file's data ([Textures](../api/textures.md#ktx2-files)). The switch `?compression=` keeps them to the families that it lists, such as `?compression=bc`, or to none with `?compression=none`. One device can then test the format of each kind of device.
197
+ The switch `?scene-format=` picks the HDR scene color's format where the device can draw it. The value `rg11b10` takes the packed small float format of 4 bytes a pixel, and `rgba16f` takes 16-bit floats of 8 bytes. The small format keeps 6 bits of mantissa in red and green and 5 in blue, against 10 in a 16-bit float. On WebGL2 it serves measurements of its cost and of banding in dark gradients. Without the switch, WebGL2 keeps `RGBA16F`: on the phones measured, the small format drew no faster.
198
+
199
+ </details>
173
200
 
174
201
  ## When the GPU goes away
175
202
 
176
- A WebGPU device can be lost, for example after a driver reset, and so can a WebGL2 context. The thread that draws then makes a new device, or waits for the context to come back. It draws the whole scene again from data the engine kept. A texture from a file loads its file again. On a phone or a tablet the engine also keeps a copy of each texture's texels after their upload, so those maps come back too. The `keepTextureCopies` option of `createEngine` turns that on or off on any device ([Page API](../api/engine.md#options)). Keeping the copies costs about one more copy of each image in memory. Where no copy is kept, such a texture draws without its map until the sketch gives it texels again ([Textures](../api/textures.md#when-the-browser-takes-the-gpu-away)). The sketch worker keeps running, so your sketch's state survives. If the GPU is lost more than twice within one minute, or no new device starts, the engine stops drawing and reports E1302.
203
+ A WebGPU device can be lost, for example after a driver reset, and so can a WebGL2 context. The thread that draws then makes a new device, or waits for the context to come back. It draws the whole scene again from data the engine kept. A texture from a file loads its file again.
204
+
205
+ On a phone or a tablet the engine also keeps a copy of each texture's texels after their upload, so those maps come back too. The `keepTextureCopies` option of `createEngine` turns that on or off on any device ([Page API](../api/engine.md#options)). Keeping the copies costs about one more copy of each image in memory. Where no copy is kept, such a texture draws without its map until the sketch gives it texels again ([Textures](../api/textures.md#when-the-browser-takes-the-gpu-away)).
206
+
207
+ The sketch worker keeps running, so your sketch's state survives. If the GPU is lost more than twice within one minute, or no new device starts, the engine stops drawing and reports E1302.
208
+
209
+ The engine also gives the GPU away itself while the browser keeps the page in its back-forward cache, where it keeps texture copies. A cached page would otherwise hold all its GPU memory, and on a phone with little memory the next page could lack it. When the page shows again, the thread that draws makes a new device and draws the scene again, as after a loss. This counts as no loss.
177
210
 
178
211
  ## Minimum browsers
179
212
 
@@ -185,7 +218,16 @@ A WebGPU device can be lost, for example after a driver reset, and so can a WebG
185
218
 
186
219
  WebAssembly SIMD sets the minimums of Chrome, Edge and Firefox. In an older browser, and in Safari before 16.4, `createEngine` fails with [E1303](../errors/E1303.md) instead of taking a slow path. The page can then show its own message.
187
220
 
188
- Safari 16.4 and 17 have WebAssembly SIMD and pass the engine's feature tests. The engine still meets faults there that no test finds in advance. On a phone with 4 GB of memory, Safari 17 refused the engine's shared memory. Its WebGL2 compiler also rejected a shader of the standard material. So null3D does not support Safari before 18, and `createEngine` fails there with [E1306](../errors/E1306.md) before it starts a worker or asks for memory. A page that the null3D Vite plugin builds still starts the core's download as its HTML arrives, and leaves it unread. Every browser on iPhone and iPad runs Safari's WebKit engine, so the same check covers Chrome, Edge and Firefox on iOS and iPadOS before 18. The check reads the browser's user agent. An `AppleWebKit/` number of 600 or more marks Apple's WebKit, and the check then reads Safari's `Version/` part, or else the iOS or iPadOS version. Chrome, Edge, Samsung Internet and Firefox on other systems give no such number, so the check passes them.
221
+ Safari 16.4 and 17 pass the engine's feature tests, but the engine meets faults there that no test finds in advance. So null3D does not support Safari before 18, and `createEngine` fails there with [E1306](../errors/E1306.md) before it starts a worker or asks for memory. Every browser on iPhone and iPad runs Safari's WebKit engine, so Chrome, Edge and Firefox on iOS and iPadOS before 18 fail the same way.
222
+
223
+ <details>
224
+ <summary>Technical details: how the engine detects old Safari</summary>
225
+
226
+ On a phone with 4 GB of memory, Safari 17 refused the engine's shared memory. Its WebGL2 compiler also rejected a shader of the standard material. A page that the null3D Vite plugin builds still starts the core's download as its HTML arrives, and leaves it unread.
227
+
228
+ The check reads the browser's user agent. An `AppleWebKit/` number of 600 or more marks Apple's WebKit, and the check then reads Safari's `Version/` part, or else the iOS or iPadOS version. Chrome, Edge, Samsung Internet and Firefox on other systems give no such number, so the check passes them.
229
+
230
+ </details>
189
231
 
190
232
  On a cross-origin isolated page, the engine runs worker threads, which wait for each other with `Atomics.waitAsync`. Firefox has it from version 145. In older versions, the threads wake each other with messages instead. The switch `?wake=message` does the same in any browser, for tests.
191
233
 
@@ -1,15 +1,11 @@
1
1
  ---
2
2
  id: concepts/color-management
3
3
  title: Color management
4
- status: experimental
5
- since: "0.1"
6
- summary: "Linear working space; sRGB hex colors and linear arrays; texture color spaces; HDR color; exposure and tone mapping; transparent canvases; parity with three.js."
4
+ summary: "Linear working space; sRGB hex colors and linear arrays; texture color spaces; HDR color; exposure and tone mapping; transparent canvases."
7
5
  ---
8
6
 
9
7
  # Color management
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
  hex["'#4a8cff' or 0x4a8cff<br/>sRGB"] --> linear
@@ -20,9 +16,11 @@ flowchart LR
20
16
  scene --> final["Final pass: tone mapping,<br/>sRGB encoding, dithering"] --> canvas[("Canvas")]
21
17
  ```
22
18
 
23
- null3D works in linear color, as three.js does with its color management on. A color that you give as a hex string or a number is sRGB, the way CSS writes colors. The engine converts it to linear once, when the call receives it. A color that you give as three numbers is linear already.
19
+ null3D works in linear color. A color that you give as a hex string or a number is sRGB, the way CSS writes colors. The engine converts it to linear once, when the call receives it. A color that you give as three numbers is linear already.
20
+
21
+ Lighting adds and scales light in linear color, so a lit surface can be brighter than white. The scene therefore draws into a high dynamic range (HDR) target. Where the device cannot draw a float target in the anti-aliasing mode, the scene takes an 8-bit path. Each shader then tone maps its own color ([The 8-bit path](#the-8-bit-path)).
24
22
 
25
- Lighting adds and scales light in linear color, so a lit surface can be brighter than white. The scene therefore draws into a high dynamic range (HDR) target. Each light and each color of the scene comes in scaled by the exposure. At the end of each frame, a tone mapping curve maps it into the display's range. The final pass then encodes it as sRGB for the canvas.
23
+ Each light and each color of the scene comes in scaled by the exposure. At the end of each frame, a tone mapping curve maps it into the display's range. The final pass then encodes it as sRGB for the canvas.
26
24
 
27
25
  ## Colors in the API
28
26
 
@@ -40,7 +38,7 @@ const same = materials.standard({ color: [0.07, 0.26, 1] }); // the same color,
40
38
  scene.createDirectionalLight({ color: '#fff4e0', intensity: 3 });
41
39
  ```
42
40
 
43
- Three numbers are linear, as three.js's `Color.setRGB` reads them. The color helpers give linear numbers too: `color.fromSrgb` converts sRGB components, and `color.fromHsl` gives what three.js's `setHSL` gives ([Math helpers](../api/math.md#colors)). A light's intensity multiplies its linear color. A color in any other form throws [E1204](../errors/E1204.md).
41
+ Three numbers are linear. The color helpers give linear numbers too: `color.fromSrgb` converts sRGB components, and `color.fromHsl` reads a hue, a saturation and a lightness as linear RGB ([Math helpers](../api/math.md#colors)). A light's intensity multiplies its linear color. A color in any other form throws [E1204](../errors/E1204.md).
44
42
 
45
43
  ## Texture color spaces
46
44
 
@@ -60,11 +58,33 @@ A strong light can make a surface many times brighter than white. The scene keep
60
58
  - `rgba16float` on WebGPU. Where the device can draw into `rg11b10ufloat` and the canvas is opaque, the scene color takes that format instead, which needs half the memory.
61
59
  - `RGBA16F` on WebGL2, where the device can draw float targets in the anti-aliasing mode.
62
60
 
63
- The final pass reads each pixel of the scene color. In the FXAA anti-aliasing mode it first smooths the edges. It darkens the edges with the vignette, when the sketch sets one, and applies the tone mapping to the exposed color. It then encodes the result as sRGB. Last, after any color grading table, it adds a little noise, called dithering, so smooth gradients show no bands. The final pass is one triangle over the canvas, with no scene work in it. Below the whole canvas's render scale it runs in two steps, while the render scale can drop. The first step does the FXAA, the tone curve and the sRGB encode at the render size. The second scales the image up ([The post-processing chain](post-processing.md#below-the-whole-canvass-render-scale)).
61
+ The final pass reads each pixel of the scene color. In the order the shader runs them:
62
+
63
+ 1. In the FXAA mode, smooth the edges.
64
+ 2. Darken the edges by the vignette, when the sketch sets one.
65
+ 3. Apply the tone mapping to the exposed color (with automatic exposure, the adapted exposure first).
66
+ 4. Encode as sRGB.
67
+ 5. Apply any color grading table.
68
+ 6. Add the dither, so smooth gradients show no bands.
69
+
70
+ The final pass is one triangle over the canvas, with no scene work in it. Below the whole canvas's render scale it runs in two steps, while the render scale can drop ([The post-processing chain](post-processing.md#below-the-whole-canvass-render-scale)).
64
71
 
65
72
  ### The 8-bit path
66
73
 
67
- Some devices cannot draw a float target in the anti-aliasing mode. These are WebGPU in compatibility mode with MSAA, and WebGL2 devices whose float targets fail the engine's test. There, each shader applies the tone mapping itself, and writes into an 8-bit target. With MSAA that target resolves straight into the canvas, so the frame has no final pass. With FXAA or no anti-aliasing, the final pass reads the target and keeps its colors.
74
+ Some devices cannot draw a float target in the anti-aliasing mode. These are WebGPU in compatibility mode with MSAA, and WebGL2 devices whose float targets fail the engine's test. There, each shader applies the tone mapping itself, and writes into an 8-bit target. With MSAA that target can resolve straight into the canvas, with no final pass. That holds while the render scale cannot drop below 1 and no effect needs the final pass. These effects need it:
75
+
76
+ - color grading
77
+ - sharpening
78
+ - outlines
79
+ - transmission
80
+ - screen-space reflections
81
+ - bounce light
82
+ - soft particles
83
+ - a material that reads the scene's depth
84
+ - the moment transparency layer
85
+ - a full-screen pass that reads the scene color
86
+
87
+ The scene's shaders apply the vignette themselves there. Low and Medium let the render scale drop below 1, so there the final pass usually runs. With FXAA or no anti-aliasing, the final pass reads the target and keeps its colors.
68
88
 
69
89
  Effects that need HDR color, such as bloom, move compatibility mode to HDR color with FXAA when a sketch turns them on. On a WebGL2 device with no float target they stay off. [The post-processing chain](post-processing.md#effects-on-devices-without-hdr-color) explains both.
70
90
 
@@ -72,9 +92,20 @@ Effects that need HDR color, such as bloom, move compatibility mode to HDR color
72
92
 
73
93
  ### Materials that keep their display color
74
94
 
75
- A material with `toneMapped: false` keeps its color as the display shows it, as three.js's `toneMapped: false` does. Use it for a panel, a sign or another object whose colors are set for the screen, such as a heads-up display in the world.
95
+ A material with `toneMapped: false` keeps its color as the display shows it. Use it for a panel, a sign or another object whose colors are set for the screen, such as a heads-up display in the world.
96
+
97
+ ![Two rows of the same seven bright colors: the top row keeps its display color, the bottom row takes the tone curve.](../images/concepts/color-management/tone-mapped.webp)
98
+
99
+ toneMapped: false on the top row.
76
100
 
77
- The 8-bit path honours it in each material's own shader, which tone maps there: the shader encodes the color without the curve. The HDR path tone maps the whole image once, in its final pass. While a material keeps its display color, that pass also reads a mask of the surfaces whose material does so, and it skips the curve for those pixels. A blended surface keeps the curve on the HDR path, because a blended pixel mixes two surfaces and the mask cannot say which one owns it. Draw such a surface on the 8-bit path with `createEngine({ hdr: false })` if it needs the exact color. [The post-processing chain](post-processing.md) explains what else that path changes.
101
+ The 8-bit path honors it in each material's own shader. The HDR path honors it in its final pass, for surfaces that do not blend. A blended surface still takes the tone curve on the HDR path. If it needs the exact color, use the 8-bit path with `createEngine({ hdr: false })` ([The post-processing chain](post-processing.md) explains what else that path changes).
102
+
103
+ <details>
104
+ <summary>Technical details: how each path keeps the display color</summary>
105
+
106
+ On the 8-bit path the shader encodes the color without the curve. The HDR path's final pass reads a mask of the marked surfaces and skips the curve there. A blended pixel mixes two surfaces, so the mask cannot say which one owns it.
107
+
108
+ </details>
78
109
 
79
110
  The vignette and the sRGB encoding still apply to such a material. The exposure scales its colors before them, as it scales every other color.
80
111
 
@@ -91,29 +122,27 @@ export default defineSketch(({ post }) => {
91
122
  });
92
123
  ```
93
124
 
94
- | `toneMapping` | three.js equivalent | Look |
95
- | --- | --- | --- |
96
- | `'agx-punchy'` (the default) | None | AgX with Filament's punchy look: more contrast and more color, with AgX's hues. |
97
- | `'agx'` | `AgXToneMapping` | Softer contrast. Bright colors fade toward white and keep their hue. |
98
- | `'aces'` | `ACESFilmicToneMapping` | Strong contrast. Bright saturated colors change hue on their way to white: red turns orange, then yellow, and blue turns purple. |
99
- | `'neutral'` | `NeutralToneMapping` | Base colors keep their values until they near white. Khronos made it for product images. |
100
- | `'none'` | `LinearToneMapping` | The exposed color, clipped at white. A bright color loses detail once a channel reaches white. |
125
+ | `toneMapping` | Look |
126
+ | --- | --- |
127
+ | `'agx-punchy'` (the default) | AgX with Filament's punchy look: more contrast and more color, with AgX's hues. |
128
+ | `'agx'` | Softer contrast. Bright colors fade toward white and keep their hue. |
129
+ | `'aces'` | Strong contrast, and the color is scaled by 1 / 0.6 first. Bright saturated colors change hue on their way to white: red turns orange, then yellow, and blue turns purple. |
130
+ | `'neutral'` | Base colors keep their values until they near white. Khronos made it for product images. |
131
+ | `'none'` | The exposed color, clipped at white. A bright color loses detail once a channel reaches white. |
101
132
 
102
133
  Punchy AgX suits most scenes: bright lights and colors keep their hue, and the picture keeps its contrast. Plain AgX looks flatter. For a product view, where a material's color must show as its maker gave it, use `'neutral'`, as model-viewer does.
103
134
 
104
- The exposure multiplies the scene's color before the tone mapping. An exposure of 2 is one stop brighter, and 0.5 is one stop darker. The engine applies it to each light and each color as they enter the scene. That gives the same picture as scaling the finished color, and keeps scenes in real units inside the range of the HDR target. [Lighting and environment](lighting.md#units-and-exposure) explains it. The engine uses three.js's formulas for each curve, so a scene looks the same in both engines with the same settings.
135
+ The exposure multiplies the scene's color before the tone mapping. An exposure of 2 is one stop brighter, and 0.5 is one stop darker. The engine applies it to each light and each color as they enter the scene. That gives the same picture as scaling the finished color, and keeps scenes in real units inside the range of the HDR target. [Lighting and environment](lighting.md#units-and-exposure) explains it.
105
136
 
106
- Automatic exposure adapts the picture to the scene's brightness over time, as an eye does. The scene still draws at the exposure that `exposure` and `ev100` set. A meter on the GPU then reads each frame, and the final pass multiplies the HDR color by the adapted exposure before the tone mapping. [The post-processing chain](post-processing.md#automatic-exposure) explains the meter.
137
+ Automatic exposure adapts the picture to the scene's brightness over time, as an eye does. The scene still draws at the exposure that `exposure` and `ev100` set. A meter on the GPU then reads each frame, and the final pass multiplies the HDR color by the adapted exposure before the tone mapping. [The post-processing chain](post-processing.md#automatic-exposure) explains the meter. The [automatic exposure demo](https://github.com/null3d-engine/null3d/tree/main/examples/auto-exposure) walks from a sunny courtyard into a dark hall, so the eye opens and closes.
107
138
 
108
139
  ## The background
109
140
 
110
- The background color is part of the scene. Exposure and tone mapping change it as they change the objects, as in three.js's WebGPURenderer. The curves, for example, make dark colors a little darker. To show an exact page color behind the scene, use `toneMapping: 'none'` at an exposure of 1. You can also use a transparent canvas over a CSS background.
111
-
112
- A [background texture](../api/scene.md#the-camera-and-the-background) draws into the scene color too, so exposure and tone mapping change it in the same way. three.js's WebGLRenderer draws an sRGB background texture without them. To show the texture's own colors, use `toneMapping: 'none'` at an exposure of 1.
141
+ The background color and a [background texture](../api/scene.md#the-camera-and-the-background) are part of the scene. Exposure and tone mapping change them as they change the objects, so the curves, for example, make dark colors a little darker. To show either one with its own colors, use `toneMapping: 'none'` at an exposure of 1. A transparent canvas over a CSS background gives an exact page color behind the scene instead.
113
142
 
114
143
  ## Transparent canvases
115
144
 
116
- `createEngine({ transparent: true })` makes a see-through canvas. The page shows through wherever no object draws, until the sketch calls `scene.setBackground`. The canvas holds premultiplied alpha, the form that browsers composite, so a partly covered edge pixel keeps its color scaled by its coverage.
145
+ `createEngine({ transparent: true })` makes a see-through canvas. The page shows through wherever no object draws, until the sketch calls `scene.setBackground`. The canvas holds premultiplied alpha, the form that browsers composite, so a partly covered edge pixel keeps its color scaled by its coverage. The [depth-only holdout demo](https://github.com/null3d-engine/null3d/tree/main/examples/depth-only) starts on a see-through canvas over a page backdrop.
117
146
 
118
147
  ```ts
119
148
  const engine = await createEngine({
@@ -123,17 +152,6 @@ const engine = await createEngine({
123
152
  });
124
153
  ```
125
154
 
126
- ## Parity with three.js
127
-
128
- - Hex colors, linear lighting and sRGB output work as in three.js r152 and later, where color management is on by default.
129
- - Three numbers are linear, as `Color.setRGB` reads them.
130
- - A color map with `texture.colorSpace = SRGBColorSpace` is a texture with an sRGB format in null3D.
131
- - A data map with `NoColorSpace` or `LinearSRGBColorSpace` is a texture with a linear format.
132
- - The tone mapping curves use three.js's formulas. The defaults differ: three.js uses no tone mapping, and null3D uses punchy AgX, which three.js lacks. A port of a scene with `AgXToneMapping` sets `toneMapping: 'agx'`. A port of a scene without tone mapping sets `toneMapping: 'none'`.
133
- - three.js's `NoToneMapping` ignores the exposure. null3D's `'none'` applies it, as `LinearToneMapping` does, and an exposure of 1 gives the same image.
134
- - three.js's WebGLRenderer draws a `scene.background` color without tone mapping. null3D tone maps the background, as three.js's WebGPURenderer does.
135
- - null3D always dithers its output, and three.js only dithers materials that ask for it. The difference is at most one step of an 8-bit color.
136
-
137
155
  ## Related pages
138
156
 
139
157
  - [Post-processing API](../api/post.md): `post.set` and each setting.