@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.
- package/README.md +109 -0
- package/THIRD-PARTY-NOTICES.txt +0 -1
- package/dist/wasm/single/null3d.js +25 -10
- package/dist/wasm/single/null3d_bg.wasm +0 -0
- package/dist/wasm/threaded/null3d.js +25 -10
- package/dist/wasm/threaded/null3d_bg.wasm +0 -0
- package/docs/api/animation.md +114 -86
- package/docs/api/assets.md +135 -49
- package/docs/api/cameras.md +45 -12
- package/docs/api/controls.md +88 -62
- package/docs/api/debug.md +116 -41
- package/docs/api/engine.md +117 -35
- package/docs/api/feature-draws.md +23 -17
- package/docs/api/feature-effects.md +11 -11
- package/docs/api/feature-instances.md +70 -19
- package/docs/api/features.md +77 -47
- package/docs/api/geometry.md +132 -82
- package/docs/api/grass.md +55 -13
- package/docs/api/impostors.md +175 -22
- package/docs/api/input.md +24 -18
- package/docs/api/lights.md +78 -51
- package/docs/api/lines.md +41 -33
- package/docs/api/materials.md +248 -121
- package/docs/api/math.md +12 -13
- package/docs/api/objects.md +47 -22
- package/docs/api/page.md +58 -7
- package/docs/api/particles.md +33 -20
- package/docs/api/points.md +19 -31
- package/docs/api/post.md +75 -42
- package/docs/api/quality.md +42 -17
- package/docs/api/raycast.md +65 -51
- package/docs/api/reference/animation.md +10 -11
- package/docs/api/reference/assets.md +25 -22
- package/docs/api/reference/cameras.md +8 -4
- package/docs/api/reference/controls.md +134 -25
- package/docs/api/reference/debug.md +81 -14
- package/docs/api/reference/engine.md +58 -17
- package/docs/api/reference/feature-draws.md +3 -4
- package/docs/api/reference/feature-effects.md +2 -3
- package/docs/api/reference/feature-instances.md +5 -4
- package/docs/api/reference/features.md +7 -4
- package/docs/api/reference/geometry.md +287 -97
- package/docs/api/reference/grass.md +63 -3
- package/docs/api/reference/impostors.md +208 -13
- package/docs/api/reference/input.md +4 -5
- package/docs/api/reference/lights.md +13 -12
- package/docs/api/reference/lines.md +10 -11
- package/docs/api/reference/materials.md +54 -53
- package/docs/api/reference/math.md +35 -24
- package/docs/api/reference/objects.md +11 -12
- package/docs/api/reference/particles.md +31 -6
- package/docs/api/reference/points.md +6 -7
- package/docs/api/reference/post.md +21 -20
- package/docs/api/reference/quality.md +8 -5
- package/docs/api/reference/raycast.md +7 -8
- package/docs/api/reference/render.md +5 -4
- package/docs/api/reference/scene.md +52 -30
- package/docs/api/reference/sketch.md +15 -11
- package/docs/api/reference/sound.md +234 -0
- package/docs/api/reference/splats.md +42 -3
- package/docs/api/reference/sprites.md +7 -8
- package/docs/api/reference/tasks.md +16 -3
- package/docs/api/reference/terrain.md +27 -5
- package/docs/api/reference/textures.md +5 -6
- package/docs/api/reference/three-compat.md +18 -7
- package/docs/api/reference/time.md +1 -2
- package/docs/api/reference/ui.md +12 -9
- package/docs/api/reference/vertex-draws.md +5 -6
- package/docs/api/reference/water.md +153 -9
- package/docs/api/reference/wind.md +17 -4
- package/docs/api/render.md +73 -29
- package/docs/api/scene.md +164 -60
- package/docs/api/sketch.md +102 -15
- package/docs/api/sound.md +205 -0
- package/docs/api/splats.md +46 -12
- package/docs/api/sprites.md +10 -24
- package/docs/api/tasks.md +33 -24
- package/docs/api/terrain.md +42 -22
- package/docs/api/textures.md +68 -19
- package/docs/api/three-compat.md +15 -7
- package/docs/api/time.md +3 -5
- package/docs/api/ui.md +19 -23
- package/docs/api/vertex-draws.md +13 -12
- package/docs/api/water.md +262 -35
- package/docs/api/wind.md +63 -17
- package/docs/cli/null3d.md +177 -27
- package/docs/concepts/architecture.md +73 -27
- package/docs/concepts/assets.md +57 -33
- package/docs/concepts/backends.md +69 -27
- package/docs/concepts/color-management.md +54 -36
- package/docs/concepts/culling.md +68 -47
- package/docs/concepts/handles.md +14 -5
- package/docs/concepts/instances.md +74 -25
- package/docs/concepts/large-worlds.md +18 -8
- package/docs/concepts/lighting.md +155 -87
- package/docs/concepts/lod.md +126 -44
- package/docs/concepts/materials.md +58 -27
- package/docs/concepts/particle-buffer.md +48 -35
- package/docs/concepts/post-processing.md +84 -43
- package/docs/concepts/quality-preset-tables.md +56 -52
- package/docs/concepts/quality-presets.md +164 -52
- package/docs/concepts/render-graph.md +69 -29
- package/docs/concepts/render-layers.md +11 -21
- package/docs/concepts/shadows.md +105 -52
- package/docs/concepts/static-dynamic.md +22 -7
- package/docs/cookbook/index.md +164 -120
- package/docs/data/threejs-mapping.json +362 -367
- package/docs/errors/E1101.md +23 -5
- package/docs/errors/E1102.md +11 -3
- package/docs/errors/E1103.md +11 -3
- package/docs/errors/E1104.md +11 -3
- package/docs/errors/E1105.md +13 -5
- package/docs/errors/E1106.md +11 -3
- package/docs/errors/E1107.md +15 -5
- package/docs/errors/E1108.md +11 -3
- package/docs/errors/E1109.md +32 -6
- package/docs/errors/E1110.md +23 -5
- package/docs/errors/E1111.md +11 -3
- package/docs/errors/E1112.md +11 -3
- package/docs/errors/E1203.md +12 -4
- package/docs/errors/E1204.md +11 -3
- package/docs/errors/E1205.md +11 -3
- package/docs/errors/E1206.md +28 -6
- package/docs/errors/E1207.md +11 -3
- package/docs/errors/E1208.md +12 -3
- package/docs/errors/E1209.md +11 -3
- package/docs/errors/E1213.md +27 -5
- package/docs/errors/E1214.md +14 -6
- package/docs/errors/E1215.md +31 -6
- package/docs/errors/E1216.md +31 -6
- package/docs/errors/E1217.md +29 -6
- package/docs/errors/E1218.md +22 -6
- package/docs/errors/E1219.md +11 -3
- package/docs/errors/E1220.md +24 -5
- package/docs/errors/E1221.md +24 -5
- package/docs/errors/E1222.md +11 -3
- package/docs/errors/E1223.md +39 -6
- package/docs/errors/E1224.md +11 -3
- package/docs/errors/E1225.md +11 -3
- package/docs/errors/E1301.md +11 -3
- package/docs/errors/E1302.md +11 -3
- package/docs/errors/E1303.md +11 -3
- package/docs/errors/E1304.md +11 -3
- package/docs/errors/E1305.md +13 -3
- package/docs/errors/E1306.md +11 -3
- package/docs/errors/E1307.md +40 -0
- package/docs/errors/E1401.md +11 -3
- package/docs/errors/E1402.md +13 -5
- package/docs/errors/E1403.md +11 -3
- package/docs/errors/E1404.md +13 -3
- package/docs/errors/E1405.md +15 -4
- package/docs/errors/E1406.md +31 -5
- package/docs/errors/E1407.md +11 -3
- package/docs/errors/E1408.md +11 -3
- package/docs/errors/E1409.md +11 -3
- package/docs/errors/E1410.md +13 -5
- package/docs/errors/E1411.md +11 -3
- package/docs/errors/E1412.md +29 -6
- package/docs/errors/E1413.md +11 -3
- package/docs/errors/E1414.md +11 -3
- package/docs/errors/E1415.md +11 -3
- package/docs/errors/E1416.md +27 -6
- package/docs/errors/E1417.md +11 -3
- package/docs/errors/E1418.md +12 -3
- package/docs/errors/E1419.md +13 -5
- package/docs/errors/E1420.md +14 -6
- package/docs/errors/E1421.md +11 -3
- package/docs/errors/E1422.md +12 -3
- package/docs/errors/E1423.md +12 -3
- package/docs/errors/E1424.md +24 -5
- package/docs/errors/E1425.md +11 -3
- package/docs/errors/E1426.md +11 -3
- package/docs/errors/E1430.md +11 -3
- package/docs/errors/E1431.md +11 -3
- package/docs/errors/E1432.md +11 -3
- package/docs/errors/E1433.md +11 -3
- package/docs/errors/E1434.md +15 -6
- package/docs/errors/E1435.md +11 -3
- package/docs/errors/E1436.md +11 -3
- package/docs/errors/E1437.md +14 -6
- package/docs/errors/E1501.md +41 -6
- package/docs/errors/E1502.md +13 -3
- package/docs/errors/E1503.md +11 -3
- package/docs/errors/E1504.md +11 -3
- package/docs/errors/E1505.md +23 -5
- package/docs/errors/E1506.md +11 -3
- package/docs/errors/index.md +54 -30
- package/docs/getting-started/cdn.md +32 -10
- package/docs/getting-started/first-scene.md +21 -13
- package/docs/getting-started/hosting.md +152 -63
- package/docs/getting-started/install.md +44 -28
- package/docs/getting-started/network-use.md +33 -15
- package/docs/getting-started/project-structure.md +33 -12
- package/docs/getting-started/third-party-notices.md +12 -14
- package/docs/guides/accessibility.md +5 -5
- package/docs/guides/add-ons.md +86 -15
- package/docs/guides/agents.md +16 -9
- package/docs/guides/assets-pipeline.md +259 -82
- package/docs/guides/audio.md +115 -128
- package/docs/guides/baked-light-data.md +44 -23
- package/docs/guides/car-paint.md +38 -32
- package/docs/guides/content-pages.md +63 -35
- package/docs/guides/custom-passes.md +65 -22
- package/docs/guides/custom-shaders.md +59 -39
- package/docs/guides/debugging.md +74 -10
- package/docs/guides/deploying.md +85 -6
- package/docs/guides/deterministic-simulation.md +24 -17
- package/docs/guides/first-use-shaders.md +83 -45
- package/docs/guides/lens-kit.md +29 -26
- package/docs/guides/loading-screens.md +132 -47
- package/docs/guides/multiple-views.md +63 -13
- package/docs/guides/performance.md +192 -38
- package/docs/guides/phones.md +78 -15
- package/docs/guides/physics.md +7 -11
- package/docs/guides/screens.md +47 -33
- package/docs/guides/start-time.md +363 -0
- package/docs/guides/testing.md +152 -95
- package/docs/guides/ui-overlays.md +19 -14
- package/docs/guides/video-textures.md +14 -13
- package/docs/images/api/animation/character.webp +0 -0
- package/docs/images/api/animation/look-at-ring.webp +0 -0
- package/docs/images/api/animation/morph-tulips.webp +0 -0
- package/docs/images/api/animation/skeleton-lines.webp +0 -0
- package/docs/images/api/controls/gizmo-handles.webp +0 -0
- package/docs/images/api/controls/walk-and-fly.webp +0 -0
- package/docs/images/api/debug/debug-shapes.webp +0 -0
- package/docs/images/api/debug/levels-view.webp +0 -0
- package/docs/images/api/engine/transparent-canvas.webp +0 -0
- package/docs/images/api/feature-draws/feature-draw-clouds.webp +0 -0
- package/docs/images/api/feature-instances/compute-instances.webp +0 -0
- package/docs/images/api/feature-instances/instances-shadow.webp +0 -0
- package/docs/images/api/geometry/extra-shapes.webp +0 -0
- package/docs/images/api/geometry/generators.webp +0 -0
- package/docs/images/api/geometry/mesh-arrays.webp +0 -0
- package/docs/images/api/geometry/vertex-updates.webp +0 -0
- package/docs/images/api/grass/grass-grove.webp +0 -0
- package/docs/images/api/grass/grass-presets.webp +0 -0
- package/docs/images/api/grass/grass-shadow.webp +0 -0
- package/docs/images/api/impostors/impostor-handover.webp +0 -0
- package/docs/images/api/impostors/impostor-shadow.webp +0 -0
- package/docs/images/api/impostors/impostors-forest.webp +0 -0
- package/docs/images/api/lights/spot-cookies.webp +0 -0
- package/docs/images/api/lines/lines-lit.webp +0 -0
- package/docs/images/api/lines/lines-widths.webp +0 -0
- package/docs/images/api/materials/coat-and-sheen.webp +0 -0
- package/docs/images/api/materials/decals.webp +0 -0
- package/docs/images/api/materials/iridescence-and-anisotropy.webp +0 -0
- package/docs/images/api/materials/relief.webp +0 -0
- package/docs/images/api/materials/shader-inputs.webp +0 -0
- package/docs/images/api/materials/standard-grid.webp +0 -0
- package/docs/images/api/materials/subsurface.webp +0 -0
- package/docs/images/api/materials/translucency.webp +0 -0
- package/docs/images/api/objects/objects-turntable.webp +0 -0
- package/docs/images/api/particles/campfire.webp +0 -0
- package/docs/images/api/points/galaxy.webp +0 -0
- package/docs/images/api/reference/textures/texture-wrap.webp +0 -0
- package/docs/images/api/render/fullscreen-glow.webp +0 -0
- package/docs/images/api/render/reflection-mirror.webp +0 -0
- package/docs/images/api/render/security-camera.webp +0 -0
- package/docs/images/api/scene/aurora-sky-layer.webp +0 -0
- package/docs/images/api/sound/sound-demo.webp +0 -0
- package/docs/images/api/splats/splats-demo.webp +0 -0
- package/docs/images/api/sprites/sprites-lines.webp +0 -0
- package/docs/images/api/terrain/terrain-demo.webp +0 -0
- package/docs/images/api/textures/canvas-screen.webp +0 -0
- package/docs/images/api/textures/mipmaps.webp +0 -0
- package/docs/images/api/vertex-draws/rain.webp +0 -0
- package/docs/images/api/water/ocean.webp +0 -0
- package/docs/images/api/water/water-demo.webp +0 -0
- package/docs/images/api/water/water-rain.webp +0 -0
- package/docs/images/api/water/waterfall.webp +0 -0
- package/docs/images/concepts/assets/gltf-model.webp +0 -0
- package/docs/images/concepts/color-management/tone-mapped.webp +0 -0
- package/docs/images/concepts/culling/far-from-origin.webp +0 -0
- package/docs/images/concepts/instances/instances.webp +0 -0
- package/docs/images/concepts/instances/per-row-colors.webp +0 -0
- package/docs/images/concepts/large-worlds/large-world.webp +0 -0
- package/docs/images/concepts/lighting/area-lights.webp +0 -0
- package/docs/images/concepts/lighting/atmosphere.webp +0 -0
- package/docs/images/concepts/lighting/environment.webp +0 -0
- package/docs/images/concepts/lighting/light-shafts.webp +0 -0
- package/docs/images/concepts/lighting/reflection-probes.webp +0 -0
- package/docs/images/concepts/lod/forest.webp +0 -0
- package/docs/images/concepts/materials/weighted-transparency.webp +0 -0
- package/docs/images/concepts/post-processing/auto-exposure.webp +0 -0
- package/docs/images/concepts/post-processing/bounce-light.webp +0 -0
- package/docs/images/concepts/post-processing/depth-of-field.webp +0 -0
- package/docs/images/concepts/post-processing/post-effects-alley.webp +0 -0
- package/docs/images/concepts/post-processing/sharpen.webp +0 -0
- package/docs/images/concepts/post-processing/ssr-wet-street.webp +0 -0
- package/docs/images/concepts/render-layers/layers-cottages.webp +0 -0
- package/docs/images/concepts/shadows/hero-shadow.webp +0 -0
- package/docs/images/cookbook/index/picking.webp +0 -0
- package/docs/images/cookbook/index/time-of-day.webp +0 -0
- package/docs/images/errors/E1431/area-lights-no-tables.webp +0 -0
- package/docs/images/guides/custom-passes/reflection-water.webp +0 -0
- package/docs/images/guides/deterministic-simulation/replay-demo.webp +0 -0
- package/docs/images/guides/multiple-views/split-screen.webp +0 -0
- package/docs/images/guides/performance/overdraw-view.webp +0 -0
- package/docs/images/guides/testing/hold-mode-frame.webp +0 -0
- package/docs/images/index/showcase-island.webp +0 -0
- package/docs/images/porting/threejs-shaders/dissolve.webp +0 -0
- package/docs/images/shaders/builtins/builtins.webp +0 -0
- package/docs/images/shaders/surface-functions/custom-surface.webp +0 -0
- package/docs/images/shaders/surface-functions/vertex-offset.webp +0 -0
- package/docs/images/shots.json +2231 -0
- package/docs/index.md +18 -23
- package/docs/moves.json +1 -0
- package/docs/nav.json +300 -0
- package/docs/pages.md +230 -209
- package/docs/porting/react-three-fiber.md +225 -6
- package/docs/porting/threejs-loop-and-threads.md +217 -7
- package/docs/porting/threejs-mapping.md +1249 -233
- package/docs/porting/threejs-materials.md +218 -6
- package/docs/porting/threejs-overview.md +240 -7
- package/docs/porting/threejs-postprocessing.md +4 -8
- package/docs/porting/threejs-shaders.md +301 -6
- package/docs/porting/threejs-unsupported.md +83 -7
- package/docs/porting/verification.md +178 -6
- package/docs/shaders/builtins.md +15 -4
- package/docs/shaders/library.md +72 -45
- package/docs/shaders/surface-functions.md +59 -23
- package/docs/shaders/wgsl-rules.md +12 -5
- package/lib/debug/channel.d.ts +103 -0
- package/lib/debug/channel.js +269 -0
- package/lib/debug/debug.d.ts +11 -9
- package/lib/debug/draw.d.ts +11 -2
- package/lib/debug/draw.js +57 -6
- package/lib/debug/inspector.d.ts +60 -0
- package/lib/debug/inspector.js +475 -0
- package/lib/debug/overlay-look.d.ts +6 -0
- package/lib/debug/overlay-look.js +29 -7
- package/lib/debug/overlay.js +15 -11
- package/lib/debug/stats-options.d.ts +13 -0
- package/lib/debug/stats-panel.d.ts +22 -7
- package/lib/debug/stats-panel.js +80 -13
- package/lib/debug/stats.d.ts +2 -3
- package/lib/errors/codes.d.ts +17 -3
- package/lib/errors/codes.js +117 -105
- package/lib/errors/engine-error.js +25 -10
- package/lib/errors/fixes.d.ts +1 -0
- package/lib/errors/fixes.js +20 -19
- package/lib/generated/core.d.ts +1 -1
- package/lib/generated/core.js +1 -1
- package/lib/gpu/early-builds.d.ts +68 -0
- package/lib/gpu/early-builds.js +158 -0
- package/lib/gpu/pipeline-name.d.ts +6 -0
- package/lib/gpu/pipeline-name.js +23 -0
- package/lib/gpu/variants.d.ts +8 -2
- package/lib/gpu/variants.js +39 -7
- package/lib/gpu/webgl2/backend.d.ts +63 -2
- package/lib/gpu/webgl2/backend.js +226 -8
- package/lib/gpu/webgl2/programs.d.ts +18 -0
- package/lib/gpu/webgl2/programs.js +5 -2
- package/lib/gpu/webgpu/backend.d.ts +89 -2
- package/lib/gpu/webgpu/backend.js +255 -8
- package/lib/gpu/webgpu/pipelines.d.ts +13 -0
- package/lib/gpu/webgpu/pipelines.js +28 -14
- package/lib/index.d.ts +7 -5
- package/lib/index.js +3 -2
- package/lib/math/color.d.ts +5 -5
- package/lib/math/color.js +5 -5
- package/lib/math/mat4.d.ts +6 -12
- package/lib/math/mat4.js +6 -12
- package/lib/math/namespaces/quat.d.ts +3 -3
- package/lib/math/namespaces/quat.js +3 -3
- package/lib/math/quat.d.ts +8 -12
- package/lib/math/quat.js +8 -12
- package/lib/math/random.d.ts +2 -3
- package/lib/math/random.js +2 -3
- package/lib/math/types.d.ts +4 -4
- package/lib/math/vec3.d.ts +3 -6
- package/lib/math/vec3.js +3 -6
- package/lib/page/capabilities.d.ts +8 -8
- package/lib/page/capabilities.js +39 -25
- package/lib/page/check-store.d.ts +14 -2
- package/lib/page/check-store.js +34 -11
- package/lib/page/engine.d.ts +117 -31
- package/lib/page/engine.js +438 -99
- package/lib/page/first-frame.d.ts +16 -0
- package/lib/page/first-frame.js +35 -0
- package/lib/page/frame-stats.d.ts +34 -1
- package/lib/page/frame-stats.js +15 -0
- package/lib/page/label-loop.d.ts +7 -3
- package/lib/page/label-loop.js +26 -14
- package/lib/page/labels.d.ts +3 -3
- package/lib/page/pipeline-store.d.ts +25 -0
- package/lib/page/pipeline-store.js +84 -0
- package/lib/page/start-marker.d.ts +4 -1
- package/lib/page/start-marker.js +5 -2
- package/lib/page/stats-switch.js +2 -0
- package/lib/page/switches.d.ts +38 -6
- package/lib/page/switches.js +29 -5
- package/lib/quality/check.d.ts +24 -3
- package/lib/quality/check.js +21 -7
- package/lib/quality/chooser.d.ts +6 -0
- package/lib/quality/chooser.js +8 -0
- package/lib/quality/governor.d.ts +98 -6
- package/lib/quality/governor.js +250 -20
- package/lib/quality/preset-docs.d.ts +16 -1
- package/lib/quality/preset-docs.js +3 -0
- package/lib/quality/presets.d.ts +84 -7
- package/lib/quality/presets.js +94 -2
- package/lib/render/draw.d.ts +3 -2
- package/lib/render/draw.js +15 -5
- package/lib/render/load-draw.d.ts +7 -5
- package/lib/render/load-draw.js +7 -5
- package/lib/render/loss.d.ts +28 -10
- package/lib/render/loss.js +50 -22
- package/lib/render/recovery.d.ts +20 -0
- package/lib/render/recovery.js +44 -4
- package/lib/render/renderer.d.ts +85 -9
- package/lib/render/renderer.js +181 -42
- package/lib/render/scene-renderer.d.ts +19 -1
- package/lib/render/scene-renderer.js +25 -1
- package/lib/render/webgl2-renderers.js +8 -5
- package/lib/render/webgpu-renderers.js +5 -4
- package/lib/scene/animation.d.ts +28 -32
- package/lib/scene/animation.js +12 -15
- package/lib/scene/assets.d.ts +61 -86
- package/lib/scene/assets.js +103 -236
- package/lib/scene/background.d.ts +14 -18
- package/lib/scene/background.js +5 -2
- package/lib/scene/baked-light.d.ts +2 -2
- package/lib/scene/color.d.ts +3 -3
- package/lib/scene/downloads.d.ts +2 -0
- package/lib/scene/downloads.js +371 -0
- package/lib/scene/environment.d.ts +7 -7
- package/lib/scene/environment.js +1 -1
- package/lib/scene/fake-call-values.js +3 -3
- package/lib/scene/fog.d.ts +11 -4
- package/lib/scene/fog.js +8 -2
- package/lib/scene/frame-cameras.d.ts +35 -4
- package/lib/scene/frame-cameras.js +86 -10
- package/lib/scene/gltf.d.ts +33 -3
- package/lib/scene/gltf.js +78 -49
- package/lib/scene/grading.d.ts +2 -2
- package/lib/scene/grading.js +3 -3
- package/lib/scene/ktx2.d.ts +9 -1
- package/lib/scene/ktx2.js +3 -2
- package/lib/scene/level-rule.d.ts +121 -0
- package/lib/scene/level-rule.js +130 -0
- package/lib/scene/lines.d.ts +13 -17
- package/lib/scene/lines.js +3 -3
- package/lib/scene/lut.d.ts +1 -2
- package/lib/scene/lut.js +1 -2
- package/lib/scene/particles.d.ts +7 -3
- package/lib/scene/particles.js +3 -1
- package/lib/scene/picks.d.ts +2 -2
- package/lib/scene/pointer-events.d.ts +4 -7
- package/lib/scene/post.d.ts +39 -43
- package/lib/scene/post.js +4 -1
- package/lib/scene/prefab.d.ts +7 -8
- package/lib/scene/prefab.js +7 -8
- package/lib/scene/property-animation.d.ts +1 -1
- package/lib/scene/property-animation.js +1 -1
- package/lib/scene/queries.d.ts +7 -13
- package/lib/scene/resources.d.ts +238 -261
- package/lib/scene/resources.js +179 -81
- package/lib/scene/scene.d.ts +167 -120
- package/lib/scene/scene.js +243 -103
- package/lib/scene/serial-loads.d.ts +29 -0
- package/lib/scene/serial-loads.js +68 -0
- package/lib/scene/shader-preloads.d.ts +34 -0
- package/lib/scene/shader-preloads.js +38 -0
- package/lib/scene/sprites.d.ts +14 -17
- package/lib/scene/sprites.js +5 -6
- package/lib/scene/textures.d.ts +11 -12
- package/lib/scene/textures.js +9 -10
- package/lib/scene/time-of-day.d.ts +11 -7
- package/lib/scene/time-of-day.js +11 -8
- package/lib/scene/vertex-draws.d.ts +5 -4
- package/lib/scene/vertex-draws.js +7 -5
- package/lib/shader-artifact.json +1 -0
- package/lib/shared/core.d.ts +5 -0
- package/lib/shared/core.js +1 -0
- package/lib/shared/import-once.d.ts +6 -0
- package/lib/shared/import-once.js +19 -0
- package/lib/shared/labels.d.ts +5 -2
- package/lib/shared/labels.js +5 -2
- package/lib/shared/metrics.d.ts +38 -0
- package/lib/shared/metrics.js +62 -1
- package/lib/shared/permutation-words.d.ts +2 -0
- package/lib/shared/permutation-words.js +8 -0
- package/lib/shared/recording.d.ts +13 -5
- package/lib/shared/recording.js +31 -10
- package/lib/shared/run-task.js +7 -1
- package/lib/shared/sketch-data.d.ts +9 -0
- package/lib/shared/sketch-data.js +57 -0
- package/lib/shared/task-pending.d.ts +12 -0
- package/lib/shared/task-pending.js +61 -1
- package/lib/shared/tasks.js +79 -32
- package/lib/shared/version.d.ts +17 -1
- package/lib/shared/version.js +19 -1
- package/lib/shared/wasm.d.ts +12 -4
- package/lib/shared/wasm.js +50 -27
- package/lib/shared/worker-start.d.ts +7 -0
- package/lib/shared/worker-start.js +27 -0
- package/lib/sketch/define-sketch.d.ts +51 -7
- package/lib/sketch/define-sketch.js +2 -1
- package/lib/sketch/input.d.ts +2 -2
- package/lib/sketch/preset-check.d.ts +20 -6
- package/lib/sketch/preset-check.js +42 -17
- package/lib/sketch/quality.d.ts +69 -11
- package/lib/sketch/quality.js +54 -13
- package/lib/sketch/runner.d.ts +80 -9
- package/lib/sketch/runner.js +390 -52
- package/lib/sketch/ui.d.ts +5 -8
- package/lib/sketch/ui.js +4 -2
- package/lib/stats.d.ts +1 -0
- package/lib/workers/probe-worker.d.ts +5 -0
- package/lib/workers/probe-worker.js +13 -4
- package/lib/workers/protocol.d.ts +71 -13
- package/lib/workers/protocol.js +4 -0
- package/lib/workers/render-worker.js +29 -5
- package/lib/workers/sketch-worker.js +108 -16
- package/package.json +2 -2
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
id: concepts/quality-preset-tables
|
|
3
3
|
title: Quality preset tables
|
|
4
|
-
|
|
5
|
-
since: "0.1"
|
|
4
|
+
generated: true
|
|
6
5
|
summary: "Each preset's starting devices, GPU path caps, check rules and settings."
|
|
7
6
|
---
|
|
8
7
|
|
|
@@ -34,58 +33,63 @@ A memory reading under 4 GB lowers the starting preset by one.
|
|
|
34
33
|
| --- | --- |
|
|
35
34
|
| Target frame rate | The display's refresh rate, at most 60 frames per second unless `targetFps` asks for more |
|
|
36
35
|
| A preset holds its target | At 90% of the target or more |
|
|
36
|
+
| A preset is far below its target | Under 25% of the target: the check lowers it straight to Low |
|
|
37
|
+
| 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
38
|
| Frames drawn before each measurement | 250 ms, and up to 2000 ms more while textures upload |
|
|
38
39
|
| Measurement of each preset | 500 ms |
|
|
39
40
|
|
|
40
41
|
## Settings of each preset
|
|
41
42
|
|
|
42
|
-
| Setting | Low | Medium | High | Ultra | Changes |
|
|
43
|
-
| --- | --- | --- | --- | --- | --- |
|
|
44
|
-
| Pixel ratio cap (`maxPixelRatio`) | 1.5 | 2 | 2 | none | during play |
|
|
45
|
-
| Lowest render scale (`minRenderScale`) | 0.5 | 0.6 | 0.75 | 1 | during play |
|
|
46
|
-
| Highest render scale (`maxRenderScale`) | 1 | 1 | 1 | 1 | during play |
|
|
47
|
-
| Anti-aliasing (`antialias`) | FXAA | MSAA 4x | MSAA 4x | MSAA 4x | at the start |
|
|
48
|
-
| Moment transparency (`momentTransparency`) | no | no | no | no | at the start |
|
|
49
|
-
| Shadow cascades (`shadowCascades`) | 2 | 3 | 3 | 4 | at the start |
|
|
50
|
-
| Shadow map size in texels (`shadowMapSize`) | 1024 | 2048 | 2048 | 4096 | at the start |
|
|
51
|
-
| Shadow filter (`shadowFilter`) | 3 x 3 texels | 5 x 5 texels | 5 x 5 texels | 5 x 5 texels | during play |
|
|
52
|
-
| Far cascade updates (`farCascadeInterval`) | every 4th frame | every 3rd frame | every 2nd frame | every 2nd frame | during play |
|
|
53
|
-
| Far cascades follow moving casters (`followMovingCasters`) | yes | yes | yes | yes | during play |
|
|
54
|
-
| Far-animation updates (`farAnimationInterval`) | every 4th frame | every 4th frame | every 2nd frame | every frame | during play |
|
|
55
|
-
| Blend between shadow cascades (`shadowCascadeBlend`) | 10% of each cascade | 10% of each cascade | 10% of each cascade | 10% of each cascade | during play |
|
|
56
|
-
|
|
|
57
|
-
|
|
|
58
|
-
|
|
|
59
|
-
|
|
|
60
|
-
|
|
|
61
|
-
|
|
|
62
|
-
|
|
|
63
|
-
|
|
|
64
|
-
|
|
|
65
|
-
|
|
|
66
|
-
|
|
|
67
|
-
| Screen-space
|
|
68
|
-
|
|
|
69
|
-
|
|
|
70
|
-
|
|
|
71
|
-
|
|
|
72
|
-
|
|
|
73
|
-
|
|
|
74
|
-
|
|
|
75
|
-
|
|
|
76
|
-
|
|
|
77
|
-
|
|
|
78
|
-
|
|
|
79
|
-
|
|
|
80
|
-
|
|
|
81
|
-
|
|
|
82
|
-
|
|
|
83
|
-
|
|
|
84
|
-
|
|
|
85
|
-
|
|
|
86
|
-
|
|
|
87
|
-
|
|
|
88
|
-
|
|
|
89
|
-
|
|
|
90
|
-
| Texture
|
|
91
|
-
|
|
|
43
|
+
| Setting | Low | Medium | High | Ultra | Changes |
|
|
44
|
+
| --- | --- | --- | --- | --- | --- |
|
|
45
|
+
| Pixel ratio cap (`maxPixelRatio`) | 1.5 | 2 | 2 | none | during play |
|
|
46
|
+
| Lowest render scale (`minRenderScale`) | 0.5 | 0.6 | 0.75 | 1 | during play |
|
|
47
|
+
| Highest render scale (`maxRenderScale`) | 1 | 1 | 1 | 1 | during play |
|
|
48
|
+
| Anti-aliasing (`antialias`) | FXAA | MSAA 4x | MSAA 4x | MSAA 4x | at the start |
|
|
49
|
+
| Moment transparency (`momentTransparency`) | no | no | no | no | at the start |
|
|
50
|
+
| Shadow cascades (`shadowCascades`) | 2 | 3 | 3 | 4 | at the start |
|
|
51
|
+
| Shadow map size in texels (`shadowMapSize`) | 1024 | 2048 | 2048 | 4096 | at the start |
|
|
52
|
+
| Shadow filter (`shadowFilter`) | 3 x 3 texels | 5 x 5 texels | 5 x 5 texels | 5 x 5 texels | during play |
|
|
53
|
+
| Far cascade updates (`farCascadeInterval`) | every 4th frame | every 3rd frame | every 2nd frame | every 2nd frame | during play |
|
|
54
|
+
| Far cascades follow moving casters (`followMovingCasters`) | yes | yes | yes | yes | during play |
|
|
55
|
+
| Far-animation updates (`farAnimationInterval`) | every 4th frame | every 4th frame | every 2nd frame | every frame | during play |
|
|
56
|
+
| Blend between shadow cascades (`shadowCascadeBlend`) | 10% of each cascade | 10% of each cascade | 10% of each cascade | 10% of each cascade | during play |
|
|
57
|
+
| Sun cast shadows (`castShadows`) | yes | yes | yes | yes | during play |
|
|
58
|
+
| Spot and point light shadow tiles (`shadowTiles`) | 4 | 8 | 16 | 24 | at the start |
|
|
59
|
+
| Shadow tile size in texels (`shadowTileSize`) | 512 | 512 | 1024 | 1024 | at the start |
|
|
60
|
+
| Hero shadow tile size in texels (`heroTileSize`) | 1024 | 2048 | 2048 | 4096 | at the start |
|
|
61
|
+
| Point light shadows (`pointLightShadows`) | no | no | yes | yes | at the start |
|
|
62
|
+
| Bloom's largest level in texels on the short side (`bloomSize`) | 64 | 512 | 512 | 512 | during play |
|
|
63
|
+
| Bloom (`bloom`) | yes | yes | yes | yes | during play |
|
|
64
|
+
| Ambient occlusion (`aoScale`) | off | off | half resolution | half resolution | during play |
|
|
65
|
+
| Contact shadows (`contactShadowSteps`) | off | off (WebGL2: 4 steps at half resolution) | 8 steps at half resolution | 16 steps at half resolution | during play |
|
|
66
|
+
| Depth of field (`dofSamples`) | off | 22 taps at half resolution | 43 taps at half resolution | 71 taps at half resolution | during play |
|
|
67
|
+
| Subsurface blur of skin (`subsurfaceSamples`) | off | off | 17 taps each way | 25 taps each way | during play |
|
|
68
|
+
| Screen-space reflections (`ssrScale`) | off | quarter resolution | half resolution | half resolution | during play |
|
|
69
|
+
| Screen-space reflection steps per ray (`ssrSteps`) | 16 | 24 | 48 | 64 | during play |
|
|
70
|
+
| Screen-space bounce light (`bounceRays`) | off | off (WebGL2: 4 rays each way) | 4 rays each way | 8 rays each way | during play |
|
|
71
|
+
| 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 |
|
|
72
|
+
| Volumetric fog (`fogSlices`) | off, sun glow only | 32 slices | 64 slices | 96 slices | during play |
|
|
73
|
+
| Reflection passes (`reflectionScale`) | quarter resolution | half resolution | half resolution | full resolution | during play |
|
|
74
|
+
| Reflection probe maps (`probeSize`) | 128 x 128 | 256 x 256 | 256 x 256 | 256 x 256 | during play |
|
|
75
|
+
| Area lights per frame (`areaLights`) | 4 | 8 | 16 | 32 | during play |
|
|
76
|
+
| Depth-fitted light clusters (WebGPU) (`lightFit`) | no | yes | yes | yes | during play |
|
|
77
|
+
| Level of detail threshold (`lodThreshold`) | 2 px | 1 px | 1 px | 1 px | during play |
|
|
78
|
+
| Level of detail threshold in shadows (`lodShadowThreshold`) | 1 texel | 1 texel | 1 texel | 1 texel | during play |
|
|
79
|
+
| Distance band fades (`lodFade`) | no | yes | yes | yes | during play |
|
|
80
|
+
| Physical sky (`physicalSky`) | the analytic sky stands in | from its tables | from its tables | from its tables | during play |
|
|
81
|
+
| Cloud march steps (`cloudSteps`) | flat layer | flat layer | 32 | 48 | during play |
|
|
82
|
+
| Frame-budget governor (`governor`) | on | on | on | on | during play |
|
|
83
|
+
| Governor raises the level threshold (`governorLevels`) | yes | yes | yes | yes | during play |
|
|
84
|
+
| Depth prepass (`depthPrepass`) | no (WebGL2: yes) | no (WebGL2: yes) | no (WebGL2: yes) | no (WebGL2: yes) | during play |
|
|
85
|
+
| GPU occlusion culling (WebGPU) (`gpuOcclusion`) | no | no | yes | yes | at the start |
|
|
86
|
+
| Morph targets per object on WebGL2 (`morphTargets`) | 8 | 16 | 32 | 64 | at the start |
|
|
87
|
+
| Software occlusion culling (WebGL2) (`softwareOcclusion`) | no | no | no | no | during play |
|
|
88
|
+
| Parallax occlusion mapping (`parallax`) | no | yes | yes | yes | during play |
|
|
89
|
+
| Soft particles (`softParticles`) | no | yes | yes | yes | during play |
|
|
90
|
+
| Anisotropic filtering cap (`maxAnisotropy`) | 2x | 4x | 8x | 16x | during play |
|
|
91
|
+
| Texture uploads per frame (`uploadBytesPerFrame`) | 2 MiB | 4 MiB | 8 MiB | 16 MiB | during play |
|
|
92
|
+
| Texture memory budget (`textureMemoryMiB`) | 256 MiB | 512 MiB | 1024 MiB | 2048 MiB | during play |
|
|
93
|
+
| Engine memory maximum (`memoryMaximumMiB`) | 1024 MiB | 1024 MiB | 1024 MiB | 1024 MiB | before loading |
|
|
94
|
+
|
|
95
|
+
The [Skyway showcase](https://github.com/null3d-engine/null3d/tree/main/examples/showcase/skyway) runs each preset on a real scene. The Island showcase overrides the presets, so it does not show these settings.
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
---
|
|
2
2
|
id: concepts/quality-presets
|
|
3
3
|
title: "Quality presets, dynamic resolution and frame budgets"
|
|
4
|
-
status: experimental
|
|
5
|
-
since: "0.1"
|
|
6
4
|
summary: "Low to Ultra; pixel-ratio caps; the preset check; switching presets; the frame-budget governor; quality events for sketch code."
|
|
7
5
|
---
|
|
8
6
|
|
|
9
7
|
# Quality presets, dynamic resolution and frame budgets
|
|
10
8
|
|
|
11
|
-
>
|
|
9
|
+
> 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.
|
|
10
|
+
>
|
|
11
|
+
> A sketch can switch presets with `quality.setPreset`.
|
|
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 -->
|
|
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" -->
|
|
28
|
+
check -- "yes, or Low" --> governor["The governor starts"]
|
|
28
29
|
play -- "quality.setPreset" --> play
|
|
29
30
|
```
|
|
30
31
|
|
|
@@ -59,7 +60,14 @@ The [starting preset of each device](quality-preset-tables.md#starting-preset-of
|
|
|
59
60
|
|
|
60
61
|
Only Chromium browsers report the device's memory, and they report at most 8 GB. So memory can lower a preset, but it never raises one. The engine picks Ultra only when a page asks for it.
|
|
61
62
|
|
|
62
|
-
A tablet slows down as it heats up,
|
|
63
|
+
A tablet slows down as it heats up, so Medium and High can fall below 60 frames per second after a few minutes. A cool tablet passes the preset check at Medium, so the engine still starts tablets there. Medium and High trade frame rate for sharper shadows and edges. When a steady rate matters more, name Low: `createEngine({ canvas, sketch, preset: 'low' })`.
|
|
64
|
+
|
|
65
|
+
<details>
|
|
66
|
+
<summary>Technical details: an iPad Pro as it heats up</summary>
|
|
67
|
+
|
|
68
|
+
In the S4 benchmark, an 11-inch iPad Pro held 60 frames per second at Medium while cool. The benchmark is [a town of 5,000 still objects and 200 moving vehicles with a shadow-casting sun](../guides/performance.md#phones-and-tablets). After a few minutes it ran at about 45, with the governor at its lowest render scale and every shadow step taken. At Low, the same iPad held 60 frames per second in 298 of 299 seconds after 5 minutes of warm-up.
|
|
69
|
+
|
|
70
|
+
</details>
|
|
63
71
|
|
|
64
72
|
The GPU path then caps the preset, because WebGL2 and WebGPU's compatibility mode lack features that the heavier presets use. For example, compatibility mode cannot draw multisampled float targets.
|
|
65
73
|
|
|
@@ -79,19 +87,33 @@ A name that is not `auto`, `low`, `medium`, `high` or `ultra` fails the start wi
|
|
|
79
87
|
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
88
|
|
|
81
89
|
- 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.
|
|
90
|
+
- 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.
|
|
91
|
+
|
|
92
|
+
This also applies to a preset that the page names, so a device that crashed at the player's choice can start again. A crashed start still lowers a named preset by one, and two in a row still start it at Low. The `?preset=` switch skips the preset check and the lowest-tier entry, not the crash lowering. The page can read the count in `engine.mode.crashedStarts` and tell the player.
|
|
83
93
|
|
|
84
|
-
|
|
94
|
+
When the browser refuses the storage, as in a sandboxed frame, each start counts as a normal one. Hold mode ([Testing your sketch](../guides/testing.md#hold-mode)) and the `?preset=` switch leave the note alone. The note belongs to one sketch module and one origin.
|
|
85
95
|
|
|
86
96
|
## The preset check
|
|
87
97
|
|
|
88
98
|
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
99
|
|
|
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
|
|
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
|
|
94
|
-
|
|
100
|
+
1. The sketch's setup runs at the chosen preset and builds its scene. `createEngine` resolves.
|
|
101
|
+
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.
|
|
102
|
+
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.
|
|
103
|
+
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.
|
|
104
|
+
|
|
105
|
+
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.
|
|
106
|
+
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.
|
|
107
|
+
|
|
108
|
+
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.
|
|
109
|
+
|
|
110
|
+
A page that would rather hide a change of preset behind its loading screen asks for the check before play:
|
|
111
|
+
|
|
112
|
+
```ts
|
|
113
|
+
const engine = await createEngine({ canvas, sketch, presetCheck: 'before-play' });
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
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
117
|
|
|
96
118
|
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
119
|
|
|
@@ -108,11 +130,20 @@ const engine = await createEngine({ canvas, sketch, targetFps: 'display' });
|
|
|
108
130
|
|
|
109
131
|
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
132
|
|
|
111
|
-
The
|
|
133
|
+
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 the Skyway showcase demo drew.
|
|
134
|
+
|
|
135
|
+
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. 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
136
|
|
|
113
137
|
### Repeat visits
|
|
114
138
|
|
|
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
|
|
139
|
+
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`.
|
|
140
|
+
|
|
141
|
+
<details>
|
|
142
|
+
<summary>Technical details: first and repeat visit times</summary>
|
|
143
|
+
|
|
144
|
+
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. The check took about 0.8 seconds on a MacBook Pro.
|
|
145
|
+
|
|
146
|
+
</details>
|
|
116
147
|
|
|
117
148
|
A stored result applies only while the start matches the one that the check measured:
|
|
118
149
|
|
|
@@ -123,12 +154,15 @@ A stored result applies only while the start matches the one that the check meas
|
|
|
123
154
|
|
|
124
155
|
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
156
|
|
|
126
|
-
The
|
|
157
|
+
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
158
|
|
|
128
|
-
|
|
159
|
+
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.
|
|
160
|
+
|
|
161
|
+
`engine.mode.presetCheck` reports what the check measured, once `engine.presetChecked` has resolved:
|
|
129
162
|
|
|
130
163
|
```ts
|
|
131
164
|
const engine = await createEngine({ canvas, sketch });
|
|
165
|
+
await engine.presetChecked;
|
|
132
166
|
const check = engine.mode.presetCheck;
|
|
133
167
|
if (check && check.from !== engine.mode.preset)
|
|
134
168
|
console.log(`${check.from} missed ${check.targetFps} fps; the engine runs ${engine.mode.preset}`);
|
|
@@ -144,28 +178,42 @@ A change of preset can change pipelines and render targets, and building them ta
|
|
|
144
178
|
|
|
145
179
|
## The settings of each preset
|
|
146
180
|
|
|
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.
|
|
181
|
+
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.
|
|
182
|
+
|
|
183
|
+
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.
|
|
184
|
+
|
|
185
|
+
The engine makes its memory while it tests the GPU paths. So the memory maximum follows the starting preset and the crashed starts, and the GPU path does not cap it. The `memory` option of `createEngine` replaces it: [Page API](../api/engine.md#memory).
|
|
148
186
|
|
|
149
|
-
The
|
|
187
|
+
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.
|
|
188
|
+
|
|
189
|
+
### Pixel ratio cap
|
|
150
190
|
|
|
151
191
|
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
192
|
|
|
153
|
-
|
|
193
|
+
### Shadow memory
|
|
194
|
+
|
|
195
|
+
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.
|
|
196
|
+
|
|
197
|
+
| Preset | Shadow map | Shadow atlas | Both | Atlas with a hero |
|
|
198
|
+
| --- | --- | --- | --- | --- |
|
|
199
|
+
| Low | 4 MiB | 4 MiB | 8 MiB | 20 MiB |
|
|
200
|
+
| Medium | 24 MiB | 8 MiB | 32 MiB | 144 MiB |
|
|
201
|
+
| High | 24 MiB | 64 MiB | 88 MiB | 272 MiB |
|
|
202
|
+
| Ultra | 128 MiB | 96 MiB | 224 MiB | 1,536 MiB, refused |
|
|
154
203
|
|
|
155
|
-
|
|
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 |
|
|
204
|
+
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.
|
|
161
205
|
|
|
162
|
-
|
|
206
|
+
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.
|
|
207
|
+
|
|
208
|
+
### Texture filtering and uploads
|
|
163
209
|
|
|
164
210
|
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
211
|
|
|
166
212
|
### Texture memory
|
|
167
213
|
|
|
168
|
-
The texture memory budget caps the GPU memory of the scene's textures. A phone or a tablet closes a tab that uses too much memory, with no warning, so the budget keeps textures well below that point. Each preset's budget stays under half the lowest point that the engine's tab memory test measured on the devices that the preset serves.
|
|
214
|
+
The texture memory budget caps the GPU memory of the scene's textures. A phone or a tablet closes a tab that uses too much memory, with no warning, so the budget keeps textures well below that point. Each preset's budget stays under half the lowest point that the engine's tab memory test measured on the devices that the preset serves.
|
|
215
|
+
|
|
216
|
+
Phones and tablets take at most 1,008 MiB on any preset: half the 2,016 MiB at which an iPad Pro's tab closed. The page's `textureMemoryMiB` option replaces the preset's budget and the cap, and `quality.set({ textureMemoryMiB })` changes it during play.
|
|
169
217
|
|
|
170
218
|
```mermaid
|
|
171
219
|
flowchart LR
|
|
@@ -185,27 +233,55 @@ A texture loses at most 3 levels, so a texture of 1024 x 1024 texels keeps at le
|
|
|
185
233
|
|
|
186
234
|
When room returns, 5% under the budget, the engine loads the dropped levels again from the texture's file. The browser's cache usually holds the file. The texture draws with the levels it has until the new ones are on the GPU. The band of 5% on either side keeps the engine from dropping and loading the same levels in turn. The sketch reads the memory and the dropped levels in `quality.textureMemory`: [Quality API](../api/quality.md#texture-memory).
|
|
187
235
|
|
|
188
|
-
|
|
236
|
+
### Anti-aliasing
|
|
189
237
|
|
|
190
|
-
|
|
238
|
+
Low smooths edges with FXAA, and the other presets with MSAA. MSAA draws 4 samples per pixel, which costs a phone's GPU memory and bandwidth. FXAA draws one sample and smooths edges in the final pass, at a small cost in sharpness.
|
|
239
|
+
|
|
240
|
+
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. 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)).
|
|
241
|
+
|
|
242
|
+
A sketch's own preset change never moves it. [GPU tiers and backends](backends.md#color-and-anti-aliasing-on-each-tier) compares the modes.
|
|
191
243
|
|
|
192
244
|
### Moment transparency
|
|
193
245
|
|
|
194
|
-
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.
|
|
246
|
+
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. The [Island showcase](https://github.com/null3d-engine/null3d/tree/main/examples/showcase/island) starts the engine with the layer on.
|
|
247
|
+
|
|
248
|
+
The layer costs memory and GPU time. On the Island showcase at High at 1920 x 1080, GPU textures grew by 40 MiB on WebGPU and by 52 MiB on WebGL2. In the [S1 benchmark](../guides/performance.md) at High, on a MacBook Pro in Chrome, it added about 0.6 ms of GPU time a frame on WebGPU. On WebGL2 it added about 1.1 ms. It adds almost no processor time. A desktop GPU's fill rate is not a phone's, so measure on the phone.
|
|
249
|
+
|
|
250
|
+
<details>
|
|
251
|
+
<summary>Technical details: the moment layer's memory</summary>
|
|
195
252
|
|
|
196
|
-
The layer's moment store and color sum take 8 bytes per pixel each at the render size
|
|
253
|
+
The layer's moment store and color sum take 8 bytes per pixel each at the render size. Its surfaces write both, which is 16 bytes per pixel a frame, or 33 MB at 1920 x 1080.
|
|
197
254
|
|
|
198
|
-
|
|
255
|
+
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.
|
|
256
|
+
|
|
257
|
+
The 33 MB counts the writes alone, and the memory is larger. 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.
|
|
258
|
+
|
|
259
|
+
</details>
|
|
199
260
|
|
|
200
261
|
### The depth prepass
|
|
201
262
|
|
|
202
|
-
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.
|
|
263
|
+
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.
|
|
264
|
+
|
|
265
|
+
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.
|
|
266
|
+
|
|
267
|
+
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.
|
|
268
|
+
|
|
269
|
+
On WebGL2, every preset turns the prepass on, except on the [lowest quality tier](#the-lowest-quality-tier). On WebGPU and in its compatibility mode, every preset leaves it off. The preset table shows this default. Ambient occlusion, [contact shadows](shadows.md#contact-shadows), screen-space bounce light and screen-space reflections read the prepass's depth. So they draw the prepass while they run, whatever the preset or the option says. Bounce light runs on High and Ultra on WebGPU outside compatibility mode, so those presets draw the prepass there.
|
|
270
|
+
|
|
271
|
+
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`, and `quality.set({ depthPrepass })` changes it during play.
|
|
272
|
+
|
|
273
|
+
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.
|
|
203
274
|
|
|
204
|
-
|
|
275
|
+
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.
|
|
205
276
|
|
|
206
|
-
|
|
277
|
+
Both GPU paths draw the prepass, and it gives the same image as a frame without it. The opaque pass shades a pixel only where its depth equals the prepass's depth exactly.
|
|
207
278
|
|
|
208
|
-
|
|
279
|
+
<details>
|
|
280
|
+
<summary>Technical details: why both passes compute the same depth</summary>
|
|
281
|
+
|
|
282
|
+
So both passes must compute each vertex's depth to the last bit. On WebGPU, the prepass uses a shader that computes positions only. Custom materials and sprites place their vertices in their own way, so there they draw with their own vertex shader. On WebGL2, every object draws with the vertex shader of its own material. A fragment shader that writes nothing completes each such program. On WebGL2, two separate shader programs can compute slightly different depths for one triangle, and a surface would then vanish from the frame.
|
|
283
|
+
|
|
284
|
+
</details>
|
|
209
285
|
|
|
210
286
|
One case differs: two opaque surfaces at exactly the same depth. Without the prepass, the surface drawn first shows. With it, both pass the test for equal depth, so the surface drawn last shows. The engine chooses its own draw order, so an exact tie has no defined winner. The winner may also differ between GPU paths, as WebGL2 draws the prepass by default and WebGPU does not. Give overlapping surfaces, such as decals and ground markings, a depth bias, or move one a little, so one is nearer.
|
|
211
287
|
|
|
@@ -218,7 +294,9 @@ const plain = await createEngine({ canvas, sketch, depthPrepass: false });
|
|
|
218
294
|
|
|
219
295
|
### GPU occlusion culling
|
|
220
296
|
|
|
221
|
-
With GPU occlusion culling, each camera skips the opaque objects that others hide. It draws the depth of the large opaque objects that showed in its last frame, and builds a depth pyramid from it. Then it draws only the objects that show. [Culling](culling.md#gpu-occlusion-culling-on-webgpu) describes the two phases.
|
|
297
|
+
With GPU occlusion culling, each camera skips the opaque objects that others hide. It draws the depth of the large opaque objects that showed in its last frame, and builds a depth pyramid from it. Then it draws only the objects that show. [Culling](culling.md#gpu-occlusion-culling-on-webgpu) describes the two phases.
|
|
298
|
+
|
|
299
|
+
High and Ultra turn it on for desktops. Phones and tablets keep it off on every preset. A check during play turns its passes off while they hide too little or make the GPU's frame longer, so a scene where they do not pay loses almost nothing.
|
|
222
300
|
|
|
223
301
|
The `gpuOcclusion` option of `createEngine` replaces the preset's choice, and `?occlusion=on` or `?occlusion=off` wins over the option, to compare the scene's GPU time. It is fixed while the engine runs. It runs only on WebGPU, so `quality.settings.gpuOcclusion` is false on WebGL2. It runs beside the depth prepass, which ambient occlusion and screen-space bounce light turn on.
|
|
224
302
|
|
|
@@ -238,14 +316,26 @@ The engine can draw the scene at a render scale below the canvas's size. Its fin
|
|
|
238
316
|
During play, the engine moves the scale between the `minRenderScale` and `maxRenderScale` settings:
|
|
239
317
|
|
|
240
318
|
- 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
|
-
- 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.
|
|
242
|
-
-
|
|
243
|
-
-
|
|
244
|
-
- 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
|
-
- Frames at 57 to 59 frames per second hold the target but have no time to spare, so the scale stays where it is.
|
|
246
|
-
- A rise is on trial for 30 seconds. If the scale drops back within that time, the next rise to that scale waits twice as long, up to 80 seconds. Each scale keeps its own wait, so a rise to a scale that has not failed still comes after 5 seconds. A phone that heats up can hold a higher scale for a few seconds and then fall behind. So the scale settles below the point where frames fall behind.
|
|
319
|
+
- 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. 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.
|
|
320
|
+
- 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.
|
|
321
|
+
- 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.
|
|
247
322
|
- It takes no step in the first 2 seconds of play, or while textures wait to upload. It starts to judge the frames again after a pause.
|
|
248
323
|
|
|
324
|
+
<details>
|
|
325
|
+
<summary>Technical details: how the controller judges frames and trials a rise</summary>
|
|
326
|
+
|
|
327
|
+
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.
|
|
328
|
+
|
|
329
|
+
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. In Safari, some frames wait an extra callback even at the full rate.
|
|
330
|
+
|
|
331
|
+
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.
|
|
332
|
+
|
|
333
|
+
Frames at 57 to 59 frames per second hold the target but have no time to spare, so the scale stays where it is.
|
|
334
|
+
|
|
335
|
+
A rise is on trial for 30 seconds. If the scale drops back within that time, the next rise to that scale waits twice as long, up to 80 seconds. Each scale keeps its own wait, so a rise to a scale that has not failed still comes after 5 seconds. A phone that heats up can hold a higher scale for a few seconds and then fall behind. So the scale settles below the point where frames fall behind.
|
|
336
|
+
|
|
337
|
+
</details>
|
|
338
|
+
|
|
249
339
|
The scene's render targets keep the canvas's size at every scale, and the scene draws into their top-left corner. So a new scale makes no GPU object and allocates no memory. `engine.measure()` counts the GPU objects that the engine made, in `gpuObjects`.
|
|
250
340
|
|
|
251
341
|
A sketch reads the scale in `quality.renderScale`, and changes the range with `quality.set`:
|
|
@@ -267,16 +357,22 @@ export default defineSketch(({ quality, page }) => {
|
|
|
267
357
|
});
|
|
268
358
|
```
|
|
269
359
|
|
|
270
|
-
A `minRenderScale` of 1 keeps the whole canvas. Hold mode draws at `maxRenderScale`, so tests draw the same image on every run.
|
|
360
|
+
A `minRenderScale` of 1 keeps the whole canvas. Hold mode draws at `maxRenderScale`, so tests draw the same image on every run. Below a scale of 1, the final pass runs in two steps. [The post-processing chain](post-processing.md#below-the-whole-canvass-render-scale) gives both steps, the effect of `sharpen` and the two costs that a lowest scale of 1 avoids.
|
|
361
|
+
|
|
362
|
+
<details>
|
|
363
|
+
<summary>Technical details: the 8-bit GPU paths</summary>
|
|
364
|
+
|
|
365
|
+
Some GPU paths draw the scene's color in 8 bits: WebGPU's compatibility mode, and WebGL2 devices that cannot draw multisampled float targets. There, with MSAA, a lowest scale below 1 adds the final pass, which copies the image to the canvas. At a lowest scale of 1, the scene's render pass writes straight to the canvas.
|
|
366
|
+
|
|
367
|
+
</details>
|
|
271
368
|
|
|
272
369
|
## The frame-budget governor
|
|
273
370
|
|
|
274
371
|
```mermaid
|
|
275
372
|
flowchart LR
|
|
276
|
-
over["1 s over budget"] -->
|
|
277
|
-
|
|
278
|
-
detail -- "still over budget" -->
|
|
279
|
-
far -- "still over budget" --> filter["4. Shadow filter: 3 x 3 texels"]
|
|
373
|
+
over["1 s over budget"] --> budgets["Sketch budgets: 0.25 lower, and<br/>render scale: 0.05 lower, in turn,<br/>down to minRenderScale"]
|
|
374
|
+
budgets -- "still over budget" --> detail["Detail, shadow and effect steps,<br/>in the order below"]
|
|
375
|
+
detail -- "still over budget" --> effects["Then bloom, ambient occlusion,<br/>reflections, contact shadows,<br/>far animation and fog, one step each"]
|
|
280
376
|
room["5 s with time to spare"] --> back["One step back up,<br/>in the reverse order"]
|
|
281
377
|
```
|
|
282
378
|
|
|
@@ -293,15 +389,31 @@ Dynamic resolution is the first part of the frame-budget governor. A sketch can
|
|
|
293
389
|
9. Far characters update their poses half as often, up to every 4th frame. Each step doubles the interval, so the step happens only while the `farAnimationInterval` setting is below 4. A sketch reads `quality.governor.farAnimationInterval` to give it to its far characters ([Animation](../api/animation.md#crowds)).
|
|
294
390
|
10. The volumetric fog draws half the slices of its grid, into the same textures, so its rays turn a little coarser along the view and no texture is made. This step happens only while the volumetric fog draws.
|
|
295
391
|
|
|
296
|
-
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.
|
|
392
|
+
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.
|
|
393
|
+
|
|
394
|
+
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
395
|
|
|
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,
|
|
396
|
+
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
397
|
|
|
300
398
|
`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
399
|
|
|
400
|
+
### The lowest quality tier
|
|
401
|
+
|
|
402
|
+
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 for 5 seconds and frames still miss the target. Its cuts are a render scale floor of one third of the canvas's width and height, no sun shadows, and no bloom. Reflection passes draw at a quarter of the render size. On WebGL2 it also turns the depth prepass off.
|
|
403
|
+
|
|
404
|
+
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.
|
|
405
|
+
|
|
406
|
+
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 time to spare for as long as a step up waits. That is 5 seconds at first, and longer after failed step ups. It then waits 5 seconds before the tier can enter again, so a device cannot flap.
|
|
407
|
+
|
|
408
|
+
`?tier=lowest` starts a page in the tier, for tests, devices and a known weak class. A page that starts in the tier also caps the render scale at one third, so it draws at that scale from the first frame. The governor stays the default path to the tier.
|
|
409
|
+
|
|
410
|
+
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. The [Island showcase](https://github.com/null3d-engine/null3d/tree/main/examples/showcase/island) opts out this way.
|
|
411
|
+
|
|
302
412
|
### Settings of an add-on's feature
|
|
303
413
|
|
|
304
|
-
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.
|
|
414
|
+
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.
|
|
415
|
+
|
|
416
|
+
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.
|
|
305
417
|
|
|
306
418
|
## Related pages
|
|
307
419
|
|