@ignifx/core 0.14.0 → 0.15.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (51) hide show
  1. package/dist/agx-tone-mapping-Cgt844j6.js +53 -0
  2. package/dist/agx-tone-mapping-Cgt844j6.js.map +1 -0
  3. package/dist/auto-exposure-uzPn0beO.js +246 -0
  4. package/dist/auto-exposure-uzPn0beO.js.map +1 -0
  5. package/dist/bloom-hdr-CLtQj-oY.js +315 -0
  6. package/dist/bloom-hdr-CLtQj-oY.js.map +1 -0
  7. package/dist/contact-shadows-T523EXaP.js +84 -0
  8. package/dist/contact-shadows-T523EXaP.js.map +1 -0
  9. package/dist/{environment-Cq2BmA96.js → environment-DPi0_0SP.js} +18 -4
  10. package/dist/environment-DPi0_0SP.js.map +1 -0
  11. package/dist/gtao-_nr0b6-E.js +630 -0
  12. package/dist/gtao-_nr0b6-E.js.map +1 -0
  13. package/dist/hdr-output-BrUvpAsE.js +525 -0
  14. package/dist/hdr-output-BrUvpAsE.js.map +1 -0
  15. package/dist/index.d.ts +452 -20
  16. package/dist/index.d.ts.map +1 -1
  17. package/dist/index.js +900 -43
  18. package/dist/index.js.map +1 -1
  19. package/dist/{instanced-mesh-instance-DYwH0vLi.js → instanced-mesh-instance-NnODkvqK.js} +2 -2
  20. package/dist/{instanced-mesh-instance-DYwH0vLi.js.map → instanced-mesh-instance-NnODkvqK.js.map} +1 -1
  21. package/dist/mat4-D6exvAuO.js +949 -0
  22. package/dist/mat4-D6exvAuO.js.map +1 -0
  23. package/dist/{render-path-Dx0learj.js → render-path-Be7WgN7r.js} +35 -4
  24. package/dist/render-path-Be7WgN7r.js.map +1 -0
  25. package/dist/{render-texture-IuR0iFVa.js → render-texture-C_TnaSz2.js} +28 -2
  26. package/dist/render-texture-C_TnaSz2.js.map +1 -0
  27. package/dist/scene-color-passes-DlNr-qyZ.js +65 -0
  28. package/dist/scene-color-passes-DlNr-qyZ.js.map +1 -0
  29. package/dist/scene-inputs-BxGOsnIZ.js +318 -0
  30. package/dist/scene-inputs-BxGOsnIZ.js.map +1 -0
  31. package/dist/{shader-material-CDQ0Y5kN.js → shader-material-B6p66wB8.js} +17 -6
  32. package/dist/shader-material-B6p66wB8.js.map +1 -0
  33. package/dist/{shader-material-BPb_oEZQ.js → shader-material-C0TAUr4t.js} +102 -4
  34. package/dist/shader-material-C0TAUr4t.js.map +1 -0
  35. package/dist/ssgi-Dm-maZrc.js +113 -0
  36. package/dist/ssgi-Dm-maZrc.js.map +1 -0
  37. package/dist/{surface-shader-CwQ03yHG.js → surface-shader-BaK0kvBB.js} +2 -2
  38. package/dist/{surface-shader-CwQ03yHG.js.map → surface-shader-BaK0kvBB.js.map} +1 -1
  39. package/dist/taa-BwBZLy11.js +480 -0
  40. package/dist/taa-BwBZLy11.js.map +1 -0
  41. package/dist/{vec3-T2PasQZv.js → vec3-D-0Y2mzE.js} +4 -948
  42. package/dist/vec3-D-0Y2mzE.js.map +1 -0
  43. package/package.json +1 -1
  44. package/dist/environment-Cq2BmA96.js.map +0 -1
  45. package/dist/hdr-output-DDpIo4Q5.js +0 -300
  46. package/dist/hdr-output-DDpIo4Q5.js.map +0 -1
  47. package/dist/render-path-Dx0learj.js.map +0 -1
  48. package/dist/render-texture-IuR0iFVa.js.map +0 -1
  49. package/dist/shader-material-BPb_oEZQ.js.map +0 -1
  50. package/dist/shader-material-CDQ0Y5kN.js.map +0 -1
  51. package/dist/vec3-T2PasQZv.js.map +0 -1
package/dist/index.js CHANGED
@@ -1,15 +1,16 @@
1
1
  import { a as CORE_ERROR_MESSAGES, c as THIRD_PARTY_ERROR_PREFIX, i as isIgnifxError, l as isValidErrorCode, n as assertNever, o as CoreErrorCode, r as formatErrorMessage, s as ErrorRange, t as IgnifxError } from "./ignifx-error-oYdVnT1S.js";
2
2
  import { _ as smoothStep, a as clamp, c as deltaAngleDegrees, d as lerpAngleDegrees, f as moveTowards, g as sign, h as repeat, i as approximately, l as inverseLerp, m as radToDeg, n as EPSILON, o as clamp01, p as pingPong, r as RAD_TO_DEG, s as degToRad, t as DEG_TO_RAD, u as lerp, v as wrapAngleDegrees } from "./math-utils-BcDnL-gi.js";
3
- import { $ as basisToQuatToRef, A as setMeshReceiveShadows, B as localPosition, C as overrideSubtreeMaterials, D as setMeshId, E as setMeshBounds, F as updateMeshPositions$1, G as readWorldMatrix, H as localScale, I as updateMeshUvs$1, J as setNodeSelfVisible, K as reparentKeepingWorld, L as createNode, M as setMeshSubtreeVisible, N as updateMeshColors$1, O as setMeshMaterial, P as updateMeshNormals$1, Q as Mat4, R as disposeNode, S as disposeMeshTemplate, T as removeMeshFromScene, U as parentNode, V as localRotation, W as readNodeTag, X as worldMatrixVersion, Y as tagNode, Z as MAT4_IDENTITY, _ as createMeshFromGeometry, a as VEC3_ONE, b as createTorusMesh, c as VEC3_ZERO, d as cloneMeshUnderNode, f as collectSubtreeMeshes, g as createGroundMesh, h as createCylinderMesh, i as VEC3_LEFT, j as setMeshRenderOrder, k as setMeshPickable, l as Vec3, m as createCapsuleMesh, n as VEC3_DOWN, o as VEC3_RIGHT, p as createBoxMesh, q as setNodeName, r as VEC3_FORWARD, s as VEC3_UP, t as VEC3_BACKWARD, u as addMeshToScene, v as createPlaneMesh, w as recomputeMeshBounds, x as detachMeshBounds, y as createSphereMesh, z as linkParent } from "./vec3-T2PasQZv.js";
3
+ import { n as Mat4, r as basisToQuatToRef, t as MAT4_IDENTITY } from "./mat4-D6exvAuO.js";
4
+ import { A as setMeshReceiveShadows, B as localPosition, C as overrideSubtreeMaterials, D as setMeshId, E as setMeshBounds, F as updateMeshPositions$1, G as readWorldMatrix, H as localScale, I as updateMeshUvs$1, J as setNodeSelfVisible, K as reparentKeepingWorld, L as createNode, M as setMeshSubtreeVisible, N as updateMeshColors$1, O as setMeshMaterial, P as updateMeshNormals$1, R as disposeNode, S as disposeMeshTemplate, T as removeMeshFromScene, U as parentNode, V as localRotation, W as readNodeTag, X as worldMatrixVersion, Y as tagNode, _ as createMeshFromGeometry, a as VEC3_ONE, b as createTorusMesh, c as VEC3_ZERO, d as cloneMeshUnderNode, f as collectSubtreeMeshes, g as createGroundMesh, h as createCylinderMesh, i as VEC3_LEFT, j as setMeshRenderOrder, k as setMeshPickable, l as Vec3, m as createCapsuleMesh, n as VEC3_DOWN, o as VEC3_RIGHT, p as createBoxMesh, q as setNodeName, r as VEC3_FORWARD, s as VEC3_UP, t as VEC3_BACKWARD, u as addMeshToScene, v as createPlaneMesh, w as recomputeMeshBounds, x as detachMeshBounds, y as createSphereMesh, z as linkParent } from "./vec3-D-0Y2mzE.js";
4
5
  import { t as Color } from "./color-DrR6GFTd.js";
5
- import { a as readSceneImageProcessing, c as setSceneEnvironmentRotation, l as setSceneFog, n as installSceneEnvironment, o as setSceneClearColor, r as loadSceneEnvironment, s as setSceneEnvironmentBlur, t as TONE_MAPPING_NAMES, u as setSceneImageProcessingOptions } from "./environment-Cq2BmA96.js";
6
+ import { a as readSceneImageProcessing, c as setSceneEnvironmentRotation, l as setSceneFog, n as installSceneEnvironment, o as setSceneClearColor, r as loadSceneEnvironment, s as setSceneEnvironmentBlur, t as TONE_MAPPING_NAMES, u as setSceneImageProcessingOptions } from "./environment-DPi0_0SP.js";
6
7
  import { a as markMaterialDirty, c as setPbrBaseColor, i as createStandardMaterialFromProps, l as setPbrMetallicRoughness, n as createDefaultMaterial, r as createPbrMaterialFromProps, s as setMaterialAlpha, t as MATERIAL_ALPHA_MODES } from "./material-CGk5mAah.js";
7
8
  import { t as setOwnJsonProperty } from "./json-CzZZ6K4x.js";
8
9
  import { a as postEffectValuesCodec, i as declaredTextureBinding, n as POST_EFFECT_FUNCTION, o as asJsonArray, r as customEffect, s as asJsonObject, t as POST_EFFECT_BUILTIN_UNIFORMS } from "./post-effect-BHl7U56q.js";
9
- import { n as installOffscreenRenderPath } from "./render-path-Dx0learj.js";
10
+ import { n as installOffscreenRenderPath } from "./render-path-Be7WgN7r.js";
10
11
  import { a as SHADER_BLEND_MODES, c as SHADER_KINDS, d as SURFACE_HOOK_NAMES, f as SURFACE_UNIFORM_BLOCK, i as SHADER_ATTRIBUTE_NAMES, l as SHADER_TEXTURE_FALLBACKS, o as SHADER_CULL_MODES, r as LITE_SYSTEM_UNIFORM_NAMES, s as SHADER_INSTANCING_MODES, t as IGNIFX_UNIFORM_NAMES, u as SHADER_UNIFORM_TYPES } from "./shader-declaration-5q__jycG.js";
11
12
  import { a as defineMaterialPlugin, i as MATERIAL_PLUGIN_SAMPLER_BUDGET, n as MATERIAL_PLUGIN_DEFAULT_PRIORITY, o as isLiteMaterialPluginPoint, r as MATERIAL_PLUGIN_RESERVED_NAMES, t as LITE_MATERIAL_PLUGIN_POINTS } from "./material-plugin-BUlqLsap.js";
12
- import { acquireTexture, addTask, addToScene, buildFrameGraphTask, captureScreenshot, cloneTransformNode, createBloomPostProcessTask, createCsmDirectionalShadowGenerator, createDirectionalLight, createEngine, createEsmDirectionalShadowGenerator, createFontFromBuffer, createFreeCamera, createGpuPicker, createHemisphericLight, createImageProcessingTask, createMeshFromData, createNullEngine, createPcfDirectionalShadowGenerator, createPcfSpotlightShadowGenerator, createPointLight, createRenderTarget, createSceneContext, createSmaaPostProcessTask, createSpotLight, createStorageBuffer, createTexture2DFromPixels, disableOrthographicCamera, disposeEngine, disposePicker, disposeScene, disposeStorageBuffer, enableBoneControl, enableDeviceLostSceneRecovery, enableMaterialPlugins, enableMaterialStencil, enableOrthographicCamera, enablePbrLightmap, enableSkeletonShadows, enableStandardSkeleton, forceWebGpuDeviceLossForTesting, getEffectiveAspectRatio, getFrameGraph, getProjectionMatrix, getRenderTaskGpuTimings, getViewMatrix, getViewProjectionMatrix, isPbrMaterial, isShaderMaterial, loadTexture2D, onBeforeRender, pickAsync, pickWithRay, rebuildSceneRenderables, registerScene, registerSceneWithShadowSupport, releaseTexture, removeFromScene, resizeEngine, resolveCameraViewport, setGpuTimingEnabled, setShadowTaskCasterMeshes, setSubtreeVisible, setSurfaceSize, startEngine, stopEngine, updateStorageBuffer, updateTexture2DFromPixels } from "@babylonjs/lite";
13
+ import { acquireTexture, addTask, addToScene, buildFrameGraphTask, captureScreenshot, cloneTransformNode, createBloomPostProcessTask, createCsmDirectionalShadowGenerator, createDirectionalLight, createEngine, createEsmDirectionalShadowGenerator, createFontFromBuffer, createFreeCamera, createGpuPicker, createHemisphericLight, createImageProcessingTask, createMeshFromData, createNullEngine, createPcfDirectionalShadowGenerator, createPcfSpotlightShadowGenerator, createPointLight, createRenderTarget, createSceneContext, createSmaaPostProcessTask, createSpotLight, createStorageBuffer, createTexture2DFromPixels, disableOrthographicCamera, disposeEngine, disposePicker, disposeScene, disposeStorageBuffer, enableBoneControl, enableDeviceLostSceneRecovery, enableMaterialPlugins, enableMaterialStencil, enableOrthographicCamera, enablePbrLightmap, enableSkeletonShadows, enableStandardSkeleton, forceWebGpuDeviceLossForTesting, getEffectiveAspectRatio, getFrameGraph, getProjectionMatrix, getRenderTaskGpuTimings, getViewMatrix, getViewProjectionMatrix, isPbrMaterial, isShaderMaterial, loadTexture2D, onBeforeRender, pickAsync, pickWithRay, rebuildSceneRenderables, registerScene, registerSceneWithShadowSupport, releaseTexture, removeFromScene, resizeEngine, resolveCameraViewport, setGpuTimingEnabled, setRenderTaskGpuTimingEnabled, setShadowTaskCasterMeshes, setSubtreeVisible, setSurfaceSize, startEngine, stopEngine, updateStorageBuffer, updateTexture2DFromPixels } from "@babylonjs/lite";
13
14
  //#region src/signal/signal.ts
14
15
  /** One attached handler. `handler === null` marks the entry dead and awaiting compaction. */
15
16
  var Connection = class {
@@ -4816,7 +4817,7 @@ function createServiceKey(name) {
4816
4817
  *
4817
4818
  * @public
4818
4819
  */
4819
- const VERSION = "0.14.0";
4820
+ const VERSION = "0.15.0";
4820
4821
  //#endregion
4821
4822
  //#region src/assets/delivery-system.ts
4822
4823
  /**
@@ -7173,7 +7174,7 @@ function environmentSchema() {
7173
7174
  //#endregion
7174
7175
  //#region src/render/instanced-mesh-support.ts
7175
7176
  /** The dynamically imported adapter, memoised for the process. */
7176
- let layer = null;
7177
+ let layer$1 = null;
7177
7178
  /**
7178
7179
  * Loads the thin-instance adapter, once per process.
7179
7180
  *
@@ -7182,8 +7183,8 @@ let layer = null;
7182
7183
  * @internal
7183
7184
  */
7184
7185
  async function loadInstancedMeshSupport() {
7185
- const loaded = layer ?? await import("./instanced-mesh-instance-DYwH0vLi.js");
7186
- layer = loaded;
7186
+ const loaded = layer$1 ?? await import("./instanced-mesh-instance-NnODkvqK.js");
7187
+ layer$1 = loaded;
7187
7188
  return loaded;
7188
7189
  }
7189
7190
  /**
@@ -7194,7 +7195,7 @@ async function loadInstancedMeshSupport() {
7194
7195
  * @internal
7195
7196
  */
7196
7197
  function instancedMeshSupport() {
7197
- return layer;
7198
+ return layer$1;
7198
7199
  }
7199
7200
  //#endregion
7200
7201
  //#region src/render/shader-support.ts
@@ -7210,7 +7211,7 @@ let surfaceLayer = null;
7210
7211
  * @internal
7211
7212
  */
7212
7213
  async function loadShaderSupport() {
7213
- const loaded = shaderLayer ?? await import("./shader-material-CDQ0Y5kN.js").then((n) => n.n);
7214
+ const loaded = shaderLayer ?? await import("./shader-material-B6p66wB8.js").then((n) => n.n);
7214
7215
  shaderLayer = loaded;
7215
7216
  await loaded.loadShaderMaterialAdapter();
7216
7217
  return loaded;
@@ -7233,7 +7234,7 @@ function shaderSupport() {
7233
7234
  * @internal
7234
7235
  */
7235
7236
  async function loadSurfaceShaderSupport() {
7236
- const loaded = surfaceLayer ?? await import("./surface-shader-CwQ03yHG.js");
7237
+ const loaded = surfaceLayer ?? await import("./surface-shader-BaK0kvBB.js");
7237
7238
  surfaceLayer = loaded;
7238
7239
  return loaded;
7239
7240
  }
@@ -9099,12 +9100,29 @@ function enableGpuTiming(engine) {
9099
9100
  setGpuTimingEnabled(engine, true);
9100
9101
  }
9101
9102
  /**
9103
+ * Turns per-task GPU timing on or off, so `readRenderTaskGpuTimings` reports each frame-graph task.
9104
+ *
9105
+ * @remarks
9106
+ * Lite keeps this separate from whole-frame timing (`enableGpuTiming`), and loads its profiler with
9107
+ * a dynamic import on the first enable, so the snapshot reads `"pending"` until a later frame's
9108
+ * readback lands. Without `timestamp-query` it reads `"unsupported"`.
9109
+ *
9110
+ * @param engine - The engine to measure.
9111
+ * @param enabled - Whether to time each task.
9112
+ * @returns A promise that settles once the profiler is installed (or removed).
9113
+ *
9114
+ * @internal
9115
+ */
9116
+ async function setRenderTaskGpuTiming(engine, enabled) {
9117
+ await setRenderTaskGpuTimingEnabled(engine, enabled);
9118
+ }
9119
+ /**
9102
9120
  * Reads the latest per-task GPU timing snapshot.
9103
9121
  *
9104
9122
  * @remarks
9105
9123
  * Check `status` first: `"unsupported"` on a device without timestamp queries, `"disabled"` until
9106
9124
  * per-task timing is switched on, `"pending"` until the first readback lands, `"error"` when the
9107
- * readback failed. `tasks` is in frame execution order and its names are the frame graph's own —
9125
+ * readback failed, `"available"` otherwise. `tasks` is in frame execution order and its names are the frame graph's own —
9108
9126
  * `"shadow"`, `"scene"`, and whatever a post-process task was named.
9109
9127
  *
9110
9128
  * @param engine - The engine to read.
@@ -10236,14 +10254,29 @@ function readTargetSizePx(engine, out) {
10236
10254
  readSurfaceSizePx(engine, out);
10237
10255
  }
10238
10256
  /**
10239
- * Turns whole-frame GPU timing on.
10257
+ * Turns whole-frame and per-task GPU timing on.
10240
10258
  *
10241
10259
  * @param engine - The engine to measure.
10260
+ * @returns A promise that settles once per-task timing is installed; until then `readTaskTimings`
10261
+ * reads `"pending"`.
10242
10262
  *
10243
10263
  * @internal
10244
10264
  */
10245
- function startGpuTiming(engine) {
10265
+ async function startGpuTiming(engine) {
10246
10266
  enableGpuTiming(engine);
10267
+ await setRenderTaskGpuTiming(engine, true);
10268
+ }
10269
+ /**
10270
+ * Turns per-task GPU timing off. Whole-frame timing is turned off by `disableGpuTiming`, which
10271
+ * needs no device.
10272
+ *
10273
+ * @param engine - The engine to stop measuring.
10274
+ * @returns A promise that settles once the profiler is removed.
10275
+ *
10276
+ * @internal
10277
+ */
10278
+ async function stopTaskTiming(engine) {
10279
+ await setRenderTaskGpuTiming(engine, false);
10247
10280
  }
10248
10281
  /**
10249
10282
  * Reads the latest per-task GPU timing snapshot, in ignifx's own shape.
@@ -10281,7 +10314,7 @@ function readTaskTimings(engine) {
10281
10314
  * @internal
10282
10315
  */
10283
10316
  async function loadRenderTextureFactory() {
10284
- return (await import("./render-texture-IuR0iFVa.js")).createLiteRenderTexture;
10317
+ return (await import("./render-texture-C_TnaSz2.js")).createLiteRenderTexture;
10285
10318
  }
10286
10319
  //#endregion
10287
10320
  //#region src/render/image-processing-color.ts
@@ -10403,6 +10436,9 @@ function applyCurve(curve, color) {
10403
10436
  case "neutral":
10404
10437
  neutral(color);
10405
10438
  return;
10439
+ case "agx":
10440
+ agx(color);
10441
+ return;
10406
10442
  default: assertNever(curve, "tone mapping");
10407
10443
  }
10408
10444
  }
@@ -10463,6 +10499,45 @@ function neutral(color) {
10463
10499
  color.g = color.g * scale + (newPeak - color.g * scale) * blend;
10464
10500
  color.b = color.b * scale + (newPeak - color.b * scale) * blend;
10465
10501
  }
10502
+ /** The lowest exposure AgX encodes, in EV around 0.18 grey. */
10503
+ const AGX_MIN_EV = -12.47393;
10504
+ /** The highest exposure AgX encodes, in EV around 0.18 grey. */
10505
+ const AGX_MAX_EV = 4.026069;
10506
+ /**
10507
+ * ignifx's AgX (`src/lite/gpu/agx-tone-mapping.ts`, Benjamin Wendt's minimal AgX base): inset,
10508
+ * log2 encode, the polynomial sigmoid, outset, then back to linear with `pow(c, 2.2)`.
10509
+ *
10510
+ * @param color - The exposed colour; overwritten.
10511
+ */
10512
+ function agx(color) {
10513
+ const r = agxEncode(.842479062253094 * color.r + .0784335999999992 * color.g + .0792237451477643 * color.b);
10514
+ const g = agxEncode(.0423282422610123 * color.r + .878468636469772 * color.g + .0791661274605434 * color.b);
10515
+ const b = agxEncode(.0423756549057051 * color.r + .0784336 * color.g + .879142973793104 * color.b);
10516
+ color.r = agxDecode(1.19687900512017 * r - .0980208811401368 * g - .0990297440797205 * b);
10517
+ color.g = agxDecode(-.0528968517574562 * r + 1.15190312990417 * g - .0989611768448433 * b);
10518
+ color.b = agxDecode(-.0529716355144438 * r - .0980434501171241 * g + 1.15107367264116 * b);
10519
+ }
10520
+ /**
10521
+ * One inset channel through AgX's log2 encode and its default-contrast sigmoid.
10522
+ *
10523
+ * @param value - The inset channel.
10524
+ * @returns The display-encoded channel.
10525
+ */
10526
+ function agxEncode(value) {
10527
+ const x = (Math.min(Math.max(Math.log2(Math.max(value, 1e-10)), AGX_MIN_EV), AGX_MAX_EV) - AGX_MIN_EV) / 16.499999;
10528
+ const x2 = x * x;
10529
+ const x4 = x2 * x2;
10530
+ return 15.5 * x4 * x2 - 40.14 * x4 * x + 31.96 * x4 - 6.868 * x2 * x + .4298 * x2 + .1191 * x - .00232;
10531
+ }
10532
+ /**
10533
+ * One outset channel back to linear, as the WGSL does before Lite's encode.
10534
+ *
10535
+ * @param value - The outset channel.
10536
+ * @returns The linear channel.
10537
+ */
10538
+ function agxDecode(value) {
10539
+ return Math.max(value, 0) ** GAMMA;
10540
+ }
10466
10541
  /**
10467
10542
  * Clamps to `[0, 1]`.
10468
10543
  *
@@ -10481,6 +10556,18 @@ function saturate(value) {
10481
10556
  */
10482
10557
  const RENDER_TEXTURE_MAX_SIZE = 4096;
10483
10558
  /**
10559
+ * The Babylon Lite `metadata` key that keeps a render-scene mesh out of every render texture.
10560
+ *
10561
+ * @remarks
10562
+ * A mesh whose `metadata[EDITOR_ONLY_METADATA_KEY]` is `true` draws in the main view but never in
10563
+ * a {@link RenderTexture}: an editor's grid or helper that must not show in its game view or
10564
+ * thumbnails. Set it on a mesh reached through a `.lite` escape hatch, such as
10565
+ * `RenderOverlay.lite.mainScene` (no stability guarantee, `CONSTITUTION.md` §3.4).
10566
+ *
10567
+ * @beta
10568
+ */
10569
+ const EDITOR_ONLY_METADATA_KEY = "ignifxEditorOnly";
10570
+ /**
10484
10571
  * Checks a render texture's size.
10485
10572
  *
10486
10573
  * @param width - The requested width.
@@ -10687,6 +10774,13 @@ function renderTextureUnusableError(member) {
10687
10774
  */
10688
10775
  const CANVAS_ALPHA_MODES = ["opaque", "premultiplied"];
10689
10776
  /**
10777
+ * The ambient-occlusion qualities, in the order the inspector lists them: `"half"` computes GTAO at
10778
+ * half resolution with 2 slices of 4 steps a side, `"full"` at full resolution with 3 slices of 6.
10779
+ *
10780
+ * @public
10781
+ */
10782
+ const AMBIENT_OCCLUSION_QUALITIES = ["half", "full"];
10783
+ /**
10690
10784
  * The name the `rendering` project settings section is registered under.
10691
10785
  *
10692
10786
  * @public
@@ -10702,6 +10796,46 @@ const DEFAULT_BRDF_LUT_ADDRESS = "environments/brdf-lut.png";
10702
10796
  const DEFAULT_MSAA_SAMPLES = 4;
10703
10797
  /** The only other sample count WebGPU allows for a multisampled attachment. */
10704
10798
  const SINGLE_SAMPLE = 1;
10799
+ /**
10800
+ * The auto exposure a project that names none gets: off, metering EV −6 to 6, adapting at 2 per
10801
+ * second towards brighter scenes and 1 towards darker ones, with no compensation.
10802
+ *
10803
+ * @returns A fresh record.
10804
+ *
10805
+ * @public
10806
+ */
10807
+ function defaultAutoExposureSettings() {
10808
+ return {
10809
+ enabled: false,
10810
+ minEv: -6,
10811
+ maxEv: 6,
10812
+ speedUp: 2,
10813
+ speedDown: 1,
10814
+ compensation: 0
10815
+ };
10816
+ }
10817
+ /** The ambient-occlusion section a project that names none gets. */
10818
+ const DEFAULT_AMBIENT_OCCLUSION = {
10819
+ enabled: false,
10820
+ quality: "half",
10821
+ radius: .5,
10822
+ intensity: 1,
10823
+ falloff: .6
10824
+ };
10825
+ /**
10826
+ * The TAA record a project that names none gets: off.
10827
+ *
10828
+ * @returns A fresh record.
10829
+ */
10830
+ function defaultTaaSettings() {
10831
+ return {
10832
+ enabled: false,
10833
+ blend: .1,
10834
+ sharpness: 0,
10835
+ clamp: true,
10836
+ cutDistance: 10
10837
+ };
10838
+ }
10705
10839
  /** The clear colour a project that names none gets: opaque black. */
10706
10840
  const DEFAULT_CLEAR_COLOR = "#000000";
10707
10841
  /**
@@ -10738,7 +10872,10 @@ function defaultRenderingSettings() {
10738
10872
  a: 1
10739
10873
  },
10740
10874
  brdfLut: DEFAULT_BRDF_LUT_ADDRESS,
10741
- hdr: false
10875
+ hdr: false,
10876
+ autoExposure: defaultAutoExposureSettings(),
10877
+ ambientOcclusion: { ...DEFAULT_AMBIENT_OCCLUSION },
10878
+ taa: defaultTaaSettings()
10742
10879
  };
10743
10880
  }
10744
10881
  /**
@@ -10779,10 +10916,94 @@ function renderingSettingsSchema() {
10779
10916
  requiredLimits: map(f64(0, { min: 0 }), { tooltip: "Extra WebGPU device limits to request." }),
10780
10917
  clearColor: color(DEFAULT_CLEAR_COLOR, { tooltip: "The colour the scene is cleared to, in sRGB. A Camera or Environment overrides it." }),
10781
10918
  brdfLut: str(DEFAULT_BRDF_LUT_ADDRESS, { tooltip: "Address of the RGBD BRDF lookup table." }),
10782
- hdr: bool(false, { tooltip: "Render in HDR (rgba16float) and tone map in one final pass. PBR materials only for now." })
10919
+ hdr: bool(false, { tooltip: "Render in HDR (rgba16float) and tone map in one final pass. Custom post effects ordered first see linear colour." }),
10920
+ autoExposure: record({
10921
+ enabled: bool(false, { tooltip: "Meter the HDR scene and adapt the exposure. Needs hdr." }),
10922
+ minEv: f64(-6, { tooltip: "Darkest metered EV (log2 luminance) the exposure follows." }),
10923
+ maxEv: f64(6, { tooltip: "Brightest metered EV (log2 luminance) the exposure follows." }),
10924
+ speedUp: f64(2, {
10925
+ min: 0,
10926
+ tooltip: "Adaptation rate per second when the scene gets brighter."
10927
+ }),
10928
+ speedDown: f64(1, {
10929
+ min: 0,
10930
+ tooltip: "Adaptation rate per second when the scene gets darker."
10931
+ }),
10932
+ compensation: f64(0, { tooltip: "Stops added to the computed exposure; positive is brighter." })
10933
+ }),
10934
+ ambientOcclusion: record({
10935
+ enabled: bool(false, { tooltip: "Screen-space ambient occlusion (GTAO) on environment light." }),
10936
+ quality: enumOf(AMBIENT_OCCLUSION_QUALITIES, DEFAULT_AMBIENT_OCCLUSION.quality, { tooltip: "half: half resolution, 2 slices × 4 steps. full: full resolution, 3 slices × 6 steps." }),
10937
+ radius: f64(DEFAULT_AMBIENT_OCCLUSION.radius, {
10938
+ min: .01,
10939
+ tooltip: "How far an occluder may be from the surface it darkens, in metres."
10940
+ }),
10941
+ intensity: f64(DEFAULT_AMBIENT_OCCLUSION.intensity, {
10942
+ min: 0,
10943
+ max: 8,
10944
+ tooltip: "Exponent on the visibility: 1 is physically based, larger is darker."
10945
+ }),
10946
+ falloff: f64(DEFAULT_AMBIENT_OCCLUSION.falloff, {
10947
+ min: 0,
10948
+ max: 1,
10949
+ tooltip: "Fraction of the radius over which occluders fade out."
10950
+ })
10951
+ }),
10952
+ taa: record({
10953
+ enabled: bool(false, { tooltip: "Temporal anti-aliasing. Needs rendering.hdr." }),
10954
+ blend: f64(.1, {
10955
+ min: .01,
10956
+ max: 1,
10957
+ tooltip: "Weight of the current frame; lower is smoother."
10958
+ }),
10959
+ sharpness: f64(0, {
10960
+ min: 0,
10961
+ max: 1,
10962
+ tooltip: "Output sharpening, 0 to 1."
10963
+ }),
10964
+ clamp: bool(true, { tooltip: "Clip history to the current neighbourhood, against ghosting." }),
10965
+ cutDistance: f64(10, {
10966
+ min: 0,
10967
+ tooltip: "Camera jump per frame, in world units, that resets history."
10968
+ })
10969
+ }, { tooltip: "Temporal anti-aliasing (jittered frames accumulated over time). Needs rendering.hdr." })
10783
10970
  });
10784
10971
  }
10785
10972
  /**
10973
+ * Reads the declared `ambientOcclusion` record with every field filled in and in range.
10974
+ *
10975
+ * @remarks
10976
+ * The settings store merges a section shallowly, so `ambientOcclusion: { enabled: true }` arrives
10977
+ * without the other fields (see {@link toRenderingFeatures}); each missing or out-of-range value
10978
+ * reads as its default or its nearest bound.
10979
+ *
10980
+ * @param declared - The record as resolved, possibly partial; `undefined` when absent.
10981
+ * @returns A complete record.
10982
+ *
10983
+ * @internal
10984
+ */
10985
+ function resolveAmbientOcclusion(declared) {
10986
+ const value = declared ?? {};
10987
+ const defaults = DEFAULT_AMBIENT_OCCLUSION;
10988
+ return {
10989
+ enabled: value.enabled === true,
10990
+ quality: value.quality === "full" ? "full" : "half",
10991
+ radius: Math.max(.01, finite(value.radius, defaults.radius)),
10992
+ intensity: Math.min(8, Math.max(0, finite(value.intensity, defaults.intensity))),
10993
+ falloff: Math.min(1, Math.max(0, finite(value.falloff, defaults.falloff)))
10994
+ };
10995
+ }
10996
+ /**
10997
+ * A finite number, or a fallback.
10998
+ *
10999
+ * @param input - The declared value.
11000
+ * @param fallback - What a missing or non-finite value reads as.
11001
+ * @returns The number.
11002
+ */
11003
+ function finite(input, fallback) {
11004
+ return typeof input === "number" && Number.isFinite(input) ? input : fallback;
11005
+ }
11006
+ /**
10786
11007
  * Reads the declared feature block as the adapter's own flag record.
10787
11008
  *
10788
11009
  * @remarks
@@ -10805,9 +11026,44 @@ function toRenderingFeatures(settings) {
10805
11026
  const name = RENDERING_FEATURE_NAMES[index];
10806
11027
  if (name !== void 0) features[name] = declared[name] === true;
10807
11028
  }
11029
+ if (resolveAmbientOcclusion(settings.ambientOcclusion).enabled) features["materialPlugins"] = true;
10808
11030
  return features;
10809
11031
  }
10810
11032
  /**
11033
+ * Reads the declared `taa` record with every field filled in.
11034
+ *
11035
+ * @remarks
11036
+ * The settings store merges a section shallowly (see {@link toRenderingFeatures}), so
11037
+ * `taa: { enabled: true }` arrives without the other fields; each missing or mistyped one reads as
11038
+ * its default.
11039
+ *
11040
+ * @param settings - The resolved section.
11041
+ * @returns A complete record.
11042
+ *
11043
+ * @internal
11044
+ */
11045
+ function resolveTaaSettings(settings) {
11046
+ const declared = settings.taa ?? {};
11047
+ const defaults = defaultTaaSettings();
11048
+ return {
11049
+ enabled: declared.enabled === true,
11050
+ blend: finiteOr(declared.blend, defaults.blend),
11051
+ sharpness: finiteOr(declared.sharpness, defaults.sharpness),
11052
+ clamp: declared.clamp !== false,
11053
+ cutDistance: finiteOr(declared.cutDistance, defaults.cutDistance)
11054
+ };
11055
+ }
11056
+ /**
11057
+ * A declared number, or the fallback when it is missing or not finite.
11058
+ *
11059
+ * @param value - The declared value.
11060
+ * @param fallback - The default.
11061
+ * @returns The number to use.
11062
+ */
11063
+ function finiteOr(value, fallback) {
11064
+ return typeof value === "number" && Number.isFinite(value) ? value : fallback;
11065
+ }
11066
+ /**
10811
11067
  * Translates the section into the options the adapter hands `createEngine`.
10812
11068
  *
10813
11069
  * @remarks
@@ -10853,6 +11109,31 @@ function toRendererOptions(settings, resolutionScale) {
10853
11109
  function toSurfaceFormat(settings) {
10854
11110
  return settings.format === "" ? null : settings.format;
10855
11111
  }
11112
+ /**
11113
+ * The auto exposure knobs the HDR path is built with, or `null` when it stays off.
11114
+ *
11115
+ * @remarks
11116
+ * The settings store merges a section shallowly (see {@link toRenderingFeatures}), so a project that
11117
+ * writes `autoExposure: { enabled: true }` leaves the other fields `undefined`; each one falls back to
11118
+ * its default here.
11119
+ *
11120
+ * @param settings - The resolved section.
11121
+ * @returns The knobs, or `null` when `hdr` or `autoExposure.enabled` is off.
11122
+ *
11123
+ * @internal
11124
+ */
11125
+ function toAutoExposureOptions(settings) {
11126
+ const declared = settings.autoExposure;
11127
+ if (!settings.hdr || declared.enabled !== true) return null;
11128
+ const defaults = defaultAutoExposureSettings();
11129
+ return {
11130
+ minEv: declared.minEv ?? defaults.minEv,
11131
+ maxEv: declared.maxEv ?? defaults.maxEv,
11132
+ speedUp: declared.speedUp ?? defaults.speedUp,
11133
+ speedDown: declared.speedDown ?? defaults.speedDown,
11134
+ compensation: declared.compensation ?? defaults.compensation
11135
+ };
11136
+ }
10856
11137
  //#endregion
10857
11138
  //#region src/render/renderer.ts
10858
11139
  /**
@@ -10971,7 +11252,7 @@ var RendererImpl = class {
10971
11252
  this.#assertRenderLoop(member);
10972
11253
  const create = await loadRenderTextureFactory();
10973
11254
  this.#assertRenderLoop(member);
10974
- return create(this.engine, this.scene, width, height);
11255
+ return create(this.engine, this.scene, width, height, EDITOR_ONLY_METADATA_KEY);
10975
11256
  },
10976
11257
  release: (texture) => {
10977
11258
  this.#renderTextures.delete(texture);
@@ -10983,6 +11264,14 @@ var RendererImpl = class {
10983
11264
  #gpuAdapters = [];
10984
11265
  #handles = null;
10985
11266
  #presenter = null;
11267
+ /** The shared scene inputs' owner (`../lite/gpu/scene-inputs.ts`), loaded by the first acquire. */
11268
+ #sceneInputs = null;
11269
+ /** The same owner once loaded, so `dispose()` can free it synchronously. */
11270
+ #sceneInputsHost = null;
11271
+ /** The GTAO pass (`../lite/gpu/gtao.ts`), when `rendering.ambientOcclusion` is on. */
11272
+ #ambientOcclusion = null;
11273
+ /** The TAA passes (`../lite/gpu/taa.ts`), when `rendering.taa` installed them. */
11274
+ #taa = null;
10986
11275
  #defaultMaterial = null;
10987
11276
  #resolutionScale = 1;
10988
11277
  #pixelRatio;
@@ -11109,6 +11398,77 @@ var RendererImpl = class {
11109
11398
  return this.#presenter;
11110
11399
  }
11111
11400
  /**
11401
+ * Leases the shared scene inputs — depth, normals, velocity and a depth pyramid from one geometry
11402
+ * pass (`docs/architecture/07-rendering.md` §2.12) — for a screen-space effect.
11403
+ *
11404
+ * @remarks
11405
+ * The first call loads the `scene-inputs` chunk and adds the pass to the frame graph; the last
11406
+ * `release()` removes it. Nothing is loaded or added until an effect calls this.
11407
+ *
11408
+ * @returns The lease, or `null` under the null engine or once the renderer is disposed.
11409
+ *
11410
+ * @internal
11411
+ */
11412
+ async acquireSceneInputs() {
11413
+ if (this.isHeadless || this.#isDisposed) return null;
11414
+ const { engine, scene } = this;
11415
+ this.#sceneInputs ??= import("./scene-inputs-BxGOsnIZ.js").then((module) => {
11416
+ const host = module.createSceneInputsHost(engine, scene);
11417
+ this.#sceneInputsHost = host;
11418
+ if (this.#isDisposed) host.dispose();
11419
+ return host;
11420
+ });
11421
+ return (await this.#sceneInputs).acquire(this.#isSceneRegistered);
11422
+ }
11423
+ /**
11424
+ * Installs temporal anti-aliasing when `rendering.taa.enabled` is on (GI plan steps G5–G6).
11425
+ *
11426
+ * @remarks
11427
+ * Loads the `taa` chunk and leases the scene inputs only then. TAA needs the HDR render path;
11428
+ * without `rendering.hdr` it logs a warning and stays off. `app.initialize()` calls it once, after
11429
+ * the engine exists and before the scene is registered.
11430
+ *
11431
+ * @returns A promise that settles once the passes are in the frame graph, or at once when off.
11432
+ *
11433
+ * @internal
11434
+ */
11435
+ async installTemporalAntiAliasing() {
11436
+ const options = resolveTaaSettings(this.settings);
11437
+ if (!options.enabled || this.isHeadless || this.#taa !== null) return;
11438
+ const hdr = this.#presenter?.hdr ?? null;
11439
+ if (hdr === null) {
11440
+ this.#app.log.warn("rendering.taa needs rendering.hdr; temporal anti-aliasing stays off.");
11441
+ return;
11442
+ }
11443
+ const module = await import("./taa-BwBZLy11.js");
11444
+ const inputs = await this.acquireSceneInputs();
11445
+ if (inputs === null) return;
11446
+ this.#taa = module.installTemporalAntiAliasing(this.engine, this.scene, hdr, inputs, options, this.#isSceneRegistered);
11447
+ }
11448
+ /**
11449
+ * The TAA passes, when installed.
11450
+ *
11451
+ * @returns The handle, or `null`.
11452
+ *
11453
+ * @internal
11454
+ */
11455
+ get taa() {
11456
+ return this.#taa;
11457
+ }
11458
+ resetTemporalHistory() {
11459
+ this.#taa?.reset();
11460
+ }
11461
+ /**
11462
+ * How many scene-input leases are live; `0` before the first acquire.
11463
+ *
11464
+ * @returns The count.
11465
+ *
11466
+ * @internal
11467
+ */
11468
+ get sceneInputsUserCount() {
11469
+ return this.#sceneInputsHost?.userCount ?? 0;
11470
+ }
11471
+ /**
11112
11472
  * Whether `app.start()` has registered the render scene, after which Lite has compiled what it is
11113
11473
  * going to compile.
11114
11474
  *
@@ -11168,8 +11528,14 @@ var RendererImpl = class {
11168
11528
  set profileTasks(value) {
11169
11529
  this.#profileTasks = value;
11170
11530
  if (this.isHeadless) return;
11171
- if (value) startGpuTiming(this.engine);
11172
- else disableGpuTiming(this.engine);
11531
+ const reportFailure = (error) => {
11532
+ this.#app.log.warn(`renderer.profileTasks could not switch per-task GPU timing: ${String(error)}`);
11533
+ };
11534
+ if (value) startGpuTiming(this.engine).catch(reportFailure);
11535
+ else {
11536
+ disableGpuTiming(this.engine);
11537
+ stopTaskTiming(this.engine).catch(reportFailure);
11538
+ }
11173
11539
  }
11174
11540
  /**
11175
11541
  * Whether the shader clock runs in an edit-mode app.
@@ -11629,6 +11995,60 @@ var RendererImpl = class {
11629
11995
  };
11630
11996
  this.#presenter = presenter;
11631
11997
  this.applyClearColor(this.settings.clearColor);
11998
+ if (!this.isHeadless && resolveAmbientOcclusion(this.settings.ambientOcclusion).enabled) this.requireGpuAdapter(this.#installAmbientOcclusion());
11999
+ }
12000
+ /**
12001
+ * Loads the GTAO chunk and builds the pass on a scene-inputs lease (`rendering.ambientOcclusion`).
12002
+ *
12003
+ * @returns A promise that settles once the pass is in the frame graph.
12004
+ */
12005
+ async #installAmbientOcclusion() {
12006
+ const settings = resolveAmbientOcclusion(this.settings.ambientOcclusion);
12007
+ const [module, inputs] = await Promise.all([import("./gtao-_nr0b6-E.js"), this.acquireSceneInputs()]);
12008
+ if (inputs === null) return;
12009
+ if (this.#isDisposed) {
12010
+ inputs.release();
12011
+ return;
12012
+ }
12013
+ const pass = await module.createAmbientOcclusion(this.engine, this.scene, inputs, {
12014
+ quality: settings.quality,
12015
+ radius: settings.radius,
12016
+ intensity: settings.intensity,
12017
+ falloff: settings.falloff,
12018
+ onError: (error) => {
12019
+ this.#app.onError.emit({
12020
+ error,
12021
+ source: "asset",
12022
+ phase: null,
12023
+ entity: null,
12024
+ component: null
12025
+ });
12026
+ }
12027
+ }, this.#isSceneRegistered);
12028
+ if (this.#isDisposed) {
12029
+ pass.dispose();
12030
+ return;
12031
+ }
12032
+ this.#ambientOcclusion = pass;
12033
+ }
12034
+ /**
12035
+ * The GTAO pass's per-frame work: gives new PBR materials the AO plugin. The `PreRender` system
12036
+ * calls it every frame; it does nothing while `rendering.ambientOcclusion` is off.
12037
+ *
12038
+ * @internal
12039
+ */
12040
+ updateAmbientOcclusion() {
12041
+ this.#ambientOcclusion?.update(this.#isSceneRegistered);
12042
+ }
12043
+ /**
12044
+ * Whether the GTAO pass is built and running.
12045
+ *
12046
+ * @returns `true` once `rendering.ambientOcclusion` has installed it.
12047
+ *
12048
+ * @internal
12049
+ */
12050
+ get isAmbientOcclusionActive() {
12051
+ return this.#ambientOcclusion !== null;
11632
12052
  }
11633
12053
  /**
11634
12054
  * Writes an sRGB colour onto the render scene's clear colour, so it presents as authored.
@@ -11840,14 +12260,19 @@ var RendererImpl = class {
11840
12260
  return this.#isDisposed ? [] : held;
11841
12261
  }
11842
12262
  /**
11843
- * Releases the open overlays, the picker and the warm-up probes. The core extension registers it
11844
- * as a disposer.
12263
+ * Releases the open overlays, the picker, the warm-up probes and the scene inputs. The core
12264
+ * extension registers it as a disposer.
11845
12265
  *
11846
12266
  * @internal
11847
12267
  */
11848
12268
  dispose() {
11849
12269
  this.#isDisposed = true;
11850
12270
  this.#afterRebuild.length = 0;
12271
+ this.#ambientOcclusion?.dispose();
12272
+ this.#ambientOcclusion = null;
12273
+ this.#sceneInputsHost?.dispose();
12274
+ this.#sceneInputsHost = null;
12275
+ this.#taa = null;
11851
12276
  for (const overlay of this.#overlays.values()) overlay.dispose();
11852
12277
  for (const texture of this.#renderTextures) texture.dispose();
11853
12278
  const picker = this.#picker;
@@ -13101,6 +13526,8 @@ var Light = class Light extends Component {
13101
13526
  #appliedSpotAngle = NaN;
13102
13527
  #appliedSpotExponent = NaN;
13103
13528
  #appliedShadows = false;
13529
+ /** A copy of the `shadows` record the current generator was built from, or `null` without one. */
13530
+ #appliedShadowSettings = null;
13104
13531
  #appliedIncludeSize = -1;
13105
13532
  #appliedExcludeSize = -1;
13106
13533
  #entityVersion = -1;
@@ -13273,24 +13700,28 @@ var Light = class Light extends Component {
13273
13700
  }
13274
13701
  }
13275
13702
  /**
13276
- * Attaches or detaches the shadow generator the `shadows` record asks for.
13703
+ * Attaches, rebuilds or detaches the shadow generator the `shadows` record asks for.
13704
+ *
13705
+ * @remarks
13706
+ * Lite reads every field (technique, map size, the cascade knobs) only when it builds a
13707
+ * generator, so a change to any of them on a light that already casts builds a new one.
13277
13708
  *
13278
13709
  * @param renderer - The rendering service, for the engine and the feature flags.
13279
- * @returns `true` when a generator was attached or detached.
13710
+ * @returns `true` when a generator was attached, rebuilt or detached.
13280
13711
  */
13281
13712
  #applyShadows(renderer) {
13282
13713
  const light = this.#light;
13283
13714
  const wanted = this.shadows.enabled && this.isEnabledInHierarchy && renderer.features.shadows && !renderer.isHeadless;
13284
- if (light === null || wanted === this.#appliedShadows) {
13715
+ const isStale = wanted && !sameShadowSettings(this.#appliedShadowSettings, this.shadows);
13716
+ if (light === null || wanted === this.#appliedShadows && !isStale) {
13285
13717
  this.#warnAboutShadows(renderer);
13286
13718
  return false;
13287
13719
  }
13288
13720
  if (renderer.isRebuildInFlight) return false;
13289
13721
  this.#appliedShadows = wanted;
13290
- if (!wanted) {
13291
- this.#releaseGenerator(renderer);
13292
- return true;
13293
- }
13722
+ this.#releaseGenerator(renderer);
13723
+ if (!wanted) return true;
13724
+ this.#appliedShadowSettings = { ...this.shadows };
13294
13725
  this.#generator = attachShadows(renderer.engine, light, this.shadows);
13295
13726
  renderer.needsShadowLayoutReset = true;
13296
13727
  return true;
@@ -13333,6 +13764,7 @@ var Light = class Light extends Component {
13333
13764
  const generator = this.#generator;
13334
13765
  const light = this.#light;
13335
13766
  this.#generator = null;
13767
+ this.#appliedShadowSettings = null;
13336
13768
  if (generator !== null) {
13337
13769
  detachShadows(renderer.scene, light, generator);
13338
13770
  renderer.needsShadowLayoutReset = true;
@@ -13350,6 +13782,7 @@ var Light = class Light extends Component {
13350
13782
  this.#light = null;
13351
13783
  this.#appliedType = null;
13352
13784
  this.#appliedShadows = false;
13785
+ this.#appliedShadowSettings = null;
13353
13786
  const remove = () => {
13354
13787
  if (generator !== null) {
13355
13788
  detachShadows(renderer.scene, light, generator);
@@ -13361,6 +13794,34 @@ var Light = class Light extends Component {
13361
13794
  else renderer.afterRebuild(remove);
13362
13795
  }
13363
13796
  };
13797
+ /** Every field of {@link LightShadowSettings}; Lite reads all of them when it builds a generator. */
13798
+ const SHADOW_SETTING_KEYS = [
13799
+ "enabled",
13800
+ "technique",
13801
+ "mapSize",
13802
+ "bias",
13803
+ "normalBias",
13804
+ "darkness",
13805
+ "cascades",
13806
+ "maxDistance",
13807
+ "stabilizeCascades",
13808
+ "cascadeLambda",
13809
+ "cascadeBlend"
13810
+ ];
13811
+ /**
13812
+ * Whether a generator built from `applied` still matches the declared `shadows` record.
13813
+ *
13814
+ * @param applied - The record the generator was built from, or `null` when there is none.
13815
+ * @param declared - The component's record now.
13816
+ * @returns `true` when every field is the same.
13817
+ *
13818
+ * @internal
13819
+ */
13820
+ function sameShadowSettings(applied, declared) {
13821
+ if (applied === null) return false;
13822
+ for (const key of SHADOW_SETTING_KEYS) if (applied[key] !== declared[key]) return false;
13823
+ return true;
13824
+ }
13364
13825
  /**
13365
13826
  * Builds the Lite light of one kind, unparented and at the world origin.
13366
13827
  *
@@ -17208,6 +17669,12 @@ var PostProcessChain = class {
17208
17669
  #isFrameGraphBuilt;
17209
17670
  /** The sampled ping-pong links the custom effects read and write. */
17210
17671
  #sampledLinks = [];
17672
+ /** The `rgba16float` links the custom effects ahead of the HDR output pass ping-pong through. */
17673
+ #linearLinks = [];
17674
+ /** What the HDR output pass reads while the chain is enabled; `null` when no effect runs ahead of it. */
17675
+ #linearOutput = null;
17676
+ /** How many tasks run after the output pass, on display colour; only those take over the swapchain. */
17677
+ #displayTaskCount = 0;
17211
17678
  /** The recorded custom effects, in chain order. */
17212
17679
  #custom = [];
17213
17680
  /** The bloom task, when the chain has one; the one task whose tuning is retuned live. */
@@ -17245,7 +17712,9 @@ var PostProcessChain = class {
17245
17712
  const plainLinks = [];
17246
17713
  let source = presenter.sceneColor;
17247
17714
  let sourceTexture = null;
17248
- for (let index = 0; index < ordered.length; index += 1) {
17715
+ const first = effectTasks === null ? 0 : this.#recordLinearEffects(effectTasks, engine, scene, ordered);
17716
+ const linearTaskCount = this.#tasks.length;
17717
+ for (let index = first; index < ordered.length; index += 1) {
17249
17718
  const effect = ordered[index];
17250
17719
  if (effect === void 0) continue;
17251
17720
  const isLast = index === ordered.length - 1;
@@ -17273,6 +17742,8 @@ var PostProcessChain = class {
17273
17742
  source = target;
17274
17743
  sourceTexture = link?.texture ?? null;
17275
17744
  }
17745
+ this.#displayTaskCount = this.#tasks.length - linearTaskCount;
17746
+ if (this.#displayTaskCount === 0) return;
17276
17747
  presenter.setPresentEnabled(false);
17277
17748
  }
17278
17749
  /**
@@ -17333,7 +17804,8 @@ var PostProcessChain = class {
17333
17804
  const task = this.#tasks[index];
17334
17805
  if (task !== void 0) setPostProcessTaskEnabled(task, enabled);
17335
17806
  }
17336
- if (this.#tasks.length > 0) this.#presenter.setPresentEnabled(!enabled);
17807
+ if (this.#linearOutput !== null) this.#presenter.hdr?.setOutputSource(enabled ? this.#linearOutput : null);
17808
+ if (this.#displayTaskCount > 0) this.#presenter.setPresentEnabled(!enabled);
17337
17809
  }
17338
17810
  /**
17339
17811
  * Uploads every custom effect's uniform bytes, and only the ones that changed.
@@ -17382,8 +17854,15 @@ var PostProcessChain = class {
17382
17854
  }
17383
17855
  }
17384
17856
  if (this.#tasks.length > 0) this.#presenter.setPresentEnabled(true);
17857
+ if (this.#linearOutput !== null) {
17858
+ this.#presenter.hdr?.setOutputSource(null);
17859
+ this.#linearOutput = null;
17860
+ }
17385
17861
  const effects = effectTaskSupport();
17386
17862
  for (const recorded of this.#custom) effects?.disposeCustomEffect(recorded.effect);
17863
+ for (const link of this.#linearLinks) effects?.disposeEffectChainLink(link);
17864
+ this.#linearLinks.length = 0;
17865
+ this.#displayTaskCount = 0;
17387
17866
  for (const link of this.#sampledLinks) effects?.disposeEffectChainLink(link);
17388
17867
  this.#custom.length = 0;
17389
17868
  this.#sampledLinks.length = 0;
@@ -17431,6 +17910,56 @@ var PostProcessChain = class {
17431
17910
  return effects.createCustomEffectTask(engine, scene, `ignifx:post-effect:${request.address}`, wrapper, target);
17432
17911
  }
17433
17912
  /**
17913
+ * Under `rendering.hdr`, records the custom effects ordered before any built-in one ahead of the
17914
+ * output pass, where they read and write linear `rgba16float` colour (GI plan step G3).
17915
+ *
17916
+ * @remarks
17917
+ * The first reads the scene's HDR texture directly, which is already a sampled `Texture2D`, so no
17918
+ * copy is needed; the last one's link becomes the output pass's input. Built-in effects and every
17919
+ * effect after the first of them stay behind the output pass: Lite's bloom, SMAA and
17920
+ * image-processing tasks expect display colour in the surface's format.
17921
+ *
17922
+ * @param effects - The effect adapter.
17923
+ * @param engine - The engine.
17924
+ * @param scene - The scene.
17925
+ * @param ordered - The chain's effects, in order.
17926
+ * @returns How many leading effects were recorded; `0` without HDR.
17927
+ */
17928
+ #recordLinearEffects(effects, engine, scene, ordered) {
17929
+ const hdr = this.#presenter.hdr;
17930
+ if (hdr === null) return 0;
17931
+ let sourceTexture = hdr.sceneTexture;
17932
+ let count = 0;
17933
+ for (; count < ordered.length; count += 1) {
17934
+ const effect = ordered[count];
17935
+ if (effect?.name !== "custom") break;
17936
+ const link = this.#nextLinearLink(effects, engine, sourceTexture);
17937
+ const task = this.#recordCustom(effects, engine, scene, effect, sourceTexture, link.target);
17938
+ hdr.insertLinearTask(task, this.#isFrameGraphBuilt);
17939
+ this.#tasks.push(task);
17940
+ sourceTexture = link.texture;
17941
+ }
17942
+ if (count > 0) {
17943
+ this.#linearOutput = sourceTexture;
17944
+ hdr.setOutputSource(sourceTexture);
17945
+ }
17946
+ return count;
17947
+ }
17948
+ /**
17949
+ * Returns an `rgba16float` link other than the one an effect reads, creating it on first use.
17950
+ *
17951
+ * @param effects - The effect adapter.
17952
+ * @param engine - The engine.
17953
+ * @param source - The texture the next effect reads.
17954
+ * @returns The link to write.
17955
+ */
17956
+ #nextLinearLink(effects, engine, source) {
17957
+ for (const link of this.#linearLinks) if (link.texture !== source) return link;
17958
+ const created = effects.createEffectChainLink(engine, "rgba16float", engine.canvas.width, engine.canvas.height, `ignifx:post-effect-linear-${String(this.#linearLinks.length)}`);
17959
+ this.#linearLinks.push(created);
17960
+ return created;
17961
+ }
17962
+ /**
17434
17963
  * The next sampled ping-pong link that is not the one being read.
17435
17964
  *
17436
17965
  * @remarks
@@ -17617,6 +18146,181 @@ function nextLink(engine, links, source) {
17617
18146
  return created;
17618
18147
  }
17619
18148
  //#endregion
18149
+ //#region src/render/hdr-bloom-support.ts
18150
+ /** The loaded module, memoised for the process. */
18151
+ let layer = null;
18152
+ /** The pending import, so concurrent callers share it. */
18153
+ let loading = null;
18154
+ /**
18155
+ * Loads the HDR bloom chunk, once per process.
18156
+ *
18157
+ * @returns The module.
18158
+ *
18159
+ * @internal
18160
+ */
18161
+ async function loadHdrBloomSupport() {
18162
+ loading ??= import("./bloom-hdr-CLtQj-oY.js").then((module) => {
18163
+ layer = module;
18164
+ return module;
18165
+ });
18166
+ return loading;
18167
+ }
18168
+ /**
18169
+ * The HDR bloom chunk, if it has been loaded.
18170
+ *
18171
+ * @returns The module, or `null` before {@link loadHdrBloomSupport} settled.
18172
+ *
18173
+ * @internal
18174
+ */
18175
+ function hdrBloomSupport() {
18176
+ return layer;
18177
+ }
18178
+ //#endregion
18179
+ //#region src/render/screen-space-effects.ts
18180
+ /** Numbers each Lite camera object, so the key can name it. */
18181
+ let cameraIds = null;
18182
+ /** The next camera number. */
18183
+ let nextCameraId = 1;
18184
+ /**
18185
+ * The scene-colour effects of one `PostProcessStack`.
18186
+ *
18187
+ * @internal
18188
+ */
18189
+ var ScreenSpaceEffects = class {
18190
+ /** The key the current (or pending) build was started for; `""` when nothing should run. */
18191
+ #key = "";
18192
+ /** Bumped by every new build and by dispose, so a superseded async build cleans up after itself. */
18193
+ #generation = 0;
18194
+ #built = null;
18195
+ /**
18196
+ * Whether a build is live.
18197
+ *
18198
+ * @returns `true` once the passes are in the frame graph.
18199
+ */
18200
+ get isBuilt() {
18201
+ return this.#built !== null;
18202
+ }
18203
+ /**
18204
+ * How many frame-graph tasks the passes added.
18205
+ *
18206
+ * @returns The count, `0` while nothing is built.
18207
+ */
18208
+ get taskCount() {
18209
+ return this.#built?.installed.taskCount ?? 0;
18210
+ }
18211
+ /**
18212
+ * Builds, rebuilds or tears down the passes to match the records, then pushes the live tuning.
18213
+ * Called from the stack's `sync` every `PreRender`.
18214
+ *
18215
+ * @param renderer - The rendering service.
18216
+ * @param contact - The `contactShadows` record.
18217
+ * @param ssgi - The `ssgi` record.
18218
+ * @param isEnabled - Whether the stack is enabled in the hierarchy.
18219
+ */
18220
+ sync(renderer, contact, ssgi, isEnabled) {
18221
+ const key = buildKey(renderer, contact, ssgi, isEnabled);
18222
+ if (key !== this.#key) {
18223
+ this.#key = key;
18224
+ this.#teardown(renderer.isSceneRegistered);
18225
+ if (key !== "") this.#build(renderer, contact, ssgi, this.#generation).catch((failure) => {
18226
+ renderer.app.log.error(`PostProcessStack could not build contact shadows or SSGI: ${failure instanceof Error ? failure.message : String(failure)}`);
18227
+ });
18228
+ return;
18229
+ }
18230
+ const built = this.#built;
18231
+ if (built === null) return;
18232
+ built.contact?.update(contact);
18233
+ built.ssgi?.update(ssgi, renderer.isSceneRegistered);
18234
+ }
18235
+ /**
18236
+ * Removes everything, and stops a build in flight.
18237
+ *
18238
+ * @param isSceneRegistered - Whether materials the SSGI plugin leaves must be rebuilt.
18239
+ */
18240
+ dispose(isSceneRegistered) {
18241
+ this.#key = "";
18242
+ this.#teardown(isSceneRegistered);
18243
+ }
18244
+ /**
18245
+ * Frees the current build and invalidates any pending one.
18246
+ *
18247
+ * @param isSceneRegistered - Whether materials the SSGI plugin leaves must be rebuilt.
18248
+ */
18249
+ #teardown(isSceneRegistered) {
18250
+ this.#generation += 1;
18251
+ const built = this.#built;
18252
+ this.#built = null;
18253
+ if (built === null) return;
18254
+ built.ssgi?.dispose(isSceneRegistered);
18255
+ built.installed.dispose();
18256
+ built.inputs.release();
18257
+ }
18258
+ /**
18259
+ * Loads the chunks, leases the scene inputs, and installs the passes.
18260
+ *
18261
+ * @param renderer - The rendering service.
18262
+ * @param contact - The `contactShadows` record.
18263
+ * @param ssgi - The `ssgi` record.
18264
+ * @param generation - The generation this build belongs to.
18265
+ */
18266
+ async #build(renderer, contact, ssgi, generation) {
18267
+ const [inputs, wiring, contactModule, ssgiModule] = await Promise.all([
18268
+ renderer.acquireSceneInputs(),
18269
+ import("./scene-color-passes-DlNr-qyZ.js"),
18270
+ contact.enabled ? import("./contact-shadows-T523EXaP.js") : null,
18271
+ ssgi.enabled ? import("./ssgi-Dm-maZrc.js") : null
18272
+ ]);
18273
+ const presenter = renderer.presenter;
18274
+ const camera = renderer.isHeadless ? null : renderer.scene.camera;
18275
+ if (generation !== this.#generation || inputs === null || presenter === null || camera === null) {
18276
+ inputs?.release();
18277
+ return;
18278
+ }
18279
+ const { engine, scene } = renderer;
18280
+ const passes = [];
18281
+ const contactPass = contactModule?.createContactShadowsPass(engine, scene, inputs.depthTarget, camera, contact) ?? null;
18282
+ if (contactPass !== null) passes.push(contactPass);
18283
+ const ssgiPass = ssgiModule?.createSsgiPass(engine, scene, inputs.depthTarget, camera, {
18284
+ tuning: ssgi,
18285
+ halfResolution: ssgi.halfResolution,
18286
+ usePlugin: renderer.settings.hdr || renderer.features.materialPlugins
18287
+ }) ?? null;
18288
+ if (ssgiPass !== null) passes.push(ssgiPass);
18289
+ const installed = wiring.installSceneColorPasses(engine, scene, presenter, passes, renderer.isSceneRegistered);
18290
+ this.#built = {
18291
+ inputs,
18292
+ installed,
18293
+ contact: contactPass,
18294
+ ssgi: ssgiPass
18295
+ };
18296
+ contactPass?.update(contact);
18297
+ ssgiPass?.update(ssgi, renderer.isSceneRegistered);
18298
+ }
18299
+ };
18300
+ /**
18301
+ * The build's identity: which passes run, SSGI's resolution, and the camera; `""` for none.
18302
+ *
18303
+ * @param renderer - The rendering service.
18304
+ * @param contact - The `contactShadows` record.
18305
+ * @param ssgi - The `ssgi` record.
18306
+ * @param isEnabled - Whether the stack is enabled in the hierarchy.
18307
+ * @returns The key.
18308
+ */
18309
+ function buildKey(renderer, contact, ssgi, isEnabled) {
18310
+ if (!isEnabled || !contact.enabled && !ssgi.enabled || renderer.isHeadless || renderer.presenter === null) return "";
18311
+ const camera = renderer.scene.camera;
18312
+ if (camera === null) return "";
18313
+ cameraIds ??= /* @__PURE__ */ new WeakMap();
18314
+ let id = cameraIds.get(camera);
18315
+ if (id === void 0) {
18316
+ id = nextCameraId;
18317
+ nextCameraId += 1;
18318
+ cameraIds.set(camera, id);
18319
+ }
18320
+ const gi = ssgi.enabled ? `ssgi:${ssgi.halfResolution ? "half" : "full"}` : "";
18321
+ return `${contact.enabled ? "contact" : ""}|${gi}|camera:${String(id)}`;
18322
+ }
18323
+ //#endregion
17620
18324
  //#region src/render/post-process-stack.ts
17621
18325
  /**
17622
18326
  * One instance of a post-process chain, attached to the main camera's entity
@@ -17647,6 +18351,8 @@ var PostProcessStack = class PostProcessStack extends Component {
17647
18351
  static allowMultiple = false;
17648
18352
  /** The serialized field declarations (ADR-0004). */
17649
18353
  static schema = postProcessSchema();
18354
+ /** The contact-shadow and SSGI passes, which run on the scene colour before the chain. */
18355
+ #screenSpace = new ScreenSpaceEffects();
17650
18356
  /** Applies the schema defaults, exactly as `Component.define` would. */
17651
18357
  constructor() {
17652
18358
  super();
@@ -17655,6 +18361,10 @@ var PostProcessStack = class PostProcessStack extends Component {
17655
18361
  #chain = null;
17656
18362
  #built = "";
17657
18363
  #hasWarnedAboutFeature = false;
18364
+ /** The HDR bloom chain, once a stack under `rendering.hdr` asked for bloom. */
18365
+ #hdrBloom = null;
18366
+ /** Whether loading the HDR bloom chunk failed, so it is reported once. */
18367
+ #hdrBloomFailed = false;
17658
18368
  /** The shader addresses whose compilation already failed, so the report is made once each. */
17659
18369
  #failedShaders = /* @__PURE__ */ new Set();
17660
18370
  /** The entry buffer `#chainKey` refills every frame. */
@@ -17679,7 +18389,18 @@ var PostProcessStack = class PostProcessStack extends Component {
17679
18389
  * `postProcessing` rendering feature is off.
17680
18390
  */
17681
18391
  get taskCount() {
17682
- return this.#chain?.taskCount ?? 0;
18392
+ return (this.#chain?.taskCount ?? 0) + (this.#hdrBloom?.taskCount ?? 0);
18393
+ }
18394
+ /**
18395
+ * The HDR bloom chain, once it is recorded.
18396
+ *
18397
+ * @returns The chain, or `null` without `rendering.hdr`, before bloom was enabled, or while its
18398
+ * chunk loads.
18399
+ *
18400
+ * @internal
18401
+ */
18402
+ get hdrBloom() {
18403
+ return this.#hdrBloom;
17683
18404
  }
17684
18405
  /** Nothing to do at attach: the chain is built on the first sync that wants an effect. */
17685
18406
  onAttach() {
@@ -17688,10 +18409,14 @@ var PostProcessStack = class PostProcessStack extends Component {
17688
18409
  }
17689
18410
  /** Disables and disposes every task the stack recorded. */
17690
18411
  onDetach() {
18412
+ this.#screenSpace.dispose(this.#screenSpace.isBuilt && rendererOfStack(this).isSceneRegistered);
17691
18413
  const chain = this.#chain;
17692
18414
  this.#chain = null;
17693
18415
  this.#built = "";
17694
18416
  chain?.dispose();
18417
+ const bloom = this.#hdrBloom;
18418
+ this.#hdrBloom = null;
18419
+ bloom?.dispose();
17695
18420
  }
17696
18421
  /**
17697
18422
  * Builds the chain when the effects it should hold change, and keeps the recorded tasks' tuning
@@ -17714,16 +18439,61 @@ var PostProcessStack = class PostProcessStack extends Component {
17714
18439
  * @internal
17715
18440
  */
17716
18441
  sync(renderer) {
18442
+ this.#syncHdrBloom(renderer);
18443
+ this.#screenSpace.sync(renderer, this.contactShadows, this.ssgi, this.isEnabledInHierarchy);
17717
18444
  const wanted = this.#chainKey(renderer);
17718
18445
  if (wanted !== this.#built) {
17719
18446
  this.#rebuild(renderer, wanted);
17720
18447
  return;
17721
18448
  }
17722
- if (!this.#hasWarnedAboutFeature && !renderer.features.postProcessing) this.#warnAboutFeature(renderer, this.plannedChain().length);
18449
+ if (!this.#hasWarnedAboutFeature && !renderer.features.postProcessing) this.#warnAboutFeature(renderer, this.plannedChain().length + this.#screenSpaceCount());
17723
18450
  const surface = renderer.surface;
17724
18451
  applyPostProcessSettings(this.#chain, this.isEnabledInHierarchy, this.bloom, this.smaa, renderer.effectClock, surface?.width ?? 0, surface?.height ?? 0, renderer.isSceneRegistered);
17725
18452
  }
17726
18453
  /**
18454
+ * Keeps the HDR bloom chain in step with the `bloom` record under `rendering.hdr`.
18455
+ *
18456
+ * @remarks
18457
+ * The chain is built once, the first frame bloom is wanted after its chunk has loaded, and is
18458
+ * then only switched on or off: Lite cannot remove its tasks, and nothing in the record changes
18459
+ * its shape. Until the chunk is in, the frame presents without bloom.
18460
+ *
18461
+ * @param renderer - The rendering service, for the presenter and the scene.
18462
+ */
18463
+ #syncHdrBloom(renderer) {
18464
+ const hdr = renderer.presenter?.hdr ?? null;
18465
+ const isWanted = hdr !== null && this.bloom.enabled && this.isEnabledInHierarchy;
18466
+ if (this.#hdrBloom === null) {
18467
+ if (!isWanted || this.#hdrBloomFailed) return;
18468
+ const support = hdrBloomSupport();
18469
+ if (support === null) {
18470
+ loadHdrBloomSupport().catch((failure) => {
18471
+ this.#reportHdrBloomFailure(renderer, failure);
18472
+ });
18473
+ return;
18474
+ }
18475
+ this.#hdrBloom = support.installHdrBloom(renderer.engine, renderer.scene, hdr, renderer.isSceneRegistered);
18476
+ }
18477
+ const bloom = this.bloom;
18478
+ this.#hdrBloom.setEnabled(isWanted);
18479
+ this.#hdrBloom.apply({
18480
+ intensity: bloom.intensity,
18481
+ radius: bloom.radius,
18482
+ threshold: bloom.hdrThreshold
18483
+ });
18484
+ }
18485
+ /**
18486
+ * Reports, once, that the HDR bloom chunk did not load.
18487
+ *
18488
+ * @param renderer - The rendering service, for the log.
18489
+ * @param failure - What the import threw.
18490
+ */
18491
+ #reportHdrBloomFailure(renderer, failure) {
18492
+ if (this.#hdrBloomFailed) return;
18493
+ this.#hdrBloomFailed = true;
18494
+ renderer.app.log.error(`HDR bloom could not be loaded, so {entity} renders without it. ${String(failure)}`, this.entity.name);
18495
+ }
18496
+ /**
17727
18497
  * Replaces the chain with one that holds the effects the fields currently ask for.
17728
18498
  *
17729
18499
  * @remarks
@@ -17742,7 +18512,15 @@ var PostProcessStack = class PostProcessStack extends Component {
17742
18512
  previous?.dispose();
17743
18513
  const requests = this.#requests(renderer);
17744
18514
  this.#chain = recordPostProcessChain(renderer.engine, renderer.scene, renderer.presenter, renderer.isHeadless, requests, renderer.isSceneRegistered, this.isEnabledInHierarchy, this.#reportRefusedValues);
17745
- this.#warnAboutFeature(renderer, requests.length);
18515
+ this.#warnAboutFeature(renderer, requests.length + this.#screenSpaceCount());
18516
+ }
18517
+ /**
18518
+ * How many of the scene-colour passes the fields ask for.
18519
+ *
18520
+ * @returns 0, 1 or 2.
18521
+ */
18522
+ #screenSpaceCount() {
18523
+ return (this.contactShadows.enabled ? 1 : 0) + (this.ssgi.enabled ? 1 : 0);
17746
18524
  }
17747
18525
  /**
17748
18526
  * Says once, at warning level, that the stack asks for effects the project did not opt into.
@@ -17775,9 +18553,10 @@ var PostProcessStack = class PostProcessStack extends Component {
17775
18553
  */
17776
18554
  #requests(renderer) {
17777
18555
  const sourceIsSrgb = renderer.settings.srgb;
18556
+ const isHdr = renderer.settings.hdr;
17778
18557
  const requests = [];
17779
18558
  for (const entry of this.#entries()) {
17780
- if (!entry.enabled) continue;
18559
+ if (!entry.enabled || isHdr && entry.name === "bloom") continue;
17781
18560
  const settings = entry.settings;
17782
18561
  if (entry.name !== "custom" || settings === null) {
17783
18562
  requests.push({
@@ -17867,11 +18646,12 @@ var PostProcessStack = class PostProcessStack extends Component {
17867
18646
  */
17868
18647
  #chainKey(renderer) {
17869
18648
  const entries = this.#fillEntries(this.#entryScratch);
18649
+ const isHdr = renderer.settings.hdr;
17870
18650
  let key = "";
17871
18651
  let hasCustom = false;
17872
18652
  for (let index = 0; index < entries.length; index += 1) {
17873
18653
  const entry = entries[index];
17874
- if (entry === void 0 || !entry.enabled) continue;
18654
+ if (entry === void 0 || !entry.enabled || isHdr && entry.name === "bloom") continue;
17875
18655
  const settings = entry.settings;
17876
18656
  if (entry.name !== "custom" || settings === null) {
17877
18657
  key = key === "" ? entry.name : `${key},${entry.name}`;
@@ -17888,7 +18668,7 @@ var PostProcessStack = class PostProcessStack extends Component {
17888
18668
  const part = `custom:${settings.shader?.address ?? ""}:${textures}`;
17889
18669
  key = key === "" ? part : `${key},${part}`;
17890
18670
  }
17891
- if (this.bloom.enabled) key = `${key}|scale=${String(this.bloom.scale)}`;
18671
+ if (this.bloom.enabled && !isHdr) key = `${key}|scale=${String(this.bloom.scale)}`;
17892
18672
  if (hasCustom) {
17893
18673
  const surface = renderer.surface;
17894
18674
  key = `${key}|size=${String(surface?.width ?? 0)}x${String(surface?.height ?? 0)}`;
@@ -17951,6 +18731,17 @@ function fallbackTexture(app, declaration) {
17951
18731
  return shaderSupport()?.shaderMaterialsOf(app).fallbackTexture(declaration) ?? null;
17952
18732
  }
17953
18733
  /**
18734
+ * Reaches the rendering service from a stack, for the tests that drive `sync` by hand.
18735
+ *
18736
+ * @param stack - The component.
18737
+ * @returns The service.
18738
+ *
18739
+ * @internal
18740
+ */
18741
+ function rendererOfStack(stack) {
18742
+ return rendererInternals(stack.app.renderer);
18743
+ }
18744
+ /**
17954
18745
  * Builds the component's declared fields.
17955
18746
  *
17956
18747
  * @returns The schema. Built inside a function, not at module scope: a schema field is a function
@@ -17982,8 +18773,22 @@ function postProcessSchema() {
17982
18773
  min: .05,
17983
18774
  max: 1,
17984
18775
  tooltip: "Fraction of full resolution the blur runs at."
18776
+ }),
18777
+ intensity: f32(.1, {
18778
+ min: 0,
18779
+ max: 1,
18780
+ tooltip: "HDR bloom only: how much glow is mixed into the frame."
18781
+ }),
18782
+ radius: f32(.7, {
18783
+ min: 0,
18784
+ max: 1,
18785
+ tooltip: "HDR bloom only: how far the glow spreads, from tight (0) to wide (1)."
18786
+ }),
18787
+ hdrThreshold: f32(0, {
18788
+ min: 0,
18789
+ tooltip: "HDR bloom only: linear luminance below which nothing glows; 0 lets every pixel glow by its energy."
17985
18790
  })
17986
- }, { tooltip: "Bloom." }),
18791
+ }, { tooltip: "Bloom. With rendering.hdr on, HDR bloom on the linear scene colour replaces the LDR pass and reads intensity, radius and hdrThreshold; without it, the other fields apply." }),
17987
18792
  smaa: record({
17988
18793
  enabled: bool(false, { tooltip: "Whether subpixel morphological anti-aliasing runs." }),
17989
18794
  order: i32(1, { tooltip: "Position in the chain; lower runs first." }),
@@ -18009,7 +18814,51 @@ function postProcessSchema() {
18009
18814
  order: i32(10, { tooltip: "Position in the chain; lower runs first." }),
18010
18815
  values: custom(postEffectValuesCodec(), { tooltip: "Overrides of the file's declared uniform defaults, by declared name." }),
18011
18816
  textures: map(asset(TextureAsset), { tooltip: "Textures for the file's declared samplers." })
18012
- }), [], { tooltip: "Custom full-screen WGSL effects, ordered among the built-ins by order." })
18817
+ }), [], { tooltip: "Custom full-screen WGSL effects, ordered among the built-ins by order." }),
18818
+ contactShadows: record({
18819
+ enabled: bool(false, { tooltip: "Whether screen-space contact shadows run." }),
18820
+ intensity: f32(.6, {
18821
+ min: 0,
18822
+ max: 4,
18823
+ tooltip: "How dark a contact gets."
18824
+ }),
18825
+ length: f32(.3, {
18826
+ min: .001,
18827
+ tooltip: "How far each ray marches towards the light, in world units."
18828
+ }),
18829
+ thickness: f32(.35, {
18830
+ min: .001,
18831
+ tooltip: "Assumed thickness behind each depth sample, in world units."
18832
+ }),
18833
+ samples: u32(8, {
18834
+ min: 1,
18835
+ max: 64,
18836
+ tooltip: "March steps per pixel."
18837
+ })
18838
+ }, { tooltip: "Short shadows where objects meet, towards the main directional light. Runs on the scene colour before the chain; needs rendering.features.postProcessing." }),
18839
+ ssgi: record({
18840
+ enabled: bool(false, { tooltip: "Whether screen-space global illumination runs (beta, desktop tier)." }),
18841
+ intensity: f32(1, {
18842
+ min: 0,
18843
+ max: 4,
18844
+ tooltip: "How strongly the bounced light is added."
18845
+ }),
18846
+ radius: f32(2, {
18847
+ min: .001,
18848
+ tooltip: "How far each ray marches, in world units."
18849
+ }),
18850
+ samples: u32(8, {
18851
+ min: 1,
18852
+ max: 64,
18853
+ tooltip: "March steps per ray."
18854
+ }),
18855
+ halfResolution: bool(true, { tooltip: "Trace at half resolution. A change rebuilds the pass." }),
18856
+ environmentDiffuse: f32(.5, {
18857
+ min: 0,
18858
+ max: 1,
18859
+ tooltip: "How much of the environment's diffuse light remains while SSGI runs, so the bounce is not counted twice. Needs rendering.hdr or the materialPlugins feature."
18860
+ })
18861
+ }, { tooltip: "One bounce of the lit scene colour (beta, desktop tier). Runs on the scene colour before the chain; needs rendering.features.postProcessing." })
18013
18862
  });
18014
18863
  }
18015
18864
  //#endregion
@@ -18119,6 +18968,7 @@ var RenderSyncSystem = class {
18119
18968
  renderer.syncRenderTextures(cameras);
18120
18969
  topologyChanged = this.#applyEnvironment(world) || topologyChanged;
18121
18970
  renderer.refreshClearColor();
18971
+ renderer.updateAmbientOcclusion();
18122
18972
  this.#applyStacks(world);
18123
18973
  this.#areCastersDirty = this.#areCastersDirty || castersChanged;
18124
18974
  if (renderer.materialCacheResets.unconfirmed && !this.#isRebuildDue && !renderer.isRebuildInFlight) this.#rebuildRenderables();
@@ -25661,6 +26511,8 @@ function createHeadlessEngine() {
25661
26511
  * @param features.postProcessing - `true` to render into an offscreen target and composite it.
25662
26512
  * @param features.hdr - `true` to render into an `rgba16float` target and tone map it in a final
25663
26513
  * pass (`./gpu/hdr-output.ts`, its own chunk, loaded only then). Implies the offscreen path.
26514
+ * @param features.autoExposure - With `hdr`, the auto exposure knobs (`./gpu/auto-exposure.ts`, its
26515
+ * own chunk, loaded only then); `null` or absent leaves it off.
25664
26516
  * @returns The engine, the scene, and the presenter when there is one.
25665
26517
  * @throws IgnifxError with code `IGX-0701` when WebGPU is unavailable.
25666
26518
  *
@@ -25673,8 +26525,11 @@ async function createRenderEngine(canvas, options, features) {
25673
26525
  const offscreen = hdr || features?.postProcessing === true;
25674
26526
  const scene = createRenderScene(engine, { offscreen });
25675
26527
  let presenter = null;
25676
- if (hdr) presenter = (await import("./hdr-output-DDpIo4Q5.js")).installHdrRenderPath(engine, scene);
25677
- else if (offscreen) presenter = installOffscreenRenderPath(engine, scene);
26528
+ if (hdr) {
26529
+ const knobs = features.autoExposure ?? null;
26530
+ const exposure = knobs === null ? null : await import("./auto-exposure-uzPn0beO.js");
26531
+ presenter = (await import("./hdr-output-BrUvpAsE.js")).installHdrRenderPath(engine, scene, exposure === null || knobs === null ? void 0 : (hdrTexture) => exposure.installAutoExposure(engine, scene, hdrTexture, knobs));
26532
+ } else if (offscreen) presenter = installOffscreenRenderPath(engine, scene);
25678
26533
  return {
25679
26534
  engine,
25680
26535
  scene,
@@ -34323,12 +35178,14 @@ var AppImpl = class {
34323
35178
  const renderer = rendererInternals(this.renderer);
34324
35179
  this.#handles = canvas === null ? createHeadlessEngine() : await createRenderEngine(canvas, this.#engineOptions(rendering), {
34325
35180
  postProcessing: renderer.renderingFeatures.postProcessing,
34326
- hdr: rendering.hdr
35181
+ hdr: rendering.hdr,
35182
+ autoExposure: toAutoExposureOptions(rendering)
34327
35183
  });
34328
35184
  if (canvas !== null) this.platform.setWebGpu(await probeWebGpuInfo());
34329
35185
  this.assets.attachEngine(this.#handles.engine);
34330
35186
  renderer.attachHandles(this.#handles.engine, this.#handles.scene, this.#handles.presenter);
34331
35187
  this.#enableDeviceLossRecovery(rendering);
35188
+ await renderer.installTemporalAntiAliasing();
34332
35189
  const time = this.#settings.time;
34333
35190
  this.time.applySettings(time.fixedDeltaTime, time.maximumDeltaTime, time.timeScale);
34334
35191
  const world = createWorld({
@@ -37072,6 +37929,6 @@ function settingsJsonSchema(app) {
37072
37929
  };
37073
37930
  }
37074
37931
  //#endregion
37075
- export { ASSET_DIAGNOSTICS_COUNTERS, ASSET_DIAGNOSTICS_GROUP, ASSET_MANIFEST_FORMAT, ASSET_MANIFEST_VERSION, AssetLoadError, CANVAS_ALPHA_MODES, CORE_ERROR_MESSAGES, Camera, Color, Component, ComponentRegistry, CoreErrorCode, DEFAULT_ASSET_CONCURRENCY, DEFAULT_ASSET_ROOT, DEFAULT_BRDF_LUT_ADDRESS, DEFAULT_LAYER, DEFAULT_MEMORY_SINK_LIMIT, DEFAULT_STORAGE_NAMESPACE, DEG_TO_RAD, Diagnostics, EASINGS, EASING_NAMES, EMPTY_ASSET_MANIFEST, ENVIRONMENT_ASSET_TYPE, ENVIRONMENT_FILE_EXTENSION, ENVIRONMENT_FILE_EXTENSIONS, ENVIRONMENT_FILE_FORMAT, ENVIRONMENT_FORMAT_VERSION, EPSILON, Entity, Environment, EnvironmentAsset, ErrorRange, FOG_MODE_NAMES, FONT_ASSET_TYPE, FONT_FILE_EXTENSIONS, FRAME_HISTORY_LENGTH, FieldKind, FontAsset, IGNIFX_UNIFORM_NAMES, INVALID_HANDLE, IgnifxError, IndexedDbStorageBackend, InstancedMeshRenderer, LIGHT_TYPES, LITE_MATERIAL_PLUGIN_POINTS, LITE_SYSTEM_UNIFORM_NAMES, LOG_LEVEL_SEVERITY, LayerMask, LayerTable, Light, LogLevel, MAT4_IDENTITY, MATERIAL_ALPHA_MODES, MATERIAL_ASSET_TYPE, MATERIAL_FILE_EXTENSION, MATERIAL_FILE_FORMAT, MATERIAL_FORMAT_VERSION, MATERIAL_KINDS, MATERIAL_PLUGIN_DEFAULT_PRIORITY, MATERIAL_PLUGIN_RESERVED_NAMES, MATERIAL_PLUGIN_SAMPLER_BUDGET, MAX_LAYERS, MAX_ULID_TIME_MS, MESH_ASSET_TYPE, MESH_FILE_EXTENSION, MESH_FILE_FORMAT, MESH_FORMAT_VERSION, MESH_PRIMITIVES, MESH_PRIMITIVE_OPTIONS, MODEL_ASSET_TYPE, MODEL_FILE_EXTENSIONS, Mat4, MaterialAsset, MemoryStorageBackend, MeshAsset, MeshRenderer, Model, ModelAsset, NAMESPACE_SEGMENT_MAX_LENGTH, PBR_TEXTURE_SLOTS, PHASES, PHASE_COUNT, PHASE_NAMES, POST_EFFECT_BUILTIN_UNIFORMS, POST_EFFECT_FUNCTION, PROJECTIONS, Phase, PhysicsCallbackName, PostProcessStack, QUAT_IDENTITY, Quat, RAD_TO_DEG, RENDERING_SETTINGS_SECTION, RENDER_DIAGNOSTICS_COUNTERS, RENDER_DIAGNOSTICS_GROUP, RENDER_TEXTURE_MAX_SIZE, RESERVED_LAYER_NAMES, SCENE_ASSET_TYPE, SCENE_FILE_EXTENSIONS, SCENE_FILE_FORMAT, SCENE_FORMAT_VERSION, SETTINGS_DESCRIPTION_FORMAT, SHADER_ASSET_TYPE, SHADER_ATTRIBUTE_NAMES, SHADER_BLEND_MODES, SHADER_CULL_MODES, SHADER_FILE_EXTENSIONS, SHADER_INSTANCING_MODES, SHADER_KINDS, SHADER_TEXTURE_FALLBACKS, SHADER_UNIFORM_TYPES, SHADOW_TECHNIQUES, STANDARD_TEXTURE_SLOTS, STORAGE_BUFFER_ASSET_TYPE, STORAGE_KEY_MAX_LENGTH, SURFACE_HOOK_NAMES, SURFACE_UNIFORM_BLOCK, SceneAssetToken, SceneInstance, SchemaIssueCode, Script, ScriptCallbackKind, ShaderAsset, Signal, StorageBufferAsset, TEXTURE_ASSET_TYPE, THIRD_PARTY_ERROR_PREFIX, TONE_MAPPING_NAMES, TWEEN_LOOP_FOREVER, TWEEN_SYSTEM_ORDER, TWEEN_VALUE_KINDS, TagSet, TextureAsset, Transform, Tween, UidRemap, VEC2_ONE, VEC2_ZERO, VEC3_BACKWARD, VEC3_DOWN, VEC3_FORWARD, VEC3_LEFT, VEC3_ONE, VEC3_RIGHT, VEC3_UP, VEC3_ZERO, VERSION, Vec2, Vec3, Vec4, World, addComponentFromRecord, applyInit, applyOverridesToAsset, approximately, array, assertNever, assertSceneDependenciesLoaded, asset, assetRef, binaryAssetLoader, bool, canonicalizeNumber, clamp, clamp01, color, componentRef, computeSceneHash, coreExtension, createApp, createAssetManifest, createConsoleSink, createCryptoRandom, createDefaults, createDiagnosticsGroup, createEnvironmentLoader, createErrorCodeRegistry, createFileStorageBackend, createFontLoader, createFrameSample, createLayerTable, createLogger, createManualClock, createMaterialAsset, createMaterialLoader, createMemorySink, createMeshLoader, createModelLoader, createPerformanceClock, createRay, createSceneAsset, createSceneLoader, createSeededRandom, createServiceKey, createShaderLoader, createStorageBufferAsset, createTextureLoader, createUlidFactory, curve, custom, customEffect, decodeProps, decodeValue, defaultRenderingSettings, defineExtension, defineMaterialPlugin, defineSchema, degToRad, deltaAngleDegrees, describeEnvironmentFileFormat, describeMaterialFileFormat, describeMeshFileFormat, describeRegisteredSchemas, describeSceneFileFormat, describeSchema, describeSchemas, describeSettings, encodeProps, encodeValue, entityRef, enumOf, environmentDefinition, f32, f64, forceRendererDeviceLossForTesting, formatErrorMessage, generateUlid, i32, instantiateScene, inverseLerp, isAssetRef, isIgnifxError, isLiteMaterialPluginPoint, isSceneFileHeader, isUlid, isValidErrorCode, isWebGpuAvailable, jsonAssetLoader, layerMask, lerp, lerpAngleDegrees, loadSceneDependencies, map, meshFileJsonSchema, moveTowards, optional, parseOverridePath, pbrMaterialDefinition, pingPong, platformInternals, quat, radToDeg, record, repeat, resetFrameSample, resolveEase, revertOverrides, sceneFileJsonSchema, serializeComponent, serializeEntity, serializeScene, settingsJsonSchema, shaderMaterialDefinition, sign, smoothStep, standardMaterialDefinition, storageInternals, str, stringifySceneFile, textAssetLoader, toJsonSchema, transformSchema, u32, validateProps, validateSceneFile, validateValue, vec2, vec3, vec4, waitFixedUpdate, waitSeconds, waitSecondsRealtime, waitUntil, waitWhile, wrapAngleDegrees };
37932
+ export { AMBIENT_OCCLUSION_QUALITIES, ASSET_DIAGNOSTICS_COUNTERS, ASSET_DIAGNOSTICS_GROUP, ASSET_MANIFEST_FORMAT, ASSET_MANIFEST_VERSION, AssetLoadError, CANVAS_ALPHA_MODES, CORE_ERROR_MESSAGES, Camera, Color, Component, ComponentRegistry, CoreErrorCode, DEFAULT_ASSET_CONCURRENCY, DEFAULT_ASSET_ROOT, DEFAULT_BRDF_LUT_ADDRESS, DEFAULT_LAYER, DEFAULT_MEMORY_SINK_LIMIT, DEFAULT_STORAGE_NAMESPACE, DEG_TO_RAD, Diagnostics, EASINGS, EASING_NAMES, EDITOR_ONLY_METADATA_KEY, EMPTY_ASSET_MANIFEST, ENVIRONMENT_ASSET_TYPE, ENVIRONMENT_FILE_EXTENSION, ENVIRONMENT_FILE_EXTENSIONS, ENVIRONMENT_FILE_FORMAT, ENVIRONMENT_FORMAT_VERSION, EPSILON, Entity, Environment, EnvironmentAsset, ErrorRange, FOG_MODE_NAMES, FONT_ASSET_TYPE, FONT_FILE_EXTENSIONS, FRAME_HISTORY_LENGTH, FieldKind, FontAsset, IGNIFX_UNIFORM_NAMES, INVALID_HANDLE, IgnifxError, IndexedDbStorageBackend, InstancedMeshRenderer, LIGHT_TYPES, LITE_MATERIAL_PLUGIN_POINTS, LITE_SYSTEM_UNIFORM_NAMES, LOG_LEVEL_SEVERITY, LayerMask, LayerTable, Light, LogLevel, MAT4_IDENTITY, MATERIAL_ALPHA_MODES, MATERIAL_ASSET_TYPE, MATERIAL_FILE_EXTENSION, MATERIAL_FILE_FORMAT, MATERIAL_FORMAT_VERSION, MATERIAL_KINDS, MATERIAL_PLUGIN_DEFAULT_PRIORITY, MATERIAL_PLUGIN_RESERVED_NAMES, MATERIAL_PLUGIN_SAMPLER_BUDGET, MAX_LAYERS, MAX_ULID_TIME_MS, MESH_ASSET_TYPE, MESH_FILE_EXTENSION, MESH_FILE_FORMAT, MESH_FORMAT_VERSION, MESH_PRIMITIVES, MESH_PRIMITIVE_OPTIONS, MODEL_ASSET_TYPE, MODEL_FILE_EXTENSIONS, Mat4, MaterialAsset, MemoryStorageBackend, MeshAsset, MeshRenderer, Model, ModelAsset, NAMESPACE_SEGMENT_MAX_LENGTH, PBR_TEXTURE_SLOTS, PHASES, PHASE_COUNT, PHASE_NAMES, POST_EFFECT_BUILTIN_UNIFORMS, POST_EFFECT_FUNCTION, PROJECTIONS, Phase, PhysicsCallbackName, PostProcessStack, QUAT_IDENTITY, Quat, RAD_TO_DEG, RENDERING_SETTINGS_SECTION, RENDER_DIAGNOSTICS_COUNTERS, RENDER_DIAGNOSTICS_GROUP, RENDER_TEXTURE_MAX_SIZE, RESERVED_LAYER_NAMES, SCENE_ASSET_TYPE, SCENE_FILE_EXTENSIONS, SCENE_FILE_FORMAT, SCENE_FORMAT_VERSION, SETTINGS_DESCRIPTION_FORMAT, SHADER_ASSET_TYPE, SHADER_ATTRIBUTE_NAMES, SHADER_BLEND_MODES, SHADER_CULL_MODES, SHADER_FILE_EXTENSIONS, SHADER_INSTANCING_MODES, SHADER_KINDS, SHADER_TEXTURE_FALLBACKS, SHADER_UNIFORM_TYPES, SHADOW_TECHNIQUES, STANDARD_TEXTURE_SLOTS, STORAGE_BUFFER_ASSET_TYPE, STORAGE_KEY_MAX_LENGTH, SURFACE_HOOK_NAMES, SURFACE_UNIFORM_BLOCK, SceneAssetToken, SceneInstance, SchemaIssueCode, Script, ScriptCallbackKind, ShaderAsset, Signal, StorageBufferAsset, TEXTURE_ASSET_TYPE, THIRD_PARTY_ERROR_PREFIX, TONE_MAPPING_NAMES, TWEEN_LOOP_FOREVER, TWEEN_SYSTEM_ORDER, TWEEN_VALUE_KINDS, TagSet, TextureAsset, Transform, Tween, UidRemap, VEC2_ONE, VEC2_ZERO, VEC3_BACKWARD, VEC3_DOWN, VEC3_FORWARD, VEC3_LEFT, VEC3_ONE, VEC3_RIGHT, VEC3_UP, VEC3_ZERO, VERSION, Vec2, Vec3, Vec4, World, addComponentFromRecord, applyInit, applyOverridesToAsset, approximately, array, assertNever, assertSceneDependenciesLoaded, asset, assetRef, binaryAssetLoader, bool, canonicalizeNumber, clamp, clamp01, color, componentRef, computeSceneHash, coreExtension, createApp, createAssetManifest, createConsoleSink, createCryptoRandom, createDefaults, createDiagnosticsGroup, createEnvironmentLoader, createErrorCodeRegistry, createFileStorageBackend, createFontLoader, createFrameSample, createLayerTable, createLogger, createManualClock, createMaterialAsset, createMaterialLoader, createMemorySink, createMeshLoader, createModelLoader, createPerformanceClock, createRay, createSceneAsset, createSceneLoader, createSeededRandom, createServiceKey, createShaderLoader, createStorageBufferAsset, createTextureLoader, createUlidFactory, curve, custom, customEffect, decodeProps, decodeValue, defaultAutoExposureSettings, defaultRenderingSettings, defineExtension, defineMaterialPlugin, defineSchema, degToRad, deltaAngleDegrees, describeEnvironmentFileFormat, describeMaterialFileFormat, describeMeshFileFormat, describeRegisteredSchemas, describeSceneFileFormat, describeSchema, describeSchemas, describeSettings, encodeProps, encodeValue, entityRef, enumOf, environmentDefinition, f32, f64, forceRendererDeviceLossForTesting, formatErrorMessage, generateUlid, i32, instantiateScene, inverseLerp, isAssetRef, isIgnifxError, isLiteMaterialPluginPoint, isSceneFileHeader, isUlid, isValidErrorCode, isWebGpuAvailable, jsonAssetLoader, layerMask, lerp, lerpAngleDegrees, loadSceneDependencies, map, meshFileJsonSchema, moveTowards, optional, parseOverridePath, pbrMaterialDefinition, pingPong, platformInternals, quat, radToDeg, record, repeat, resetFrameSample, resolveEase, revertOverrides, sceneFileJsonSchema, serializeComponent, serializeEntity, serializeScene, settingsJsonSchema, shaderMaterialDefinition, sign, smoothStep, standardMaterialDefinition, storageInternals, str, stringifySceneFile, textAssetLoader, toJsonSchema, transformSchema, u32, validateProps, validateSceneFile, validateValue, vec2, vec3, vec4, waitFixedUpdate, waitSeconds, waitSecondsRealtime, waitUntil, waitWhile, wrapAngleDegrees };
37076
37933
 
37077
37934
  //# sourceMappingURL=index.js.map