@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
package/docs/shaders/builtins.md
CHANGED
|
@@ -1,14 +1,12 @@
|
|
|
1
1
|
---
|
|
2
2
|
id: shaders/builtins
|
|
3
3
|
title: Built-in shader inputs
|
|
4
|
-
status: experimental
|
|
5
|
-
since: "0.1"
|
|
6
4
|
summary: "Camera, time, object and instance values available to custom shaders, with the camera's and the object's matrices and ids."
|
|
7
5
|
---
|
|
8
6
|
|
|
9
7
|
# Built-in shader inputs
|
|
10
8
|
|
|
11
|
-
>
|
|
9
|
+
> The built-in values hold no light values. Pass a light's direction or color to a material as a uniform.
|
|
12
10
|
|
|
13
11
|
A custom material's WGSL reads four built-in values besides its inputs: `frame`, `camera`, `object` and `material`. The engine fills them before it calls your functions, in the vertex offset and in the surface function alike. Read them anywhere in your WGSL, as global values. A [full shader](../guides/custom-shaders.md#full-shaders) imports `frame`, `camera` and `object` from `null3d::builtins`, and fills them with `fill_builtins`.
|
|
14
12
|
|
|
@@ -24,6 +22,10 @@ fn surface(input: SurfaceInput) -> Surface {
|
|
|
24
22
|
}
|
|
25
23
|
```
|
|
26
24
|
|
|
25
|
+

|
|
26
|
+
|
|
27
|
+
One material that reads frame, camera and object values. It is not the opening example.
|
|
28
|
+
|
|
27
29
|
## `frame`
|
|
28
30
|
|
|
29
31
|
The values of the frame, the same for every draw in it.
|
|
@@ -103,7 +105,7 @@ The custom material's uniforms, which the WGSL declares as `struct Uniforms`. [S
|
|
|
103
105
|
|
|
104
106
|
## What the inputs cost
|
|
105
107
|
|
|
106
|
-
|
|
108
|
+
A value that a material does not read costs nothing. The inputs in this table cost something, so only WGSL that reads them gets them:
|
|
107
109
|
|
|
108
110
|
| Input | Its cost, only where the WGSL reads it |
|
|
109
111
|
| --- | --- |
|
|
@@ -116,6 +118,15 @@ The values above that a material does not read cost it nothing. A few inputs cos
|
|
|
116
118
|
|
|
117
119
|
The pixel's position, the camera's values and `object.position` cost nothing.
|
|
118
120
|
|
|
121
|
+
A mesh that lacks the vertex colors, the vertex record or the tangent that a material reads does not draw with that material. A mesh without second texture coordinates gives its first set in their place.
|
|
122
|
+
|
|
123
|
+
<details>
|
|
124
|
+
<summary>Technical details: how the plugin finds the inputs a material reads</summary>
|
|
125
|
+
|
|
126
|
+
The plugin finds which fields the WGSL reads when it builds the material. It counts a field only where the WGSL reads it from a value of the input's type, such as the `input: VertexInput` parameter. So a structure of your own may name a field `tangent` or `colors` at no cost.
|
|
127
|
+
|
|
128
|
+
</details>
|
|
129
|
+
|
|
119
130
|
## Positions relative to the camera
|
|
120
131
|
|
|
121
132
|
The engine draws everything relative to the camera, so positions stay precise far from the origin of the world. The surface input's `relativePosition` is the position of a point relative to the camera. It is exact near the camera wherever the camera is. Use it for distances, fades and effects that depend on the view.
|
package/docs/shaders/library.md
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
id: shaders/library
|
|
3
3
|
title: Shader library and imports
|
|
4
|
-
|
|
5
|
-
since: "0.1"
|
|
4
|
+
generated: true
|
|
6
5
|
summary: "The WGSL modules that ship with the engine: math, noise, color, lighting, fog, vertex, depth and signed distance helpers, and how to import them."
|
|
7
6
|
---
|
|
8
7
|
|
|
@@ -10,7 +9,7 @@ summary: "The WGSL modules that ship with the engine: math, noise, color, lighti
|
|
|
10
9
|
|
|
11
10
|
# Shader library and imports
|
|
12
11
|
|
|
13
|
-
>
|
|
12
|
+
> A custom material's surface function, vertex offset or full shader can call these modules.
|
|
14
13
|
|
|
15
14
|
The shader library is a set of WGSL modules that ship with the engine. A shader imports a module with an `#import` line, and the build adds the functions that the shader calls. The build then translates the shader for WebGL2, so each function works on both GPU paths. The engine's own shaders use the same modules.
|
|
16
15
|
|
|
@@ -47,8 +46,8 @@ Imported names follow two rules:
|
|
|
47
46
|
| --- | --- |
|
|
48
47
|
| [`null3d::math`](#null3dmath) | Constants and small helpers that the other modules share: squares, ranges, a modulo that matches GLSL's `mod`, and rotations. |
|
|
49
48
|
| [`null3d::noise`](#null3dnoise) | Hashes, random numbers and noise. |
|
|
50
|
-
| [`null3d::color`](#null3dcolor) | Color in linear space: sRGB encoding and decoding, luminance, HSV, and the tone mapping curves
|
|
51
|
-
| [`null3d::lighting`](#null3dlighting) | Lighting in linear color: the Lambert model, and the physically based model of glTF's metallic-roughness materials with
|
|
49
|
+
| [`null3d::color`](#null3dcolor) | Color in linear space: sRGB encoding and decoding, luminance, HSV, and the tone mapping curves AgX, AgX punchy, Khronos PBR Neutral and ACES filmic. |
|
|
50
|
+
| [`null3d::lighting`](#null3dlighting) | Lighting in linear color: the Lambert model, and the physically based model of glTF's metallic-roughness materials, with Lambert diffuse light and a GGX highlight. |
|
|
52
51
|
| [`null3d::fog`](#null3dfog) | The scene's fog. |
|
|
53
52
|
| [`null3d::vertex`](#null3dvertex) | Helpers for vertex shaders: instance transforms, and positions relative to the camera. |
|
|
54
53
|
| [`null3d::depth`](#null3ddepth) | Depth values and distances. |
|
|
@@ -97,7 +96,7 @@ One over pi.
|
|
|
97
96
|
const EPSILON: f32 = 1e-6;
|
|
98
97
|
```
|
|
99
98
|
|
|
100
|
-
A small positive number that keeps a divisor away from zero
|
|
99
|
+
A small positive number, one millionth, that keeps a divisor away from zero.
|
|
101
100
|
|
|
102
101
|
### `square`
|
|
103
102
|
|
|
@@ -369,7 +368,7 @@ Fractal noise in 2D from simplex noise, from about -1 to 1.
|
|
|
369
368
|
|
|
370
369
|
## `null3d::color`
|
|
371
370
|
|
|
372
|
-
Color in linear space: sRGB encoding and decoding, luminance, HSV, and the tone mapping curves
|
|
371
|
+
Color in linear space: sRGB encoding and decoding, luminance, HSV, and the tone mapping curves AgX, AgX punchy, Khronos PBR Neutral and ACES filmic. Shaders light in linear color, and encode sRGB only at the output. The tone mapping curves take linear color that the exposure has already scaled, and return linear color from 0 to 1, ready for sRGB encoding.
|
|
373
372
|
|
|
374
373
|
### `linear_to_srgb`
|
|
375
374
|
|
|
@@ -401,7 +400,9 @@ The brightest linear color that the engine stores in a 16-bit float target: one
|
|
|
401
400
|
fn limit_hdr(c: vec3f) -> vec3f
|
|
402
401
|
```
|
|
403
402
|
|
|
404
|
-
A linear color with each channel no brighter than HDR_LIMIT, so that a 16-bit float target holds it. Infinity becomes HDR_LIMIT, and a NaN becomes 0, so it draws black.
|
|
403
|
+
A linear color with each channel no brighter than HDR_LIMIT, so that a 16-bit float target holds it. Infinity becomes HDR_LIMIT, and a NaN becomes 0, so it draws black.
|
|
404
|
+
|
|
405
|
+
The NaN test reads the bits: an exponent of all ones with a mantissa that is not 0. WGSL lets a compiler assume that no NaN exists, so a test such as `c != c` may fold to false, and `min` may return either operand for a NaN. A NaN that stays in the scene color spreads through bloom's blur over the whole picture.
|
|
405
406
|
|
|
406
407
|
### `luminance`
|
|
407
408
|
|
|
@@ -409,7 +410,7 @@ A linear color with each channel no brighter than HDR_LIMIT, so that a 16-bit fl
|
|
|
409
410
|
fn luminance(c: vec3f) -> f32
|
|
410
411
|
```
|
|
411
412
|
|
|
412
|
-
The relative luminance of a linear color, with the Rec. 709 weights
|
|
413
|
+
The relative luminance of a linear color, with the Rec. 709 weights 0.2126, 0.7152 and 0.0722.
|
|
413
414
|
|
|
414
415
|
### `rgb_to_hsv`
|
|
415
416
|
|
|
@@ -465,7 +466,7 @@ The curve fit of the ACES reference rendering transform and output device transf
|
|
|
465
466
|
fn tone_map_aces(c: vec3f) -> vec3f
|
|
466
467
|
```
|
|
467
468
|
|
|
468
|
-
ACES filmic tone mapping,
|
|
469
|
+
ACES filmic tone mapping, a fit of the ACES curve. It scales the color by 1 / 0.6 first, which suits a bright viewing place.
|
|
469
470
|
|
|
470
471
|
### `LINEAR_REC2020_TO_LINEAR_SRGB`
|
|
471
472
|
|
|
@@ -545,7 +546,7 @@ AgX's default contrast curve, as a polynomial fit.
|
|
|
545
546
|
fn tone_map_agx(c: vec3f) -> vec3f
|
|
546
547
|
```
|
|
547
548
|
|
|
548
|
-
AgX tone mapping,
|
|
549
|
+
AgX tone mapping, the curve of Blender and Filament, in Rec. 2020 primaries.
|
|
549
550
|
|
|
550
551
|
### `AGX_PUNCHY_POWER`
|
|
551
552
|
|
|
@@ -577,11 +578,11 @@ AgX tone mapping with Filament's punchy look: more contrast and more color than
|
|
|
577
578
|
fn tone_map_neutral(c: vec3f) -> vec3f
|
|
578
579
|
```
|
|
579
580
|
|
|
580
|
-
Khronos PBR Neutral tone mapping
|
|
581
|
+
Khronos PBR Neutral tone mapping. It keeps base colors under about 0.8 as they are, apart from a small offset.
|
|
581
582
|
|
|
582
583
|
## `null3d::lighting`
|
|
583
584
|
|
|
584
|
-
Lighting in linear color: the Lambert model, and the physically based model of glTF's metallic-roughness materials with
|
|
585
|
+
Lighting in linear color: the Lambert model, and the physically based model of glTF's metallic-roughness materials, with Lambert diffuse light and a GGX highlight. Directions are unit vectors that point away from the surface: `to_light` toward the light and `to_view` toward the camera. Light colors include the intensity.
|
|
585
586
|
|
|
586
587
|
### `ROUGHNESS_FLOOR`
|
|
587
588
|
|
|
@@ -589,7 +590,7 @@ Lighting in linear color: the Lambert model, and the physically based model of g
|
|
|
589
590
|
const ROUGHNESS_FLOOR: f32 = 0.045;
|
|
590
591
|
```
|
|
591
592
|
|
|
592
|
-
The lowest perceptual roughness of a surface, as Filament
|
|
593
|
+
The lowest perceptual roughness of a surface, as Filament has it. Even a mirror shows a highlight of this width, and reads a prefiltered level of the environment.
|
|
593
594
|
|
|
594
595
|
### `SPECULAR_AA_VARIANCE`
|
|
595
596
|
|
|
@@ -605,7 +606,7 @@ How much the change of the normal across a pixel widens the highlight, Filament'
|
|
|
605
606
|
const SPECULAR_AA_LIMIT: f32 = 0.01;
|
|
606
607
|
```
|
|
607
608
|
|
|
608
|
-
The most that the specular anti-aliasing kernel adds to the squared GGX alpha, so silhouettes do not turn matte: half of Filament's threshold, squared as Filament squares it. The lower limit flickers less on small glossy shapes
|
|
609
|
+
The most that the specular anti-aliasing kernel adds to the squared GGX alpha, so silhouettes do not turn matte: half of Filament's threshold, squared as Filament squares it. The lower limit flickers less on small glossy shapes.
|
|
609
610
|
|
|
610
611
|
### `lambert`
|
|
611
612
|
|
|
@@ -613,7 +614,7 @@ The most that the specular anti-aliasing kernel adds to the squared GGX alpha, s
|
|
|
613
614
|
fn lambert(albedo: vec3f, normal: vec3f, to_light: vec3f, light: vec3f, ambient: vec3f) -> vec3f
|
|
614
615
|
```
|
|
615
616
|
|
|
616
|
-
The light a Lambert surface reflects under one directional light and ambient light
|
|
617
|
+
The light a Lambert surface reflects under one directional light and ambient light. It is the albedo over pi times the irradiance. The direction `to_light` points from the surface toward the light. The colors `light` and `ambient` include their intensities.
|
|
617
618
|
|
|
618
619
|
### `brdf_lambert`
|
|
619
620
|
|
|
@@ -621,7 +622,7 @@ The light a Lambert surface reflects under one directional light and ambient lig
|
|
|
621
622
|
fn brdf_lambert(diffuse: vec3f) -> vec3f
|
|
622
623
|
```
|
|
623
624
|
|
|
624
|
-
The Lambert diffuse reflectance: the diffuse color over pi
|
|
625
|
+
The Lambert diffuse reflectance: the diffuse color over pi.
|
|
625
626
|
|
|
626
627
|
### `f_schlick`
|
|
627
628
|
|
|
@@ -629,7 +630,7 @@ The Lambert diffuse reflectance: the diffuse color over pi, as three.js's `BRDF_
|
|
|
629
630
|
fn f_schlick(f0: vec3f, f90: f32, v_dot_h: f32) -> vec3f
|
|
630
631
|
```
|
|
631
632
|
|
|
632
|
-
Schlick's Fresnel term, in the form with `exp2` that Epic gave
|
|
633
|
+
Schlick's Fresnel term, in the form with `exp2` that Epic gave. It is the reflectance at a half vector whose cosine with the view is `v_dot_h`. It runs from `f0` at normal incidence to `f90` at grazing angles.
|
|
633
634
|
|
|
634
635
|
### `d_ggx`
|
|
635
636
|
|
|
@@ -637,7 +638,7 @@ Schlick's Fresnel term, in the form with `exp2` that Epic gave and three.js's `F
|
|
|
637
638
|
fn d_ggx(alpha: f32, n_dot_h: f32) -> f32
|
|
638
639
|
```
|
|
639
640
|
|
|
640
|
-
The GGX normal distribution
|
|
641
|
+
The GGX normal distribution. `alpha` is the square of the perceptual roughness.
|
|
641
642
|
|
|
642
643
|
### `v_ggx_smith_correlated`
|
|
643
644
|
|
|
@@ -645,7 +646,7 @@ The GGX normal distribution, as three.js's `D_GGX`. `alpha` is the square of the
|
|
|
645
646
|
fn v_ggx_smith_correlated(alpha: f32, n_dot_l: f32, n_dot_v: f32) -> f32
|
|
646
647
|
```
|
|
647
648
|
|
|
648
|
-
The height-correlated Smith visibility term of GGX
|
|
649
|
+
The height-correlated Smith visibility term of GGX. It includes the 1 / (4 n.l n.v) of the microfacet model.
|
|
649
650
|
|
|
650
651
|
### `brdf_ggx`
|
|
651
652
|
|
|
@@ -653,7 +654,7 @@ The height-correlated Smith visibility term of GGX, as three.js's `V_GGX_SmithCo
|
|
|
653
654
|
fn brdf_ggx(to_light: vec3f, to_view: vec3f, normal: vec3f, f0: vec3f, f90: f32, roughness: f32) -> vec3f
|
|
654
655
|
```
|
|
655
656
|
|
|
656
|
-
The GGX specular reflectance for one light
|
|
657
|
+
The GGX specular reflectance for one light: the GGX distribution, Schlick's Fresnel term and the correlated Smith visibility term. `roughness` is perceptual. Where the light and the view cancel there is no half vector, and the result is zero.
|
|
657
658
|
|
|
658
659
|
### `v_ggx_smith_correlated_anisotropic`
|
|
659
660
|
|
|
@@ -661,7 +662,7 @@ The GGX specular reflectance for one light, as three.js's `BRDF_GGX`: the GGX di
|
|
|
661
662
|
fn v_ggx_smith_correlated_anisotropic(alpha_t: f32, alpha_b: f32, t_dot_v: f32, b_dot_v: f32, t_dot_l: f32, b_dot_l: f32, n_dot_v: f32, n_dot_l: f32) -> f32
|
|
662
663
|
```
|
|
663
664
|
|
|
664
|
-
The height-correlated Smith visibility term of a lobe whose GGX alpha is `alpha_t` along the tangent and `alpha_b` along the bitangent
|
|
665
|
+
The height-correlated Smith visibility term of a lobe whose GGX alpha is `alpha_t` along the tangent and `alpha_b` along the bitangent. The cosines `t_dot_v`, `b_dot_v`, `t_dot_l` and `b_dot_l` are of the view and the light with those two axes.
|
|
665
666
|
|
|
666
667
|
### `d_ggx_anisotropic`
|
|
667
668
|
|
|
@@ -669,7 +670,7 @@ The height-correlated Smith visibility term of a lobe whose GGX alpha is `alpha_
|
|
|
669
670
|
fn d_ggx_anisotropic(alpha_t: f32, alpha_b: f32, n_dot_h: f32, t_dot_h: f32, b_dot_h: f32) -> f32
|
|
670
671
|
```
|
|
671
672
|
|
|
672
|
-
The GGX distribution of a lobe that stretches along the tangent,
|
|
673
|
+
The GGX distribution of a lobe that stretches along the tangent, after Filament. The cosines `t_dot_h` and `b_dot_h` are of the half vector with the tangent and the bitangent.
|
|
673
674
|
|
|
674
675
|
### `brdf_ggx_physical`
|
|
675
676
|
|
|
@@ -677,7 +678,7 @@ The GGX distribution of a lobe that stretches along the tangent, as three.js's `
|
|
|
677
678
|
fn brdf_ggx_physical(m: PbrMaterial, normal: vec3f, to_view: vec3f, to_light: vec3f) -> vec3f
|
|
678
679
|
```
|
|
679
680
|
|
|
680
|
-
The GGX specular reflectance for one direct light of a physical material
|
|
681
|
+
The GGX specular reflectance for one direct light of a physical material: the distribution, the Fresnel term and the visibility term. The thin film's Fresnel term mixes in where the material is iridescent, and the lobe stretches along the tangent where it is anisotropic. Where the light and the view cancel there is no half vector, and the result is zero.
|
|
681
682
|
|
|
682
683
|
### `dfg_lut`
|
|
683
684
|
|
|
@@ -685,7 +686,7 @@ The GGX specular reflectance for one direct light of a physical material, as thr
|
|
|
685
686
|
fn dfg_lut(n_dot_v: f32, roughness: f32) -> vec2f
|
|
686
687
|
```
|
|
687
688
|
|
|
688
|
-
The scale and bias of the split-sum approximation of specular light from all directions, for a view at `n_dot_v` and a perceptual `roughness`. It reads
|
|
689
|
+
The scale and bias of the split-sum approximation of specular light from all directions, for a view at `n_dot_v` and a perceptual `roughness`. It reads the engine's 16 x 16 table of these terms, with the roughness across and the cosine down, filtered between the nearest four entries. The table sits in the materials' custom values, group 0 at binding 2, and on WebGL2 in the material table's texture, group 0 at binding 1. A shader that calls this function binds the texture of its path there too. The function reads the table with `textureLoad`, so the table needs no sampler and no filterable format.
|
|
689
690
|
|
|
690
691
|
### `environment_brdf`
|
|
691
692
|
|
|
@@ -693,7 +694,7 @@ The scale and bias of the split-sum approximation of specular light from all dir
|
|
|
693
694
|
fn environment_brdf(f0: vec3f, f90: f32, dfg: vec2f) -> vec3f
|
|
694
695
|
```
|
|
695
696
|
|
|
696
|
-
The specular reflectance of light from the environment, from the split-sum terms `dfg
|
|
697
|
+
The specular reflectance of light from the environment, from the split-sum terms `dfg`: `f0` times the scale plus `f90` times the bias.
|
|
697
698
|
|
|
698
699
|
### `Scattering`
|
|
699
700
|
|
|
@@ -715,7 +716,7 @@ Light that a surface's microfacets reflect once, and light that they reflect mor
|
|
|
715
716
|
fn multiscattering(f0: vec3f, f90: f32, dfg: vec2f) -> Scattering
|
|
716
717
|
```
|
|
717
718
|
|
|
718
|
-
The single and multiple scattering of light from all directions, after Fdez-Agüera's "Multiple-Scattering Microfacet Model for Real-Time Image Based Lighting".
|
|
719
|
+
The single and multiple scattering of light from all directions, after Fdez-Agüera's "Multiple-Scattering Microfacet Model for Real-Time Image Based Lighting". `dfg` holds the split-sum terms.
|
|
719
720
|
|
|
720
721
|
### `multiscatter_compensation`
|
|
721
722
|
|
|
@@ -723,7 +724,7 @@ The single and multiple scattering of light from all directions, after Fdez-Agü
|
|
|
723
724
|
fn multiscatter_compensation(f0: vec3f, dfg: vec2f) -> vec3f
|
|
724
725
|
```
|
|
725
726
|
|
|
726
|
-
The factor that gives direct specular light back the energy that single scattering loses on rough surfaces, after Turquin.
|
|
727
|
+
The factor that gives direct specular light back the energy that single scattering loses on rough surfaces, after Turquin. Its input `f0` is the reflectance at normal incidence, blended toward the base color by metalness.
|
|
727
728
|
|
|
728
729
|
### `specular_occlusion`
|
|
729
730
|
|
|
@@ -731,7 +732,7 @@ The factor that gives direct specular light back the energy that single scatteri
|
|
|
731
732
|
fn specular_occlusion(n_dot_v: f32, occlusion: f32, roughness: f32) -> f32
|
|
732
733
|
```
|
|
733
734
|
|
|
734
|
-
How much of the environment's specular light ambient occlusion lets through, after Lagarde and de Rousiers.
|
|
735
|
+
How much of the environment's specular light ambient occlusion lets through, after Lagarde and de Rousiers.
|
|
735
736
|
|
|
736
737
|
### `horizon_occlusion`
|
|
737
738
|
|
|
@@ -755,7 +756,7 @@ The amount that specular anti-aliasing adds to the squared GGX alpha: Filament's
|
|
|
755
756
|
fn distance_attenuation(distance: f32, cutoff: f32, decay: f32) -> f32
|
|
756
757
|
```
|
|
757
758
|
|
|
758
|
-
How a point or spot light fades with `distance
|
|
759
|
+
How a point or spot light fades with `distance`: one over the distance to the power `decay`, at most 100. When `cutoff` is more than 0, the light also fades smoothly to nothing at that distance, by the square of 1 less (distance / cutoff)^4.
|
|
759
760
|
|
|
760
761
|
### `spot_attenuation`
|
|
761
762
|
|
|
@@ -763,7 +764,7 @@ How a point or spot light fades with `distance`, as three.js's `getDistanceAtten
|
|
|
763
764
|
fn spot_attenuation(cone_cos: f32, penumbra_cos: f32, angle_cos: f32) -> f32
|
|
764
765
|
```
|
|
765
766
|
|
|
766
|
-
How a spot light fades toward the edge of its cone
|
|
767
|
+
How a spot light fades toward the edge of its cone: a smooth step from 0 at the edge to 1 where the penumbra starts. The arguments are cosines: of the cone's half angle, of the angle where the penumbra starts, and of the angle to the point.
|
|
767
768
|
|
|
768
769
|
### `hemisphere_irradiance`
|
|
769
770
|
|
|
@@ -771,7 +772,7 @@ How a spot light fades toward the edge of its cone, as three.js's `getSpotAttenu
|
|
|
771
772
|
fn hemisphere_irradiance(normal: vec3f, up: vec3f, sky: vec3f, ground: vec3f) -> vec3f
|
|
772
773
|
```
|
|
773
774
|
|
|
774
|
-
The irradiance of a hemisphere light
|
|
775
|
+
The irradiance of a hemisphere light. It blends from the ground color to the sky color as the normal turns toward `up`. The sky color's weight is half of 1 plus the cosine between the normal and `up`.
|
|
775
776
|
|
|
776
777
|
### `ambient_irradiance`
|
|
777
778
|
|
|
@@ -787,7 +788,7 @@ The irradiance at a unit `normal` from ambient and hemisphere lights, summed as
|
|
|
787
788
|
fn sh_irradiance(normal: vec3f, sh: array<vec3f, 9>) -> vec3f
|
|
788
789
|
```
|
|
789
790
|
|
|
790
|
-
The irradiance at a unit `normal` from nine spherical harmonics coefficients
|
|
791
|
+
The irradiance at a unit `normal` from nine spherical harmonics coefficients, with Ramamoorthi and Hanrahan's constants. The coefficients are in band order: the constant term, then y, z and x, then xy, yz, 3z^2 - 1, xz and x^2 - y^2.
|
|
791
792
|
|
|
792
793
|
### `PbrMaterial`
|
|
793
794
|
|
|
@@ -813,7 +814,7 @@ struct PbrMaterial {
|
|
|
813
814
|
}
|
|
814
815
|
```
|
|
815
816
|
|
|
816
|
-
A surface of glTF's metallic-roughness model at one point, set up for lighting
|
|
817
|
+
A surface of glTF's metallic-roughness model at one point, set up for lighting.
|
|
817
818
|
|
|
818
819
|
- `base_color`: The base color, which metals reflect.
|
|
819
820
|
- `diffuse`: The color of diffuse light: the base color without its metallic part.
|
|
@@ -837,7 +838,7 @@ A surface of glTF's metallic-roughness model at one point, set up for lighting a
|
|
|
837
838
|
fn pbr_material(base_color: vec3f, metalness: f32, roughness: f32, kernel: f32) -> PbrMaterial
|
|
838
839
|
```
|
|
839
840
|
|
|
840
|
-
Sets up a PbrMaterial
|
|
841
|
+
Sets up a PbrMaterial from glTF's base color, metalness and perceptual roughness, with Filament's specular anti-aliasing. It adds `kernel`, from `specular_aa_kernel`, to the squared GGX alpha of `roughness`, then keeps the result from ROUGHNESS_FLOOR to 1. Pass a kernel of 0 to leave the anti-aliasing out.
|
|
841
842
|
|
|
842
843
|
### `with_specular`
|
|
843
844
|
|
|
@@ -845,7 +846,7 @@ Sets up a PbrMaterial as three.js does, with Filament's specular anti-aliasing.
|
|
|
845
846
|
fn with_specular(m: PbrMaterial, reflectance: f32, color: vec3f, intensity: f32) -> PbrMaterial
|
|
846
847
|
```
|
|
847
848
|
|
|
848
|
-
A PbrMaterial with the dielectric specular values of glTF's KHR_materials_ior and KHR_materials_specular.
|
|
849
|
+
A PbrMaterial with the dielectric specular values of glTF's KHR_materials_ior and KHR_materials_specular. `reflectance` is `((ior - 1) / (ior + 1))^2`, which the color tints up to a reflectance of 1, and `intensity` scales. Metals keep their base color, and their grazing reflectance stays 1. A reflectance of 0.04 with a white color at full intensity gives `m` back unchanged.
|
|
849
850
|
|
|
850
851
|
### `Reflected`
|
|
851
852
|
|
|
@@ -867,7 +868,7 @@ Light that a surface reflects toward the camera, in its diffuse and specular par
|
|
|
867
868
|
fn direct_light(m: PbrMaterial, normal: vec3f, to_view: vec3f, to_light: vec3f, light: vec3f, compensation: vec3f) -> Reflected
|
|
868
869
|
```
|
|
869
870
|
|
|
870
|
-
The light that a PBR surface reflects from one direct light
|
|
871
|
+
The light that a PBR surface reflects from one direct light. `light` is the light's color after attenuation and shadows. `compensation` comes from `multiscatter_compensation`. The diffuse part leaves out the light that the specular layer reflects.
|
|
871
872
|
|
|
872
873
|
### `indirect_diffuse`
|
|
873
874
|
|
|
@@ -875,7 +876,7 @@ The light that a PBR surface reflects from one direct light, as three.js's `RE_D
|
|
|
875
876
|
fn indirect_diffuse(m: PbrMaterial, irradiance: vec3f, dfg: vec2f) -> vec3f
|
|
876
877
|
```
|
|
877
878
|
|
|
878
|
-
The diffuse light that a PBR surface reflects from ambient, hemisphere and probe light
|
|
879
|
+
The diffuse light that a PBR surface reflects from ambient, hemisphere and probe light. It leaves out the light that the specular layer reflects. `dfg` holds the split-sum terms.
|
|
879
880
|
|
|
880
881
|
### `indirect_specular`
|
|
881
882
|
|
|
@@ -883,11 +884,13 @@ The diffuse light that a PBR surface reflects from ambient, hemisphere and probe
|
|
|
883
884
|
fn indirect_specular(m: PbrMaterial, radiance: vec3f, irradiance: vec3f, dfg: vec2f) -> Reflected
|
|
884
885
|
```
|
|
885
886
|
|
|
886
|
-
The light that a PBR surface reflects from an environment map
|
|
887
|
+
The light that a PBR surface reflects from an environment map. The prefiltered reflection is `radiance`, and the environment's diffuse light is `irradiance`. The split-sum terms are in `dfg`.
|
|
887
888
|
|
|
888
889
|
## `null3d::fog`
|
|
889
890
|
|
|
890
|
-
The scene's fog. A fog factor runs from 0, no fog, to 1, where the fog color hides the surface. Fog measures each point's straight-line distance from the camera, so a point keeps its fog as the camera turns. The fog can thin with height, and can glow toward the sun. The engine's shaders mix their exposed linear color with the fog before any tone mapping and encoding.
|
|
891
|
+
The scene's fog. A fog factor runs from 0, no fog, to 1, where the fog color hides the surface. Fog measures each point's straight-line distance from the camera, so a point keeps its fog as the camera turns. The fog can thin with height, and can glow toward the sun. The engine's shaders mix their exposed linear color with the fog before any tone mapping and encoding.
|
|
892
|
+
|
|
893
|
+
Per pixel, the fog costs a square root, one `exp` and a `pow` for the sun glow. Fog that thins with height adds an `exp` and a division. The fog is a branch on the frame's values, not a permutation bit, so every scene shares the same shader builds.
|
|
891
894
|
|
|
892
895
|
### `OFF`
|
|
893
896
|
|
|
@@ -929,7 +932,7 @@ struct Fog {
|
|
|
929
932
|
shape: vec4f,
|
|
930
933
|
sun_glow: f32,
|
|
931
934
|
sun_exponent: f32,
|
|
932
|
-
|
|
935
|
+
background: f32,
|
|
933
936
|
curve: u32,
|
|
934
937
|
}
|
|
935
938
|
```
|
|
@@ -940,7 +943,7 @@ The scene's fog, as the engine writes it into each frame's values for the camera
|
|
|
940
943
|
- `shape`: Where linear fog starts in `x`, and where it hides everything in `y`. How fast the fog thins with height in `z`: 0 for fog that is the same at every height. In `w`, the fog's density at the camera's height, as a share of its density at its base height.
|
|
941
944
|
- `sun_glow`: How much of the sun's light the fog scatters toward the camera: 0 for no glow.
|
|
942
945
|
- `sun_exponent`: The power of the glow's fall away from the sun: higher values make the glow smaller.
|
|
943
|
-
- `
|
|
946
|
+
- `background`: How much of the fog the background takes, from 0 to 1: 1 gives the sky and a cube map the fog of a surface at the camera's far plane, 0 leaves them unfogged.
|
|
944
947
|
- `curve`: The fog's curve: `OFF`, `LINEAR`, `EXP2` or `EXPONENTIAL`.
|
|
945
948
|
|
|
946
949
|
### `fog_linear`
|
|
@@ -949,7 +952,7 @@ The scene's fog, as the engine writes it into each frame's values for the camera
|
|
|
949
952
|
fn fog_linear(distance: f32, near: f32, far: f32) -> f32
|
|
950
953
|
```
|
|
951
954
|
|
|
952
|
-
The factor of linear fog
|
|
955
|
+
The factor of linear fog: 0 up to `near`, 1 from `far`, and a smooth step between them. `near` must be less than `far`.
|
|
953
956
|
|
|
954
957
|
### `fog_exp2`
|
|
955
958
|
|
|
@@ -957,7 +960,7 @@ The factor of linear fog, as three.js's `Fog`: 0 up to `near`, 1 from `far`, and
|
|
|
957
960
|
fn fog_exp2(distance: f32, density: f32) -> f32
|
|
958
961
|
```
|
|
959
962
|
|
|
960
|
-
The factor of exponential squared fog,
|
|
963
|
+
The factor of exponential squared fog, 1 - exp(-(density × distance)²), for a `density` such as 0.02.
|
|
961
964
|
|
|
962
965
|
### `fog_exponential`
|
|
963
966
|
|
|
@@ -999,6 +1002,30 @@ fn apply_fog(c: vec3f, fog_color: vec3f, factor: f32) -> vec3f
|
|
|
999
1002
|
|
|
1000
1003
|
A color seen through fog: `c` blended toward `fog_color` by the fog factor.
|
|
1001
1004
|
|
|
1005
|
+
### `background_share`
|
|
1006
|
+
|
|
1007
|
+
```wgsl
|
|
1008
|
+
fn background_share(fog: Fog, direction: vec3f, far: f32) -> f32
|
|
1009
|
+
```
|
|
1010
|
+
|
|
1011
|
+
The share of fog over the background along `direction`, `far` from the camera, from 0, no fog, to `fog.background`, the most that the background takes. It is the fog that a surface at that distance takes, so the far edge of the land and the sky behind it meet on one color. The direction's rise shortens the path through fog that thins with height, which leaves the sky overhead lighter than the haze at the horizon.
|
|
1012
|
+
|
|
1013
|
+
### `fogged_background`
|
|
1014
|
+
|
|
1015
|
+
```wgsl
|
|
1016
|
+
fn fogged_background(fog: Fog, color: vec3f, direction: vec3f, far: f32, light_direction: vec3f, light_color: vec3f) -> vec3f
|
|
1017
|
+
```
|
|
1018
|
+
|
|
1019
|
+
A background's exposed linear color after the fog, mixed toward the fog's own as the mesh shaders mix theirs: the fog color plus the light that the fog scatters toward the camera.
|
|
1020
|
+
|
|
1021
|
+
### `background_clear`
|
|
1022
|
+
|
|
1023
|
+
```wgsl
|
|
1024
|
+
fn background_clear(fog: Fog, direction: vec3f, far: f32) -> f32
|
|
1025
|
+
```
|
|
1026
|
+
|
|
1027
|
+
How much of a background's own light survives the fog along `direction`, `far` from the camera: 1 where the background takes no fog, and 0 where the fog hides everything. A light that a pass adds over the sky, such as a cloud's, dims by this, so it sits in the fog that the sky behind it takes instead of standing out of it.
|
|
1028
|
+
|
|
1002
1029
|
## `null3d::vertex`
|
|
1003
1030
|
|
|
1004
1031
|
Helpers for vertex shaders: instance transforms, and positions relative to the camera. The engine stores each instance's world transform as three rows of a 3 x 4 affine matrix. It draws everything relative to the camera, so positions stay precise far from the origin. Each frame, it moves each transform by the offset from the camera to the transform's grid cell. The frame's view-projection matrix then puts the camera at the origin.
|
|
@@ -1109,7 +1136,7 @@ A position relative to the camera in clip space, through a view-projection matri
|
|
|
1109
1136
|
|
|
1110
1137
|
## `null3d::depth`
|
|
1111
1138
|
|
|
1112
|
-
Depth values and distances. The engine draws with reversed depth on both GPU paths. Depth is 1 at the near plane and 0 at the far plane, which spreads a float's precision evenly over distance. Both paths store the same depth values, so these helpers work on each. View-space z is negative in front of the camera
|
|
1139
|
+
Depth values and distances. The engine draws with reversed depth on both GPU paths. Depth is 1 at the near plane and 0 at the far plane, which spreads a float's precision evenly over distance. Both paths store the same depth values, so these helpers work on each. View-space z is negative in front of the camera.
|
|
1113
1140
|
|
|
1114
1141
|
### `perspective_depth_to_view_z`
|
|
1115
1142
|
|