@null3d/engine 0.0.0 → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (311) hide show
  1. package/README.md +109 -0
  2. package/THIRD-PARTY-NOTICES.txt +0 -1
  3. package/dist/wasm/single/null3d.js +19 -6
  4. package/dist/wasm/single/null3d_bg.wasm +0 -0
  5. package/dist/wasm/threaded/null3d.js +19 -6
  6. package/dist/wasm/threaded/null3d_bg.wasm +0 -0
  7. package/docs/api/animation.md +23 -67
  8. package/docs/api/assets.md +42 -26
  9. package/docs/api/cameras.md +8 -6
  10. package/docs/api/controls.md +46 -44
  11. package/docs/api/debug.md +13 -8
  12. package/docs/api/engine.md +17 -11
  13. package/docs/api/feature-draws.md +3 -3
  14. package/docs/api/feature-effects.md +3 -3
  15. package/docs/api/feature-instances.md +2 -2
  16. package/docs/api/features.md +14 -15
  17. package/docs/api/geometry.md +56 -75
  18. package/docs/api/grass.md +1 -1
  19. package/docs/api/impostors.md +120 -9
  20. package/docs/api/input.md +4 -11
  21. package/docs/api/lights.md +14 -38
  22. package/docs/api/lines.md +8 -25
  23. package/docs/api/materials.md +69 -70
  24. package/docs/api/math.md +6 -7
  25. package/docs/api/objects.md +13 -13
  26. package/docs/api/particles.md +2 -14
  27. package/docs/api/points.md +3 -25
  28. package/docs/api/post.md +22 -23
  29. package/docs/api/quality.md +11 -6
  30. package/docs/api/raycast.md +13 -32
  31. package/docs/api/reference/animation.md +9 -9
  32. package/docs/api/reference/assets.md +18 -18
  33. package/docs/api/reference/cameras.md +5 -2
  34. package/docs/api/reference/controls.md +75 -23
  35. package/docs/api/reference/debug.md +23 -8
  36. package/docs/api/reference/engine.md +22 -10
  37. package/docs/api/reference/geometry.md +161 -82
  38. package/docs/api/reference/grass.md +1 -1
  39. package/docs/api/reference/impostors.md +92 -1
  40. package/docs/api/reference/input.md +3 -3
  41. package/docs/api/reference/lights.md +9 -9
  42. package/docs/api/reference/lines.md +7 -7
  43. package/docs/api/reference/materials.md +48 -48
  44. package/docs/api/reference/math.md +22 -22
  45. package/docs/api/reference/objects.md +9 -9
  46. package/docs/api/reference/points.md +4 -4
  47. package/docs/api/reference/post.md +18 -18
  48. package/docs/api/reference/quality.md +7 -3
  49. package/docs/api/reference/raycast.md +6 -6
  50. package/docs/api/reference/render.md +2 -2
  51. package/docs/api/reference/scene.md +29 -26
  52. package/docs/api/reference/sketch.md +4 -0
  53. package/docs/api/reference/sound.md +203 -0
  54. package/docs/api/reference/sprites.md +5 -5
  55. package/docs/api/reference/terrain.md +2 -1
  56. package/docs/api/reference/textures.md +4 -4
  57. package/docs/api/reference/ui.md +3 -3
  58. package/docs/api/reference/vertex-draws.md +3 -3
  59. package/docs/api/reference/water.md +77 -6
  60. package/docs/api/reference/wind.md +2 -2
  61. package/docs/api/render.md +12 -10
  62. package/docs/api/scene.md +40 -29
  63. package/docs/api/sketch.md +64 -3
  64. package/docs/api/sound.md +169 -0
  65. package/docs/api/splats.md +7 -0
  66. package/docs/api/sprites.md +4 -20
  67. package/docs/api/tasks.md +2 -2
  68. package/docs/api/terrain.md +2 -14
  69. package/docs/api/textures.md +9 -9
  70. package/docs/api/ui.md +3 -15
  71. package/docs/api/water.md +198 -15
  72. package/docs/api/wind.md +5 -5
  73. package/docs/cli/null3d.md +93 -18
  74. package/docs/concepts/architecture.md +10 -10
  75. package/docs/concepts/assets.md +2 -19
  76. package/docs/concepts/backends.md +7 -5
  77. package/docs/concepts/color-management.md +15 -26
  78. package/docs/concepts/culling.md +1 -1
  79. package/docs/concepts/instances.md +5 -5
  80. package/docs/concepts/large-worlds.md +1 -1
  81. package/docs/concepts/lighting.md +50 -55
  82. package/docs/concepts/lod.md +2 -15
  83. package/docs/concepts/materials.md +16 -16
  84. package/docs/concepts/post-processing.md +7 -29
  85. package/docs/concepts/quality-preset-tables.md +53 -50
  86. package/docs/concepts/quality-presets.md +56 -27
  87. package/docs/concepts/render-graph.md +19 -14
  88. package/docs/concepts/render-layers.md +3 -17
  89. package/docs/concepts/shadows.md +10 -28
  90. package/docs/concepts/static-dynamic.md +2 -2
  91. package/docs/cookbook/index.md +1 -1
  92. package/docs/data/threejs-mapping.json +136 -102
  93. package/docs/errors/E1214.md +3 -3
  94. package/docs/errors/E1307.md +23 -0
  95. package/docs/errors/E1420.md +3 -3
  96. package/docs/errors/index.md +3 -2
  97. package/docs/getting-started/cdn.md +17 -1
  98. package/docs/getting-started/first-scene.md +1 -1
  99. package/docs/getting-started/hosting.md +50 -9
  100. package/docs/getting-started/install.md +8 -7
  101. package/docs/getting-started/network-use.md +10 -2
  102. package/docs/getting-started/project-structure.md +15 -6
  103. package/docs/getting-started/third-party-notices.md +8 -6
  104. package/docs/guides/accessibility.md +1 -1
  105. package/docs/guides/add-ons.md +3 -2
  106. package/docs/guides/agents.md +16 -5
  107. package/docs/guides/assets-pipeline.md +13 -12
  108. package/docs/guides/audio.md +109 -124
  109. package/docs/guides/car-paint.md +1 -1
  110. package/docs/guides/content-pages.md +10 -6
  111. package/docs/guides/custom-passes.md +9 -8
  112. package/docs/guides/custom-shaders.md +6 -3
  113. package/docs/guides/debugging.md +78 -4
  114. package/docs/guides/deploying.md +105 -5
  115. package/docs/guides/deterministic-simulation.md +1 -1
  116. package/docs/guides/first-use-shaders.md +4 -4
  117. package/docs/guides/loading-screens.md +78 -33
  118. package/docs/guides/multiple-views.md +41 -2
  119. package/docs/guides/performance.md +6 -3
  120. package/docs/guides/phones.md +12 -1
  121. package/docs/guides/physics.md +1 -1
  122. package/docs/guides/screens.md +7 -5
  123. package/docs/guides/start-time.md +328 -0
  124. package/docs/guides/testing.md +23 -5
  125. package/docs/guides/ui-overlays.md +3 -3
  126. package/docs/index.md +12 -8
  127. package/docs/pages.md +26 -23
  128. package/docs/porting/react-three-fiber.md +228 -5
  129. package/docs/porting/threejs-loop-and-threads.md +220 -6
  130. package/docs/porting/threejs-mapping.md +86 -84
  131. package/docs/porting/threejs-materials.md +212 -5
  132. package/docs/porting/threejs-overview.md +218 -5
  133. package/docs/porting/threejs-postprocessing.md +2 -2
  134. package/docs/porting/threejs-shaders.md +298 -5
  135. package/docs/porting/threejs-unsupported.md +82 -6
  136. package/docs/porting/verification.md +181 -5
  137. package/docs/shaders/builtins.md +1 -1
  138. package/docs/shaders/library.md +63 -39
  139. package/docs/shaders/surface-functions.md +11 -10
  140. package/docs/shaders/wgsl-rules.md +1 -1
  141. package/lib/debug/channel.d.ts +103 -0
  142. package/lib/debug/channel.js +269 -0
  143. package/lib/debug/debug.d.ts +9 -7
  144. package/lib/debug/draw.d.ts +9 -0
  145. package/lib/debug/draw.js +49 -2
  146. package/lib/debug/inspector.d.ts +60 -0
  147. package/lib/debug/inspector.js +475 -0
  148. package/lib/debug/stats-panel.d.ts +1 -1
  149. package/lib/debug/stats.d.ts +2 -3
  150. package/lib/errors/codes.js +8 -2
  151. package/lib/errors/engine-error.js +25 -10
  152. package/lib/errors/fixes.d.ts +1 -0
  153. package/lib/errors/fixes.js +3 -2
  154. package/lib/generated/core.d.ts +1 -1
  155. package/lib/generated/core.js +1 -1
  156. package/lib/gpu/early-builds.d.ts +68 -0
  157. package/lib/gpu/early-builds.js +158 -0
  158. package/lib/gpu/pipeline-name.d.ts +6 -0
  159. package/lib/gpu/pipeline-name.js +23 -0
  160. package/lib/gpu/webgl2/backend.d.ts +63 -2
  161. package/lib/gpu/webgl2/backend.js +226 -8
  162. package/lib/gpu/webgl2/programs.d.ts +18 -0
  163. package/lib/gpu/webgl2/programs.js +4 -1
  164. package/lib/gpu/webgpu/backend.d.ts +89 -2
  165. package/lib/gpu/webgpu/backend.js +255 -8
  166. package/lib/gpu/webgpu/pipelines.d.ts +13 -0
  167. package/lib/gpu/webgpu/pipelines.js +15 -1
  168. package/lib/index.d.ts +6 -4
  169. package/lib/index.js +3 -2
  170. package/lib/math/color.d.ts +5 -5
  171. package/lib/math/color.js +5 -5
  172. package/lib/math/mat4.d.ts +6 -12
  173. package/lib/math/mat4.js +6 -12
  174. package/lib/math/namespaces/quat.d.ts +3 -3
  175. package/lib/math/namespaces/quat.js +3 -3
  176. package/lib/math/quat.d.ts +8 -12
  177. package/lib/math/quat.js +8 -12
  178. package/lib/math/random.d.ts +2 -3
  179. package/lib/math/random.js +2 -3
  180. package/lib/math/types.d.ts +4 -4
  181. package/lib/math/vec3.d.ts +3 -6
  182. package/lib/math/vec3.js +3 -6
  183. package/lib/page/capabilities.d.ts +7 -7
  184. package/lib/page/capabilities.js +39 -25
  185. package/lib/page/check-store.d.ts +14 -2
  186. package/lib/page/check-store.js +34 -11
  187. package/lib/page/engine.d.ts +103 -26
  188. package/lib/page/engine.js +420 -97
  189. package/lib/page/first-frame.d.ts +16 -0
  190. package/lib/page/first-frame.js +35 -0
  191. package/lib/page/frame-stats.d.ts +34 -1
  192. package/lib/page/frame-stats.js +15 -0
  193. package/lib/page/label-loop.d.ts +7 -3
  194. package/lib/page/label-loop.js +17 -10
  195. package/lib/page/labels.d.ts +3 -3
  196. package/lib/page/pipeline-store.d.ts +25 -0
  197. package/lib/page/pipeline-store.js +84 -0
  198. package/lib/page/start-marker.d.ts +4 -1
  199. package/lib/page/start-marker.js +5 -2
  200. package/lib/page/switches.d.ts +32 -2
  201. package/lib/page/switches.js +9 -1
  202. package/lib/quality/check.d.ts +24 -3
  203. package/lib/quality/check.js +21 -7
  204. package/lib/quality/chooser.d.ts +6 -0
  205. package/lib/quality/chooser.js +8 -0
  206. package/lib/quality/governor.d.ts +98 -6
  207. package/lib/quality/governor.js +250 -20
  208. package/lib/quality/preset-docs.d.ts +16 -1
  209. package/lib/quality/preset-docs.js +3 -0
  210. package/lib/quality/presets.d.ts +84 -7
  211. package/lib/quality/presets.js +94 -2
  212. package/lib/render/draw.d.ts +3 -2
  213. package/lib/render/draw.js +15 -5
  214. package/lib/render/load-draw.d.ts +7 -5
  215. package/lib/render/load-draw.js +7 -5
  216. package/lib/render/loss.d.ts +28 -10
  217. package/lib/render/loss.js +50 -22
  218. package/lib/render/recovery.d.ts +20 -0
  219. package/lib/render/recovery.js +44 -4
  220. package/lib/render/renderer.d.ts +85 -9
  221. package/lib/render/renderer.js +181 -42
  222. package/lib/render/scene-renderer.d.ts +19 -1
  223. package/lib/render/scene-renderer.js +25 -1
  224. package/lib/render/webgl2-renderers.js +8 -5
  225. package/lib/render/webgpu-renderers.js +5 -4
  226. package/lib/scene/animation.d.ts +28 -32
  227. package/lib/scene/animation.js +12 -15
  228. package/lib/scene/assets.d.ts +61 -86
  229. package/lib/scene/assets.js +103 -236
  230. package/lib/scene/background.d.ts +14 -18
  231. package/lib/scene/background.js +5 -2
  232. package/lib/scene/color.d.ts +3 -3
  233. package/lib/scene/downloads.d.ts +2 -0
  234. package/lib/scene/downloads.js +371 -0
  235. package/lib/scene/environment.d.ts +7 -7
  236. package/lib/scene/environment.js +1 -1
  237. package/lib/scene/fake-call-values.js +1 -1
  238. package/lib/scene/fog.d.ts +11 -4
  239. package/lib/scene/fog.js +8 -2
  240. package/lib/scene/frame-cameras.d.ts +19 -0
  241. package/lib/scene/frame-cameras.js +58 -0
  242. package/lib/scene/gltf.d.ts +32 -2
  243. package/lib/scene/gltf.js +78 -49
  244. package/lib/scene/grading.d.ts +2 -2
  245. package/lib/scene/grading.js +3 -3
  246. package/lib/scene/ktx2.d.ts +9 -1
  247. package/lib/scene/ktx2.js +3 -2
  248. package/lib/scene/level-rule.d.ts +120 -0
  249. package/lib/scene/level-rule.js +130 -0
  250. package/lib/scene/lines.d.ts +13 -17
  251. package/lib/scene/lines.js +3 -3
  252. package/lib/scene/lut.d.ts +1 -2
  253. package/lib/scene/lut.js +1 -2
  254. package/lib/scene/picks.d.ts +2 -2
  255. package/lib/scene/pointer-events.d.ts +4 -7
  256. package/lib/scene/post.d.ts +38 -43
  257. package/lib/scene/post.js +4 -1
  258. package/lib/scene/prefab.d.ts +7 -8
  259. package/lib/scene/prefab.js +7 -8
  260. package/lib/scene/property-animation.d.ts +1 -1
  261. package/lib/scene/property-animation.js +1 -1
  262. package/lib/scene/queries.d.ts +7 -13
  263. package/lib/scene/resources.d.ts +225 -254
  264. package/lib/scene/resources.js +179 -81
  265. package/lib/scene/scene.d.ts +149 -118
  266. package/lib/scene/scene.js +196 -98
  267. package/lib/scene/serial-loads.d.ts +29 -0
  268. package/lib/scene/serial-loads.js +68 -0
  269. package/lib/scene/shader-preloads.d.ts +34 -0
  270. package/lib/scene/shader-preloads.js +38 -0
  271. package/lib/scene/sprites.d.ts +14 -17
  272. package/lib/scene/sprites.js +5 -6
  273. package/lib/scene/textures.d.ts +11 -12
  274. package/lib/scene/textures.js +9 -10
  275. package/lib/scene/time-of-day.d.ts +3 -4
  276. package/lib/scene/time-of-day.js +2 -3
  277. package/lib/scene/vertex-draws.d.ts +5 -4
  278. package/lib/scene/vertex-draws.js +7 -5
  279. package/lib/shader-artifact.json +1 -0
  280. package/lib/shared/core.d.ts +5 -0
  281. package/lib/shared/core.js +1 -0
  282. package/lib/shared/import-once.d.ts +6 -0
  283. package/lib/shared/import-once.js +19 -0
  284. package/lib/shared/metrics.d.ts +38 -0
  285. package/lib/shared/metrics.js +62 -1
  286. package/lib/shared/run-task.js +7 -1
  287. package/lib/shared/task-pending.d.ts +12 -0
  288. package/lib/shared/task-pending.js +61 -1
  289. package/lib/shared/tasks.js +79 -32
  290. package/lib/shared/version.d.ts +17 -1
  291. package/lib/shared/version.js +19 -1
  292. package/lib/shared/wasm.d.ts +12 -4
  293. package/lib/shared/wasm.js +50 -27
  294. package/lib/shared/worker-start.d.ts +7 -0
  295. package/lib/shared/worker-start.js +27 -0
  296. package/lib/sketch/define-sketch.d.ts +35 -0
  297. package/lib/sketch/input.d.ts +2 -2
  298. package/lib/sketch/preset-check.d.ts +20 -6
  299. package/lib/sketch/preset-check.js +42 -17
  300. package/lib/sketch/quality.d.ts +69 -11
  301. package/lib/sketch/quality.js +54 -13
  302. package/lib/sketch/runner.d.ts +76 -9
  303. package/lib/sketch/runner.js +385 -52
  304. package/lib/sketch/ui.d.ts +5 -8
  305. package/lib/workers/probe-worker.d.ts +5 -0
  306. package/lib/workers/probe-worker.js +13 -4
  307. package/lib/workers/protocol.d.ts +61 -13
  308. package/lib/workers/protocol.js +4 -0
  309. package/lib/workers/render-worker.js +25 -4
  310. package/lib/workers/sketch-worker.js +104 -15
  311. package/package.json +2 -2
@@ -34,58 +34,61 @@ A memory reading under 4 GB lowers the starting preset by one.
34
34
  | --- | --- |
35
35
  | Target frame rate | The display's refresh rate, at most 60 frames per second unless `targetFps` asks for more |
36
36
  | A preset holds its target | At 90% of the target or more |
37
+ | A preset is far below its target | Under 25% of the target: the check lowers it straight to Low |
38
+ | Wait before the first measurement and after each lowering | Until the pipelines are built, then until the GPU has finished 2 frames within 100 ms each, for 4000 ms at most |
37
39
  | Frames drawn before each measurement | 250 ms, and up to 2000 ms more while textures upload |
38
40
  | Measurement of each preset | 500 ms |
39
41
 
40
42
  ## Settings of each preset
41
43
 
42
- | Setting | Low | Medium | High | Ultra | Changes | Status |
43
- | --- | --- | --- | --- | --- | --- | --- |
44
- | Pixel ratio cap (`maxPixelRatio`) | 1.5 | 2 | 2 | none | during play | built |
45
- | Lowest render scale (`minRenderScale`) | 0.5 | 0.6 | 0.75 | 1 | during play | built |
46
- | Highest render scale (`maxRenderScale`) | 1 | 1 | 1 | 1 | during play | built |
47
- | Anti-aliasing (`antialias`) | FXAA | MSAA 4x | MSAA 4x | MSAA 4x | at the start | built |
48
- | Moment transparency (`momentTransparency`) | no | no | no | no | at the start | built |
49
- | Shadow cascades (`shadowCascades`) | 2 | 3 | 3 | 4 | at the start | built |
50
- | Shadow map size in texels (`shadowMapSize`) | 1024 | 2048 | 2048 | 4096 | at the start | built |
51
- | Shadow filter (`shadowFilter`) | 3 x 3 texels | 5 x 5 texels | 5 x 5 texels | 5 x 5 texels | during play | built |
52
- | Far cascade updates (`farCascadeInterval`) | every 4th frame | every 3rd frame | every 2nd frame | every 2nd frame | during play | built |
53
- | Far cascades follow moving casters (`followMovingCasters`) | yes | yes | yes | yes | during play | built |
54
- | Far-animation updates (`farAnimationInterval`) | every 4th frame | every 4th frame | every 2nd frame | every frame | during play | built |
55
- | Blend between shadow cascades (`shadowCascadeBlend`) | 10% of each cascade | 10% of each cascade | 10% of each cascade | 10% of each cascade | during play | built |
56
- | Spot and point light shadow tiles (`shadowTiles`) | 4 | 8 | 16 | 24 | at the start | built |
57
- | Shadow tile size in texels (`shadowTileSize`) | 512 | 512 | 1024 | 1024 | at the start | built |
58
- | Hero shadow tile size in texels (`heroTileSize`) | 1024 | 2048 | 2048 | 4096 | at the start | built |
59
- | Point light shadows (`pointLightShadows`) | no | no | yes | yes | at the start | built |
60
- | Bloom's largest level in texels on the short side (`bloomSize`) | 64 | 512 | 512 | 512 | during play | built |
61
- | Ambient occlusion (`aoScale`) | off | off | half resolution | half resolution | during play | built |
62
- | Contact shadows (`contactShadowSteps`) | off | off (WebGL2: 4 steps at half resolution) | 8 steps at half resolution | 16 steps at half resolution | during play | built |
63
- | Depth of field (`dofSamples`) | off | 22 taps at half resolution | 43 taps at half resolution | 71 taps at half resolution | during play | built |
64
- | Subsurface blur of skin (`subsurfaceSamples`) | off | off | 17 taps each way | 25 taps each way | during play | built |
65
- | Screen-space reflections (`ssrScale`) | off | quarter resolution | half resolution | half resolution | during play | built |
66
- | Screen-space reflection steps per ray (`ssrSteps`) | 16 | 24 | 48 | 64 | during play | built |
67
- | Screen-space bounce light (`bounceRays`) | off | off (WebGL2: 4 rays each way) | 4 rays each way | 8 rays each way | during play | built |
68
- | Automatic exposure's meter (`exposureMeter`) | 16 x 16 cells | histogram on WebGPU, else 16 x 16 cells | histogram on WebGPU, else 16 x 16 cells | histogram on WebGPU, else 16 x 16 cells | during play | built |
69
- | Volumetric fog (`fogSlices`) | off, sun glow only | 32 slices | 64 slices | 96 slices | during play | built |
70
- | Reflection passes (`reflectionScale`) | quarter resolution | half resolution | half resolution | full resolution | during play | built |
71
- | Reflection probe maps (`probeSize`) | 128 x 128 | 256 x 256 | 256 x 256 | 256 x 256 | during play | built |
72
- | Area lights per frame (`areaLights`) | 4 | 8 | 16 | 32 | during play | built |
73
- | Depth-fitted light clusters (WebGPU) (`lightFit`) | no | yes | yes | yes | during play | built |
74
- | Level of detail threshold (`lodThreshold`) | 2 px | 1 px | 1 px | 1 px | during play | built |
75
- | Level of detail threshold in shadows (`lodShadowThreshold`) | 1 texel | 1 texel | 1 texel | 1 texel | during play | built |
76
- | Distance band fades (`lodFade`) | no | yes | yes | yes | during play | built |
77
- | Physical sky (`physicalSky`) | the analytic sky stands in | from its tables | from its tables | from its tables | during play | built |
78
- | Cloud march steps (`cloudSteps`) | flat layer | flat layer | 32 | 48 | during play | built |
79
- | Frame-budget governor (`governor`) | on | on | on | on | during play | built |
80
- | Depth prepass (`depthPrepass`) | no (WebGL2: yes) | no (WebGL2: yes) | no (WebGL2: yes) | no (WebGL2: yes) | at the start | built |
81
- | GPU occlusion culling (WebGPU) (`gpuOcclusion`) | no | no | yes | yes | at the start | built |
82
- | Morph targets per object on WebGL2 (`morphTargets`) | 8 | 16 | 32 | 64 | at the start | built |
83
- | Software occlusion culling (WebGL2) (`softwareOcclusion`) | no | no | no | no | during play | built |
84
- | Parallax occlusion mapping (`parallax`) | no | yes | yes | yes | during play | built |
85
- | Soft particles (`softParticles`) | no | yes | yes | yes | during play | built |
86
- | Anisotropic filtering cap (`maxAnisotropy`) | 2x | 4x | 8x | 16x | during play | built |
87
- | Texture uploads per frame (`uploadBytesPerFrame`) | 2 MiB | 4 MiB | 8 MiB | 16 MiB | during play | built |
88
- | Point and spot lights per frame (`maxLights`) | 256 | 256 | 512 | 1024 | at the start | planned |
89
- | Lights per cluster (`maxLightsPerCluster`) | 32 | 64 | 64 | 128 | at the start | planned |
90
- | Texture memory budget (`textureMemoryMiB`) | 256 MiB | 512 MiB | 1024 MiB | 2048 MiB | during play | built |
91
- | Engine memory maximum (`memoryMaximumMiB`) | 1024 MiB | 1024 MiB | 1024 MiB | 1024 MiB | before loading | built |
44
+ | Setting | Low | Medium | High | Ultra | Changes |
45
+ | --- | --- | --- | --- | --- | --- |
46
+ | Pixel ratio cap (`maxPixelRatio`) | 1.5 | 2 | 2 | none | during play |
47
+ | Lowest render scale (`minRenderScale`) | 0.5 | 0.6 | 0.75 | 1 | during play |
48
+ | Highest render scale (`maxRenderScale`) | 1 | 1 | 1 | 1 | during play |
49
+ | Anti-aliasing (`antialias`) | FXAA | MSAA 4x | MSAA 4x | MSAA 4x | at the start |
50
+ | Moment transparency (`momentTransparency`) | no | no | no | no | at the start |
51
+ | Shadow cascades (`shadowCascades`) | 2 | 3 | 3 | 4 | at the start |
52
+ | Shadow map size in texels (`shadowMapSize`) | 1024 | 2048 | 2048 | 4096 | at the start |
53
+ | Shadow filter (`shadowFilter`) | 3 x 3 texels | 5 x 5 texels | 5 x 5 texels | 5 x 5 texels | during play |
54
+ | Far cascade updates (`farCascadeInterval`) | every 4th frame | every 3rd frame | every 2nd frame | every 2nd frame | during play |
55
+ | Far cascades follow moving casters (`followMovingCasters`) | yes | yes | yes | yes | during play |
56
+ | Far-animation updates (`farAnimationInterval`) | every 4th frame | every 4th frame | every 2nd frame | every frame | during play |
57
+ | Blend between shadow cascades (`shadowCascadeBlend`) | 10% of each cascade | 10% of each cascade | 10% of each cascade | 10% of each cascade | during play |
58
+ | Sun cast shadows (`castShadows`) | yes | yes | yes | yes | during play |
59
+ | Spot and point light shadow tiles (`shadowTiles`) | 4 | 8 | 16 | 24 | at the start |
60
+ | Shadow tile size in texels (`shadowTileSize`) | 512 | 512 | 1024 | 1024 | at the start |
61
+ | Hero shadow tile size in texels (`heroTileSize`) | 1024 | 2048 | 2048 | 4096 | at the start |
62
+ | Point light shadows (`pointLightShadows`) | no | no | yes | yes | at the start |
63
+ | Bloom's largest level in texels on the short side (`bloomSize`) | 64 | 512 | 512 | 512 | during play |
64
+ | Bloom (`bloom`) | yes | yes | yes | yes | during play |
65
+ | Ambient occlusion (`aoScale`) | off | off | half resolution | half resolution | during play |
66
+ | Contact shadows (`contactShadowSteps`) | off | off (WebGL2: 4 steps at half resolution) | 8 steps at half resolution | 16 steps at half resolution | during play |
67
+ | Depth of field (`dofSamples`) | off | 22 taps at half resolution | 43 taps at half resolution | 71 taps at half resolution | during play |
68
+ | Subsurface blur of skin (`subsurfaceSamples`) | off | off | 17 taps each way | 25 taps each way | during play |
69
+ | Screen-space reflections (`ssrScale`) | off | quarter resolution | half resolution | half resolution | during play |
70
+ | Screen-space reflection steps per ray (`ssrSteps`) | 16 | 24 | 48 | 64 | during play |
71
+ | Screen-space bounce light (`bounceRays`) | off | off (WebGL2: 4 rays each way) | 4 rays each way | 8 rays each way | during play |
72
+ | Automatic exposure's meter (`exposureMeter`) | 16 x 16 cells | histogram on WebGPU, else 16 x 16 cells | histogram on WebGPU, else 16 x 16 cells | histogram on WebGPU, else 16 x 16 cells | during play |
73
+ | Volumetric fog (`fogSlices`) | off, sun glow only | 32 slices | 64 slices | 96 slices | during play |
74
+ | Reflection passes (`reflectionScale`) | quarter resolution | half resolution | half resolution | full resolution | during play |
75
+ | Reflection probe maps (`probeSize`) | 128 x 128 | 256 x 256 | 256 x 256 | 256 x 256 | during play |
76
+ | Area lights per frame (`areaLights`) | 4 | 8 | 16 | 32 | during play |
77
+ | Depth-fitted light clusters (WebGPU) (`lightFit`) | no | yes | yes | yes | during play |
78
+ | Level of detail threshold (`lodThreshold`) | 2 px | 1 px | 1 px | 1 px | during play |
79
+ | Level of detail threshold in shadows (`lodShadowThreshold`) | 1 texel | 1 texel | 1 texel | 1 texel | during play |
80
+ | Distance band fades (`lodFade`) | no | yes | yes | yes | during play |
81
+ | Physical sky (`physicalSky`) | the analytic sky stands in | from its tables | from its tables | from its tables | during play |
82
+ | Cloud march steps (`cloudSteps`) | flat layer | flat layer | 32 | 48 | during play |
83
+ | Frame-budget governor (`governor`) | on | on | on | on | during play |
84
+ | Governor raises the level threshold (`governorLevels`) | yes | yes | yes | yes | during play |
85
+ | Depth prepass (`depthPrepass`) | no (WebGL2: yes) | no (WebGL2: yes) | no (WebGL2: yes) | no (WebGL2: yes) | during play |
86
+ | GPU occlusion culling (WebGPU) (`gpuOcclusion`) | no | no | yes | yes | at the start |
87
+ | Morph targets per object on WebGL2 (`morphTargets`) | 8 | 16 | 32 | 64 | at the start |
88
+ | Software occlusion culling (WebGL2) (`softwareOcclusion`) | no | no | no | no | during play |
89
+ | Parallax occlusion mapping (`parallax`) | no | yes | yes | yes | during play |
90
+ | Soft particles (`softParticles`) | no | yes | yes | yes | during play |
91
+ | Anisotropic filtering cap (`maxAnisotropy`) | 2x | 4x | 8x | 16x | during play |
92
+ | Texture uploads per frame (`uploadBytesPerFrame`) | 2 MiB | 4 MiB | 8 MiB | 16 MiB | during play |
93
+ | Texture memory budget (`textureMemoryMiB`) | 256 MiB | 512 MiB | 1024 MiB | 2048 MiB | during play |
94
+ | Engine memory maximum (`memoryMaximumMiB`) | 1024 MiB | 1024 MiB | 1024 MiB | 1024 MiB | before loading |
@@ -8,7 +8,7 @@ summary: "Low to Ultra; pixel-ratio caps; the preset check; switching presets; t
8
8
 
9
9
  # Quality presets, dynamic resolution and frame budgets
10
10
 
11
- > Roadmap step 0.1, first released in null3D 0.1.0. The API is experimental, so it can still change between versions. The engine chooses a preset and checks it after the first frame. It applies the preset's pixel ratio cap, render scale range, shadow, texture and anti-aliasing settings, depth prepass, occlusion culling and memory maximum. During play, the frame-budget governor moves a sketch's budgets and the render scale in turn, a budget's step first, then the live shadow settings, and a sketch can switch presets with `quality.setPreset`. The settings that the [table of settings](quality-preset-tables.md#settings-of-each-preset) marks as planned are not built yet. Coding agents must not use them.
11
+ > Roadmap step 0.1, first released in null3D 0.1.0. The API is experimental, so it can still change between versions. The engine chooses a preset and checks it in the first frames of play, or before play when the page asks. It applies the preset's pixel ratio cap, render scale range, shadow, texture and anti-aliasing settings, depth prepass, occlusion culling and memory maximum. During play, the frame-budget governor moves a sketch's budgets and the render scale in turn, a budget's step first, then the live shadow settings. A sketch can switch presets with `quality.setPreset`. The presets do not cap the count of point and spot lights. The camera lists up to 1,024 of them on every preset, and up to 128 in each cluster.
12
12
 
13
13
  ```mermaid
14
14
  flowchart TD
@@ -22,9 +22,10 @@ flowchart TD
22
22
  crashes -- "two: Low" --> preset
23
23
  preset --> settings["Settings: the preset's values,<br/>then the page's options"]
24
24
  settings --> sketch["ctx.quality in the sketch"]
25
- sketch --> check{"Preset check after the setup:<br/>does the scene hold its frame rate?"}
25
+ sketch --> play["Play from the first frame"]
26
+ play --> check{"Preset check in the first frames:<br/>does the scene hold its frame rate?"}
26
27
  check -- "no: one preset lower,<br/>then measure again" --> check
27
- check -- "yes, or Low" --> play["Play"]
28
+ check -- "yes, or Low" --> governor["The governor starts"]
28
29
  play -- "quality.setPreset" --> play
29
30
  ```
30
31
 
@@ -79,19 +80,29 @@ A name that is not `auto`, `low`, `medium`, `high` or `ultra` fails the start wi
79
80
  A phone closes a tab that uses too much memory, and the page gets no event for it. So while the engine starts, it keeps a note in the page's `localStorage`. It removes the note once the engine has drawn for its first few seconds, or when the page stops the engine or leaves before then. A note that the next start finds means that the tab crashed during that start:
80
81
 
81
82
  - After one crashed start, the engine starts one preset lower than it would.
82
- - After two in a row, it starts at Low. If the start that crashed drew with WebGPU, it draws with WebGL2, unless the page names a GPU path.
83
+ - After two in a row, it starts at Low, in the [lowest quality tier](#the-lowest-quality-tier). If the start that crashed drew with WebGPU, it draws with WebGL2, unless the page names a GPU path.
83
84
 
84
- This also applies to a preset that the page names, so a device that crashed at the player's choice can start again. The page can read the count in `engine.mode.crashedStarts` and tell the player. When the browser refuses the storage, as in a sandboxed frame, each start counts as a normal one. Hold mode and the `?preset=` switch leave the note alone. The note belongs to one sketch module and one origin.
85
+ This also applies to a preset that the page names, so a device that crashed at the player's choice can start again. The `?preset=` switch fixes the preset and starts outside the tier, as it ignores the crashes. The page can read the count in `engine.mode.crashedStarts` and tell the player. When the browser refuses the storage, as in a sandboxed frame, each start counts as a normal one. Hold mode and the `?preset=` switch leave the note alone. The note belongs to one sketch module and one origin.
85
86
 
86
87
  ## The preset check
87
88
 
88
89
  Device hints only suggest a preset. A laptop with a weak GPU and a desktop with a strong one both have a fine pointer. So when the engine chooses the preset itself, it checks the choice with the scene that the sketch built:
89
90
 
90
- 1. The sketch's setup runs at the chosen preset and builds its scene.
91
- 2. The engine draws the first frame, with every pipeline built, and then draws the scene for a moment more. The sketch's `onUpdate` does not run yet.
92
- 3. The engine measures two rates: the frames that it presented, and the frames that the GPU finished. It reads the lower one, so frames that wait in a queue on the GPU cannot pass for a healthy rate.
93
- 4. When that rate misses the target, the engine lowers the preset by one, waits for the new preset's first frame, and measures again. It stops at a preset that holds the target, or at Low. A setting that the setup changed with `quality.set` keeps its value on the lighter preset. The lighter preset also gives the anti-aliasing mode, which the device moves its canvas to before it draws that preset's first frame. Every other setting that a device fixes at start keeps the value it started with.
94
- 5. `createEngine` resolves after the check. The sketch's `quality.onChange` handlers then hear of the new preset at the start of the first frame of play.
91
+ 1. The sketch's setup runs at the chosen preset and builds its scene. `createEngine` resolves.
92
+ 2. The engine draws the first frame, with every pipeline built, and play starts: the sketch's `onUpdate`, its input and its animations run as usual.
93
+ 3. The engine waits until the GPU has finished the first frame and draws at play's rate, for up to 4 seconds. Then, for a moment, it measures two rates: the frames that it presented, and the frames that the GPU finished. It reads the lower one, so frames that wait in a queue on the GPU cannot pass for a healthy rate.
94
+ 4. When that rate misses the target, the engine lowers the preset by one, waits for the new preset's first frame, and measures again. It stops at a preset that holds the target, or at Low. A rate under a quarter of the target is far below it: the engine then lowers the preset straight to Low, and measures Low. The sketch's `quality.onChange` handlers hear of each lighter preset in the next frame. A setting that the sketch changed with `quality.set` keeps its value on the lighter preset. The lighter preset also gives the anti-aliasing mode, which the device moves its canvas to before it draws that preset's first frame. Every other setting that a device fixes at start keeps the value it started with.
95
+ 5. The check ends, and `engine.presetChecked` resolves. The [frame-budget governor](#the-frame-budget-governor) waits until then, so the check measures each preset at the full render scale.
96
+
97
+ The viewer sees the scene from its first frame, so a lighter preset applies in front of the viewer. A sketch that asks for a preset itself with `quality.setPreset` while the check runs ends the check. The sketch's choice then stands, and `engine.mode.presetCheck` stays null.
98
+
99
+ A page that would rather hide a change of preset behind its loading screen asks for the check before play:
100
+
101
+ ```ts
102
+ const engine = await createEngine({ canvas, sketch, presetCheck: 'before-play' });
103
+ ```
104
+
105
+ The engine then draws the first frame and measures the scene that the setup built, before the sketch's `onUpdate` runs. `createEngine` resolves after the check. The sketch's `quality.onChange` handlers hear of the new preset at the start of the first frame of play. The `?preset-check=before-play` or `?preset-check=during-play` switch sets the timing from the page's address, and wins over the option.
95
106
 
96
107
  The [rules of the preset check](quality-preset-tables.md#rules-of-the-preset-check) give its target frame rate, the share of the target that passes, and its times.
97
108
 
@@ -108,11 +119,13 @@ const engine = await createEngine({ canvas, sketch, targetFps: 'display' });
108
119
 
109
120
  A whole number, such as `targetFps: 90`, caps the target at that rate. The target never goes above the display's rate. A higher target costs quality: the check picks a lighter preset where the GPU cannot hold it, and the governor lowers the render scale sooner. The `?target-fps=display` or `?target-fps=90` switch sets the target from the page's address, and wins over the option. Until the engine has measured the display's rate, the target is 60, or the option's rate when that is lower. The [stats overlay](../api/debug.md#stats-overlay-and-frame-figures) shows the display's rate beside the target.
110
121
 
111
- The engine checks only a preset that it chose itself, when a lighter preset exists. A preset that the page names, the `?preset=` switch, and hold mode skip the check. So does Low, as on phones. The first frame does not wait for the check, but `createEngine` does. The check takes at least three quarters of a second for each preset that it measures. That was about 0.8 seconds on a MacBook Pro, and about 1 second on an 11-inch iPad Pro. So keep the loading screen until `createEngine` has resolved and `engine.firstFrame` has too.
122
+ The preset check starts its target at the display's rate that the engine measured before the check's first frame. It never lowers its target during the check. A GPU that falls behind slows the frame callbacks, so the rate measured under the check's own load can read as a slower display. On a Galaxy Tab A9 Plus with a 90 Hz display, that rate read 30 to 45 while Skyway drew.
123
+
124
+ The engine checks only a preset that it chose itself, when a lighter preset exists. A preset that the page names, the `?preset=` switch, and hold mode skip the check. So does Low, as on phones. The check takes at least three quarters of a second for each preset that it measures. That was about 0.8 seconds on a MacBook Pro, and about 1 second on an 11-inch iPad Pro. During play, neither `createEngine` nor the first frame waits for it. Before play, `createEngine` waits for it, so keep the loading screen until `createEngine` has resolved and `engine.firstFrame` has too.
112
125
 
113
126
  ### Repeat visits
114
127
 
115
- The engine stores the check's result in the page's `localStorage`, one for each sketch module. A later start of the sketch in the same browser on the same device takes that result and skips the check. [Caches between visits](../getting-started/hosting.md#caches-between-visits) shows the other caches that a repeat visit uses. Its setup already runs at the preset that the check chose, so `createEngine` resolves as soon as the setup ends. On an 11-inch iPad Pro, the check took about a second for each preset that it measured. There the benchmark scenes and demos showed their first frame after 1 to 2.4 seconds on a first visit. A repeat visit took 0.25 to 0.52 seconds.
128
+ The engine stores the check's result in the page's `localStorage`, one for each sketch module. A later start of the sketch in the same browser on the same device takes that result and skips the check. [Caches between visits](../getting-started/hosting.md#caches-between-visits) shows the other caches that a repeat visit uses. Its setup already runs at the preset that the check chose, so it plays at that preset from its first frame, and `engine.presetChecked` resolves with `createEngine`. On an 11-inch iPad Pro, the check took about a second for each preset that it measured. With the check before play, the benchmark scenes and demos there showed their first frame after 1 to 2.4 seconds on a first visit. A repeat visit took 0.25 to 0.52 seconds.
116
129
 
117
130
  A stored result applies only while the start matches the one that the check measured:
118
131
 
@@ -123,12 +136,15 @@ A stored result applies only while the start matches the one that the check meas
123
136
 
124
137
  Otherwise the engine measures again and stores the new result. It stores no result that it measured against a target below 60 frames per second, or below the lower target that the page set. A display that saves power with a lower refresh rate gives such a target. The settings fixed at the start keep the values of the preset that the check started from, as they do after the check's own steps. When the browser refuses the storage, each start measures. The `?check=fresh` switch makes the engine measure again too.
125
138
 
126
- The check measures the scene as the setup left it. So build the scene in the setup, and load its textures there: the check waits while textures upload. A scene that the setup leaves empty passes the check on any GPU.
139
+ The engine also stores the check's rounds each time the check lowers the preset. The check can take many seconds on a slow tablet, and a viewer who leaves the page during it loses no round. The next start begins at the preset that the check had lowered to, and its own check goes on from there. The field `engine.mode.presetCheck` then reports the earlier start's rounds with its own, from the earlier start's first preset.
127
140
 
128
- `engine.mode.presetCheck` reports what the check measured:
141
+ The check measures the scene from its first frame. So build the first view in the setup, and load its textures there: the check waits while textures upload. A scene that the setup leaves empty passes the check on any GPU.
142
+
143
+ `engine.mode.presetCheck` reports what the check measured, once `engine.presetChecked` has resolved:
129
144
 
130
145
  ```ts
131
146
  const engine = await createEngine({ canvas, sketch });
147
+ await engine.presetChecked;
132
148
  const check = engine.mode.presetCheck;
133
149
  if (check && check.from !== engine.mode.preset)
134
150
  console.log(`${check.from} missed ${check.targetFps} fps; the engine runs ${engine.mode.preset}`);
@@ -144,22 +160,22 @@ A change of preset can change pipelines and render targets, and building them ta
144
160
 
145
161
  ## The settings of each preset
146
162
 
147
- Each value is a starting point, which measurements on phones, tablets and desktops tune from release to release. A setting that changes "during play" takes a new value at any time. One that changes "at the start" is fixed while the engine runs. The preset that the engine starts with, or the page's option, gives its value, and `quality.setPreset` keeps it. The memory maximum is fixed before the engine loads. "Planned" settings belong to features that are not built yet.
163
+ Each value is a starting point, which measurements on phones, tablets and desktops tune from release to release. A setting that changes "during play" takes a new value at any time. One that changes "at the start" is fixed while the engine runs. The preset that the engine starts with, or the page's option, gives its value, and `quality.setPreset` keeps it. The memory maximum is fixed before the engine loads.
148
164
 
149
- The [settings of each preset](quality-preset-tables.md#settings-of-each-preset) give each setting's value on each preset, when it changes, and whether it is built.
165
+ The [settings of each preset](quality-preset-tables.md#settings-of-each-preset) give each setting that the engine applies, with its value on each preset and when it changes.
150
166
 
151
167
  The pixel ratio cap is the cheapest large saving on phones. The GPU fills each device pixel, and a screen's device pixels grow with the square of its ratio. So a ratio of 3 fills 2.25 times the pixels of a ratio of 2. The `maxPixelRatio` option of `createEngine` replaces the preset's cap, and `quality.set({ maxPixelRatio })` changes it during play.
152
168
 
153
- The shadow settings set the GPU memory that shadows take. The shadow map stores 2 bytes per texel. The atlas stores 4: the tiles of spot and point lights, and the sun's hero tile.
169
+ The shadow settings set the GPU memory that shadows take. The shadow map stores 2 bytes per texel. The atlas stores 4: the tiles of spot and point lights, and the sun's hero tile. The table gives the memory with every tile in use.
154
170
 
155
- | Preset | Shadow map | Shadow atlas | Both |
156
- | --- | --- | --- | --- |
157
- | Low | 4 MiB | 5 MiB | 9 MiB |
158
- | Medium | 24 MiB | 9 MiB | 33 MiB |
159
- | High | 24 MiB | 68 MiB | 92 MiB |
160
- | Ultra | 128 MiB | 100 MiB | 228 MiB |
171
+ | Preset | Shadow map | Shadow atlas | Both | Atlas with a hero |
172
+ | --- | --- | --- | --- | --- |
173
+ | Low | 4 MiB | 4 MiB | 8 MiB | 20 MiB |
174
+ | Medium | 24 MiB | 8 MiB | 32 MiB | 144 MiB |
175
+ | High | 24 MiB | 64 MiB | 88 MiB | 272 MiB |
176
+ | Ultra | 128 MiB | 96 MiB | 224 MiB | 1,536 MiB, refused |
161
177
 
162
- The shadow map takes its memory once the directional light casts shadows. The atlas takes its own once a spot or point light casts, and one more layer while the sun names a [hero shadow](shadows.md#a-hero-shadow). The table counts that layer: 1 MiB at Low and Medium, 4 MiB at High and Ultra. [Shadows](shadows.md#what-shadows-cost) gives the cost of each.
178
+ The shadow map takes its memory once the directional light casts shadows. The atlas takes its own once a spot or point light casts. While the sun names a [hero shadow](shadows.md#a-hero-shadow), the atlas has one more layer. Every layer then takes the size of the preset's `heroTileSize`: 1,024 texels on Low, 2,048 on Medium and High, and 4,096 on Ultra. An atlas above 1 GiB fails with [E1501](../errors/E1501.md). So on Ultra, a hero leaves room for 15 light tiles at most. [Shadows](shadows.md#what-shadows-cost) gives the cost of each.
163
179
 
164
180
  The anisotropic filtering cap limits the `anisotropy` option of every texture, so surfaces seen at a slant cost fewer texture reads on the lighter presets. The upload budget limits the texel bytes that one frame sends to the GPU, so loading many textures does not make one frame slow. A larger texture goes up over several frames. `quality.set({ maxAnisotropy, uploadBytesPerFrame })` changes either during play.
165
181
 
@@ -193,7 +209,7 @@ The engine makes its memory while it tests the GPU paths. So the memory maximum
193
209
 
194
210
  The `momentTransparency` option of `createEngine`, or the `?moments=on` or `?moments=off` switch, blends the camera's blended surfaces in the moment transparency layer, which needs no sort. [Moment transparency](../api/materials.md#moment-transparency) describes the layer and the materials that it draws. Every preset leaves it off, because it draws those surfaces twice, and the setting stays fixed while the engine runs.
195
211
 
196
- The layer's moment store and color sum take 8 bytes per pixel each at the render size, and its surfaces write both: 16 bytes per pixel a frame, which is 33 MB at 1920 x 1080. The composite reads both and writes the scene color, and SMAA 1x's two 8-bit steps take 8 bytes per pixel more. A multisampled scene also needs a copy of one depth sample, at 4 bytes per pixel, so the targets that the layer adds come to 28 bytes per pixel before the render graph shares any with another pass. The 33 MB counts the writes alone, and the memory is larger: on the Island showcase at High at 1920 x 1080, the stats overlay's `GPU textures` rose by 40 MiB on WebGPU with direct draws and by 52 MiB on WebGL2. The weighted blending writes 10 bytes per pixel into its two sums. SMAA smooths the layer's edges under the share that its moments cover, and the opaque geometry keeps MSAA's samples.
212
+ The layer's moment store and color sum take 8 bytes per pixel each at the render size, and its surfaces write both: 16 bytes per pixel a frame, which is 33 MB at 1920 x 1080. The composite reads both and writes the scene color, and SMAA 1x's two 8-bit steps take 8 bytes per pixel more. Its resolve step writes a copy of the scene color, at 4 or 8 bytes per pixel by the scene color's format. A multisampled scene also needs a copy of one depth sample, at 4 bytes per pixel. So the targets that the layer adds come to 32 to 36 bytes per pixel before the render graph shares any with another pass. The 33 MB counts the writes alone, and the memory is larger: on the Island showcase at High at 1920 x 1080, the stats overlay's `GPU textures` rose by 40 MiB on WebGPU with direct draws and by 52 MiB on WebGL2. The weighted blending writes 10 bytes per pixel into its two sums. SMAA smooths the layer's edges under the share that its moments cover, and the opaque geometry keeps MSAA's samples.
197
213
 
198
214
  In the S1 benchmark with its smoke switch, at High on this computer's GPU in Chrome 156, the layer added about 0.05 ms of processor time and 0.58 ms of GPU time a frame on WebGPU, about sixteen per cent of that scene's GPU frame, and about 1.12 ms on WebGL2, about twenty per cent. A phone's figure is owed, and a desktop GPU's fill rate is not a phone's.
199
215
 
@@ -201,7 +217,7 @@ In the S1 benchmark with its smoke switch, at High on this computer's GPU in Chr
201
217
 
202
218
  With the depth prepass, the engine first draws the depth of the opaque objects, with no color. The opaque pass then shades each pixel once, for its nearest surface. Without the prepass, a pixel can be shaded for several surfaces before the nearest one covers them. The prepass costs a second pass over the objects' vertices. So it saves GPU time where objects hide many others and their shading costs much, such as in a lit street of buildings. It costs time where a scene has many vertices and little overdraw.
203
219
 
204
- Some objects stay out of the prepass and shade as they would without it. These are blended objects, line batches, and objects whose material has an alpha cutoff or skips depth writes or the depth test. On WebGL2, every preset turns the prepass on. On WebGPU and in its compatibility mode, every preset leaves it off. Ambient occlusion and the directional light's [contact shadows](shadows.md#contact-shadows) turn it on while they draw, because they read the prepass's depth ([post-processing](post-processing.md#ambient-occlusion)). So High and Ultra draw it on WebGPU while the directional light casts shadows. The `depthPrepass` option of `createEngine` replaces the preset's choice. Compare the scene's GPU time with `?prepass=on` and `?prepass=off`. The prepass is fixed while the engine runs, because the scene's pipelines depend on it.
220
+ Some objects stay out of the prepass and shade as they would without it. These are blended objects, line batches, and objects whose material has an alpha cutoff or skips depth writes or the depth test. On WebGL2, every preset turns the prepass on. On WebGPU and in its compatibility mode, every preset leaves it off. Ambient occlusion, the directional light's [contact shadows](shadows.md#contact-shadows), screen-space bounce light and screen-space reflections turn it on while they draw. They read the prepass's depth ([post-processing](post-processing.md#ambient-occlusion)). So High and Ultra draw it on WebGPU outside compatibility mode, where the bounce light runs. The [lowest quality tier](#the-lowest-quality-tier) turns it off on WebGL2. Each opaque object then has a depth pipeline beside its own, which the first frame and a warm-up build too. The `depthPrepass` option of `createEngine` replaces the preset's choice. Compare the scene's GPU time with `?prepass=on` and `?prepass=off`. `quality.set({ depthPrepass })` changes it during play.
205
221
 
206
222
  WebGL2 draws the prepass because of Apple GPUs. On them, a depth prepass restores early rejection of hidden pixels in WebGL2, so each pixel is shaded about once. In the S4 benchmark on an iPad, WebGL2 went from 38 to 60 frames per second on Low. On Medium it went from 17 to 37 frames per second. The images stay the same. On Android phones that ran S4, WebGL2 kept its frame rate with the prepass, and its CPU time did not change. On WebGPU the GPU removes hidden surfaces itself, so the prepass only adds work. On the same iPad it added about 4 ms per frame to S4 on Medium.
207
223
 
@@ -240,6 +256,7 @@ During play, the engine moves the scale between the `minRenderScale` and `maxRen
240
256
  - It watches how often frames reach the screen and how often the GPU finishes one. It also watches how long the GPU takes to finish each frame.
241
257
  - A second of frames is over budget when its frame rate, on average, is under 95% of the target rate. At a target of 60, that is under 57 frames per second. The engine's benchmark reports count such a second as a miss too. Each quarter of the second must also run at least 2% slower than the target, so one short stall amid full-rate frames does not count. A second is over budget too when the GPU finishes each frame two frames late or later.
242
258
  - The target is the [target frame rate](#the-target-frame-rate): the display's refresh rate, at most 60 frames per second unless the page asks for more. The `?fps=` switch caps it at the rate that it holds. Safari calls a drawing worker from a timer, which slows when the GPU falls behind. There the engine takes the display's rate from the page's frame callbacks.
259
+ - The governor's target starts at the display's rate that the engine measured when the sketch's setup returned. A GPU that falls behind slows the frame callbacks, which then read as a slower display. So the target falls to a slower rate only while the GPU finishes each frame within the target's own frame time. Then the display or the browser slowed the frames, as a display that saves power does.
243
260
  - After a second over budget, the scale drops by 0.05. The engine then waits a second, so it judges frames at the new scale.
244
261
  - After 5 seconds at the target rate on average, with the GPU done with each frame within about one frame, the scale rises by 0.05. The average covers the whole 5 seconds. In Safari, some frames wait an extra callback even at the full rate.
245
262
  - Frames at 57 to 59 frames per second hold the target but have no time to spare, so the scale stays where it is.
@@ -295,10 +312,22 @@ Dynamic resolution is the first part of the frame-budget governor. A sketch can
295
312
 
296
313
  Each step follows the rules of dynamic resolution. Frames must stay over budget for a second before a step down, and keep time to spare for 5 seconds before a step up. A wait follows each step, and no step happens early in play, after a pause, or during uploads. The governor raises the settings in the reverse order, so the render scale comes back last. It takes shadow steps only where a directional light casts shadows. A lower render scale picks coarser levels of detail too, as the render height counts in each level's error in pixels. It never changes the preset, nor a setting that is fixed while the preset runs, such as the shadow map's size.
297
314
 
298
- Phones slow down as they heat up, often after a few minutes of play. The governor responds as it does to any slow frames: after a second over budget, it lowers the next setting. The target is the [target frame rate](#the-target-frame-rate): by default the display's refresh rate, at most 60 frames per second. When the browser lowers the rate of its frames to save battery, the rate that the engine measures falls, and the target falls with it.
315
+ Phones slow down as they heat up, often after a few minutes of play. The governor responds as it does to any slow frames: after a second over budget, it lowers the next setting. The target is the [target frame rate](#the-target-frame-rate): by default the display's refresh rate, at most 60 frames per second. When the browser lowers the rate of its frames to save battery, the rate that the engine measures falls. The target falls with it, as long as the GPU keeps up with the frames.
299
316
 
300
317
  `quality.governor` reports what the governor lowered, and the `quality.onChange` handlers run after each shadow step. So a sketch can lighten its own work at the same time: [Quality API](../api/quality.md#the-frame-budget-governor) shows how. `quality.set({ governor: false })` turns the governor off. The scene then draws at `maxRenderScale`, with the shadow settings as set, as a benchmark or a recorded video needs. Hold mode has no governor.
301
318
 
319
+ ### The lowest quality tier
320
+
321
+ Some devices reach the lowest render scale and still miss the target. Below the four presets sits a lowest tier for them. The governor enters it when the render scale has held at its floor through the sustained window, and the judged frames still miss. Its cuts are a third-size render scale floor, no sun shadows, no bloom, and reflection passes at a quarter of the render size. On WebGL2 it also turns the depth prepass off.
322
+
323
+ The tier changes live settings that a sketch can read. These are `minRenderScale`, `castShadows`, `bloom` and `reflectionScale`, and `depthPrepass` where the GPU path draws it. The four presets keep their values, so no other look changes. `quality.governor.lowest` reports whether the tier applies. A `minRenderScale` that the sketch sets itself wins over the tier's floor and cap. The scale stays at or above it in the tier and after it, and the tier keeps its other cuts.
324
+
325
+ The entry goes on trial as a step down does. Frames that come clearly slower after it take the tier back, and close it for a wait that doubles with each failed entry. The governor leaves the tier when the frames keep room through the window that raises a step. It then waits that same window before the tier can enter again, so a device cannot flap.
326
+
327
+ `?tier=lowest` starts a page in the tier, for tests, devices and a known weak class. The governor stays the default path to the tier.
328
+
329
+ A sketch whose own thread limits its frames keeps the tier out. Its smaller render cannot make the sketch work cheaper, so the picture only loses detail. `defineSketch(setup, { lowestTier: false })` sets that.
330
+
302
331
  ### Settings of an add-on's feature
303
332
 
304
333
  An add-on's feature declares its own settings in the same form as the engine's table: a value on each preset, an optional WebGL2 column, and the values it takes. The feature's budget joins the sketch's budgets. A step of the budgets' scale then lowers the feature's share of full quality with the sketch's own systems. A setting that names a `governor` follows that share: a count shrinks with it, and an interval doubles with each step. The stats overlay shows the feature's values and its budget beside the engine's figures. [Add-on feature descriptions](../api/features.md#preset-settings-and-the-frame-budget-governor) shows how a feature declares them.
@@ -32,7 +32,7 @@ flowchart LR
32
32
 
33
33
  null3D draws each frame as a series of passes. A pass is one job for the GPU, such as culling the objects that a camera cannot see, or drawing the scene from the camera. Each pass declares what it reads and what it writes. The render graph reads these declarations before a frame draws. It puts the passes in order and plans the textures they draw into.
34
34
 
35
- The engine declares its own passes. From step 0.2, a sketch adds scene passes of its own with `render.addPass`, and `render.dumpGraph()` prints the graph ([Render graph API](../api/render.md)).
35
+ The engine declares its own passes. A sketch adds scene passes of its own with `render.addPass`, and `render.dumpGraph()` prints the graph ([Render graph API](../api/render.md)).
36
36
 
37
37
  In the diagram, boxes are passes and cylinders are data. An arrow into a pass shows what it reads, and an arrow out of a pass shows what it writes. The opaque and transparent passes share one render pass on the GPU. The scene color reaches the canvas through the final pass on devices that draw HDR color. So it does in the FXAA and no anti-aliasing modes. On the other devices with MSAA, the resolve pass takes its place, along the dotted arrows. It shares the opaque and transparent passes' render pass.
38
38
 
@@ -43,6 +43,7 @@ In the diagram, boxes are passes and cylinders are data. An arrow into a pass sh
43
43
  | Light clustering | Compute, on WebGPU only | The point and spot lights of the camera's view and of each scene pass that sees one, and the depth range that the light depth pass measured | The list of lights of each cluster of each view, and the fitted slice bounds in its header |
44
44
  | Light depth | Compute, on WebGPU only, while the camera sees a local light | The camera view's scene depth | The nearest and farthest depth that the next frame's light clustering fits its slices to |
45
45
  | Culling | Compute, one pass per view (the camera's, and each shadow cascade's and tile's), on WebGPU only | The world matrix and bounds of every object and instance | The view's visible instances and draw counts |
46
+ | Skinning | Compute, on WebGPU only, while the scene has meshes that the vertex shaders do not skin, such as morphed meshes | The meshes' vertices, joints and morph weights | A buffer of skinned vertices, which the shadow and scene passes draw |
46
47
  | Shadow | Scene, one pass per shadow cascade and per tile of the shadow atlas, in the frames in which it draws | The visible casters of its view | Its layer of the shadow map or of the shadow atlas |
47
48
  | Depth prepass | Scene, one pass per view, with the `depthPrepass` setting | The view's visible instances | The scene depth |
48
49
  | Opaque | Scene, one pass per view | The view's visible instances (on WebGPU), the lights of each cluster, and the shadow map and atlas | The scene color and depth |
@@ -50,6 +51,7 @@ In the diagram, boxes are passes and cylinders are data. An arrow into a pass sh
50
51
  | Depth pyramid | Compute, one pass per camera view, on WebGPU with the `gpuOcclusion` setting | The occluders' depth | The view's depth pyramid |
51
52
  | Late culling | Compute, one pass per camera view, on WebGPU with the `gpuOcclusion` setting | The world matrix and bounds of every object, and the depth pyramid | The view's visible instances and draw counts |
52
53
  | Debug lines | Scene, in development builds, in frames with debug drawing | The frame's lines | The scene color and depth |
54
+ | Transmission copy | Fullscreen, one pass for the camera, while a surface lets light through, or screen-space reflections or the bounce light are on | The scene color and depth as the opaque pass leaves them | A copy of the opaque color, with blurred levels |
53
55
  | Transparent | Scene, one pass per view, on while some object blends | The view's blended objects, sorted back to front on the job workers | The scene color and depth |
54
56
  | Depth copy | Fullscreen, one pass for the camera, while a custom material reads the scene's depth or a soft particle fades near it | The opaque scene depth | A copy of it, one texel for each pixel |
55
57
  | Motion culling | Compute, on WebGPU only, while a pass reads the motion vectors | The world matrix of every opaque object and instance in this frame and the last | The instances that moved, with both matrices |
@@ -60,8 +62,10 @@ In the diagram, boxes are passes and cylinders are data. An arrow into a pass sh
60
62
  | Copy | Fullscreen, one per scene pass, on WebGPU only | The scene pass's image | Its texture, with the rows turned around |
61
63
  | A sketch's full-screen pass | Fullscreen, one per `render.addPass({ kind: 'fullscreen' })` | Its input image, the scene depth if its WGSL reads it, and the textures of other passes that it reads | Its texture, which the graph keeps between frames |
62
64
  | A sketch's compute pass | Compute, one per `render.addPass({ kind: 'compute' })` | The textures of other passes that it reads | Its texture, a storage texture that the pass writes and that the graph keeps between frames |
63
- | Resolve | Resolve, on the 8-bit path with MSAA, while the render scale cannot drop below 1 | The scene color | The canvas |
64
- | Final pass | Fullscreen, on the HDR path, with FXAA or no anti-aliasing, and while the render scale can drop below 1 | The scene color | The canvas |
65
+ | Resolve | Resolve, on the 8-bit path with MSAA, while the render scale cannot drop below 1 and no effect needs the final pass | The scene color | The canvas |
66
+ | Final pass | Fullscreen, on the HDR path, with FXAA or no anti-aliasing, while the render scale can drop below 1, and while an effect needs it | The scene color | The canvas |
67
+
68
+ The table lists the core passes. Each effect adds passes of its own while it is on. These are ambient occlusion, screen-space reflections, the bounce light, decals and the transparency layers. So are subsurface scattering, volumetric fog, custom effects, depth of field, bloom, automatic exposure, outlines and the still accumulation. The pick pass runs when a page asks what is under a pixel. [The post-processing chain](post-processing.md) describes most of them, and `render.dumpGraph()` lists every pass of a frame.
65
69
 
66
70
  On WebGL2 the job workers cull the objects and list the lights of each cluster before the frame draws. So the graph has no compute passes there. A shadow pass draws its casters' depth from the light. The opaque pass reads that depth, so every shadow pass runs before it. [Shadows](shadows.md) says when each cascade and each tile draws.
67
71
 
@@ -69,11 +73,11 @@ With the depth prepass on, each view draws the depth of its opaque objects first
69
73
 
70
74
  With GPU occlusion culling on, each camera view's culling pass keeps the large objects that showed in its last frame. The occluders' pass draws their depth into a target of its own, and the depth pyramid pass reads it. The late culling pass tests every object in view against the pyramid, and writes the visible instances again. The occluders' pass must read them before that write. The graph runs a pass that reads a resource "so far" after the writers declared before it, and before the writers declared after it. The depth prepass, where it runs, and the opaque pass then draw what the late culling pass kept. [Culling](culling.md#gpu-occlusion-culling-on-webgpu) describes the method.
71
75
 
72
- A view is the scene seen from one camera, culled on its own. On WebGPU each view has a culling pass, and on WebGL2 the job workers list the visible objects of each view. On a device that draws directly, the job workers list them on WebGPU too. The camera's view draws the scene color and depth, and the scene color reaches the canvas. Each scene pass that a sketch adds has a view of its own, which draws into its texture. The camera's passes read the texture of every scene pass that a material shows, so those passes run first. A view that a sketch adds with `scene.createView` draws after the camera's passes. It draws into a rectangle of the camera's scene color through the viewport and the scissor, with a depth target of its own, so its image covers the camera's there. WebGPU draws an image's top row first, and materials sample the bottom row at v = 0, as three.js's render targets hold it. So on WebGPU a copy pass turns each pass's image over into its texture. WebGL2 draws the rows in that order already. A reflection view on the HDR WebGPU path is the exception: it draws into its target directly, and `reflection_uv` turns the rows of the lookups that read it.
76
+ A view is the scene seen from one camera, culled on its own. On WebGPU each view has a culling pass, and on WebGL2 the job workers list the visible objects of each view. On a device that draws directly, the job workers list them on WebGPU too. The camera's view draws the scene color and depth, and the scene color reaches the canvas. Each scene pass that a sketch adds has a view of its own, which draws into its texture. The camera's passes read the texture of every scene pass that a material shows, so those passes run first. A view that a sketch adds with `scene.createView` draws after the camera's passes. It draws into a rectangle of the camera's scene color through the viewport and the scissor, with a depth target of its own, so its image covers the camera's there. WebGPU draws an image's top row first, and materials sample the bottom row at v = 0. So on WebGPU a copy pass turns each pass's image over into its texture. WebGL2 draws the rows in that order already. A reflection view on the HDR WebGPU path is the exception: it draws into its target directly, and `reflection_uv` turns the rows of the lookups that read it.
73
77
 
74
78
  A full-screen pass that a sketch adds is a view without a camera. It draws one triangle over its texture, and its shader writes the rows bottom first on both paths, so it needs no copy. A pass that reads only other passes' textures runs before the passes that read its own. A pass that reads the scene color, the outline mask or the scene depth runs after the camera's passes, so the camera's passes do not read its texture in the same frame: a material that shows it shows the frame before. A custom effect that reads it runs after it. A compute pass that a sketch adds is a view without a camera too. Its shader writes its texture as a storage texture. A material, an effect or another pass samples that texture in the same frame, because the graph orders the pass before them. A custom material's vertex offset that reads it also draws it in the material's shadow, motion and pick passes, so the graph orders the pass before those too.
75
79
 
76
- Where the scene draws HDR color, the final pass reads it and draws the canvas. It applies the exposure and the tone mapping, and encodes the color for the display. In the FXAA anti-aliasing mode it also smooths the edges. Some devices cannot draw float targets in the anti-aliasing mode. There the scene shaders tone map their own output into an 8-bit target. With MSAA the resolve pass then runs instead of the final pass. It draws nothing: the scene's render pass resolves its multisampled color straight into the canvas. The frame then needs no extra pass, copy or texture. With FXAA or none, the final pass reads the 8-bit target and keeps its colors. [Color management](color-management.md) covers both paths.
80
+ Where the scene draws HDR color, the final pass reads it and draws the canvas. It applies the exposure and the tone mapping, and encodes the color for the display. In the FXAA anti-aliasing mode it also smooths the edges. Some devices cannot draw float targets in the anti-aliasing mode. There the scene shaders tone map their own output into an 8-bit target. With MSAA the resolve pass then runs instead of the final pass, while no effect needs the final pass ([Color management](color-management.md#the-8-bit-path) lists them). It draws nothing: the scene's render pass resolves its multisampled color straight into the canvas. The frame then needs no extra pass, copy or texture. With FXAA or none, the final pass reads the 8-bit target and keeps its colors. [Color management](color-management.md) covers both paths.
77
81
 
78
82
  ## Scene inputs
79
83
 
@@ -83,10 +87,10 @@ A custom material or an add-on feature can read scene resources that the frame m
83
87
  | --- | --- | --- |
84
88
  | `'sceneColor'` | The scene's color before the tone curve | The camera's opaque and transparent passes |
85
89
  | `'sceneDepth'` | The scene's depth | The camera's opaque pass |
86
- | `'normals'` | The surface normals that a depth prepass writes | No pass makes them yet |
87
- | `'motionVectors'` | How far each pixel's surface moved since the last frame | The motion pass, while a reader wants it |
90
+ | `'normals'` | The surface normals | No pass makes them |
91
+ | `'motionVectors'` | How far each pixel's surface moved since the last frame | The motion pass, while the motion debug view shows it |
88
92
 
89
- A feature declares the inputs in its `reads` ([Add-on feature descriptions](../api/features.md#scene-resources)). The render graph then runs it after the passes that write them. A custom material declares `sceneInputs: ['sceneDepth']` and reads the depth with `sceneDepth` or `sceneDistance` ([Materials](../api/materials.md#the-scene-behind-a-surface)).
93
+ A feature declares the inputs in its `reads` ([Add-on feature descriptions](../api/features.md#scene-resources)). The render graph then runs it after the passes that write them. A full-screen effect reads only `'sceneColor'` and `'sceneDepth'`, and a custom material reads only `'sceneDepth'`. No pass makes `'normals'`, and the adapters refuse `'motionVectors'`. A custom material declares `sceneInputs: ['sceneDepth']` and reads the depth with `sceneDepth` or `sceneDistance` ([Materials](../api/materials.md#the-scene-behind-a-surface)).
90
94
 
91
95
  A blended material that reads the depth binds a copy of it, one texel for each pixel. The frame makes the copy after the opaque pass and before the transparent pass, so the material never samples the depth target that its own pass writes. While the copy does not exist, a draw binds one texel at the far plane and reads 0:
92
96
 
@@ -120,7 +124,7 @@ Because passes are declarations, the engine can:
120
124
  - let neighboring passes share one render pass, and let temporary targets share memory
121
125
  - switch passes on and off with no new code
122
126
  - skip passes whose output nothing uses
123
- - print the whole graph as text for people and agents to read (0.2)
127
+ - print the whole graph as text for people and agents to read
124
128
 
125
129
  ## How the graph orders passes
126
130
 
@@ -174,7 +178,7 @@ The passes that a sketch adds get the same checks. The core checks them when `re
174
178
 
175
179
  ## The text dump
176
180
 
177
- `render.dumpGraph()` returns the compiled graph as Graphviz DOT text (0.2). Paste the text into any Graphviz viewer to see it as a picture.
181
+ `render.dumpGraph()` returns the compiled graph as Graphviz DOT text. Paste the text into any Graphviz viewer to see it as a picture.
178
182
 
179
183
  - Each render or compute pass that the GPU runs is a box around the passes it runs.
180
184
  - The number before each pass is its place in the order.
@@ -189,15 +193,16 @@ digraph "render graph" {
189
193
  graph [rankdir=LR, fontname="Helvetica", fontsize=10];
190
194
  subgraph "cluster 1" {
191
195
  label="compute pass";
192
- "pass Culling" [shape=box, label="1. Culling\ncompute pass"];
196
+ "pass LightClusters" [shape=box, label="1. LightClusters\ncompute pass"];
197
+ "pass Culling" [shape=box, label="2. Culling\ncompute pass"];
193
198
  }
194
199
  subgraph "cluster 2" {
195
200
  label="render pass: full size, 4 samples\nsceneColor: clear, discard, resolve\nsceneDepth: clear, discard";
196
- "pass Opaque" [shape=box, label="2. Opaque\nscene pass, full size, all layers"];
201
+ "pass Opaque" [shape=box, label="3. Opaque\nscene pass, full size, all layers"];
197
202
  }
198
203
  subgraph "cluster 3" {
199
204
  label="render pass: canvas size\ncanvas: clear, store";
200
- "pass Final" [shape=box, label="3. Final\nfullscreen pass, canvas size"];
205
+ "pass Final" [shape=box, label="4. Final\nfullscreen pass, canvas size"];
201
206
  }
202
207
  "pass Resolve" [shape=box, style=dashed, label="Resolve\nresolve pass, full size, off"];
203
208
  "resource sceneColor" [shape=ellipse, label="sceneColor\nrg11b10ufloat, full size, 4 samples\ntexture 0: attachment\nresolves into texture 1: attachment, sampled"];
@@ -213,5 +218,5 @@ digraph "render graph" {
213
218
  - [Render layers](render-layers.md): the layer masks that decide what a pass draws.
214
219
  - [Quality presets, dynamic resolution and frame budgets](quality-presets.md): the settings that switch passes and scale the render size.
215
220
  - [Shadows](shadows.md): the shadow cascades.
216
- - [Render graph API](../api/render.md): adding passes and printing the graph (0.2).
221
+ - [Render graph API](../api/render.md): adding passes and printing the graph.
217
222
  - [The security camera demo](https://github.com/null3d-engine/null3d/tree/main/examples/security-camera): a scene pass that draws a second camera's view for a monitor.
@@ -8,7 +8,7 @@ summary: "32-bit layer masks that choose which cameras draw which objects and in
8
8
 
9
9
  # Render layers
10
10
 
11
- > Roadmap step 0.1, first released in null3D 0.1.0. The API is experimental, so it can still change between versions. Raycasts, overlap queries and declared render passes take layer masks too, from step 0.2. See [Raycasting and spatial queries](../api/raycast.md) and [Custom passes and render targets](../guides/custom-passes.md).
11
+ > Roadmap step 0.1, first released in null3D 0.1.0. The API is experimental, so it can still change between versions. Raycasts, overlap queries and declared render passes take layer masks too. See [Raycasting and spatial queries](../api/raycast.md) and [Custom passes and render targets](../guides/custom-passes.md).
12
12
 
13
13
  ```mermaid
14
14
  flowchart LR
@@ -21,7 +21,7 @@ flowchart LR
21
21
 
22
22
  A layer mask is a 32-bit number. Bit n puts an object on layer n, so the mask `1 << 2` is layer 2, and `0b101` is layers 0 and 2. Every object, every instance batch and every camera has a mask. A camera draws an object only when their masks share at least one bit.
23
23
 
24
- New objects, batches and cameras are on layer 0 alone, with the mask 1, as in three.js. Every camera draws every object until you change a mask.
24
+ New objects, batches and cameras are on layer 0 alone, with the mask 1. Every camera draws every object until you change a mask.
25
25
 
26
26
  ## Setting layers
27
27
 
@@ -62,7 +62,7 @@ export default defineSketch(({ scene, geometry, materials, input }) => {
62
62
  - The `layers` option sets the mask when you create an object, a batch or a camera. `createMesh`, `createGroup`, `createPerspectiveCamera`, `createInstances` and the calls that create lights all take it.
63
63
  - `obj.setLayers(mask)` changes an object's layers, and `batch.setLayers(mask)` changes the layers of every row of a batch.
64
64
  - `camera.setLayers(mask)` changes the layers that the camera draws.
65
- - A mask of 0 puts an object on no layer, so no camera draws it.
65
+ - A mask of 0 puts an object on no layer, so no camera draws it. A mask of `0xffffffff` puts it on all 32 layers.
66
66
  - In development builds, a mask that is not a whole number of 32 bits throws E1207. Negative numbers down to `-(2 ** 31)` work too, so `1 << 31`, which JavaScript makes negative, is layer 31.
67
67
 
68
68
  ## Layers and visibility
@@ -102,20 +102,6 @@ The engine tests each mask while it culls the scene, beside the test against the
102
102
 
103
103
  A new mask rebuilds none of the engine's tables of what it draws. On WebGPU it rewrites one number for an object, or one number per row for a batch.
104
104
 
105
- ## Coming from three.js
106
-
107
- | three.js | null3D |
108
- | --- | --- |
109
- | `object.layers.set(n)` | `obj.setLayers(1 << n)` |
110
- | `object.layers.enable(n)` and `disable(n)` | Keep the mask in your code, change its bits, and pass it to `setLayers` |
111
- | `object.layers.enableAll()` | `obj.setLayers(0xffffffff)` |
112
- | `camera.layers.set(n)` | `camera.setLayers(1 << n)` |
113
- | `instancedMesh.layers` | `batch.setLayers(mask)`, for every row |
114
-
115
- The rule is the same as three.js's: an object draws when its mask and the camera's share a bit. Lights follow the rule too: a light lights the camera's view only when its mask and the camera's share a bit.
116
-
117
- Shadows differ. three.js tests each caster against the camera's mask, so every object that the camera draws casts. null3D tests each caster against the light's mask. In a port that puts objects on extra layers, give each light that casts shadows those layers too, as [Layers and shadows](#layers-and-shadows) shows.
118
-
119
105
  ## Related pages
120
106
 
121
107
  - [Objects and transforms](../api/objects.md): `setLayers` and the other object calls.