@null3d/engine 0.1.0 → 0.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/wasm/single/null3d.js +10 -8
- package/dist/wasm/single/null3d_bg.wasm +0 -0
- package/dist/wasm/threaded/null3d.js +10 -8
- package/dist/wasm/threaded/null3d_bg.wasm +0 -0
- package/docs/api/animation.md +96 -24
- package/docs/api/assets.md +99 -29
- package/docs/api/cameras.md +38 -7
- package/docs/api/controls.md +47 -23
- package/docs/api/debug.md +105 -35
- package/docs/api/engine.md +108 -32
- package/docs/api/feature-draws.md +21 -15
- package/docs/api/feature-effects.md +8 -8
- package/docs/api/feature-instances.md +68 -17
- package/docs/api/features.md +68 -37
- package/docs/api/geometry.md +83 -14
- package/docs/api/grass.md +55 -13
- package/docs/api/impostors.md +92 -50
- package/docs/api/input.md +22 -9
- package/docs/api/lights.md +67 -16
- package/docs/api/lines.md +38 -13
- package/docs/api/materials.md +187 -59
- package/docs/api/math.md +6 -6
- package/docs/api/objects.md +40 -15
- package/docs/api/page.md +58 -7
- package/docs/api/particles.md +36 -11
- package/docs/api/points.md +18 -8
- package/docs/api/post.md +57 -23
- package/docs/api/quality.md +36 -16
- package/docs/api/raycast.md +57 -24
- package/docs/api/reference/animation.md +1 -2
- package/docs/api/reference/assets.md +7 -4
- package/docs/api/reference/cameras.md +3 -2
- package/docs/api/reference/controls.md +59 -2
- package/docs/api/reference/debug.md +58 -6
- package/docs/api/reference/engine.md +40 -10
- 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 +132 -21
- package/docs/api/reference/grass.md +62 -2
- package/docs/api/reference/impostors.md +120 -16
- package/docs/api/reference/input.md +1 -2
- package/docs/api/reference/lights.md +4 -3
- package/docs/api/reference/lines.md +3 -4
- package/docs/api/reference/materials.md +7 -6
- package/docs/api/reference/math.md +13 -2
- package/docs/api/reference/objects.md +2 -3
- package/docs/api/reference/particles.md +31 -6
- package/docs/api/reference/points.md +2 -3
- package/docs/api/reference/post.md +4 -3
- package/docs/api/reference/quality.md +1 -2
- package/docs/api/reference/raycast.md +1 -2
- package/docs/api/reference/render.md +4 -3
- package/docs/api/reference/scene.md +24 -5
- package/docs/api/reference/sketch.md +11 -11
- package/docs/api/reference/sound.md +33 -2
- package/docs/api/reference/splats.md +42 -3
- package/docs/api/reference/sprites.md +2 -3
- package/docs/api/reference/tasks.md +16 -3
- package/docs/api/reference/terrain.md +26 -5
- package/docs/api/reference/textures.md +1 -2
- package/docs/api/reference/three-compat.md +18 -7
- package/docs/api/reference/time.md +1 -2
- package/docs/api/reference/ui.md +10 -7
- package/docs/api/reference/vertex-draws.md +2 -3
- package/docs/api/reference/water.md +78 -5
- package/docs/api/reference/wind.md +15 -2
- package/docs/api/render.md +67 -25
- package/docs/api/scene.md +129 -36
- package/docs/api/sketch.md +45 -19
- package/docs/api/sound.md +48 -12
- package/docs/api/splats.md +42 -15
- package/docs/api/sprites.md +8 -6
- package/docs/api/tasks.md +31 -22
- package/docs/api/terrain.md +44 -12
- package/docs/api/textures.md +61 -12
- package/docs/api/three-compat.md +15 -7
- package/docs/api/time.md +3 -5
- package/docs/api/ui.md +18 -10
- package/docs/api/vertex-draws.md +13 -12
- package/docs/api/water.md +111 -67
- package/docs/api/wind.md +61 -15
- package/docs/cli/null3d.md +90 -15
- package/docs/concepts/architecture.md +69 -23
- package/docs/concepts/assets.md +57 -16
- package/docs/concepts/backends.md +68 -24
- package/docs/concepts/color-management.md +42 -13
- package/docs/concepts/culling.md +68 -47
- package/docs/concepts/handles.md +14 -5
- package/docs/concepts/instances.md +72 -23
- package/docs/concepts/large-worlds.md +17 -7
- package/docs/concepts/lighting.md +117 -44
- package/docs/concepts/lod.md +128 -33
- package/docs/concepts/materials.md +43 -12
- package/docs/concepts/particle-buffer.md +48 -35
- package/docs/concepts/post-processing.md +77 -14
- package/docs/concepts/quality-preset-tables.md +3 -2
- package/docs/concepts/quality-presets.md +122 -39
- package/docs/concepts/render-graph.md +56 -21
- package/docs/concepts/render-layers.md +9 -5
- package/docs/concepts/shadows.md +96 -25
- package/docs/concepts/static-dynamic.md +22 -7
- package/docs/cookbook/index.md +163 -119
- package/docs/data/threejs-mapping.json +301 -340
- 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 +11 -3
- 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 +23 -6
- package/docs/errors/E1308.md +31 -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 +11 -3
- 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 +53 -29
- package/docs/getting-started/cdn.md +15 -9
- package/docs/getting-started/first-scene.md +20 -12
- package/docs/getting-started/hosting.md +113 -63
- package/docs/getting-started/install.md +39 -24
- package/docs/getting-started/network-use.md +31 -21
- package/docs/getting-started/project-structure.md +20 -8
- package/docs/getting-started/third-party-notices.md +6 -10
- package/docs/guides/accessibility.md +4 -4
- package/docs/guides/add-ons.md +83 -13
- package/docs/guides/agents.md +13 -14
- package/docs/guides/assets-pipeline.md +294 -72
- package/docs/guides/audio.md +17 -15
- package/docs/guides/baked-light-data.md +44 -23
- package/docs/guides/car-paint.md +37 -31
- package/docs/guides/content-pages.md +86 -29
- package/docs/guides/custom-passes.md +59 -17
- package/docs/guides/custom-shaders.md +54 -37
- package/docs/guides/debugging.md +31 -41
- package/docs/guides/deploying.md +10 -27
- package/docs/guides/deterministic-simulation.md +23 -16
- package/docs/guides/first-use-shaders.md +83 -45
- package/docs/guides/lens-kit.md +29 -26
- package/docs/guides/loading-screens.md +74 -30
- package/docs/guides/multiple-views.md +22 -11
- package/docs/guides/performance.md +188 -37
- package/docs/guides/phones.md +71 -19
- package/docs/guides/physics.md +6 -10
- package/docs/guides/screens.md +41 -29
- package/docs/guides/start-time.md +126 -85
- package/docs/guides/testing.md +137 -98
- package/docs/guides/ui-overlays.md +17 -12
- 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 +14 -23
- package/docs/moves.json +1 -0
- package/docs/nav.json +300 -0
- package/docs/pages.md +230 -212
- package/docs/porting/react-three-fiber.md +2 -6
- package/docs/porting/threejs-loop-and-threads.md +1 -5
- package/docs/porting/threejs-mapping.md +1248 -234
- package/docs/porting/threejs-materials.md +10 -5
- package/docs/porting/threejs-overview.md +26 -6
- package/docs/porting/threejs-postprocessing.md +2 -6
- package/docs/porting/threejs-shaders.md +16 -14
- package/docs/porting/threejs-unsupported.md +6 -6
- package/docs/porting/verification.md +0 -4
- package/docs/shaders/builtins.md +15 -4
- package/docs/shaders/library.md +9 -6
- package/docs/shaders/surface-functions.md +51 -16
- package/docs/shaders/wgsl-rules.md +12 -5
- package/lib/debug/debug.d.ts +2 -2
- package/lib/debug/draw.d.ts +2 -2
- package/lib/debug/draw.js +8 -4
- 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 +21 -6
- package/lib/debug/stats-panel.js +80 -13
- package/lib/errors/codes.d.ts +17 -3
- package/lib/errors/codes.js +116 -105
- package/lib/errors/engine-error.js +1 -1
- package/lib/errors/fixes.d.ts +1 -0
- package/lib/errors/fixes.js +19 -18
- package/lib/generated/shader-permutations.d.ts +6 -0
- package/lib/generated/shader-permutations.js +6 -0
- package/lib/gpu/variants.d.ts +8 -2
- package/lib/gpu/variants.js +39 -7
- package/lib/gpu/webgl2/programs.js +1 -1
- package/lib/gpu/webgpu/pipelines.js +13 -13
- package/lib/index.d.ts +1 -1
- package/lib/page/capabilities.d.ts +1 -1
- package/lib/page/engine.d.ts +29 -7
- package/lib/page/engine.js +79 -7
- package/lib/page/label-loop.js +9 -4
- package/lib/page/stats-switch.js +2 -0
- package/lib/page/switches.d.ts +6 -4
- package/lib/page/switches.js +20 -4
- package/lib/scene/baked-light.d.ts +2 -2
- package/lib/scene/fake-call-values.js +2 -2
- package/lib/scene/frame-cameras.d.ts +16 -4
- package/lib/scene/frame-cameras.js +28 -10
- package/lib/scene/gltf.d.ts +1 -1
- package/lib/scene/level-rule.d.ts +6 -5
- package/lib/scene/level-rule.js +2 -2
- package/lib/scene/particles.d.ts +7 -3
- package/lib/scene/particles.js +3 -1
- package/lib/scene/post.d.ts +3 -2
- package/lib/scene/resources.d.ts +15 -9
- package/lib/scene/scene.d.ts +18 -2
- package/lib/scene/scene.js +47 -5
- package/lib/scene/time-of-day.d.ts +10 -5
- package/lib/scene/time-of-day.js +11 -7
- package/lib/shader-artifact.json +1 -1
- package/lib/shared/labels.d.ts +5 -2
- package/lib/shared/labels.js +5 -2
- package/lib/shared/permutation-words.d.ts +8 -0
- package/lib/shared/permutation-words.js +14 -0
- package/lib/shared/recording.d.ts +13 -5
- package/lib/shared/recording.js +31 -10
- package/lib/shared/sketch-data.d.ts +9 -0
- package/lib/shared/sketch-data.js +57 -0
- package/lib/shared/tier.d.ts +9 -0
- package/lib/shared/tier.js +4 -1
- package/lib/shared/version.d.ts +1 -1
- package/lib/shared/version.js +1 -1
- package/lib/sketch/define-sketch.d.ts +16 -7
- package/lib/sketch/define-sketch.js +2 -1
- package/lib/sketch/runner.d.ts +4 -0
- package/lib/sketch/runner.js +5 -0
- package/lib/sketch/ui.js +4 -2
- package/lib/stats.d.ts +1 -0
- package/lib/workers/protocol.d.ts +10 -0
- package/lib/workers/render-worker.js +4 -1
- package/lib/workers/sketch-worker.js +4 -1
- package/package.json +1 -1
|
@@ -1,14 +1,12 @@
|
|
|
1
1
|
---
|
|
2
2
|
id: concepts/particle-buffer
|
|
3
3
|
title: The particle buffer
|
|
4
|
-
status: experimental
|
|
5
|
-
since: "0.2"
|
|
6
4
|
summary: "What a particle buffer holds: its 32-byte records, its values and its frame's values; how an emitter or sketch code writes births into it; and the limits that it meets."
|
|
7
5
|
---
|
|
8
6
|
|
|
9
7
|
# The particle buffer
|
|
10
8
|
|
|
11
|
-
>
|
|
9
|
+
> This is a low-level API. The [particles add-on](../api/particles.md) fills this buffer for you, and the null3D agent skills always use the add-on. Write records yourself only for an emitter that the add-on does not fit.
|
|
12
10
|
|
|
13
11
|
```mermaid
|
|
14
12
|
flowchart LR
|
|
@@ -21,7 +19,7 @@ flowchart LR
|
|
|
21
19
|
|
|
22
20
|
A particle buffer is a scene object and a flat table of particle records. A record is written once, when a particle is born. The GPU then works out where that particle is and how it looks at its age, in closed form. No pass moves the particles, so a frame at a given time looks the same whatever frames came before it, on WebGPU and on WebGL2.
|
|
23
21
|
|
|
24
|
-
The `@null3d/particles` add-on builds its systems from buffers. Its emitters, bursts and sub-emitters decide where and when particles are born, then write the records in the engine's core. Use the add-on for most work. This page covers the buffer itself, for an emitter that the add-on does not fit.
|
|
22
|
+
The `@null3d/particles` add-on builds its systems from buffers. Its emitters, bursts and sub-emitters decide where and when particles are born, then write the records in the engine's core ([Architecture](architecture.md)). Use the add-on for most work. This page covers the buffer itself, for an emitter that the add-on does not fit.
|
|
25
23
|
|
|
26
24
|
## What the buffer holds
|
|
27
25
|
|
|
@@ -30,9 +28,26 @@ The `@null3d/particles` add-on builds its systems from buffers. Its emitters, bu
|
|
|
30
28
|
| The object | one scene object | Its place, turn, scale, layers, visibility and bounds. Birth places are in its space, so moving the object moves every particle. |
|
|
31
29
|
| The records | 32 bytes for each of `capacity` | One record for each particle that the buffer holds at once. |
|
|
32
30
|
| The values | 608 bytes | The motion and the look of every particle of the buffer, and the wind field when it names one. It uploads when `set` or `setWind` changes it. |
|
|
33
|
-
| The frame's values | 20 bytes | The time, the record count, the time shift and the wind texture's number. The sketch
|
|
31
|
+
| The frame's values | 20 bytes | The time, the record count, the time shift and the wind texture's number. The sketch or the core's emitter writes the time and count; `setWind` writes the wind texture's number. |
|
|
34
32
|
| The emitter | a block of numbers | The settings and the frame's numbers of an emitter in the core, when the buffer has one. |
|
|
35
33
|
|
|
34
|
+
Each frame's values have a slot of their own. `buffer.frame` is a view of these five numbers.
|
|
35
|
+
|
|
36
|
+
| Slot | Meaning | Who writes it |
|
|
37
|
+
| --- | --- | --- |
|
|
38
|
+
| 0 | The buffer's time in seconds. | The sketch, or the core's emitter. |
|
|
39
|
+
| 1 | How many records from the first the draw reads. | The sketch, or the core's emitter. |
|
|
40
|
+
| 2 | The first record that still counts from the old time base. | The core's emitter, when it moves the time base. |
|
|
41
|
+
| 3 | The seconds to take off the birth times of those records. | The core's emitter, when it moves the time base. |
|
|
42
|
+
| 4 | The wind texture's number. | `setWind`. |
|
|
43
|
+
|
|
44
|
+
<details>
|
|
45
|
+
<summary>Technical details: how the time base moves</summary>
|
|
46
|
+
|
|
47
|
+
Birth times are 32-bit floats, so their precision falls as the buffer's clock grows. A buffer that runs for hours moves its time base. It rewrites the birth times at their new times and tells the shader how far that move has reached. The call `shiftRecords(from, to, seconds)` takes whole seconds off the birth times of rows `from` to `to`. That moves the time that they count from. An emitter does this after 1,024 seconds.
|
|
48
|
+
|
|
49
|
+
</details>
|
|
50
|
+
|
|
36
51
|
The engine gives the object one material, with the particle shading. It blends and writes no depth. The material takes a `map` for the particles' texture, and without one each particle is a soft round dot. The `blending` option is additive or normal, and it defaults to additive. `layers` chooses the layers that the buffer draws on.
|
|
37
52
|
|
|
38
53
|
## A record
|
|
@@ -49,25 +64,6 @@ A record is eight 32-bit numbers, or 32 bytes.
|
|
|
49
64
|
|
|
50
65
|
The seed picks the particle's random size, turn, spin, color and first flipbook frame. Two particles of one buffer get their own values from their own seeds. Call `write(index, record, seed)` with the eight numbers in that order: place, birth time, velocity, lifetime. The seed is the third argument.
|
|
51
66
|
|
|
52
|
-
Call `writeRecords(block, count, first)` to write many births in one call. The block holds nine numbers for each birth: the eight above and the seed. Row `first` takes the first birth, and the rest follow, wrapping at the capacity. The engine packs the records and marks them, so the sketch's loop fills the block and the call writes it. Pass a block that stays the same size from frame to frame, which keeps the engine's room for it. Call `shiftRecords(from, to, seconds)` to take whole seconds off the birth times of rows `from` to `to`, which moves the time that they count from.
|
|
53
|
-
|
|
54
|
-
## Layout in practice
|
|
55
|
-
|
|
56
|
-
The records are one table, with a row for each particle that the buffer holds at once. An index from 0 to `capacity - 1` names a row. The buffer keeps no list of live particles. The shader reads each record's birth time and lifetime, so a particle draws nothing before its birth and nothing after its death.
|
|
57
|
-
|
|
58
|
-
`frame[1]` says how many records from the first the draw reads, at most the capacity. Set it to the number of rows that hold a record, so rows that the sketch never wrote do not draw. Rows past the count draw nothing even when they hold a live particle. Once the count reaches the capacity, every row runs the vertex shader in every frame. A record past its life leaves before it makes a quad.
|
|
59
|
-
|
|
60
|
-
An emitter usually fills the table in order and then writes over the oldest rows:
|
|
61
|
-
|
|
62
|
-
```ts
|
|
63
|
-
// The n-th birth goes into row n. After a full table, the rows start again.
|
|
64
|
-
buffer.write(born % buffer.capacity, record, born & 0xffff);
|
|
65
|
-
```
|
|
66
|
-
|
|
67
|
-
A capacity that fits the rate over the longest lifetime keeps that safe. A write over a row whose particle is still alive ends that particle early.
|
|
68
|
-
|
|
69
|
-
A buffer draws as one blended object. Its particles keep the order of their records, and the engine does not sort them among themselves. Additive blending needs no order, which suits most effects. With normal blending, keep the particles faint and soft, as smoke is.
|
|
70
|
-
|
|
71
67
|
## Write into the buffer
|
|
72
68
|
|
|
73
69
|
The sketch below writes a fountain straight into a buffer, and the GPU moves every particle.
|
|
@@ -123,7 +119,7 @@ export default defineSketch(async ({ scene, time }) => {
|
|
|
123
119
|
|
|
124
120
|
Await the creation in the setup, because the first call downloads the particle code. If the code does not download, the promise rejects with [E1406](../errors/E1406.md).
|
|
125
121
|
|
|
126
|
-
Make the record array once. Every birth is then a write into engine memory, so a frame allocates nothing. The frame array is a view into that memory: take it once and assign its numbers.
|
|
122
|
+
Make the record array once. Every birth is then a write into engine memory, so a frame allocates nothing. The frame array is a view into that memory: take it once and assign its numbers. The count in `frame[1]` stops the draw at the rows that hold a record ([Layout in practice](#layout-in-practice) explains).
|
|
127
123
|
|
|
128
124
|
`commit()` marks the records written since the last call for the next frame's upload. A call in every frame is enough: writes that continue the run are marked there, and a write elsewhere marks its range at once.
|
|
129
125
|
|
|
@@ -135,6 +131,22 @@ The birth time counts from `frame[0]`, which must rise with the frame's time. Ke
|
|
|
135
131
|
|
|
136
132
|
`buffer.destroy()` frees the records, the GPU buffers and the object.
|
|
137
133
|
|
|
134
|
+
### Write many births in one call
|
|
135
|
+
|
|
136
|
+
Call `writeRecords(block, count, first)` to write many births in one call. The block holds nine numbers for each birth: the eight above and the seed. Row `first` takes the first birth, and the rest follow, wrapping at the capacity.
|
|
137
|
+
|
|
138
|
+
The engine packs the records and marks them, so the sketch's loop fills the block and the call writes it. Pass a block that stays the same size from frame to frame, which keeps the engine's room for it.
|
|
139
|
+
|
|
140
|
+
## Layout in practice
|
|
141
|
+
|
|
142
|
+
The records are one table, with a row for each particle that the buffer holds at once. An index from 0 to `capacity - 1` names a row. The buffer keeps no list of live particles. The shader reads each record's birth time and lifetime, so a particle draws nothing before its birth and nothing after its death.
|
|
143
|
+
|
|
144
|
+
`frame[1]` says how many records from the first the draw reads, at most the capacity. Set it to the number of rows that hold a record, so rows that the sketch never wrote do not draw. Rows past the count draw nothing even when they hold a live particle. Once the count reaches the capacity, every row runs the vertex shader in every frame. A record past its life leaves before it makes a quad.
|
|
145
|
+
|
|
146
|
+
An emitter usually fills the table in order, as the fountain example does, and then writes over the oldest rows. A capacity that fits the rate over the longest lifetime keeps that safe. A write over a row whose particle is still alive ends that particle early.
|
|
147
|
+
|
|
148
|
+
A buffer draws as one blended object. Its particles keep the order of their records, and the engine does not sort them among themselves. Additive blending needs no order, which suits most effects. With normal blending, keep the particles faint and soft, as smoke is.
|
|
149
|
+
|
|
138
150
|
## An emitter in the core
|
|
139
151
|
|
|
140
152
|
A buffer can also emit. Configure an emitter once, and the core writes a frame's records in one call. The particles add-on uses this path. The core makes every record of the frame. It plans and fires the sub-emitters, and moves the time base. The sketch runs no loop over the births.
|
|
@@ -152,14 +164,14 @@ buffer.configureEmitter({
|
|
|
152
164
|
// In each frame, after the objects have their world places. The five numbers are the frame's
|
|
153
165
|
// start and end, its rate, and 1 or 0 for whether it emits and whether it is a prewarmed first
|
|
154
166
|
// frame. Make the array once: a fraction passed as a call argument is boxed.
|
|
155
|
-
const
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
buffer.emitFrame(
|
|
167
|
+
const emitNumbers = new Float64Array(5);
|
|
168
|
+
|
|
169
|
+
emitNumbers[0] = time.now - dt;
|
|
170
|
+
emitNumbers[1] = time.now;
|
|
171
|
+
emitNumbers[2] = 200;
|
|
172
|
+
emitNumbers[3] = 1;
|
|
173
|
+
emitNumbers[4] = 0;
|
|
174
|
+
buffer.emitFrame(emitNumbers);
|
|
163
175
|
```
|
|
164
176
|
|
|
165
177
|
`configureEmitter` takes the seed and the shape: point, sphere, cone, box or disc. It also takes the direction and its spread, with the speed and lifetime ranges. A velocity, the bursts, the duration, the loop, the followed object and the sub-emitters follow. The engine keeps the motion and the values, so the core's events follow the same closed form as the shader.
|
|
@@ -187,15 +199,16 @@ A frame's upload therefore grows with the births it writes. The number of partic
|
|
|
187
199
|
- The engine's memory holds 32 bytes for each record, and the GPU holds a copy of the same bytes. A buffer that cannot get its memory throws [E1109](../errors/E1109.md).
|
|
188
200
|
- The count is rounded down to a whole number, at most the capacity. A count that is not finite, or that is 0 or less, draws nothing.
|
|
189
201
|
- The lifetime is a 16-bit float with about three digits of precision, rounded down. One above 65,504 seconds stores as 65,504. One below about 0.00003 seconds stores as zero, so the particle never draws.
|
|
190
|
-
- Birth times are 32-bit floats, so their precision falls as the buffer's clock grows. A buffer that runs for hours moves its time base
|
|
202
|
+
- Birth times are 32-bit floats, so their precision falls as the buffer's clock grows. A buffer that runs for hours moves its time base ([technical details](#what-the-buffer-holds)).
|
|
191
203
|
- A buffer with a map draws nothing in a frame where the map's image is not yet on the GPU.
|
|
192
|
-
-
|
|
204
|
+
- The `softness` value fades particles out over that distance, in meters, where they near the surfaces behind them ([Soft particles](../api/particles.md#soft-particles)). A value above 0 makes the camera copy its opaque depth in each frame, which is one full-screen pass. The Low preset turns soft particles off. The [particles demo](https://github.com/null3d-engine/null3d/tree/main/examples/particles) sets a softness of 0.25 on its campfire flames, so they meet the ground softly.
|
|
193
205
|
- The particles cast no shadow and lights do not light them. A raycast against the object tests its one triangle at the origin, which has no area, so it never hits a particle.
|
|
194
206
|
- After `destroy()`, the buffer's calls and arrays throw.
|
|
195
207
|
|
|
196
208
|
## Related pages
|
|
197
209
|
|
|
198
210
|
- [Particles](../api/particles.md): the add-on that makes systems from this buffer, with emitters and sub-emitters.
|
|
211
|
+
- [The particles demo](https://github.com/null3d-engine/null3d/tree/main/examples/particles): the campfire glade draws its flames, embers and smoke from particle buffers.
|
|
199
212
|
- [Instances and batching](instances.md): typed arrays that sketch code writes, row by row.
|
|
200
213
|
- [Culling](culling.md): how the engine culls the buffer by its object's bounds.
|
|
201
214
|
- [GPU tiers and backends](backends.md): the two paths that draw the same particles.
|
|
@@ -1,21 +1,25 @@
|
|
|
1
1
|
---
|
|
2
2
|
id: concepts/post-processing
|
|
3
3
|
title: The post-processing chain
|
|
4
|
-
status: experimental
|
|
5
|
-
since: "0.2"
|
|
6
4
|
summary: "HDR scene color, ambient occlusion and screen-space reflections at half size, custom effects, depth of field with near and far fields, bloom through a chain of mip levels, automatic exposure from a meter on the GPU, an outline mask, and the final pass for the vignette, tone mapping, FXAA, outlines, color grading and dithering, in two steps once the render scale can drop below the whole canvas; still views that blend and then rest the GPU."
|
|
7
5
|
---
|
|
8
6
|
|
|
9
7
|
# The post-processing chain
|
|
10
8
|
|
|
11
|
-
|
|
9
|
+

|
|
10
|
+
|
|
11
|
+
The post effects demo: built-in bloom, reflections and outline, and the lens kit's custom effect.
|
|
12
|
+
|
|
13
|
+
> The chain has HDR scene color, ambient occlusion, screen-space reflections, screen-space bounce light, custom effects, depth of field, bloom, automatic exposure and outlines. The final pass adds color grading, the vignette, sharpening and custom tone curves. A still view blends and then rests the GPU.
|
|
12
14
|
|
|
13
15
|
```mermaid
|
|
14
16
|
flowchart LR
|
|
15
17
|
prepass["Depth prepass"] --> ao["Ambient occlusion:<br/>three steps at half size"]
|
|
16
18
|
prepass --> ssr["Screen-space reflections:<br/>a depth pyramid and a trace<br/>at half size"]
|
|
19
|
+
prepass --> bounce["Bounce light:<br/>a trace and a denoise<br/>at half size"]
|
|
17
20
|
ao --> scene
|
|
18
21
|
ssr --> scene
|
|
22
|
+
bounce --> scene
|
|
19
23
|
copy["The frame before's<br/>opaque colors"] --> scene
|
|
20
24
|
scene["Scene passes:<br/>linear HDR color"] --> fog["Volumetric fog:<br/>adds the light in the fog"]
|
|
21
25
|
fog --> custom["Custom effects:<br/>joined into few passes"]
|
|
@@ -24,7 +28,7 @@ flowchart LR
|
|
|
24
28
|
down --> up["Bloom's steps up:<br/>each level blends in<br/>the one below"]
|
|
25
29
|
dof --> meter["Exposure meter:<br/>a histogram or a downsample<br/>into one texel"]
|
|
26
30
|
up --> meter
|
|
27
|
-
meter --> final["Final pass:
|
|
31
|
+
meter --> final["Final pass: applies the adapted exposure,<br/>smooths edges with FXAA,<br/>blends in bloom, then<br/>the vignette and tone mapping"]
|
|
28
32
|
dof --> final
|
|
29
33
|
up --> final
|
|
30
34
|
mask["Outline mask:<br/>outlined objects"] --> line
|
|
@@ -34,7 +38,15 @@ flowchart LR
|
|
|
34
38
|
scaled --> canvas
|
|
35
39
|
```
|
|
36
40
|
|
|
37
|
-
|
|
41
|
+
Each frame draws the scene into a linear HDR target, runs the effects that need that range, then turns the result into the canvas's colors in a final pass. The steps, in order:
|
|
42
|
+
|
|
43
|
+
1. Before the opaque objects shade, the depth prepass draws depth. Ambient occlusion and screen-space reflections read it.
|
|
44
|
+
2. The scene passes draw linear color with no upper limit into a float target, the scene color. The exposure scales each light and color as it enters, so the scene color holds exposed color. The opaque pass darkens its ambient light with the occlusion and reflects the frame before's colors where the reflections' rays hit.
|
|
45
|
+
3. The HDR effects read the scene color in this order: the volumetric fog's light ([Lighting and environment](lighting.md#volumetric-fog)), custom effects, depth of field, then bloom. The [light shafts demo](https://github.com/null3d-engine/null3d/tree/main/examples/light-shafts) shows that stage at dusk, with sun rays between the trunks.
|
|
46
|
+
4. The final pass smooths edges with FXAA, adds the effects' results, darkens the edges with the vignette and applies the tone curve: AgX with a punchy look by default, which keeps the hues of bright colors ([Color management](color-management.md#exposure-and-tone-mapping)). Then it encodes sRGB.
|
|
47
|
+
5. In the same pass, it draws the outline's line, applies the color grading table when the sketch sets one, and dithers last.
|
|
48
|
+
|
|
49
|
+
Steps 4 and 5 run as one pass only while the render scale cannot drop below the whole canvas. Low, Medium and High let it drop, and then the work splits in two ([Below the whole canvas's render scale](#below-the-whole-canvass-render-scale)).
|
|
38
50
|
|
|
39
51
|
Every full-screen pass reads and writes the whole screen once more. On a phone at its full resolution that is tens of megabytes per frame, so the engine keeps such passes few. Bloom's passes draw small levels of a fixed size. The outline draws only a mask of the outlined meshes. The final pass reads their results without a pass of its own.
|
|
40
52
|
|
|
@@ -57,10 +69,21 @@ export default defineSketch(({ scene, geometry, materials, post }) => {
|
|
|
57
69
|
|
|
58
70
|
## Below the whole canvas's render scale
|
|
59
71
|
|
|
60
|
-
The engine can draw the scene at a lower scale than the canvas, then scale the image up, to hold a frame rate on a slow GPU ([Dynamic resolution](quality-presets.md#dynamic-resolution)).
|
|
72
|
+
The engine can draw the scene at a lower scale than the canvas, then scale the image up, to hold a frame rate on a slow GPU ([Dynamic resolution](quality-presets.md#dynamic-resolution)). While the render scale can drop below 1, as it can on the Low, Medium and High presets, the final pass runs in two steps.
|
|
73
|
+
|
|
74
|
+
The first step tone maps the image at the render size into an 8-bit target. The second step scales that target up to the canvas with an upscaler that keeps edges sharp, then draws the outline's line, applies the color grading table and dithers. While the scale cannot drop below 1, one pass does all of this work.
|
|
75
|
+
|
|
76
|
+
<details>
|
|
77
|
+
<summary>Technical details: the two steps and the upscaler</summary>
|
|
61
78
|
|
|
62
|
-
1. The first step draws at the render size, one pixel for each render pixel. It adds bloom's light
|
|
63
|
-
|
|
79
|
+
1. The first step draws at the render size, one pixel for each render pixel. It adds bloom's light and darkens the edges with the vignette. It runs the output transform, which is the tone curve and the sRGB encode. It smooths edges with FXAA too.
|
|
80
|
+
|
|
81
|
+
It writes an 8-bit target the size of the canvas, with the image in its corner at the render scale. The second step reads that target as display color. The first step leaves the dither to the second step: that step draws canvas pixels, so the noise lands at the canvas's size.
|
|
82
|
+
2. The second step is the plain final pass. It reads the 8-bit target and scales it up to the whole canvas with GSR 1, Qualcomm's spatial upscaler, which keeps edges sharper than a bilinear filter. The pass blends the four nearest texels as a bilinear filter does, then votes on their green channel to find an edge.
|
|
83
|
+
|
|
84
|
+
Where an edge passes, it weighs twelve texels around the pixel and adds a bounded correction to the blend. A flat area keeps the blend alone. The work runs only where a pixel reads a smaller corner on the canvas, so an image at the whole canvas's scale pays nothing for it. Then the pass sharpens the display color while the sketch asks for it ([Sharpening](#sharpening)). It draws the outline's line, applies the color grading table when the sketch sets one, and dithers.
|
|
85
|
+
|
|
86
|
+
</details>
|
|
64
87
|
|
|
65
88
|
The two steps also draw at the whole canvas's scale while the sketch sets `sharpen`, since the sharpening reads display color. Without it, one pass does the work there, as the sections below describe.
|
|
66
89
|
|
|
@@ -121,6 +144,10 @@ With the default weights, bloom draws 15 small passes: 8 steps down and 7 steps
|
|
|
121
144
|
|
|
122
145
|
Depth of field blurs what lies in front of and behind the focus distance, as a camera lens does. Each pixel's blur is the circle of confusion of a thin lens, from the pixel's depth, the focal length, the aperture and the focus distance. The near field, what lies in front of the focus, and the far field, what lies behind it, blur apart:
|
|
123
146
|
|
|
147
|
+

|
|
148
|
+
|
|
149
|
+
Depth of field in the camera lens demo.
|
|
150
|
+
|
|
124
151
|
1. The setup step reads four pixels of the scene's color and depth for each texel of a target at half the render size. It finds each pixel's blur, and writes their color with the smallest blur. In-focus color counts less in the average, so sharp detail does not bleed into the blur.
|
|
125
152
|
2. The gather reads a spiral of taps over a disk around each texel, or over a polygon when the aperture has blades. A tap adds to the far field only where both its own blur and the texel's reach it. It adds to the near field wherever its own blur reaches the texel.
|
|
126
153
|
3. A small tent filter smooths the gather.
|
|
@@ -163,6 +190,10 @@ Depth of field adds three passes at half the render size and one at the render s
|
|
|
163
190
|
|
|
164
191
|
Automatic exposure adapts the picture to the scene's brightness, as an eye or a camera does. A meter on the GPU reads the color that the final pass reads, in the same frame. It writes the adapted exposure into one texel, and the final pass multiplies the color by it before FXAA, the vignette and the tone curve.
|
|
165
192
|
|
|
193
|
+

|
|
194
|
+
|
|
195
|
+
The stone hall with automatic exposure on.
|
|
196
|
+
|
|
166
197
|
```ts
|
|
167
198
|
post.set({ autoExposure: { minEv: -6, speedDown: 0.7 } });
|
|
168
199
|
```
|
|
@@ -212,7 +243,9 @@ post.addEffect({ wgsl: warm });
|
|
|
212
243
|
- Effects run after the scene passes and before depth of field and bloom, on linear HDR color after the exposure. Light that an effect adds can glow, and the tone curve maps it with the rest.
|
|
213
244
|
- Each effect reads the color that the effect before it wrote. It can read any pixel, and the scene's depth on every GPU path.
|
|
214
245
|
- Effects run from the lowest `order` to the highest, at most 8 at once.
|
|
215
|
-
- An effect that calls `effectBloom(input.uv)` reads a level of bloom's chain, and `bloomLevel` names which level, from 0 for the narrowest glow. The chain then draws before the effects, from the scene color rather than from their output, and the final pass still blends its glow into the picture after them.
|
|
246
|
+
- An effect that calls `effectBloom(input.uv)` reads a level of bloom's chain, and `bloomLevel` names which level, from 0 for the narrowest glow. The chain then draws before the effects, from the scene color rather than from their output, and the final pass still blends its glow into the picture after them.
|
|
247
|
+
|
|
248
|
+
A streak, a glare or a halo reads the level that suits its width instead of blurring the picture again. Such an effect draws in a pass of its own, as an effect with textures does, and a level that the chain does not draw reads black.
|
|
216
249
|
- Two targets of the render size serve all the effects. The render graph lets them share memory, because each effect's target lives only until the next effect has read it.
|
|
217
250
|
- A full-screen pass reads and writes 8 bytes per pixel. The engine joins an effect that reads only its own pixel into the pass of the effect before it, while the render scale cannot drop below the whole canvas. With bloom and FXAA off, the last of these passes folds into the final pass then too. While the scale can drop, each effect draws a pass of its own, at every scale ([below the whole canvas's render scale](#below-the-whole-canvass-render-scale)). [Custom passes](../guides/custom-passes.md#cost) gives the rules.
|
|
218
251
|
|
|
@@ -271,6 +304,10 @@ Ambient occlusion adds the depth prepass and three small passes at half the rend
|
|
|
271
304
|
|
|
272
305
|
Screen-space reflections make shiny opaque surfaces reflect what the screen shows along their mirror direction. A wet street shows the lamps and windows above it, a polished floor the furniture on it, and a metal pipe the wall beside it. They work in four steps, the first three at the size of ambient occlusion's grid:
|
|
273
306
|
|
|
307
|
+

|
|
308
|
+
|
|
309
|
+
Screen-space reflections in the wet street demo.
|
|
310
|
+
|
|
274
311
|
1. The depth prepass draws the opaque objects' depth, and a first step copies the depth of one pixel under each texel, as for ambient occlusion.
|
|
275
312
|
2. Six small steps build a depth pyramid. Each texel of a level keeps the nearest depth of the four texels under it, so a level shows where nothing stands in front of a ray.
|
|
276
313
|
3. The trace rebuilds each surface's normal from the depth, and marches its mirror ray through the pyramid. Where a cell holds nothing nearer than the ray, the ray crosses the whole cell and climbs to a larger one. Where it does, the ray drops to a smaller cell, until it meets a surface. A hit counts only where the ray passes no further behind that surface than `thickness`. The trace keeps the ray's length.
|
|
@@ -302,7 +339,9 @@ Screen-space reflections and ambient occlusion share one grid, at the larger of
|
|
|
302
339
|
|
|
303
340
|
### Cost
|
|
304
341
|
|
|
305
|
-
The reflections add the depth prepass, the depth copy, six small steps for the pyramid, the trace and the copy of the opaque colors with its mip levels. Transmission shares that copy.
|
|
342
|
+
The reflections add the depth prepass, the depth copy, six small steps for the pyramid, the trace and the copy of the opaque colors with its mip levels. Transmission shares that copy.
|
|
343
|
+
|
|
344
|
+
The opaque pass reads four texels of the screen texture at each pixel, the same reads that ambient occlusion and contact shadows use. It adds one filtered read to each pixel of a smooth enough surface. While the reflections are off, the frame has none of these passes or targets, and the shaders download only when a sketch first turns them on.
|
|
306
345
|
|
|
307
346
|
The engine's benchmark scene of 100,000 boxes over a polished floor ran on a MacBook Pro in Chrome. With WebGPU, the reflections added about 0.7 ms of GPU time per frame on Medium, at a quarter of the render size. On High, at half the size, they added about 1.8 ms. On WebGL2 they added between 0.25 and 1.24 ms. They added no CPU time beyond the noise.
|
|
308
347
|
|
|
@@ -314,6 +353,12 @@ The engine's benchmark scene of 100,000 boxes over a polished floor ran on a Mac
|
|
|
314
353
|
|
|
315
354
|
Screen-space bounce light adds one bounce of the indirect light that the camera's view shows. A red wall throws red light onto the floor beside it. A green wall throws green light onto the other side. The environment's light is one color for every direction, so it cannot show that.
|
|
316
355
|
|
|
356
|
+

|
|
357
|
+
|
|
358
|
+
Bounce light off and on.
|
|
359
|
+
|
|
360
|
+
Bounce light needs no `post.set` call. The High and Ultra presets draw it, and so does Medium on WebGL2. While it draws, the depth prepass runs too. `quality.set({ bounceRays: 0 })` turns it off.
|
|
361
|
+
|
|
317
362
|
A mirror's color holds what it shows this view, not light that its surface sends every way, so the gather leaves out what lies on the plane of a mirror view: the first two mirrors of a scene, and water's reflection among them. A glossy surface with no mirror view, such as a floor that screen-space reflections draw, still sends its color. No buffer holds a surface's roughness for the gather to read.
|
|
318
363
|
|
|
319
364
|
The light draws on ambient occlusion's grid, at half the render size, and it reuses that feature's depth copy and normals:
|
|
@@ -326,7 +371,7 @@ The light draws on ambient occlusion's grid, at half the render size, and it reu
|
|
|
326
371
|
quality.set({ bounceRays: 8 });
|
|
327
372
|
```
|
|
328
373
|
|
|
329
|
-
- The quality setting `bounceRays` is the number of rays each texel casts: 0 draws none. High sets 4 and Ultra 8. Low and Medium set 0, and WebGL2, which ends at Medium, sets 4 there. A change takes effect during play and makes no GPU object.
|
|
374
|
+
- The quality setting `bounceRays` is the number of rays each texel casts: 0 draws none. High sets 4 and Ultra 8. Low and Medium set 0, and WebGL2, which ends at Medium, sets 4 there. A change takes effect during play and makes no GPU object.
|
|
330
375
|
- The light is one frame behind the scene, as screen-space reflections are. The first frame after it turns on shows none.
|
|
331
376
|
- The light draws nothing on the 8-bit path, whose copy holds display color. Compatibility mode draws that path, so it draws no bounce light.
|
|
332
377
|
- A scene with a [light probe grid](lighting.md#light-probe-grid) draws no bounce light. The grid already holds one bounce, with the validity and sky-occlusion terms that the screen cannot supply.
|
|
@@ -334,7 +379,7 @@ quality.set({ bounceRays: 8 });
|
|
|
334
379
|
|
|
335
380
|
### Cost
|
|
336
381
|
|
|
337
|
-
The light costs two passes at half the render size and a few texture reads in the opaque pass. At 1920 x 1080 on the Mac it added 2.5 ms at High and 1.3 ms at Ultra on WebGPU. It added 0.8 ms at WebGL2's Medium. At half the render scale it adds about a millisecond.
|
|
382
|
+
The light costs two passes at half the render size and a few texture reads in the opaque pass. At 1920 x 1080 on the Mac it added 2.5 ms at High and 1.3 ms at Ultra on WebGPU. It added 0.8 ms at WebGL2's Medium. At half the render scale it adds about a millisecond. Ultra's eight rays measured a little less than High's four. The gap is within the spread between runs, so expect about the same cost on both.
|
|
338
383
|
|
|
339
384
|
|
|
340
385
|
## Outlines
|
|
@@ -366,12 +411,18 @@ A color grading table, from a `.cube` or a `.3dl` file through `assets.loadLut`
|
|
|
366
411
|
- Both draw on every GPU path, with HDR color or without it, as [Post-processing API](../api/post.md#vignette) says.
|
|
367
412
|
- They are settings of the final pass, not passes of their own. Turning one on builds no pipeline, so the picture changes in the next frame with no pause.
|
|
368
413
|
- Each table is a 3D texture, read with one filtered texture read per pixel. The vignette costs a few operations per pixel.
|
|
369
|
-
- The grading controls' table holds 32 texels a side, and the final pass takes the square root of a color before it reads the table, which places the texels closer together toward black where a grade's curve is steepest.
|
|
414
|
+
- The grading controls' table holds 32 texels a side, and the final pass takes the square root of a color before it reads the table, which places the texels closer together toward black where a grade's curve is steepest.
|
|
415
|
+
|
|
416
|
+
A job worker computes the table's texels, so a value that changes stalls no frame. The frame that lands a bake uploads the table, 256 KB. The table keeps the worker's whole range, past white, and the canvas clips it, so a color that crosses white inside a texel's cell still matches the grade.
|
|
370
417
|
|
|
371
418
|
## Sharpening
|
|
372
419
|
|
|
373
420
|
Sharpening makes edges and fine detail crisper, as a lens that is stopped down does. `post.set({ sharpen: 0.5 })` turns it on with half its strength, and it is off by default. [The post-processing API](../api/post.md#sharpening) lists its setting.
|
|
374
421
|
|
|
422
|
+

|
|
423
|
+
|
|
424
|
+
Sharpening, enlarged 4 times.
|
|
425
|
+
|
|
375
426
|
- It works on display color, after the tone mapping and the sRGB encoding, as FSR 1's RCAS does at the end of its chain. Sharpening light before the tone curve lets a bright edge gain colored rings, so the engine sharpens what the canvas shows.
|
|
376
427
|
- RCAS is robust contrast-adaptive sharpening. Each pixel reads the four neighbors that cross it. The pass takes a share of them that grows where they form an edge, and shrinks it where the ring around the pixel is noise. Flat areas and grain therefore stay as they are. It also limits the result to the colors' own range, so no channel clips and no dark or bright halo appears.
|
|
377
428
|
- It draws at the whole canvas's render scale. A render scale below 1 sharpens its own upscale, so the value adds nothing there.
|
|
@@ -389,7 +440,12 @@ An 8-bit canvas holds 256 steps of each color, and a smooth gradient between two
|
|
|
389
440
|
|
|
390
441
|
## Still-camera accumulation
|
|
391
442
|
|
|
392
|
-
|
|
443
|
+
A still view goes through these steps:
|
|
444
|
+
|
|
445
|
+
1. Each frame draws the scene with the camera moved by a fraction of a pixel, and blends it into a kept 16-bit history.
|
|
446
|
+
2. After 63 blended frames, about a second at 60 frames per second, the history holds their average. Its edges and fine detail are smoother than any one frame's.
|
|
447
|
+
3. The thread that draws then takes frames without drawing them, so the GPU rests, and the canvas keeps the sharp picture.
|
|
448
|
+
4. The first frame that changes draws at once, as a moving view does, and the blending starts again.
|
|
393
449
|
|
|
394
450
|
The engine finds a still view by comparing each frame's draw commands and uploaded values with those of the frame two frames before. It leaves out only the values that change on their own in every frame: the clock, the sub-pixel offset and the blend's weight. Anything else that changes counts as a change, so the picture never freezes while something moves. The sketch keeps running while the view rests, so `onUpdate` sees input and time as before.
|
|
395
451
|
|
|
@@ -418,3 +474,10 @@ The devices that the engine was tested on all draw HDR color with WebGL2, and wi
|
|
|
418
474
|
- [Color management](color-management.md): HDR color, the final pass and the 8-bit path.
|
|
419
475
|
- [The render graph](render-graph.md): how the passes of a frame are declared and ordered.
|
|
420
476
|
- [Quality presets](quality-presets.md): `bloomSize`, `aoScale`, `dofSamples`, the depth prepass and the frame-budget governor.
|
|
477
|
+
- [The whole chain](https://github.com/null3d-engine/null3d/tree/main/examples/post-effects): bloom, ambient occlusion, an outline, depth of field, a vignette, sharpening and color grading in one neon alley.
|
|
478
|
+
- [Depth of field](https://github.com/null3d-engine/null3d/tree/main/examples/camera-lens): the focus racks across a chess board during a dolly zoom.
|
|
479
|
+
- [Automatic exposure](https://github.com/null3d-engine/null3d/tree/main/examples/auto-exposure): a walk from a sunny courtyard into a dark hall.
|
|
480
|
+
- [Screen-space reflections](https://github.com/null3d-engine/null3d/tree/main/examples/wet-street): puddles that mirror the lit windows, the neon signs and a passing taxi.
|
|
481
|
+
- [Screen-space bounce light](https://github.com/null3d-engine/null3d/tree/main/examples/bounce-light): red and green walls that tint a gray floor and back wall.
|
|
482
|
+
- [Outlines](https://github.com/null3d-engine/null3d/tree/main/examples/picking): a click outlines the selected piece, and the hidden parts keep their own line.
|
|
483
|
+
- [Color grading tables](https://github.com/null3d-engine/null3d/tree/main/examples/compare/night-town): a city block whose color grade comes from a table, in both engines.
|
|
@@ -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
|
|
|
@@ -92,3 +91,5 @@ A memory reading under 4 GB lowers the starting preset by one.
|
|
|
92
91
|
| Texture uploads per frame (`uploadBytesPerFrame`) | 2 MiB | 4 MiB | 8 MiB | 16 MiB | during play |
|
|
93
92
|
| Texture memory budget (`textureMemoryMiB`) | 256 MiB | 512 MiB | 1024 MiB | 2048 MiB | during play |
|
|
94
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.
|