@ignifx/core 0.14.0 → 0.16.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 (58) hide show
  1. package/decoders/draco3dgltf.LICENSE.md +201 -0
  2. package/decoders/draco_decoder.js +116 -0
  3. package/decoders/draco_decoder_gltf.wasm +0 -0
  4. package/decoders/vendored.json +22 -0
  5. package/dist/agx-tone-mapping-Cgt844j6.js +53 -0
  6. package/dist/agx-tone-mapping-Cgt844j6.js.map +1 -0
  7. package/dist/auto-exposure-uzPn0beO.js +246 -0
  8. package/dist/auto-exposure-uzPn0beO.js.map +1 -0
  9. package/dist/bloom-hdr-CLtQj-oY.js +315 -0
  10. package/dist/bloom-hdr-CLtQj-oY.js.map +1 -0
  11. package/dist/contact-shadows-T523EXaP.js +84 -0
  12. package/dist/contact-shadows-T523EXaP.js.map +1 -0
  13. package/dist/{decoders-CHJ7vduE.js → decoders-BUQrlS8U.js} +3 -2
  14. package/dist/decoders-BUQrlS8U.js.map +1 -0
  15. package/dist/{environment-Cq2BmA96.js → environment-DPi0_0SP.js} +18 -4
  16. package/dist/environment-DPi0_0SP.js.map +1 -0
  17. package/dist/gtao-_nr0b6-E.js +630 -0
  18. package/dist/gtao-_nr0b6-E.js.map +1 -0
  19. package/dist/hdr-output-BrUvpAsE.js +525 -0
  20. package/dist/hdr-output-BrUvpAsE.js.map +1 -0
  21. package/dist/index.d.ts +509 -24
  22. package/dist/index.d.ts.map +1 -1
  23. package/dist/index.js +1522 -512
  24. package/dist/index.js.map +1 -1
  25. package/dist/{instanced-mesh-instance-DYwH0vLi.js → instanced-mesh-instance-NnODkvqK.js} +2 -2
  26. package/dist/{instanced-mesh-instance-DYwH0vLi.js.map → instanced-mesh-instance-NnODkvqK.js.map} +1 -1
  27. package/dist/mat4-D6exvAuO.js +949 -0
  28. package/dist/mat4-D6exvAuO.js.map +1 -0
  29. package/dist/{render-path-Dx0learj.js → render-path-Be7WgN7r.js} +35 -4
  30. package/dist/render-path-Be7WgN7r.js.map +1 -0
  31. package/dist/{render-texture-IuR0iFVa.js → render-texture-C_TnaSz2.js} +28 -2
  32. package/dist/render-texture-C_TnaSz2.js.map +1 -0
  33. package/dist/scene-color-passes-DlNr-qyZ.js +65 -0
  34. package/dist/scene-color-passes-DlNr-qyZ.js.map +1 -0
  35. package/dist/scene-inputs-BxGOsnIZ.js +318 -0
  36. package/dist/scene-inputs-BxGOsnIZ.js.map +1 -0
  37. package/dist/{shader-material-CDQ0Y5kN.js → shader-material-B6p66wB8.js} +17 -6
  38. package/dist/shader-material-B6p66wB8.js.map +1 -0
  39. package/dist/{shader-material-BPb_oEZQ.js → shader-material-C0TAUr4t.js} +102 -4
  40. package/dist/shader-material-C0TAUr4t.js.map +1 -0
  41. package/dist/ssgi-Dm-maZrc.js +113 -0
  42. package/dist/ssgi-Dm-maZrc.js.map +1 -0
  43. package/dist/{surface-shader-CwQ03yHG.js → surface-shader-BaK0kvBB.js} +2 -2
  44. package/dist/{surface-shader-CwQ03yHG.js.map → surface-shader-BaK0kvBB.js.map} +1 -1
  45. package/dist/taa-BwBZLy11.js +480 -0
  46. package/dist/taa-BwBZLy11.js.map +1 -0
  47. package/dist/{vec3-T2PasQZv.js → vec3-D-0Y2mzE.js} +4 -948
  48. package/dist/vec3-D-0Y2mzE.js.map +1 -0
  49. package/package.json +4 -2
  50. package/dist/decoders-CHJ7vduE.js.map +0 -1
  51. package/dist/environment-Cq2BmA96.js.map +0 -1
  52. package/dist/hdr-output-DDpIo4Q5.js +0 -300
  53. package/dist/hdr-output-DDpIo4Q5.js.map +0 -1
  54. package/dist/render-path-Dx0learj.js.map +0 -1
  55. package/dist/render-texture-IuR0iFVa.js.map +0 -1
  56. package/dist/shader-material-BPb_oEZQ.js.map +0 -1
  57. package/dist/shader-material-CDQ0Y5kN.js.map +0 -1
  58. package/dist/vec3-T2PasQZv.js.map +0 -1
@@ -0,0 +1,318 @@
1
+ import { GeometryTextureType, addTaskAfter, addTaskAtStart, buildFrameGraphTask, createCopyToTextureTask, createDepthPyramid, createDepthPyramidTask, createGeometryRendererTask, createSurfaceRenderTargetTexture, disposeRenderTargetTexture, getFrameGraph, onRenderTargetTextureResize, withSampledDepthTexture } from "@babylonjs/lite";
2
+ //#region src/lite/gpu/scene-inputs.ts
3
+ /**
4
+ * Shared scene inputs (`docs/plan/2026-11-gi-phase-1-execution-plan.md`, step G4;
5
+ * `docs/architecture/07-rendering.md` §2.12): one geometry pass that screen-space effects (TAA, GTAO,
6
+ * contact shadows, SSGI) read instead of each drawing the scene again. Its own chunk: the renderer
7
+ * imports it only when an effect asks for it, so a project with no such effect loads none of it and
8
+ * its frame graph has none of these tasks (`CONSTITUTION.md` §2.5).
9
+ *
10
+ * ```text
11
+ * [shadow] → geometry ─→ normals copy ─→ velocity copy ─→ depth pyramid → scene → …
12
+ * ├ depth (depth32float, sampled)
13
+ * ├ world normal ─(copy)─→ normals
14
+ * └ velocity ─(copy)─→ velocity
15
+ * ```
16
+ *
17
+ * - **Depth** is a surface-sized `depth32float` target with a sampled facade
18
+ * (`withSampledDepthTexture`) handed to the geometry task as its depth (spike S2). Reverse-Z: 0 is
19
+ * the far plane. `depth24plus-stencil8`, the main pass's format, cannot be bound in compute.
20
+ * - **Normals and velocity** are geometry attachments, which Lite exposes only as task-owned
21
+ * `RenderTarget`s; compute and effect bindings take a `Texture2D`, so each is copied into a target
22
+ * that has one (spike S2, upstream ask 3).
23
+ * - **The depth pyramid** is Lite's `createDepthPyramid`: an `r32float` mip chain where each level
24
+ * keeps the `max` (in reverse-Z, the nearest surface) of its four children.
25
+ * - **Ref-counted.** {@link SceneInputsHost.acquire} adds the tasks for the first user;
26
+ * {@link SceneInputs.release} by the last one removes and disposes them.
27
+ * - **Resize and device loss.** The targets are sized by the surface, so `frameGraph.build()`
28
+ * reallocates them, on a resize and on a recovered device alike. The depth target's resize
29
+ * callback rebuilds the pyramid (its pipelines belong to one device) and tells every user through
30
+ * {@link SceneInputs.onChange}, so they can rebind.
31
+ */
32
+ /**
33
+ * The frame-graph task names, in the order they run.
34
+ *
35
+ * @internal
36
+ */
37
+ const SCENE_INPUT_TASK_NAMES = {
38
+ geometry: "ignifx:scene-inputs",
39
+ normals: "ignifx:scene-inputs-normals",
40
+ velocity: "ignifx:scene-inputs-velocity",
41
+ depthPyramid: "ignifx:scene-inputs-depth-pyramid"
42
+ };
43
+ /**
44
+ * The texture format of each input.
45
+ *
46
+ * @internal
47
+ */
48
+ const SCENE_INPUT_FORMATS = {
49
+ depth: "depth32float",
50
+ normals: "rgba16float",
51
+ velocity: "rgba16float",
52
+ depthPyramid: "r32float"
53
+ };
54
+ /**
55
+ * Creates the scene-inputs owner for one scene. It adds nothing to the frame graph until the first
56
+ * {@link SceneInputsHost.acquire}.
57
+ *
58
+ * @param engine - The engine, which is also the primary surface.
59
+ * @param scene - The render scene.
60
+ * @returns The host.
61
+ *
62
+ * @internal
63
+ */
64
+ function createSceneInputsHost(engine, scene) {
65
+ let shared = null;
66
+ const leases = /* @__PURE__ */ new Set();
67
+ let isDisposed = false;
68
+ const releaseLease = (lease) => {
69
+ if (!leases.delete(lease) || leases.size > 0 || shared === null) return;
70
+ teardown(scene, shared);
71
+ shared = null;
72
+ };
73
+ return {
74
+ acquire(isFrameGraphBuilt) {
75
+ if (isDisposed) return null;
76
+ shared ??= buildSharedInputs(engine, scene, isFrameGraphBuilt);
77
+ const inputs = shared;
78
+ let isReleased = false;
79
+ const own = /* @__PURE__ */ new Set();
80
+ const lease = {
81
+ depth: requireDepthFacade(inputs.depth),
82
+ depthTarget: inputs.depth.rt,
83
+ normals: inputs.normals.texture,
84
+ velocity: inputs.velocity.texture,
85
+ get depthPyramid() {
86
+ return inputs.pyramid.current.texture;
87
+ },
88
+ get depthPyramidMipCount() {
89
+ return inputs.pyramid.current.mipCount;
90
+ },
91
+ get isReleased() {
92
+ return isReleased;
93
+ },
94
+ onChange(callback) {
95
+ inputs.listeners.add(callback);
96
+ own.add(callback);
97
+ return () => {
98
+ inputs.listeners.delete(callback);
99
+ own.delete(callback);
100
+ };
101
+ },
102
+ release() {
103
+ if (isReleased) return;
104
+ isReleased = true;
105
+ for (const callback of own) inputs.listeners.delete(callback);
106
+ own.clear();
107
+ releaseLease(lease);
108
+ }
109
+ };
110
+ leases.add(lease);
111
+ return lease;
112
+ },
113
+ get userCount() {
114
+ return leases.size;
115
+ },
116
+ dispose() {
117
+ if (isDisposed) return;
118
+ isDisposed = true;
119
+ for (const lease of leases) lease.release();
120
+ }
121
+ };
122
+ }
123
+ /**
124
+ * Builds the targets and tasks, and splices the tasks into the frame graph ahead of the scene pass.
125
+ *
126
+ * @param engine - The engine.
127
+ * @param scene - The scene.
128
+ * @param isFrameGraphBuilt - Whether each task must be recorded now.
129
+ * @returns The shared state.
130
+ */
131
+ function buildSharedInputs(engine, scene, isFrameGraphBuilt) {
132
+ const depth = createSurfaceRenderTargetTexture(engine, {
133
+ lbl: "ignifx:scene-inputs-depth",
134
+ dFormat: SCENE_INPUT_FORMATS.depth,
135
+ samples: 1,
136
+ size: engine
137
+ }, withSampledDepthTexture);
138
+ const normals = createSurfaceRenderTargetTexture(engine, {
139
+ lbl: "ignifx:scene-inputs-normals",
140
+ format: SCENE_INPUT_FORMATS.normals,
141
+ samples: 1,
142
+ size: engine
143
+ });
144
+ const velocity = createSurfaceRenderTargetTexture(engine, {
145
+ lbl: "ignifx:scene-inputs-velocity",
146
+ format: SCENE_INPUT_FORMATS.velocity,
147
+ samples: 1,
148
+ size: engine
149
+ });
150
+ const geometry = createGeometryRendererTask({
151
+ name: SCENE_INPUT_TASK_NAMES.geometry,
152
+ size: engine,
153
+ depthTexture: depth.rt,
154
+ textureDescriptions: [{
155
+ type: GeometryTextureType.WORLD_NORMAL,
156
+ format: SCENE_INPUT_FORMATS.normals
157
+ }, {
158
+ type: GeometryTextureType.LINEAR_VELOCITY,
159
+ format: SCENE_INPUT_FORMATS.velocity
160
+ }]
161
+ }, engine, scene);
162
+ const copyNormals = createCopyToTextureTask({
163
+ name: SCENE_INPUT_TASK_NAMES.normals,
164
+ sourceTexture: requireAttachment(geometry.geometryWorldNormalTexture, "world normal"),
165
+ targetTexture: normals.rt
166
+ }, engine, scene);
167
+ const copyVelocity = createCopyToTextureTask({
168
+ name: SCENE_INPUT_TASK_NAMES.velocity,
169
+ sourceTexture: requireAttachment(geometry.geometryLinearVelocityTexture, "linear velocity"),
170
+ targetTexture: velocity.rt
171
+ }, engine, scene);
172
+ const depthFacade = requireDepthFacade(depth);
173
+ const pyramid = { current: newPyramid(engine, depthFacade) };
174
+ const buildPyramid = createDepthPyramidTask(engine, scene, {
175
+ pyramid: {
176
+ get texture() {
177
+ return pyramid.current.texture;
178
+ },
179
+ get mipCount() {
180
+ return pyramid.current.mipCount;
181
+ },
182
+ build(source, encoder) {
183
+ pyramid.current.build(source, encoder);
184
+ },
185
+ resize(width, height) {
186
+ pyramid.current.resize(width, height);
187
+ },
188
+ dispose() {
189
+ pyramid.current.dispose();
190
+ }
191
+ },
192
+ source: () => depthFacade
193
+ });
194
+ Reflect.set(buildPyramid, "name", SCENE_INPUT_TASK_NAMES.depthPyramid);
195
+ const tasks = [
196
+ geometry,
197
+ copyNormals,
198
+ copyVelocity,
199
+ buildPyramid
200
+ ];
201
+ addTaskAtStart(scene, geometry);
202
+ addTaskAfter(scene, copyNormals, geometry);
203
+ addTaskAfter(scene, copyVelocity, copyNormals);
204
+ addTaskAfter(scene, buildPyramid, copyVelocity);
205
+ if (isFrameGraphBuilt) {
206
+ const graph = getFrameGraph(scene);
207
+ for (const task of tasks) buildFrameGraphTask(graph, task);
208
+ }
209
+ const listeners = /* @__PURE__ */ new Set();
210
+ return {
211
+ depth,
212
+ normals,
213
+ velocity,
214
+ tasks,
215
+ pyramid,
216
+ listeners,
217
+ stopResizeWatch: onRenderTargetTextureResize(depth, () => {
218
+ pyramid.current.dispose();
219
+ pyramid.current = newPyramid(engine, depthFacade);
220
+ for (const listener of listeners) listener();
221
+ })
222
+ };
223
+ }
224
+ /**
225
+ * Removes the tasks from the frame graph and frees every task and target.
226
+ *
227
+ * @param scene - The scene.
228
+ * @param shared - What {@link buildSharedInputs} built.
229
+ */
230
+ function teardown(scene, shared) {
231
+ shared.stopResizeWatch();
232
+ shared.listeners.clear();
233
+ for (const task of shared.tasks) {
234
+ task.executionEnabled = false;
235
+ removeFrameGraphTask(scene, task);
236
+ task.dispose();
237
+ }
238
+ disposeRenderTargetTexture(shared.depth);
239
+ disposeRenderTargetTexture(shared.normals);
240
+ disposeRenderTargetTexture(shared.velocity);
241
+ }
242
+ /**
243
+ * Takes a task out of the scene's frame graph.
244
+ *
245
+ * @remarks
246
+ * Lite 1.34 has no public remove (`index.d.ts` 206–217 add only), and a disposed task left in the
247
+ * graph is recorded again by the next `frameGraph.build()` against freed targets. The task list is
248
+ * the private `_tasks` array every `addTask*` splices (`lib/frame-graph/frame-graph-actions.js`).
249
+ * If a later Lite renames it, the task stays in, disabled.
250
+ *
251
+ * @param scene - The scene.
252
+ * @param task - The task to remove.
253
+ */
254
+ function removeFrameGraphTask(scene, task) {
255
+ const tasks = frameGraphTasks(scene);
256
+ const index = tasks?.indexOf(task) ?? -1;
257
+ if (tasks !== null && index >= 0) tasks.splice(index, 1);
258
+ }
259
+ /**
260
+ * The scene's frame-graph task list, or `null` when Lite no longer exposes it.
261
+ *
262
+ * @param scene - The scene.
263
+ * @returns The live array (Lite's own), or `null`.
264
+ *
265
+ * @internal
266
+ */
267
+ function frameGraphTasks(scene) {
268
+ const tasks = Reflect.get(getFrameGraph(scene), "_tasks");
269
+ return isTaskList(tasks) ? tasks : null;
270
+ }
271
+ /**
272
+ * Whether a value is Lite's task array.
273
+ *
274
+ * @param value - The value read from the frame graph.
275
+ * @returns `true` for an array.
276
+ */
277
+ function isTaskList(value) {
278
+ return Array.isArray(value);
279
+ }
280
+ /**
281
+ * Creates a depth pyramid the size of the depth facade's current texture.
282
+ *
283
+ * @param engine - The engine, whose current device owns the pipelines.
284
+ * @param depth - The depth facade.
285
+ * @returns The pyramid.
286
+ */
287
+ function newPyramid(engine, depth) {
288
+ return createDepthPyramid(engine, {
289
+ width: depth.width,
290
+ height: depth.height,
291
+ reduce: "max"
292
+ });
293
+ }
294
+ /**
295
+ * The sampled depth facade of the depth target.
296
+ *
297
+ * @param depth - The depth target, created with `withSampledDepthTexture`.
298
+ * @returns The facade.
299
+ */
300
+ function requireDepthFacade(depth) {
301
+ if (depth.depthTexture === null) throw new Error("Lite built the scene-inputs depth target without a sampled depth facade.");
302
+ return depth.depthTexture;
303
+ }
304
+ /**
305
+ * A geometry attachment the task was asked for.
306
+ *
307
+ * @param target - The accessor's value.
308
+ * @param what - The attachment, for the error.
309
+ * @returns The attachment.
310
+ */
311
+ function requireAttachment(target, what) {
312
+ if (target === null) throw new Error(`Lite's geometry task built no ${what} attachment.`);
313
+ return target;
314
+ }
315
+ //#endregion
316
+ export { SCENE_INPUT_TASK_NAMES, createSceneInputsHost, frameGraphTasks };
317
+
318
+ //# sourceMappingURL=scene-inputs-BxGOsnIZ.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"scene-inputs-BxGOsnIZ.js","names":[],"sources":["../src/lite/gpu/scene-inputs.ts"],"sourcesContent":["import {\n addTaskAfter,\n addTaskAtStart,\n buildFrameGraphTask,\n createCopyToTextureTask,\n createDepthPyramid,\n createDepthPyramidTask,\n createGeometryRendererTask,\n createSurfaceRenderTargetTexture,\n disposeRenderTargetTexture,\n GeometryTextureType,\n getFrameGraph,\n onRenderTargetTextureResize,\n withSampledDepthTexture,\n} from \"@babylonjs/lite\";\nimport type {\n DepthPyramid,\n EngineContext,\n RenderTarget,\n RenderTargetTextureResult,\n SceneContext,\n Task,\n Texture2D,\n} from \"@babylonjs/lite\";\n\n/**\n * Shared scene inputs (`docs/plan/2026-11-gi-phase-1-execution-plan.md`, step G4;\n * `docs/architecture/07-rendering.md` §2.12): one geometry pass that screen-space effects (TAA, GTAO,\n * contact shadows, SSGI) read instead of each drawing the scene again. Its own chunk: the renderer\n * imports it only when an effect asks for it, so a project with no such effect loads none of it and\n * its frame graph has none of these tasks (`CONSTITUTION.md` §2.5).\n *\n * ```text\n * [shadow] → geometry ─→ normals copy ─→ velocity copy ─→ depth pyramid → scene → …\n * ├ depth (depth32float, sampled)\n * ├ world normal ─(copy)─→ normals\n * └ velocity ─(copy)─→ velocity\n * ```\n *\n * - **Depth** is a surface-sized `depth32float` target with a sampled facade\n * (`withSampledDepthTexture`) handed to the geometry task as its depth (spike S2). Reverse-Z: 0 is\n * the far plane. `depth24plus-stencil8`, the main pass's format, cannot be bound in compute.\n * - **Normals and velocity** are geometry attachments, which Lite exposes only as task-owned\n * `RenderTarget`s; compute and effect bindings take a `Texture2D`, so each is copied into a target\n * that has one (spike S2, upstream ask 3).\n * - **The depth pyramid** is Lite's `createDepthPyramid`: an `r32float` mip chain where each level\n * keeps the `max` (in reverse-Z, the nearest surface) of its four children.\n * - **Ref-counted.** {@link SceneInputsHost.acquire} adds the tasks for the first user;\n * {@link SceneInputs.release} by the last one removes and disposes them.\n * - **Resize and device loss.** The targets are sized by the surface, so `frameGraph.build()`\n * reallocates them, on a resize and on a recovered device alike. The depth target's resize\n * callback rebuilds the pyramid (its pipelines belong to one device) and tells every user through\n * {@link SceneInputs.onChange}, so they can rebind.\n */\n\n/**\n * The frame-graph task names, in the order they run.\n *\n * @internal\n */\nexport const SCENE_INPUT_TASK_NAMES = {\n geometry: \"ignifx:scene-inputs\",\n normals: \"ignifx:scene-inputs-normals\",\n velocity: \"ignifx:scene-inputs-velocity\",\n depthPyramid: \"ignifx:scene-inputs-depth-pyramid\",\n} as const;\n\n/**\n * The texture format of each input.\n *\n * @internal\n */\nexport const SCENE_INPUT_FORMATS: {\n readonly depth: \"depth32float\";\n readonly normals: \"rgba16float\";\n readonly velocity: \"rgba16float\";\n readonly depthPyramid: \"r32float\";\n} = { depth: \"depth32float\", normals: \"rgba16float\", velocity: \"rgba16float\", depthPyramid: \"r32float\" };\n\n/**\n * One user's lease on the shared scene inputs.\n *\n * @remarks\n * Every texture is sized like the surface (backing-store pixels) and holds this frame's values for\n * any task that runs after the inputs' tasks, which sit at the start of the frame graph. A resize or\n * a recovered device swaps the GPU textures behind the same objects; bind groups that captured a\n * view must be rebuilt in {@link SceneInputs.onChange}.\n *\n * @internal\n */\nexport interface SceneInputs {\n /** Scene depth, `depth32float`, reverse-Z (1 near, 0 far). Bind with `sampleType: \"depth\"`. */\n readonly depth: Texture2D;\n /**\n * The same depth as the single-sample `RenderTarget` it lives in, for Lite tasks that take a\n * `depthTexture` target (contact shadows, SSGI).\n */\n readonly depthTarget: RenderTarget;\n /** World-space normals, `rgba16float`, stored as `n * 0.5 + 0.5`; 0 where nothing was drawn. */\n readonly normals: Texture2D;\n /**\n * Screen-space motion, `rgba16float`: `xy = 0.5 * (previousNdc - currentNdc)`, so UV units with Y\n * up, pointing from where a pixel is now to where it was last frame; 0 where nothing was drawn.\n * Camera motion always counts. Object motion counts for Standard materials only: Lite 1.34's PBR\n * geometry view reprojects the current world position (`pbr-geometry-output-shader.js` line 41),\n * so a moving PBR mesh under a still camera reads 0.\n */\n readonly velocity: Texture2D;\n /**\n * The depth pyramid, `r32float`, every mip level; level `n` is the `max` of its four children in\n * level `n - 1`. Read with `textureLoad(tex, coord, mip)`. A resize or recovered device replaces\n * this object, so read it again after {@link SceneInputs.onChange}.\n */\n readonly depthPyramid: Texture2D;\n /** How many mip levels {@link SceneInputs.depthPyramid} has. */\n readonly depthPyramidMipCount: number;\n /** `true` once {@link SceneInputs.release} ran. */\n readonly isReleased: boolean;\n /**\n * Registers a callback for when the textures were reallocated (resize, recovered device).\n *\n * @param callback - Runs during the frame graph rebuild, before the next frame is recorded.\n * @returns A function that unregisters it.\n */\n onChange(callback: () => void): () => void;\n /** Ends this lease. The last release removes and disposes the tasks and targets. Idempotent. */\n release(): void;\n}\n\n/**\n * The per-scene owner of the shared inputs: one per renderer.\n *\n * @internal\n */\nexport interface SceneInputsHost {\n /**\n * Leases the inputs, creating the geometry pass for the first user.\n *\n * @param isFrameGraphBuilt - Whether the scene is registered, so new tasks must be recorded now;\n * before registration `registerScene` records them.\n * @returns A lease; call its `release()` when done. `null` once the host is disposed.\n */\n acquire(isFrameGraphBuilt: boolean): SceneInputs | null;\n /** How many leases are live. */\n readonly userCount: number;\n /** Ends every lease and frees everything. Idempotent. */\n dispose(): void;\n}\n\n/** What the first acquire builds and the last release frees. */\ninterface SharedInputs {\n readonly depth: RenderTargetTextureResult;\n readonly normals: RenderTargetTextureResult;\n readonly velocity: RenderTargetTextureResult;\n readonly tasks: readonly Task[];\n readonly pyramid: { current: DepthPyramid };\n readonly listeners: Set<() => void>;\n readonly stopResizeWatch: () => void;\n}\n\n/**\n * Creates the scene-inputs owner for one scene. It adds nothing to the frame graph until the first\n * {@link SceneInputsHost.acquire}.\n *\n * @param engine - The engine, which is also the primary surface.\n * @param scene - The render scene.\n * @returns The host.\n *\n * @internal\n */\nexport function createSceneInputsHost(engine: EngineContext, scene: SceneContext): SceneInputsHost {\n let shared: SharedInputs | null = null;\n const leases = new Set<SceneInputs>();\n let isDisposed = false;\n\n const releaseLease = (lease: SceneInputs): void => {\n if (!leases.delete(lease) || leases.size > 0 || shared === null) {\n return;\n }\n teardown(scene, shared);\n shared = null;\n };\n\n return {\n acquire(isFrameGraphBuilt: boolean): SceneInputs | null {\n if (isDisposed) {\n return null;\n }\n shared ??= buildSharedInputs(engine, scene, isFrameGraphBuilt);\n const inputs = shared;\n let isReleased = false;\n const own = new Set<() => void>();\n const lease: SceneInputs = {\n depth: requireDepthFacade(inputs.depth),\n depthTarget: inputs.depth.rt,\n normals: inputs.normals.texture,\n velocity: inputs.velocity.texture,\n get depthPyramid(): Texture2D {\n return inputs.pyramid.current.texture;\n },\n get depthPyramidMipCount(): number {\n return inputs.pyramid.current.mipCount;\n },\n get isReleased(): boolean {\n return isReleased;\n },\n onChange(callback: () => void): () => void {\n inputs.listeners.add(callback);\n own.add(callback);\n return (): void => {\n inputs.listeners.delete(callback);\n own.delete(callback);\n };\n },\n release(): void {\n if (isReleased) {\n return;\n }\n isReleased = true;\n for (const callback of own) {\n inputs.listeners.delete(callback);\n }\n own.clear();\n releaseLease(lease);\n },\n };\n leases.add(lease);\n return lease;\n },\n get userCount(): number {\n return leases.size;\n },\n dispose(): void {\n if (isDisposed) {\n return;\n }\n isDisposed = true;\n for (const lease of leases) {\n lease.release();\n }\n },\n };\n}\n\n/**\n * Builds the targets and tasks, and splices the tasks into the frame graph ahead of the scene pass.\n *\n * @param engine - The engine.\n * @param scene - The scene.\n * @param isFrameGraphBuilt - Whether each task must be recorded now.\n * @returns The shared state.\n */\nfunction buildSharedInputs(engine: EngineContext, scene: SceneContext, isFrameGraphBuilt: boolean): SharedInputs {\n const depth = createSurfaceRenderTargetTexture(\n engine,\n { lbl: \"ignifx:scene-inputs-depth\", dFormat: SCENE_INPUT_FORMATS.depth, samples: 1, size: engine },\n withSampledDepthTexture,\n );\n const normals = createSurfaceRenderTargetTexture(engine, {\n lbl: \"ignifx:scene-inputs-normals\",\n format: SCENE_INPUT_FORMATS.normals,\n samples: 1,\n size: engine,\n });\n const velocity = createSurfaceRenderTargetTexture(engine, {\n lbl: \"ignifx:scene-inputs-velocity\",\n format: SCENE_INPUT_FORMATS.velocity,\n samples: 1,\n size: engine,\n });\n const geometry = createGeometryRendererTask(\n {\n name: SCENE_INPUT_TASK_NAMES.geometry,\n size: engine,\n depthTexture: depth.rt,\n textureDescriptions: [\n { type: GeometryTextureType.WORLD_NORMAL, format: SCENE_INPUT_FORMATS.normals },\n { type: GeometryTextureType.LINEAR_VELOCITY, format: SCENE_INPUT_FORMATS.velocity },\n ],\n },\n engine,\n scene,\n );\n const copyNormals = createCopyToTextureTask(\n {\n name: SCENE_INPUT_TASK_NAMES.normals,\n sourceTexture: requireAttachment(geometry.geometryWorldNormalTexture, \"world normal\"),\n targetTexture: normals.rt,\n },\n engine,\n scene,\n );\n const copyVelocity = createCopyToTextureTask(\n {\n name: SCENE_INPUT_TASK_NAMES.velocity,\n sourceTexture: requireAttachment(geometry.geometryLinearVelocityTexture, \"linear velocity\"),\n targetTexture: velocity.rt,\n },\n engine,\n scene,\n );\n const depthFacade = requireDepthFacade(depth);\n const pyramid = { current: newPyramid(engine, depthFacade) };\n // The pyramid task adopts what it is given and disposes it with the graph; a forwarding object\n // lets the inner pyramid be replaced after a resize or a recovered device.\n const forward: DepthPyramid = {\n get texture(): Texture2D {\n return pyramid.current.texture;\n },\n get mipCount(): number {\n return pyramid.current.mipCount;\n },\n build(source: Texture2D, encoder?: GPUCommandEncoder): void {\n pyramid.current.build(source, encoder);\n },\n resize(width: number, height: number): void {\n pyramid.current.resize(width, height);\n },\n dispose(): void {\n pyramid.current.dispose();\n },\n };\n const buildPyramid = createDepthPyramidTask(engine, scene, { pyramid: forward, source: () => depthFacade });\n Reflect.set(buildPyramid, \"name\", SCENE_INPUT_TASK_NAMES.depthPyramid);\n\n const tasks: readonly Task[] = [geometry, copyNormals, copyVelocity, buildPyramid];\n addTaskAtStart(scene, geometry);\n addTaskAfter(scene, copyNormals, geometry);\n addTaskAfter(scene, copyVelocity, copyNormals);\n addTaskAfter(scene, buildPyramid, copyVelocity);\n if (isFrameGraphBuilt) {\n const graph = getFrameGraph(scene);\n for (const task of tasks) {\n buildFrameGraphTask(graph, task);\n }\n }\n\n const listeners = new Set<() => void>();\n const stopResizeWatch = onRenderTargetTextureResize(depth, () => {\n pyramid.current.dispose();\n pyramid.current = newPyramid(engine, depthFacade);\n for (const listener of listeners) {\n listener();\n }\n });\n return { depth, normals, velocity, tasks, pyramid, listeners, stopResizeWatch };\n}\n\n/**\n * Removes the tasks from the frame graph and frees every task and target.\n *\n * @param scene - The scene.\n * @param shared - What {@link buildSharedInputs} built.\n */\nfunction teardown(scene: SceneContext, shared: SharedInputs): void {\n shared.stopResizeWatch();\n shared.listeners.clear();\n for (const task of shared.tasks) {\n // Disable first: a disposed task that still executes is a use-after-free.\n task.executionEnabled = false;\n removeFrameGraphTask(scene, task);\n task.dispose();\n }\n disposeRenderTargetTexture(shared.depth);\n disposeRenderTargetTexture(shared.normals);\n disposeRenderTargetTexture(shared.velocity);\n}\n\n/**\n * Takes a task out of the scene's frame graph.\n *\n * @remarks\n * Lite 1.34 has no public remove (`index.d.ts` 206–217 add only), and a disposed task left in the\n * graph is recorded again by the next `frameGraph.build()` against freed targets. The task list is\n * the private `_tasks` array every `addTask*` splices (`lib/frame-graph/frame-graph-actions.js`).\n * If a later Lite renames it, the task stays in, disabled.\n *\n * @param scene - The scene.\n * @param task - The task to remove.\n */\nfunction removeFrameGraphTask(scene: SceneContext, task: Task): void {\n const tasks = frameGraphTasks(scene);\n const index = tasks?.indexOf(task) ?? -1;\n if (tasks !== null && index >= 0) {\n tasks.splice(index, 1);\n }\n}\n\n/**\n * The scene's frame-graph task list, or `null` when Lite no longer exposes it.\n *\n * @param scene - The scene.\n * @returns The live array (Lite's own), or `null`.\n *\n * @internal\n */\nexport function frameGraphTasks(scene: SceneContext): Task[] | null {\n const tasks: unknown = Reflect.get(getFrameGraph(scene), \"_tasks\");\n return isTaskList(tasks) ? tasks : null;\n}\n\n/**\n * Whether a value is Lite's task array.\n *\n * @param value - The value read from the frame graph.\n * @returns `true` for an array.\n */\nfunction isTaskList(value: unknown): value is Task[] {\n return Array.isArray(value);\n}\n\n/**\n * Creates a depth pyramid the size of the depth facade's current texture.\n *\n * @param engine - The engine, whose current device owns the pipelines.\n * @param depth - The depth facade.\n * @returns The pyramid.\n */\nfunction newPyramid(engine: EngineContext, depth: Texture2D): DepthPyramid {\n return createDepthPyramid(engine, { width: depth.width, height: depth.height, reduce: \"max\" });\n}\n\n/**\n * The sampled depth facade of the depth target.\n *\n * @param depth - The depth target, created with `withSampledDepthTexture`.\n * @returns The facade.\n */\nfunction requireDepthFacade(depth: RenderTargetTextureResult): Texture2D {\n if (depth.depthTexture === null) {\n throw new Error(\"Lite built the scene-inputs depth target without a sampled depth facade.\");\n }\n return depth.depthTexture;\n}\n\n/**\n * A geometry attachment the task was asked for.\n *\n * @param target - The accessor's value.\n * @param what - The attachment, for the error.\n * @returns The attachment.\n */\nfunction requireAttachment(target: RenderTarget | null, what: string): RenderTarget {\n if (target === null) {\n throw new Error(`Lite's geometry task built no ${what} attachment.`);\n }\n return target;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA4DA,MAAa,yBAAyB;CACpC,UAAU;CACV,SAAS;CACT,UAAU;CACV,cAAc;AAChB;;;;;;AAOA,MAAa,sBAKT;CAAE,OAAO;CAAgB,SAAS;CAAe,UAAU;CAAe,cAAc;AAAW;;;;;;;;;;;AA6FvG,SAAgB,sBAAsB,QAAuB,OAAsC;CACjG,IAAI,SAA8B;CAClC,MAAM,yBAAS,IAAI,IAAiB;CACpC,IAAI,aAAa;CAEjB,MAAM,gBAAgB,UAA6B;EACjD,IAAI,CAAC,OAAO,OAAO,KAAK,KAAK,OAAO,OAAO,KAAK,WAAW,MACzD;EAEF,SAAS,OAAO,MAAM;EACtB,SAAS;CACX;CAEA,OAAO;EACL,QAAQ,mBAAgD;GACtD,IAAI,YACF,OAAO;GAET,WAAW,kBAAkB,QAAQ,OAAO,iBAAiB;GAC7D,MAAM,SAAS;GACf,IAAI,aAAa;GACjB,MAAM,sBAAM,IAAI,IAAgB;GAChC,MAAM,QAAqB;IACzB,OAAO,mBAAmB,OAAO,KAAK;IACtC,aAAa,OAAO,MAAM;IAC1B,SAAS,OAAO,QAAQ;IACxB,UAAU,OAAO,SAAS;IAC1B,IAAI,eAA0B;KAC5B,OAAO,OAAO,QAAQ,QAAQ;IAChC;IACA,IAAI,uBAA+B;KACjC,OAAO,OAAO,QAAQ,QAAQ;IAChC;IACA,IAAI,aAAsB;KACxB,OAAO;IACT;IACA,SAAS,UAAkC;KACzC,OAAO,UAAU,IAAI,QAAQ;KAC7B,IAAI,IAAI,QAAQ;KAChB,aAAmB;MACjB,OAAO,UAAU,OAAO,QAAQ;MAChC,IAAI,OAAO,QAAQ;KACrB;IACF;IACA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5C;;;;;;;;;;;;;AAcA,SAAS,qBAAqB,OAAqB,MAAkB;CACnE,MAAM,QAAQ,gBAAgB,KAAK;CACnC,MAAM,QAAQ,OAAO,QAAQ,IAAI,KAAK;CACtC,IAAI,UAAU,QAAQ,SAAS,GAC7B,MAAM,OAAO,OAAO,CAAC;AAEzB;;;;;;;;;AAUA,SAAgB,gBAAgB,OAAoC;CAClE,MAAM,QAAiB,QAAQ,IAAI,cAAc,KAAK,GAAG,QAAQ;CACjE,OAAO,WAAW,KAAK,IAAI,QAAQ;AACrC;;;;;;;AAQA,SAAS,WAAW,OAAiC;CACnD,OAAO,MAAM,QAAQ,KAAK;AAC5B;;;;;;;;AASA,SAAS,WAAW,QAAuB,OAAgC;CACzE,OAAO,mBAAmB,QAAQ;EAAE,OAAO,MAAM;EAAO,QAAQ,MAAM;EAAQ,QAAQ;CAAM,CAAC;AAC/F;;;;;;;AAQA,SAAS,mBAAmB,OAA6C;CACvE,IAAI,MAAM,iBAAiB,MACzB,MAAM,IAAI,MAAM,0EAA0E;CAE5F,OAAO,MAAM;AACf;;;;;;;;AASA,SAAS,kBAAkB,QAA6B,MAA4B;CAClF,IAAI,WAAW,MACb,MAAM,IAAI,MAAM,iCAAiC,KAAK,aAAa;CAErE,OAAO;AACT"}
@@ -1,6 +1,7 @@
1
1
  import { o as CoreErrorCode, t as IgnifxError } from "./ignifx-error-oYdVnT1S.js";
2
2
  import { t as Color } from "./color-DrR6GFTd.js";
3
3
  import { t as setOwnJsonProperty } from "./json-CzZZ6K4x.js";
4
+ import { r as isHdrScene } from "./render-path-Be7WgN7r.js";
4
5
  import { n as IGNIFX_UNIFORM_TYPES, r as LITE_SYSTEM_UNIFORM_NAMES, t as IGNIFX_UNIFORM_NAMES } from "./shader-declaration-5q__jycG.js";
5
6
  //#region \0rolldown/runtime.js
6
7
  var __defProp = Object.defineProperty;
@@ -173,7 +174,7 @@ let adapter = null;
173
174
  */
174
175
  async function loadShaderMaterialAdapter() {
175
176
  if (adapter !== null) return;
176
- const loaded = await import("./shader-material-BPb_oEZQ.js");
177
+ const loaded = await import("./shader-material-C0TAUr4t.js");
177
178
  loaded.enableShaderUniformCaching();
178
179
  adapter = loaded;
179
180
  }
@@ -613,7 +614,7 @@ var ShaderMaterialState = class {
613
614
  const kept = this.#values.get(uniform.name);
614
615
  values.set(uniform.name, kept !== void 0 && kept.length === ELEMENT_COUNTS[uniform.type] ? kept : uniformStore(uniform));
615
616
  }
616
- this.#material = buildLiteShaderMaterial(this.definition.name, shader, values, this.#resolveDefines(shader));
617
+ this.#material = buildLiteShaderMaterial(this.#app, this.definition.name, shader, values, this.#resolveDefines(shader));
617
618
  this.#values.clear();
618
619
  for (const [name, store] of values) this.#values.set(name, store);
619
620
  this.#rebind(declaration);
@@ -890,13 +891,18 @@ function buildShaderMaterialState(app, shader, definition, textures) {
890
891
  },
891
892
  hint: `Declare it in ${shader.address} with an // @ignifx define pragma.`
892
893
  });
893
- const state = new ShaderMaterialState(app, shader, definition, buildLiteShaderMaterial(definition.name, shader, /* @__PURE__ */ new Map(), defines), requireShaderMaterialAdapter(shader));
894
+ const state = new ShaderMaterialState(app, shader, definition, buildLiteShaderMaterial(app, definition.name, shader, /* @__PURE__ */ new Map(), defines), requireShaderMaterialAdapter(shader));
894
895
  state.initialise(textures);
895
896
  return state;
896
897
  }
897
898
  /**
898
899
  * Builds the Babylon Lite material a declaration describes, through the dynamically loaded adapter.
899
900
  *
901
+ * @remarks
902
+ * Under `rendering.hdr` the fragment is wrapped to write linear colour (GI plan step G3), so the
903
+ * output pass does not encode it a second time.
904
+ *
905
+ * @param app - The app, whose scene says whether it renders through `rendering.hdr`.
900
906
  * @param name - The material's name.
901
907
  * @param shader - The shader.
902
908
  * @param values - Current custom uniform values to seed the declaration's defaults with.
@@ -904,8 +910,13 @@ function buildShaderMaterialState(app, shader, definition, textures) {
904
910
  * @returns The Lite material.
905
911
  * @throws IgnifxError with code `IGX-0715` when the adapter has not been loaded yet.
906
912
  */
907
- function buildLiteShaderMaterial(name, shader, values, defines) {
908
- return requireShaderMaterialAdapter(shader).createShaderMaterialFromOptions(toShaderMaterialOptions(name, shader.source, shader.declaration, values, defines));
913
+ function buildLiteShaderMaterial(app, name, shader, values, defines) {
914
+ const options = toShaderMaterialOptions(name, shader.source, shader.declaration, values, defines);
915
+ const linearOutput = !app.isHeadless && isHdrScene(app.lite.scene);
916
+ return requireShaderMaterialAdapter(shader).createShaderMaterialFromOptions(linearOutput ? {
917
+ ...options,
918
+ linearOutput
919
+ } : options);
909
920
  }
910
921
  /**
911
922
  * A number, or an array of that many zeros, matching what a uniform of that arity starts at.
@@ -1010,4 +1021,4 @@ function shapeMismatch(declaration, material, expected, actual) {
1010
1021
  //#endregion
1011
1022
  export { shader_material_exports as n, shaderMaterialsOf as t };
1012
1023
 
1013
- //# sourceMappingURL=shader-material-CDQ0Y5kN.js.map
1024
+ //# sourceMappingURL=shader-material-B6p66wB8.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"shader-material-B6p66wB8.js","names":[],"sources":["../src/render/shader-material.ts"],"sourcesContent":["import { CoreErrorCode } from \"../errors/error-codes.js\";\nimport { IgnifxError } from \"../errors/ignifx-error.js\";\nimport { isHdrScene } from \"../lite/gpu/render-path.js\";\nimport { Color } from \"../math/color.js\";\nimport { setOwnJsonProperty } from \"../schema/json.js\";\nimport { IGNIFX_UNIFORM_TYPES, IGNIFX_UNIFORM_NAMES, LITE_SYSTEM_UNIFORM_NAMES } from \"./shader-declaration.js\";\nimport type { ShaderAsset } from \"./shader-asset.js\";\nimport type {\n IgnifxUniformName,\n ShaderDeclaration,\n ShaderTextureDeclaration,\n ShaderUniformDeclaration,\n ShaderUniformType,\n} from \"./shader-declaration.js\";\nimport type { ShaderMaterialDefinition } from \"./shader-material-definition.js\";\nimport type { StorageBufferAsset } from \"./storage-buffer-asset.js\";\nimport type { TextureAsset } from \"./texture-asset.js\";\nimport type { App } from \"../app/types.js\";\nimport type { AssetHandle } from \"../assets/types.js\";\nimport type {\n LiteShaderMaterial,\n ShaderMaterialAdapter,\n ShaderMaterialBuildOptions,\n ShaderSamplerEntry,\n ShaderStorageEntry,\n ShaderUniformEntry,\n} from \"../lite/gpu/shader-material.js\";\nimport type { LiteTexture2D } from \"../lite/gpu/texture.js\";\nimport type { ColorLike } from \"../math/types.js\";\nimport type { Disconnect } from \"../signal/signal.js\";\n\n/**\n * The `\"shader\"` material family (`docs/plan/2026-09-terrain-particles-shaders.md` §3.1): a\n * `ShaderAsset` plus the values a material sets on it.\n *\n * Nothing here imports Babylon Lite: {@link toShaderMaterialOptions} is the whole mapping onto the\n * shape `createShaderMaterial` takes, as plain data, and the adapter itself arrives through\n * {@link loadShaderMaterialAdapter} so a project that loads no `.wgsl` never fetches that chunk\n * (`./shader-support.ts`).\n *\n * Two Lite rules shape the design:\n *\n * - A declared sampler must have something bound (error 309), so an unbound declared texture gets\n * the declaration's 1x1 fallback and `setTexture(name, null)` restores it rather than unbinding.\n * - A declared storage buffer must have something bound too (error 310), and `array<T>` has no 1x1\n * equivalent, so such a material is not drawable until `setStorageBuffer` binds one.\n */\n\n/** The uniform names Babylon Lite and ignifx write themselves, which a material may not set. */\nconst ENGINE_UNIFORM_NAMES: readonly string[] = Object.freeze([...LITE_SYSTEM_UNIFORM_NAMES, ...IGNIFX_UNIFORM_NAMES]);\n\n/** How many floats the `PreRender` system's frame buffer holds: direction, colour, ambient. */\nconst FRAME_FLOATS = 9;\n\n/** Where the main light's direction starts inside the frame buffer. */\nconst DIRECTION_OFFSET = 0;\n\n/** Where the main light's colour starts inside the frame buffer. */\nconst LIGHT_COLOR_OFFSET = 3;\n\n/** Where the ambient colour starts inside the frame buffer. */\nconst AMBIENT_OFFSET = 6;\n\n/** How many elements each uniform type holds. */\nconst ELEMENT_COUNTS: Readonly<Record<ShaderUniformType, number>> = Object.freeze({\n f32: 1,\n u32: 1,\n i32: 1,\n \"vec2<f32>\": 2,\n \"vec3<f32>\": 3,\n \"vec4<f32>\": 4,\n \"mat4x4<f32>\": 16,\n});\n\n/**\n * The premultiplied-alpha blend state, which Babylon Lite's two named modes cannot express.\n *\n * @remarks\n * `blendMode: \"alpha\"` compiles `srcFactor: \"src-alpha\"` (`lib/material/shader/shader-pipeline.js`),\n * which multiplies the source colour by its alpha a second time. A premultiplied surface has\n * already done that, so it needs `srcFactor: \"one\"` — the state that lets additive and over-blended\n * particles share one draw.\n */\nconst PREMULTIPLIED_BLEND: GPUBlendState = Object.freeze({\n color: Object.freeze({ srcFactor: \"one\", dstFactor: \"one-minus-src-alpha\", operation: \"add\" }),\n alpha: Object.freeze({ srcFactor: \"one\", dstFactor: \"one-minus-src-alpha\", operation: \"add\" }),\n});\n\n/**\n * Maps a shader file's declaration and a material's `define` overrides onto the shape\n * `createShaderMaterial` takes.\n *\n * @remarks\n * Pure data in, pure data out, so every mapping rule is asserted headlessly:\n *\n * - `blend opaque` leaves blending off; `alpha` and `additive` are Lite's two named modes;\n * `premultiplied` supplies an explicit `GPUBlendState`, because Lite's `\"alpha\"` mode multiplies\n * by alpha a second time.\n * - `depthWrite` is passed explicitly, because the declaration already resolved Lite's\n * \"blended defaults to off unless stated\" rule.\n * - `depthTest off` becomes `depthCompare: \"always\"`; `depthTest on` passes `null`, which leaves\n * Lite's reverse-Z default in place.\n * - `instancing matrices` and `matrices-colors` differ only in `useThinInstanceColors`; which\n * pipeline layout a mesh draws with is Lite's decision at build time, from whether the mesh has a\n * thin-instance colour stream.\n * - A colour uniform's declared default is sRGB and is decoded here, which is the one place the\n * conversion happens for defaults.\n *\n * @param name - The material's name, for GPU debug labels.\n * @param source - The whole `.wgsl` file.\n * @param declaration - What the file's pragmas declared.\n * @param uniforms - The initial value of every custom uniform, keyed by name, already **linear**.\n * @param defines - The resolved `define` values.\n * @returns The options.\n *\n * @internal\n */\nexport function toShaderMaterialOptions(\n name: string,\n source: string,\n declaration: ShaderDeclaration,\n uniforms: ReadonlyMap<string, Float32Array>,\n defines: Readonly<Record<string, boolean | number>>,\n): ShaderMaterialBuildOptions {\n const entries: ShaderUniformEntry[] = [];\n // `for…of` rather than an indexed loop: this runs once per material build, not per frame, and the\n // iterator yields the element type rather than `T | undefined`.\n for (const system of declaration.system) {\n entries.push(system);\n }\n for (const ignifx of declaration.ignifx) {\n const type = IGNIFX_UNIFORM_TYPES[ignifx];\n entries.push({ name: ignifx, type, defaultValue: zeros(ELEMENT_COUNTS[type]) });\n }\n for (const uniform of declaration.uniforms) {\n entries.push({\n name: uniform.name,\n type: uniform.type,\n defaultValue: Array.from(uniforms.get(uniform.name) ?? uniformStore(uniform)),\n });\n }\n const samplers: ShaderSamplerEntry[] = [];\n for (const texture of declaration.textures) {\n samplers.push({ name: texture.name, viewDimension: texture.array ? \"2d-array\" : \"2d\" });\n }\n const storageBuffers: ShaderStorageEntry[] = [];\n for (const storage of declaration.storage) {\n storageBuffers.push({ name: storage.name, type: storage.type });\n }\n const pipeline = declaration.pipeline;\n const blended = pipeline.blend !== \"opaque\";\n return {\n name,\n source,\n attributes: declaration.attributes,\n uniforms: entries,\n samplers,\n storageBuffers,\n defines,\n useThinInstanceColors: pipeline.instancing === \"matrices-colors\",\n needAlphaBlending: blended,\n blendMode: pipeline.blend === \"additive\" ? \"additive\" : \"alpha\",\n blend: pipeline.blend === \"premultiplied\" ? PREMULTIPLIED_BLEND : null,\n transmissive: pipeline.transmissive,\n backFaceCulling: pipeline.cull === \"back\",\n depthWrite: pipeline.depthWrite,\n depthCompare: pipeline.depthTest ? null : \"always\",\n };\n}\n\n/** The dynamically imported Babylon Lite adapter, memoised for the process. */\nlet adapter: ShaderMaterialAdapter | null = null;\n\n/**\n * Loads the custom-WGSL half of the Babylon Lite adapter, once per process.\n *\n * @remarks\n * The shader **loader** awaits this before it hands back a `ShaderAsset`, which is what makes\n * {@link shaderMaterialAdapter} safe to call from the synchronous material builders. Loading it also\n * turns on Lite's cached uniform serialization plans, which is what makes the per-frame `time`\n * upload rewrite only the slots that changed.\n *\n * @returns A promise that resolves once the adapter is in place.\n *\n * @internal\n */\nexport async function loadShaderMaterialAdapter(): Promise<void> {\n if (adapter !== null) {\n return;\n }\n const loaded = await import(\"../lite/gpu/shader-material.js\");\n loaded.enableShaderUniformCaching();\n // The assignment is what checks `ShaderMaterialAdapter` against the module it stands for.\n adapter = loaded;\n}\n\n/**\n * The adapter, if it has been loaded.\n *\n * @returns The module, or `null` before any `.wgsl` has been loaded.\n *\n * @internal\n */\nexport function shaderMaterialAdapter(): ShaderMaterialAdapter | null {\n return adapter;\n}\n\n/**\n * The adapter, or the failure a material built before the `.wgsl` loader ran produces.\n *\n * @param shader - The shader being built, for the message.\n * @returns The adapter.\n * @throws IgnifxError with code `IGX-0715` when the chunk has not been loaded.\n */\nfunction requireShaderMaterialAdapter(shader: ShaderAsset): ShaderMaterialAdapter {\n const module = shaderMaterialAdapter();\n if (module === null) {\n throw new IgnifxError(\n CoreErrorCode.shaderCompileFailed,\n `${shader.address} cannot be built because the shader adapter has not been loaded.`,\n {\n context: { asset: shader.address, message: \"adapter not loaded\" },\n hint: \"Load the .wgsl through app.assets, which is what loads the adapter.\",\n },\n );\n }\n return module;\n}\n\n/**\n * The per-app state the shader material family needs: the 1x1 fallback textures declared samplers\n * fall back to, and the list of live materials whose per-frame ignifx uniforms have to be written.\n *\n * @remarks\n * It hangs off the app through a lazily created `WeakMap` rather than a service, so a shader\n * material works whether or not an extension registered anything, and two apps in one process keep\n * separate state (`CONSTITUTION.md` §3.6).\n *\n * @internal\n */\nexport class ShaderMaterialRegistry {\n readonly #app: App;\n\n /** Live materials that declare at least one ignifx uniform, in no particular order. */\n readonly #animated: ShaderMaterialState[] = [];\n\n readonly #fallbacks = new Map<string, LiteTexture2D>();\n\n /**\n * Creates the registry.\n *\n * @param app - The app it belongs to.\n */\n constructor(app: App) {\n this.#app = app;\n }\n\n /**\n * The materials the `PreRender` uniform system has to write this frame.\n *\n * @returns The list; the registry's own array, iterated without copying.\n */\n get animated(): readonly ShaderMaterialState[] {\n return this.#animated;\n }\n\n /**\n * Starts writing a material's ignifx uniforms every frame.\n *\n * @param state - The material.\n */\n add(state: ShaderMaterialState): void {\n if (!this.#animated.includes(state)) {\n this.#animated.push(state);\n }\n }\n\n /**\n * Stops writing a material's ignifx uniforms.\n *\n * @param state - The material.\n */\n remove(state: ShaderMaterialState): void {\n const index = this.#animated.indexOf(state);\n if (index < 0) {\n return;\n }\n const last = this.#animated.pop();\n if (last !== undefined && index < this.#animated.length) {\n this.#animated[index] = last;\n }\n }\n\n /**\n * The 1x1 texture a declared-but-unbound sampler is filled with, created on first use and shared\n * for the life of the app.\n *\n * @param declaration - The sampler declaration, for its `default` and `array` flags.\n * @returns The texture, or `null` under a headless app or before the adapter has loaded.\n */\n fallbackTexture(declaration: ShaderTextureDeclaration): LiteTexture2D | null {\n const module = shaderMaterialAdapter();\n if (module === null || this.#app.isHeadless) {\n return null;\n }\n return module.resolveFallbackTexture(\n this.#app.lite.engine,\n this.#fallbacks,\n declaration.fallback,\n declaration.array,\n );\n }\n}\n\n/** The per-app registries, created on first use so module scope allocates nothing. */\nlet registries: WeakMap<App, ShaderMaterialRegistry> | null = null;\n\n/**\n * The shader material state of one app.\n *\n * @param app - The app.\n * @returns Its registry, created on first use.\n *\n * @internal\n */\nexport function shaderMaterialsOf(app: App): ShaderMaterialRegistry {\n const map = (registries ??= new WeakMap<App, ShaderMaterialRegistry>());\n const existing = map.get(app);\n if (existing !== undefined) {\n return existing;\n }\n const created = new ShaderMaterialRegistry(app);\n map.set(app, created);\n return created;\n}\n\n/**\n * One live `\"shader\"` material: the Babylon Lite material, the CPU-side copy of every value written\n * to it, and the bindings it has to replay when the shader file or a `define` changes.\n *\n * @remarks\n * `MaterialAsset` owns one of these and forwards `setUniform`, `getUniform`, `setTexture`,\n * `setDefine`, and `setStorageBuffer` to it. It is `@internal` because the public surface is the\n * material's methods, not this object.\n *\n * @internal\n */\nexport class ShaderMaterialState {\n /** The definition the material was built from; a clone replays it. */\n readonly definition: ShaderMaterialDefinition;\n\n readonly #app: App;\n\n readonly #values = new Map<string, Float32Array>();\n\n readonly #textures = new Map<string, AssetHandle<TextureAsset> | null>();\n\n readonly #storage = new Map<string, AssetHandle<StorageBufferAsset> | null>();\n\n readonly #defines = new Map<string, boolean | number>();\n\n /** The last light values written, so an unchanged light costs no upload. */\n readonly #light = new Float32Array(FRAME_FLOATS);\n\n /** The ignifx-provided uniforms the file declares, paired with their stores. */\n readonly #engineSlots: { readonly name: IgnifxUniformName; readonly store: Float32Array }[] = [];\n\n #shader: ShaderAsset;\n\n #material: LiteShaderMaterial;\n\n /**\n * The adapter every write goes through. Captured once, because a state can only be built after\n * {@link buildLiteShaderMaterial} has proved the chunk is in memory.\n */\n readonly #adapter: ShaderMaterialAdapter;\n\n #hasLight = false;\n\n #hasWarnedAboutLight = false;\n\n #onReplaced: Disconnect | null = null;\n\n /**\n * Builds the material. Use {@link buildShaderMaterialState}.\n *\n * @param app - The app that owns the engine, the log, and the registry.\n * @param shader - The shader the material sets values on.\n * @param definition - The declaration.\n * @param material - The already-built Babylon Lite material.\n * @param liteAdapter - The custom-WGSL adapter every write goes through.\n */\n constructor(\n app: App,\n shader: ShaderAsset,\n definition: ShaderMaterialDefinition,\n material: LiteShaderMaterial,\n liteAdapter: ShaderMaterialAdapter,\n ) {\n this.#app = app;\n this.#adapter = liteAdapter;\n this.#shader = shader;\n this.definition = definition;\n this.#material = material;\n // Not zeros: a light really at the origin pointing along +Z would then never be written.\n this.#light.fill(Number.NaN);\n }\n\n /**\n * The shader the material is values for.\n *\n * @returns The shader asset, which a hot reload replaces.\n */\n get shader(): ShaderAsset {\n return this.#shader;\n }\n\n /**\n * The Babylon Lite material, which `setDefine` and a hot reload replace with a new object.\n *\n * @returns The material.\n */\n get material(): LiteShaderMaterial {\n return this.#material;\n }\n\n /**\n * Whether the shader declares any ignifx-provided uniform, and so needs a per-frame write.\n *\n * @returns `true` when the `PreRender` system has work to do for this material.\n */\n get isAnimated(): boolean {\n return this.#shader.declaration.ignifx.length > 0;\n }\n\n /**\n * Whether every declared storage buffer has a buffer bound, which is what Babylon Lite needs\n * before the material can be drawn at all.\n *\n * @returns `true` when the material is drawable.\n */\n get isDrawable(): boolean {\n const declared = this.#shader.declaration.storage;\n for (let index = 0; index < declared.length; index += 1) {\n const name = declared[index]?.name;\n if (name !== undefined && (this.#storage.get(name) ?? null) === null) {\n return false;\n }\n }\n return true;\n }\n\n /**\n * Writes a declared uniform.\n *\n * @param name - The uniform's name.\n * @param value - The value: a number, a numeric array, or — for a `color` uniform — an sRGB\n * colour, which is uploaded linear.\n * @throws IgnifxError with code `IGX-0712` when the shader declares no such uniform or the engine\n * writes it, or `IGX-0713` when the value has the wrong shape.\n */\n setUniform(name: string, value: number | readonly number[] | Float32Array | ColorLike): void {\n const declaration = this.#writableUniform(name);\n const store = this.#values.get(name) ?? uniformStore(declaration);\n this.#values.set(name, store);\n writeUniformValue(store, declaration, value, this.definition.name);\n this.#write(name, store);\n }\n\n /**\n * Reads the current CPU-side value of a declared uniform.\n *\n * @param name - The uniform's name.\n * @param out - Receives the value for a vector or matrix uniform; a fresh array is allocated when\n * it is omitted.\n * @returns The number for a scalar uniform, or the filled array.\n * @throws IgnifxError with code `IGX-0712` when the shader declares no such uniform, or\n * `IGX-0713` when `out` is too short.\n */\n getUniform(name: string, out?: Float32Array): number | Float32Array {\n const declaration = this.#uniform(name);\n const store = this.#values.get(name) ?? uniformStore(declaration);\n this.#values.set(name, store);\n if (store.length === 1 && out === undefined) {\n return store[0] ?? 0;\n }\n if (out === undefined) {\n return Float32Array.from(store);\n }\n if (out.length < store.length) {\n throw new IgnifxError(\n CoreErrorCode.shaderValueMismatch,\n `${name} on ${this.definition.name} expects ${String(store.length)} floats, not ${String(out.length)}.`,\n {\n context: { name, material: this.definition.name, expected: store.length, actual: out.length },\n hint: \"Pass an out array at least as long as the uniform's element count.\",\n },\n );\n }\n out.set(store);\n return out;\n }\n\n /**\n * Binds a texture to a declared sampler, or restores the declaration's fallback.\n *\n * @param name - The sampler's name.\n * @param texture - The texture, or `null` for the declared 1x1 fallback.\n * @throws IgnifxError with code `IGX-0712` when the shader declares no such sampler.\n */\n setTexture(name: string, texture: AssetHandle<TextureAsset> | null): void {\n const declaration = this.#texture(name);\n this.#textures.set(name, texture);\n this.#bindTexture(declaration, texture);\n }\n\n /**\n * Binds a storage buffer to a declared binding.\n *\n * @param name - The binding's name.\n * @param buffer - The buffer, or `null` to unbind. A material with an unbound declared storage\n * buffer cannot be drawn.\n * @throws IgnifxError with code `IGX-0712` when the shader declares no such storage buffer.\n */\n setStorageBuffer(name: string, buffer: AssetHandle<StorageBufferAsset> | null): void {\n const declared = this.#shader.declaration.storage;\n let found = false;\n for (let index = 0; index < declared.length; index += 1) {\n if (declared[index]?.name === name) {\n found = true;\n break;\n }\n }\n if (!found) {\n throw this.#unknownBinding(name, \"storage buffer\");\n }\n this.#storage.set(name, buffer);\n this.#bindStorage(name, buffer);\n }\n\n /**\n * Overrides a declared `define` and rebuilds the Babylon Lite material, because a define is a\n * WGSL `const` baked into the compiled pipeline.\n *\n * @remarks\n * The rebuild replaces the Lite material **object**. `MeshRenderer` re-reads\n * `MaterialAsset.lite.material` every `PreRender` and writes it onto its mesh when it changed,\n * and Lite's `mesh.material` setter enqueues a material swap that the next frame drains\n * (`lib/scene/mesh-scene-registry.js`), so the new pipeline is picked up on the following frame\n * with no explicit topology flag.\n *\n * @param name - The define's name.\n * @param value - The new value.\n * @throws IgnifxError with code `IGX-0712` when the shader declares no such define.\n */\n setDefine(name: string, value: boolean | number): void {\n const declared = this.#shader.declaration.defines;\n let fileValue: boolean | number | undefined;\n for (let index = 0; index < declared.length; index += 1) {\n const definition = declared[index];\n if (definition?.name === name) {\n fileValue = definition.value;\n break;\n }\n }\n if (fileValue === undefined) {\n throw this.#unknownBinding(name, \"define\");\n }\n // Compared against the value in force, not against the override map, so re-setting what the\n // file already declares is not a pipeline rebuild.\n if ((this.#defines.get(name) ?? fileValue) === value) {\n return;\n }\n this.#defines.set(name, value);\n this.#rebuild(this.#shader);\n }\n\n /**\n * Writes this frame's ignifx uniforms. The `PreRender` system calls it.\n *\n * @param time - Scaled seconds since `app.start()`.\n * @param unscaledTime - Unscaled seconds since `app.start()`.\n * @param deltaTime - Scaled seconds since the previous frame.\n * @param light - Nine floats: the main light's world direction, its linear colour times its\n * intensity, and the ambient colour.\n * @param hasLight - Whether an enabled directional light supplied the first six.\n */\n writeFrameUniforms(\n time: number,\n unscaledTime: number,\n deltaTime: number,\n light: Float32Array,\n hasLight: boolean,\n ): void {\n let lightChanged = this.#hasLight !== hasLight;\n this.#hasLight = hasLight;\n for (let index = 0; index < this.#light.length; index += 1) {\n if (this.#light[index] !== light[index]) {\n this.#light[index] = light[index] ?? 0;\n lightChanged = true;\n }\n }\n const slots = this.#engineSlots;\n for (let index = 0; index < slots.length; index += 1) {\n const slot = slots[index];\n if (slot === undefined) {\n continue;\n }\n switch (slot.name) {\n case \"time\":\n this.#writeScalar(slot.name, slot.store, time);\n break;\n case \"unscaledTime\":\n this.#writeScalar(slot.name, slot.store, unscaledTime);\n break;\n case \"deltaTime\":\n this.#writeScalar(slot.name, slot.store, deltaTime);\n break;\n case \"mainLightDirection\":\n if (lightChanged) {\n this.#writeTriple(slot.name, slot.store, light, DIRECTION_OFFSET);\n }\n break;\n case \"mainLightColor\":\n if (lightChanged) {\n this.#writeTriple(slot.name, slot.store, light, LIGHT_COLOR_OFFSET);\n }\n break;\n case \"ambientColor\":\n if (lightChanged) {\n this.#writeTriple(slot.name, slot.store, light, AMBIENT_OFFSET);\n }\n break;\n default:\n break;\n }\n }\n if (!hasLight && !this.#hasWarnedAboutLight && this.#needsLight()) {\n this.#hasWarnedAboutLight = true;\n const declared = this.#engineSlots.map((slot) => slot.name).join(\", \");\n this.#app.log.warnOnce(\n `${CoreErrorCode.shaderLightUniformWithoutLight}:${this.definition.name}`,\n `${CoreErrorCode.shaderLightUniformWithoutLight}: ${this.definition.name} declares ${declared}, ` +\n \"but this world has no enabled directional light; zeros are uploaded.\",\n );\n }\n }\n\n /**\n * Replays the definition's values, textures, defines, and storage bindings onto a freshly built\n * Babylon Lite material, and connects the hot-reload hook. Called once, by\n * {@link buildShaderMaterialState}.\n *\n * @param textures - The texture handles the loader resolved, in declaration order.\n */\n initialise(textures: readonly AssetHandle<TextureAsset>[]): void {\n const declaration = this.#shader.declaration;\n for (const name of Object.keys(this.definition.defines)) {\n const value = this.definition.defines[name];\n if (value !== undefined) {\n this.#defines.set(name, value);\n }\n }\n for (const name of Object.keys(this.definition.values)) {\n const value = this.definition.values[name];\n if (value !== undefined) {\n this.setUniform(name, value);\n }\n }\n const addresses = Object.keys(this.definition.textures);\n for (let index = 0; index < declaration.textures.length; index += 1) {\n const declared = declaration.textures[index];\n if (declared === undefined) {\n continue;\n }\n const slot = addresses.indexOf(declared.name);\n const handle = slot < 0 ? undefined : textures[slot];\n this.#textures.set(declared.name, handle ?? null);\n this.#bindTexture(declared, handle ?? null);\n }\n this.#refreshEngineSlots();\n if (this.isAnimated) {\n shaderMaterialsOf(this.#app).add(this);\n }\n const source = this.#app.assets.get<ShaderAsset>(this.definition.shader);\n this.#onReplaced =\n source?.onReplaced.connect((value: ShaderAsset): void => {\n this.#reload(value);\n }) ?? null;\n }\n\n /**\n * Stops the per-frame writes and the hot-reload hook. The `material` asset type's `unload` runs\n * it when the last holder releases the material.\n */\n dispose(): void {\n this.#onReplaced?.();\n this.#onReplaced = null;\n shaderMaterialsOf(this.#app).remove(this);\n }\n\n /**\n * Rebuilds the Lite material for a replaced shader file, keeping the previous one on failure.\n *\n * @param shader - The re-parsed shader asset.\n */\n #reload(shader: ShaderAsset): void {\n try {\n this.#rebuild(shader);\n this.#shader = shader;\n } catch (error: unknown) {\n this.#app.onError.emit({\n error: new IgnifxError(\n CoreErrorCode.shaderCompileFailed,\n `${shader.address} failed to rebuild; the previous material stays in use. ${String(error)}`,\n {\n context: { asset: shader.address, message: String(error) },\n cause: error,\n hint: \"Fix the shader file; the running material is the last one that built.\",\n },\n ),\n source: \"asset\",\n phase: null,\n entity: null,\n component: null,\n });\n }\n }\n\n /**\n * Builds a new Lite material from a declaration and replays every binding that still exists.\n *\n * @param shader - The shader to build from.\n */\n #rebuild(shader: ShaderAsset): void {\n const declaration = shader.declaration;\n const previous = this.#shader;\n // The Lite material is replaced halfway through, so a failure has to put the old one back or the\n // material would be left drawing a new program against the old declaration's bindings.\n const previousMaterial = this.#material;\n const previousValues = new Map(this.#values);\n this.#shader = shader;\n try {\n const values = new Map<string, Float32Array>();\n for (let index = 0; index < declaration.uniforms.length; index += 1) {\n const uniform = declaration.uniforms[index];\n if (uniform === undefined) {\n continue;\n }\n const kept = this.#values.get(uniform.name);\n values.set(\n uniform.name,\n kept !== undefined && kept.length === ELEMENT_COUNTS[uniform.type] ? kept : uniformStore(uniform),\n );\n }\n this.#material = buildLiteShaderMaterial(\n this.#app,\n this.definition.name,\n shader,\n values,\n this.#resolveDefines(shader),\n );\n this.#values.clear();\n for (const [name, store] of values) {\n this.#values.set(name, store);\n }\n this.#rebind(declaration);\n } catch (error: unknown) {\n this.#shader = previous;\n this.#material = previousMaterial;\n this.#values.clear();\n for (const [name, store] of previousValues) {\n this.#values.set(name, store);\n }\n throw error;\n }\n }\n\n /**\n * Re-applies the texture and storage bindings that the new declaration still has, dropping the\n * ones it no longer declares.\n *\n * @param declaration - The new declaration.\n */\n #rebind(declaration: ShaderDeclaration): void {\n const textures = new Map(this.#textures);\n this.#textures.clear();\n for (let index = 0; index < declaration.textures.length; index += 1) {\n const declared = declaration.textures[index];\n if (declared === undefined) {\n continue;\n }\n const handle = textures.get(declared.name) ?? null;\n this.#textures.set(declared.name, handle);\n this.#bindTexture(declared, handle);\n }\n const storage = new Map(this.#storage);\n this.#storage.clear();\n for (let index = 0; index < declaration.storage.length; index += 1) {\n const name = declaration.storage[index]?.name;\n if (name === undefined) {\n continue;\n }\n const handle = storage.get(name) ?? null;\n this.#storage.set(name, handle);\n this.#bindStorage(name, handle);\n }\n this.#refreshEngineSlots();\n const registry = shaderMaterialsOf(this.#app);\n if (this.isAnimated) {\n registry.add(this);\n } else {\n registry.remove(this);\n }\n this.#light.fill(Number.NaN);\n }\n\n /**\n * The declared `define` values with this material's overrides applied.\n *\n * @param shader - The shader whose declaration supplies the defaults.\n * @returns The resolved values.\n */\n #resolveDefines(shader: ShaderAsset): Readonly<Record<string, boolean | number>> {\n const resolved: Record<string, boolean | number> = {};\n const declared = shader.declaration.defines;\n for (let index = 0; index < declared.length; index += 1) {\n const define = declared[index];\n if (define === undefined) {\n continue;\n }\n setOwnJsonProperty(resolved, define.name, this.#defines.get(define.name) ?? define.value);\n }\n return resolved;\n }\n\n /**\n * Binds a texture, or the declaration's fallback when there is none.\n *\n * @param declaration - The sampler declaration.\n * @param handle - The texture handle, or `null`.\n */\n #bindTexture(declaration: ShaderTextureDeclaration, handle: AssetHandle<TextureAsset> | null): void {\n const loaded = handle?.state === \"loaded\" ? handle.value.lite.texture : null;\n this.#adapter.writeShaderTexture(\n this.#material,\n declaration.name,\n loaded ?? shaderMaterialsOf(this.#app).fallbackTexture(declaration),\n );\n }\n\n /**\n * Binds a storage buffer.\n *\n * @param name - The binding's name.\n * @param handle - The buffer handle, or `null`.\n */\n #bindStorage(name: string, handle: AssetHandle<StorageBufferAsset> | null): void {\n this.#adapter.writeShaderStorageBuffer(\n this.#material,\n name,\n handle?.state === \"loaded\" ? handle.value.lite.buffer : null,\n );\n }\n\n /**\n * Writes one CPU-side value through to Babylon Lite.\n *\n * @param name - The uniform's name.\n * @param store - The value.\n */\n #write(name: string, store: Float32Array): void {\n this.#adapter.writeShaderUniform(this.#material, name, store);\n }\n\n /**\n * Writes one engine-owned scalar uniform through its CPU-side store.\n *\n * @param name - The uniform's name.\n * @param store - The store, which is also what `getUniform` reads.\n * @param value - The value.\n */\n #writeScalar(name: string, store: Float32Array, value: number): void {\n store[0] = value;\n this.#adapter.writeShaderUniform(this.#material, name, store);\n }\n\n /**\n * Writes three floats of an engine-owned `vec3<f32>` uniform, without allocating.\n *\n * @param name - The uniform's name.\n * @param store - The store, which is also what `getUniform` reads.\n * @param source - The nine-float frame buffer.\n * @param offset - Where the triple starts inside it.\n */\n #writeTriple(name: string, store: Float32Array, source: Float32Array, offset: number): void {\n store.set(source.subarray(offset, offset + 3));\n this.#adapter.writeShaderUniform(this.#material, name, store);\n }\n\n /**\n * Resolves the CPU-side store of every ignifx-provided uniform the file declares, so the\n * per-frame write is an indexed loop with no name lookup (coding standards §7).\n */\n #refreshEngineSlots(): void {\n const slots = this.#engineSlots;\n slots.length = 0;\n const declared = this.#shader.declaration.ignifx;\n for (let index = 0; index < declared.length; index += 1) {\n const name = declared[index];\n if (name === undefined) {\n continue;\n }\n const count = ELEMENT_COUNTS[IGNIFX_UNIFORM_TYPES[name]];\n const store = this.#values.get(name) ?? new Float32Array(count);\n this.#values.set(name, store);\n slots.push({ name, store });\n }\n }\n\n /**\n * Whether the shader declares a uniform that needs a directional light.\n *\n * @returns `true` when `mainLightDirection` or `mainLightColor` is declared.\n */\n #needsLight(): boolean {\n const declared = this.#shader.declaration.ignifx;\n for (let index = 0; index < declared.length; index += 1) {\n const name = declared[index];\n if (name === \"mainLightDirection\" || name === \"mainLightColor\") {\n return true;\n }\n }\n return false;\n }\n\n /**\n * Looks a custom uniform declaration up.\n *\n * @param name - The uniform's name.\n * @returns The declaration.\n * @throws IgnifxError with code `IGX-0712`.\n */\n #uniform(name: string): ShaderUniformDeclaration {\n const custom = this.#customUniform(name);\n if (custom !== null) {\n return custom;\n }\n const engine = this.#engineUniform(name);\n if (engine !== null) {\n return engine;\n }\n throw this.#unknownBinding(name, \"uniform\");\n }\n\n /**\n * Looks a custom uniform declaration up, refusing the ones the engine writes.\n *\n * @param name - The uniform's name.\n * @returns The declaration.\n * @throws IgnifxError with code `IGX-0712`.\n */\n #writableUniform(name: string): ShaderUniformDeclaration {\n const custom = this.#customUniform(name);\n if (custom !== null) {\n return custom;\n }\n if (ENGINE_UNIFORM_NAMES.includes(name)) {\n throw new IgnifxError(\n CoreErrorCode.unknownShaderBinding,\n `${name} on ${this.definition.name} is written by the engine every frame and cannot be set.`,\n {\n context: { material: this.definition.name, name },\n hint: \"System uniforms come from Babylon Lite and the ignifx uniforms from the PreRender system.\",\n },\n );\n }\n throw this.#unknownBinding(name, \"uniform\");\n }\n\n /**\n * The file's own declaration of a uniform, if it declares one by that name.\n *\n * @param name - The uniform's name.\n * @returns The declaration, or `null`.\n */\n #customUniform(name: string): ShaderUniformDeclaration | null {\n const declared = this.#shader.declaration.uniforms;\n for (let index = 0; index < declared.length; index += 1) {\n const uniform = declared[index];\n if (uniform !== undefined && uniform.name === name) {\n return uniform;\n }\n }\n return null;\n }\n\n /**\n * The synthetic declaration of an ignifx-provided uniform the file declared, so `getUniform` can\n * read back what the `PreRender` system wrote.\n *\n * @param name - The uniform's name.\n * @returns The declaration, or `null` when the file declares no such engine uniform.\n */\n #engineUniform(name: string): ShaderUniformDeclaration | null {\n const declared = this.#shader.declaration.ignifx;\n for (let index = 0; index < declared.length; index += 1) {\n const ignifx = declared[index];\n if (ignifx !== undefined && ignifx === name) {\n return {\n name: ignifx,\n type: IGNIFX_UNIFORM_TYPES[ignifx],\n defaultValue: zeros(ELEMENT_COUNTS[IGNIFX_UNIFORM_TYPES[ignifx]]),\n color: false,\n range: null,\n step: null,\n tooltip: null,\n };\n }\n }\n return null;\n }\n\n /**\n * Looks a sampler declaration up.\n *\n * @param name - The sampler's name.\n * @returns The declaration.\n * @throws IgnifxError with code `IGX-0712`.\n */\n #texture(name: string): ShaderTextureDeclaration {\n const declared = this.#shader.declaration.textures;\n for (let index = 0; index < declared.length; index += 1) {\n const texture = declared[index];\n if (texture !== undefined && texture.name === name) {\n return texture;\n }\n }\n throw this.#unknownBinding(name, \"texture\");\n }\n\n /**\n * Builds the `IGX-0712` failure an undeclared binding name produces.\n *\n * @param name - The name that was asked for.\n * @param what - What kind of binding was expected.\n * @returns The error to throw.\n */\n #unknownBinding(name: string, what: string): IgnifxError {\n return new IgnifxError(\n CoreErrorCode.unknownShaderBinding,\n `${this.definition.name} declares no ${what} named ${name}.`,\n {\n context: { material: this.definition.name, name },\n hint: `Declare it in ${this.#shader.address} with an // @ignifx ${what} pragma.`,\n },\n );\n }\n}\n\n/**\n * Builds the live state of a `\"shader\"` material: the Babylon Lite material, then every value,\n * texture, and define the definition names.\n *\n * @param app - The app that owns the engine, the log, and the registry.\n * @param shader - The shader the material sets values on.\n * @param definition - The declaration.\n * @param textures - The texture handles the loader resolved, in the order the definition's\n * `textures` record names them.\n * @returns The state.\n * @throws IgnifxError with code `IGX-0715` when the adapter has not been loaded, `IGX-0712` for an\n * undeclared value or define name, or `IGX-0713` for a value of the wrong shape.\n *\n * @internal\n */\nexport function buildShaderMaterialState(\n app: App,\n shader: ShaderAsset,\n definition: ShaderMaterialDefinition,\n textures: readonly AssetHandle<TextureAsset>[],\n): ShaderMaterialState {\n const defines: Record<string, boolean | number> = {};\n const declared = shader.declaration.defines;\n for (let index = 0; index < declared.length; index += 1) {\n const define = declared[index];\n if (define !== undefined) {\n const given = Object.hasOwn(definition.defines, define.name) ? definition.defines[define.name] : undefined;\n setOwnJsonProperty(defines, define.name, given ?? define.value);\n }\n }\n for (const name of Object.keys(definition.defines)) {\n if (!Object.hasOwn(defines, name)) {\n throw new IgnifxError(\n CoreErrorCode.unknownShaderBinding,\n `${definition.name} declares no define named ${name}.`,\n {\n context: { material: definition.name, name },\n hint: `Declare it in ${shader.address} with an // @ignifx define pragma.`,\n },\n );\n }\n }\n const material = buildLiteShaderMaterial(app, definition.name, shader, new Map(), defines);\n const state = new ShaderMaterialState(app, shader, definition, material, requireShaderMaterialAdapter(shader));\n state.initialise(textures);\n return state;\n}\n\n/**\n * Builds the Babylon Lite material a declaration describes, through the dynamically loaded adapter.\n *\n * @remarks\n * Under `rendering.hdr` the fragment is wrapped to write linear colour (GI plan step G3), so the\n * output pass does not encode it a second time.\n *\n * @param app - The app, whose scene says whether it renders through `rendering.hdr`.\n * @param name - The material's name.\n * @param shader - The shader.\n * @param values - Current custom uniform values to seed the declaration's defaults with.\n * @param defines - The resolved `define` values.\n * @returns The Lite material.\n * @throws IgnifxError with code `IGX-0715` when the adapter has not been loaded yet.\n */\nfunction buildLiteShaderMaterial(\n app: App,\n name: string,\n shader: ShaderAsset,\n values: ReadonlyMap<string, Float32Array>,\n defines: Readonly<Record<string, boolean | number>>,\n): LiteShaderMaterial {\n const options = toShaderMaterialOptions(name, shader.source, shader.declaration, values, defines);\n const linearOutput = !app.isHeadless && isHdrScene(app.lite.scene);\n return requireShaderMaterialAdapter(shader).createShaderMaterialFromOptions(\n linearOutput ? { ...options, linearOutput } : options,\n );\n}\n\n/**\n * A number, or an array of that many zeros, matching what a uniform of that arity starts at.\n *\n * @param count - How many elements the uniform holds.\n * @returns The zero value.\n */\nfunction zeros(count: number): number | readonly number[] {\n if (count === 1) {\n return 0;\n }\n const values: number[] = [];\n for (let index = 0; index < count; index += 1) {\n values.push(0);\n }\n return values;\n}\n\n/**\n * A fresh CPU-side store for one uniform, filled with its declared default — **linear** for a\n * colour, because that is what the GPU reads.\n *\n * @param declaration - The uniform declaration.\n * @returns The store.\n */\nfunction uniformStore(declaration: ShaderUniformDeclaration): Float32Array {\n const count = ELEMENT_COUNTS[declaration.type];\n const store = new Float32Array(count);\n const value = declaration.defaultValue;\n if (typeof value === \"number\") {\n store[0] = value;\n } else {\n store.set(value.slice(0, count));\n }\n if (declaration.color) {\n decodeColourComponents(store);\n }\n return store;\n}\n\n/**\n * Writes a caller's value into a uniform's CPU-side store, checking its shape and decoding a\n * colour.\n *\n * @param store - The store to write into.\n * @param declaration - The uniform declaration.\n * @param value - The caller's value.\n * @param material - The material's name, for diagnostics.\n * @throws IgnifxError with code `IGX-0713` when the value's shape does not match the declared type.\n */\nfunction writeUniformValue(\n store: Float32Array,\n declaration: ShaderUniformDeclaration,\n value: number | readonly number[] | Float32Array | ColorLike,\n material: string,\n): void {\n const count = store.length;\n if (typeof value === \"number\") {\n if (count !== 1) {\n throw shapeMismatch(declaration, material, `${declaration.type} (${String(count)} floats)`, \"a single number\");\n }\n store[0] = value;\n return;\n }\n if (isColorLike(value)) {\n if (count !== 3 && count !== 4) {\n throw shapeMismatch(declaration, material, `${declaration.type} (${String(count)} floats)`, \"a colour\");\n }\n store[0] = Color.srgbToLinear(value.r);\n store[1] = Color.srgbToLinear(value.g);\n store[2] = Color.srgbToLinear(value.b);\n if (count === 4) {\n store[3] = value.a;\n }\n return;\n }\n if (value.length !== count) {\n throw shapeMismatch(\n declaration,\n material,\n `${declaration.type} (${String(count)} floats)`,\n `${String(value.length)} floats`,\n );\n }\n store.set(value instanceof Float32Array ? value : Float32Array.from(value));\n if (declaration.color) {\n decodeColourComponents(store);\n }\n}\n\n/**\n * Decodes a store's first three components from sRGB to linear, in place.\n *\n * @remarks\n * A `subarray` view and `map` rather than three indexed reads: a `Float32Array` element is typed\n * `number | undefined` under `noUncheckedIndexedAccess`, and `map` hands the callback a `number`.\n * It runs on a value write, never per frame.\n *\n * @param store - The store, at least three floats long.\n */\nfunction decodeColourComponents(store: Float32Array): void {\n const rgb = store.subarray(0, 3);\n rgb.set(rgb.map((component) => Color.srgbToLinear(component)));\n}\n\n/**\n * Whether a value is an sRGB colour rather than a numeric array.\n *\n * @param value - The candidate.\n * @returns `true` for an object carrying `r`, `g`, `b`, and `a`.\n */\nfunction isColorLike(value: readonly number[] | Float32Array | ColorLike): value is ColorLike {\n return !Array.isArray(value) && !(value instanceof Float32Array);\n}\n\n/**\n * Builds the `IGX-0713` failure a wrongly shaped value produces.\n *\n * @param declaration - The uniform declaration.\n * @param material - The material's name.\n * @param expected - What the uniform takes.\n * @param actual - What the caller passed.\n * @returns The error to throw.\n */\nfunction shapeMismatch(\n declaration: ShaderUniformDeclaration,\n material: string,\n expected: string,\n actual: string,\n): IgnifxError {\n return new IgnifxError(\n CoreErrorCode.shaderValueMismatch,\n `${declaration.name} on ${material} expects ${expected}, not ${actual}.`,\n {\n context: { name: declaration.name, material, expected, actual },\n hint: \"A colour uniform takes a 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