@ignifx/core 0.21.1 → 0.22.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.
- package/dist/{gtao-BmdrXXJz.js → gtao-CVAYWBEJ.js} +2 -2
- package/dist/{gtao-BmdrXXJz.js.map → gtao-CVAYWBEJ.js.map} +1 -1
- package/dist/index.d.ts +24 -9
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +48 -25
- package/dist/index.js.map +1 -1
- package/dist/{prefab-overrides-DwrPDVVt.d.ts → prefab-overrides-CkwXhp5A.d.ts} +24 -2
- package/dist/{prefab-overrides-DwrPDVVt.d.ts.map → prefab-overrides-CkwXhp5A.d.ts.map} +1 -1
- package/dist/prefab.d.ts +1 -1
- package/dist/scene-color-passes-CM_T2KF-.js +177 -0
- package/dist/scene-color-passes-CM_T2KF-.js.map +1 -0
- package/dist/{scene-inputs-_0j2Hi6L.js → scene-inputs-CbTkrkOw.js} +220 -50
- package/dist/scene-inputs-CbTkrkOw.js.map +1 -0
- package/dist/ssgi-Dk20U3oR.js +492 -0
- package/dist/ssgi-Dk20U3oR.js.map +1 -0
- package/package.json +1 -1
- package/dist/scene-color-passes-DgXJ45Ql.js +0 -88
- package/dist/scene-color-passes-DgXJ45Ql.js.map +0 -1
- package/dist/scene-inputs-_0j2Hi6L.js.map +0 -1
- package/dist/ssgi-DSnhqotl.js +0 -113
- package/dist/ssgi-DSnhqotl.js.map +0 -1
|
@@ -8,10 +8,11 @@ import { GeometryTextureType, addTaskAfter, addTaskAtStart, buildFrameGraphTask,
|
|
|
8
8
|
* §2.5).
|
|
9
9
|
*
|
|
10
10
|
* ```text
|
|
11
|
-
* [shadow] → geometry ─→ normals copy ─→ velocity copy ─→ depth pyramid → scene → …
|
|
11
|
+
* [shadow] → geometry ─→ normals copy ─→ velocity copy ─→ [albedo copy] ─→ depth pyramid → scene → …
|
|
12
12
|
* ├ depth (depth32float, sampled)
|
|
13
13
|
* ├ world normal ─(copy)─→ normals
|
|
14
|
-
*
|
|
14
|
+
* ├ velocity ─(copy)─→ velocity
|
|
15
|
+
* └ [albedo ─(copy)─→ albedo]
|
|
15
16
|
* ```
|
|
16
17
|
*
|
|
17
18
|
* - **Depth** is a surface-sized `depth32float` target with a sampled facade
|
|
@@ -21,6 +22,11 @@ import { GeometryTextureType, addTaskAfter, addTaskAtStart, buildFrameGraphTask,
|
|
|
21
22
|
* `RenderTarget`s; compute and effect bindings take a `Texture2D`, so each is copied into a target
|
|
22
23
|
* that has one (`docs/architecture/07-rendering.md` §8, upstream ask "geometry attachments as
|
|
23
24
|
* `Texture2D`").
|
|
25
|
+
* - **Albedo** is a third attachment only while a user asked for it ({@link SceneInputsOptions.albedo},
|
|
26
|
+
* SSGI): the first such acquire replaces the geometry task and its copies with ones that also
|
|
27
|
+
* write albedo, keeping every target the other users hold. The old tasks keep drawing until the
|
|
28
|
+
* new geometry task has loaded its material code, so no frame is left without inputs. Albedo
|
|
29
|
+
* stays until the last lease of any kind is released.
|
|
24
30
|
* - **The depth pyramid** is Lite's `createDepthPyramid`: an `r32float` mip chain where each level
|
|
25
31
|
* keeps the `max` (in reverse-Z, the nearest surface) of its four children.
|
|
26
32
|
* - **Ref-counted.** {@link SceneInputsHost.acquire} adds the tasks for the first user;
|
|
@@ -39,6 +45,7 @@ const SCENE_INPUT_TASK_NAMES = {
|
|
|
39
45
|
geometry: "ignifx:scene-inputs",
|
|
40
46
|
normals: "ignifx:scene-inputs-normals",
|
|
41
47
|
velocity: "ignifx:scene-inputs-velocity",
|
|
48
|
+
albedo: "ignifx:scene-inputs-albedo",
|
|
42
49
|
depthPyramid: "ignifx:scene-inputs-depth-pyramid"
|
|
43
50
|
};
|
|
44
51
|
/**
|
|
@@ -50,6 +57,7 @@ const SCENE_INPUT_FORMATS = {
|
|
|
50
57
|
depth: "depth32float",
|
|
51
58
|
normals: "rgba16float",
|
|
52
59
|
velocity: "rgba16float",
|
|
60
|
+
albedo: "rgba8unorm",
|
|
53
61
|
depthPyramid: "r32float"
|
|
54
62
|
};
|
|
55
63
|
/**
|
|
@@ -58,11 +66,12 @@ const SCENE_INPUT_FORMATS = {
|
|
|
58
66
|
*
|
|
59
67
|
* @param engine - The engine, which is also the primary surface.
|
|
60
68
|
* @param scene - The render scene.
|
|
69
|
+
* @param report - Called with a message when work the host does after `acquire` returned fails.
|
|
61
70
|
* @returns The host.
|
|
62
71
|
*
|
|
63
72
|
* @internal
|
|
64
73
|
*/
|
|
65
|
-
function createSceneInputsHost(engine, scene) {
|
|
74
|
+
function createSceneInputsHost(engine, scene, report) {
|
|
66
75
|
let shared = null;
|
|
67
76
|
const leases = /* @__PURE__ */ new Set();
|
|
68
77
|
let isDisposed = false;
|
|
@@ -72,10 +81,12 @@ function createSceneInputsHost(engine, scene) {
|
|
|
72
81
|
shared = null;
|
|
73
82
|
};
|
|
74
83
|
return {
|
|
75
|
-
acquire(isFrameGraphBuilt) {
|
|
84
|
+
acquire(isFrameGraphBuilt, options) {
|
|
76
85
|
if (isDisposed) return null;
|
|
77
|
-
|
|
86
|
+
const wantsAlbedo = options?.albedo === true;
|
|
87
|
+
shared ??= buildSharedInputs(engine, scene, isFrameGraphBuilt, wantsAlbedo);
|
|
78
88
|
const inputs = shared;
|
|
89
|
+
if (wantsAlbedo && inputs.albedo === null) addAlbedo(engine, scene, inputs, isFrameGraphBuilt, report);
|
|
79
90
|
let isReleased = false;
|
|
80
91
|
const own = /* @__PURE__ */ new Set();
|
|
81
92
|
const lease = {
|
|
@@ -83,6 +94,9 @@ function createSceneInputsHost(engine, scene) {
|
|
|
83
94
|
depthTarget: inputs.depth.rt,
|
|
84
95
|
normals: inputs.normals.texture,
|
|
85
96
|
velocity: inputs.velocity.texture,
|
|
97
|
+
get albedo() {
|
|
98
|
+
return inputs.albedo?.texture ?? null;
|
|
99
|
+
},
|
|
86
100
|
get depthPyramid() {
|
|
87
101
|
return inputs.pyramid.current.texture;
|
|
88
102
|
},
|
|
@@ -127,9 +141,10 @@ function createSceneInputsHost(engine, scene) {
|
|
|
127
141
|
* @param engine - The engine.
|
|
128
142
|
* @param scene - The scene.
|
|
129
143
|
* @param isFrameGraphBuilt - Whether each task must be recorded now.
|
|
144
|
+
* @param withAlbedo - Whether the geometry pass also writes albedo.
|
|
130
145
|
* @returns The shared state.
|
|
131
146
|
*/
|
|
132
|
-
function buildSharedInputs(engine, scene, isFrameGraphBuilt) {
|
|
147
|
+
function buildSharedInputs(engine, scene, isFrameGraphBuilt, withAlbedo) {
|
|
133
148
|
const depth = createSurfaceRenderTargetTexture(engine, {
|
|
134
149
|
lbl: "ignifx:scene-inputs-depth",
|
|
135
150
|
dFormat: SCENE_INPUT_FORMATS.depth,
|
|
@@ -148,31 +163,16 @@ function buildSharedInputs(engine, scene, isFrameGraphBuilt) {
|
|
|
148
163
|
samples: 1,
|
|
149
164
|
size: engine
|
|
150
165
|
});
|
|
151
|
-
const
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
}, {
|
|
159
|
-
type: GeometryTextureType.LINEAR_VELOCITY,
|
|
160
|
-
format: SCENE_INPUT_FORMATS.velocity
|
|
161
|
-
}]
|
|
162
|
-
}, engine, scene);
|
|
163
|
-
const copyNormals = createCopyToTextureTask({
|
|
164
|
-
name: SCENE_INPUT_TASK_NAMES.normals,
|
|
165
|
-
sourceTexture: requireAttachment(geometry.geometryWorldNormalTexture, "world normal"),
|
|
166
|
-
targetTexture: normals.rt
|
|
167
|
-
}, engine, scene);
|
|
168
|
-
const copyVelocity = createCopyToTextureTask({
|
|
169
|
-
name: SCENE_INPUT_TASK_NAMES.velocity,
|
|
170
|
-
sourceTexture: requireAttachment(geometry.geometryLinearVelocityTexture, "linear velocity"),
|
|
171
|
-
targetTexture: velocity.rt
|
|
172
|
-
}, engine, scene);
|
|
166
|
+
const albedo = withAlbedo ? createAlbedoTarget(engine) : null;
|
|
167
|
+
const geometryTasks = createGeometryTasks(engine, scene, {
|
|
168
|
+
depth,
|
|
169
|
+
normals,
|
|
170
|
+
velocity,
|
|
171
|
+
albedo
|
|
172
|
+
});
|
|
173
173
|
const depthFacade = requireDepthFacade(depth);
|
|
174
174
|
const pyramid = { current: newPyramid(engine, depthFacade) };
|
|
175
|
-
const
|
|
175
|
+
const pyramidTask = createDepthPyramidTask(engine, scene, {
|
|
176
176
|
pyramid: {
|
|
177
177
|
get texture() {
|
|
178
178
|
return pyramid.current.texture;
|
|
@@ -192,27 +192,19 @@ function buildSharedInputs(engine, scene, isFrameGraphBuilt) {
|
|
|
192
192
|
},
|
|
193
193
|
source: () => depthFacade
|
|
194
194
|
});
|
|
195
|
-
Reflect.set(
|
|
196
|
-
const
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
copyVelocity,
|
|
200
|
-
buildPyramid
|
|
201
|
-
];
|
|
202
|
-
addTaskAtStart(scene, geometry);
|
|
203
|
-
addTaskAfter(scene, copyNormals, geometry);
|
|
204
|
-
addTaskAfter(scene, copyVelocity, copyNormals);
|
|
205
|
-
addTaskAfter(scene, buildPyramid, copyVelocity);
|
|
206
|
-
if (isFrameGraphBuilt) {
|
|
207
|
-
const graph = getFrameGraph(scene);
|
|
208
|
-
for (const task of tasks) buildFrameGraphTask(graph, task);
|
|
209
|
-
}
|
|
195
|
+
Reflect.set(pyramidTask, "name", SCENE_INPUT_TASK_NAMES.depthPyramid);
|
|
196
|
+
const last = insertGeometryTasks(scene, geometryTasks, isFrameGraphBuilt);
|
|
197
|
+
addTaskAfter(scene, pyramidTask, last);
|
|
198
|
+
if (isFrameGraphBuilt) buildFrameGraphTask(getFrameGraph(scene), pyramidTask);
|
|
210
199
|
const listeners = /* @__PURE__ */ new Set();
|
|
211
200
|
return {
|
|
212
201
|
depth,
|
|
213
202
|
normals,
|
|
214
203
|
velocity,
|
|
215
|
-
|
|
204
|
+
albedo,
|
|
205
|
+
geometryTasks,
|
|
206
|
+
isTornDown: false,
|
|
207
|
+
pyramidTask,
|
|
216
208
|
pyramid,
|
|
217
209
|
listeners,
|
|
218
210
|
stopResizeWatch: onRenderTargetTextureResize(depth, () => {
|
|
@@ -223,22 +215,200 @@ function buildSharedInputs(engine, scene, isFrameGraphBuilt) {
|
|
|
223
215
|
};
|
|
224
216
|
}
|
|
225
217
|
/**
|
|
218
|
+
* Creates the albedo target.
|
|
219
|
+
*
|
|
220
|
+
* @param engine - The engine, which is also the surface.
|
|
221
|
+
* @returns The target and its sampled facade.
|
|
222
|
+
*/
|
|
223
|
+
function createAlbedoTarget(engine) {
|
|
224
|
+
return createSurfaceRenderTargetTexture(engine, {
|
|
225
|
+
lbl: "ignifx:scene-inputs-albedo",
|
|
226
|
+
format: SCENE_INPUT_FORMATS.albedo,
|
|
227
|
+
samples: 1,
|
|
228
|
+
size: engine
|
|
229
|
+
});
|
|
230
|
+
}
|
|
231
|
+
/**
|
|
232
|
+
* Creates the geometry task and one copy per colour attachment.
|
|
233
|
+
*
|
|
234
|
+
* @param engine - The engine.
|
|
235
|
+
* @param scene - The scene.
|
|
236
|
+
* @param targets - The depth the pass writes and the targets its attachments are copied into.
|
|
237
|
+
* @param targets.depth - The depth target.
|
|
238
|
+
* @param targets.normals - The normals target.
|
|
239
|
+
* @param targets.velocity - The velocity target.
|
|
240
|
+
* @param targets.albedo - The albedo target, or `null` to leave albedo out of the pass.
|
|
241
|
+
* @returns The tasks, in the order they run.
|
|
242
|
+
*/
|
|
243
|
+
function createGeometryTasks(engine, scene, targets) {
|
|
244
|
+
const textureDescriptions = [{
|
|
245
|
+
type: GeometryTextureType.WORLD_NORMAL,
|
|
246
|
+
format: SCENE_INPUT_FORMATS.normals
|
|
247
|
+
}, {
|
|
248
|
+
type: GeometryTextureType.LINEAR_VELOCITY,
|
|
249
|
+
format: SCENE_INPUT_FORMATS.velocity
|
|
250
|
+
}];
|
|
251
|
+
if (targets.albedo !== null) textureDescriptions.push({
|
|
252
|
+
type: GeometryTextureType.ALBEDO,
|
|
253
|
+
format: SCENE_INPUT_FORMATS.albedo
|
|
254
|
+
});
|
|
255
|
+
const geometry = createGeometryRendererTask({
|
|
256
|
+
name: SCENE_INPUT_TASK_NAMES.geometry,
|
|
257
|
+
size: engine,
|
|
258
|
+
depthTexture: targets.depth.rt,
|
|
259
|
+
textureDescriptions
|
|
260
|
+
}, engine, scene);
|
|
261
|
+
const tasks = [
|
|
262
|
+
geometry,
|
|
263
|
+
createCopyToTextureTask({
|
|
264
|
+
name: SCENE_INPUT_TASK_NAMES.normals,
|
|
265
|
+
sourceTexture: requireAttachment(geometry.geometryWorldNormalTexture, "world normal"),
|
|
266
|
+
targetTexture: targets.normals.rt
|
|
267
|
+
}, engine, scene),
|
|
268
|
+
createCopyToTextureTask({
|
|
269
|
+
name: SCENE_INPUT_TASK_NAMES.velocity,
|
|
270
|
+
sourceTexture: requireAttachment(geometry.geometryLinearVelocityTexture, "linear velocity"),
|
|
271
|
+
targetTexture: targets.velocity.rt
|
|
272
|
+
}, engine, scene)
|
|
273
|
+
];
|
|
274
|
+
if (targets.albedo !== null) tasks.push(createCopyToTextureTask({
|
|
275
|
+
name: SCENE_INPUT_TASK_NAMES.albedo,
|
|
276
|
+
sourceTexture: requireAttachment(geometry.geometryAlbedoTexture, "albedo"),
|
|
277
|
+
targetTexture: targets.albedo.rt
|
|
278
|
+
}, engine, scene));
|
|
279
|
+
return tasks;
|
|
280
|
+
}
|
|
281
|
+
/**
|
|
282
|
+
* Puts the geometry task at the start of the frame graph and its copies right after it.
|
|
283
|
+
*
|
|
284
|
+
* @param scene - The scene.
|
|
285
|
+
* @param tasks - What {@link createGeometryTasks} made.
|
|
286
|
+
* @param isFrameGraphBuilt - Whether each task must be recorded now.
|
|
287
|
+
* @returns The last task inserted.
|
|
288
|
+
*/
|
|
289
|
+
function insertGeometryTasks(scene, tasks, isFrameGraphBuilt) {
|
|
290
|
+
const [geometry, ...copies] = tasks;
|
|
291
|
+
if (geometry === void 0) throw new Error("The scene inputs have no geometry task.");
|
|
292
|
+
addTaskAtStart(scene, geometry);
|
|
293
|
+
let after = geometry;
|
|
294
|
+
for (const copy of copies) {
|
|
295
|
+
addTaskAfter(scene, copy, after);
|
|
296
|
+
after = copy;
|
|
297
|
+
}
|
|
298
|
+
if (isFrameGraphBuilt) {
|
|
299
|
+
const graph = getFrameGraph(scene);
|
|
300
|
+
for (const task of tasks) buildFrameGraphTask(graph, task);
|
|
301
|
+
}
|
|
302
|
+
return after;
|
|
303
|
+
}
|
|
304
|
+
/**
|
|
305
|
+
* Replaces the geometry task and its copies with ones that also write albedo.
|
|
306
|
+
*
|
|
307
|
+
* @remarks
|
|
308
|
+
* Lite fixes a geometry task's attachments at creation. The depth, normals and velocity targets,
|
|
309
|
+
* and the pyramid task that reads the depth, stay as they are, so no other user has to rebind.
|
|
310
|
+
*
|
|
311
|
+
* A geometry task draws nothing until its `_preload` has imported the code for the scene's
|
|
312
|
+
* material families. Lite awaits that at scene registration (`lib/scene/scene-core.js`); for a
|
|
313
|
+
* task added later it only starts on the first draw, which leaves that frame empty
|
|
314
|
+
* (`lib/frame-graph/geometry-renderer-task.js`, `resolveSourceMaterial`). So in a registered scene
|
|
315
|
+
* the new tasks are created first and swapped in once that promise settles, and the old ones draw
|
|
316
|
+
* until then. The albedo target exists from the start and holds nothing until the swap.
|
|
317
|
+
*
|
|
318
|
+
* @param engine - The engine.
|
|
319
|
+
* @param scene - The scene.
|
|
320
|
+
* @param shared - The shared state, updated in place.
|
|
321
|
+
* @param isFrameGraphBuilt - Whether the scene is registered.
|
|
322
|
+
* @param report - Called with a message when the swap fails; the old tasks then stay.
|
|
323
|
+
*/
|
|
324
|
+
function addAlbedo(engine, scene, shared, isFrameGraphBuilt, report) {
|
|
325
|
+
const albedo = createAlbedoTarget(engine);
|
|
326
|
+
shared.albedo = albedo;
|
|
327
|
+
const next = createGeometryTasks(engine, scene, shared);
|
|
328
|
+
const swap = () => {
|
|
329
|
+
if (shared.isTornDown) {
|
|
330
|
+
disposeTasks(next);
|
|
331
|
+
return;
|
|
332
|
+
}
|
|
333
|
+
const previous = shared.geometryTasks;
|
|
334
|
+
const textureBefore = albedo.texture.texture;
|
|
335
|
+
carryPreviousViewProjection(previous[0], next[0]);
|
|
336
|
+
try {
|
|
337
|
+
insertGeometryTasks(scene, next, isFrameGraphBuilt);
|
|
338
|
+
} catch (failure) {
|
|
339
|
+
removeTasks(scene, next);
|
|
340
|
+
report(`The scene inputs could not add albedo: ${failure instanceof Error ? failure.message : String(failure)}`);
|
|
341
|
+
return;
|
|
342
|
+
}
|
|
343
|
+
removeTasks(scene, previous);
|
|
344
|
+
shared.geometryTasks = next;
|
|
345
|
+
if (albedo.texture.texture !== textureBefore) for (const listener of shared.listeners) listener();
|
|
346
|
+
};
|
|
347
|
+
const preload = isFrameGraphBuilt ? Reflect.get(next[0] ?? {}, "_preload") : void 0;
|
|
348
|
+
if (typeof preload !== "function") {
|
|
349
|
+
swap();
|
|
350
|
+
return;
|
|
351
|
+
}
|
|
352
|
+
Promise.resolve(Reflect.apply(preload, next[0], [])).then(swap, swap);
|
|
353
|
+
}
|
|
354
|
+
/**
|
|
355
|
+
* Hands the previous frame's view-projection from one geometry task to its replacement, so the
|
|
356
|
+
* velocity the new task writes for PBR meshes in its first frame is measured from the last frame
|
|
357
|
+
* drawn. A Standard mesh tracks its own previous matrix per geometry view and writes no velocity
|
|
358
|
+
* for that one frame (`lib/material/standard/standard-geometry-output-shader.js`).
|
|
359
|
+
*
|
|
360
|
+
* @remarks
|
|
361
|
+
* The field is private to Lite (`_previousViewProjection`, `lib/frame-graph/geometry-renderer-task.js`)
|
|
362
|
+
* and starts as zeros. If a later Lite renames it, the first frame's velocity is wrong and TAA
|
|
363
|
+
* drops its history for that frame.
|
|
364
|
+
*
|
|
365
|
+
* @param from - The task being replaced.
|
|
366
|
+
* @param to - The task replacing it.
|
|
367
|
+
*/
|
|
368
|
+
function carryPreviousViewProjection(from, to) {
|
|
369
|
+
const source = from === void 0 ? void 0 : Reflect.get(from, "_previousViewProjection");
|
|
370
|
+
const target = to === void 0 ? void 0 : Reflect.get(to, "_previousViewProjection");
|
|
371
|
+
if (source instanceof Float32Array && target instanceof Float32Array && source.length === target.length) target.set(source);
|
|
372
|
+
}
|
|
373
|
+
/**
|
|
226
374
|
* Removes the tasks from the frame graph and frees every task and target.
|
|
227
375
|
*
|
|
228
376
|
* @param scene - The scene.
|
|
229
377
|
* @param shared - What {@link buildSharedInputs} built.
|
|
230
378
|
*/
|
|
231
379
|
function teardown(scene, shared) {
|
|
380
|
+
shared.isTornDown = true;
|
|
232
381
|
shared.stopResizeWatch();
|
|
233
382
|
shared.listeners.clear();
|
|
234
|
-
|
|
383
|
+
removeTasks(scene, [...shared.geometryTasks, shared.pyramidTask]);
|
|
384
|
+
disposeRenderTargetTexture(shared.depth);
|
|
385
|
+
disposeRenderTargetTexture(shared.normals);
|
|
386
|
+
disposeRenderTargetTexture(shared.velocity);
|
|
387
|
+
if (shared.albedo !== null) disposeRenderTargetTexture(shared.albedo);
|
|
388
|
+
}
|
|
389
|
+
/**
|
|
390
|
+
* Takes tasks out of the frame graph and disposes them.
|
|
391
|
+
*
|
|
392
|
+
* @param scene - The scene.
|
|
393
|
+
* @param tasks - The tasks.
|
|
394
|
+
*/
|
|
395
|
+
function removeTasks(scene, tasks) {
|
|
396
|
+
for (const task of tasks) {
|
|
235
397
|
task.executionEnabled = false;
|
|
236
398
|
removeFrameGraphTask(scene, task);
|
|
399
|
+
}
|
|
400
|
+
disposeTasks(tasks);
|
|
401
|
+
}
|
|
402
|
+
/**
|
|
403
|
+
* Disposes tasks that are not in a frame graph.
|
|
404
|
+
*
|
|
405
|
+
* @param tasks - The tasks.
|
|
406
|
+
*/
|
|
407
|
+
function disposeTasks(tasks) {
|
|
408
|
+
for (const task of tasks) {
|
|
409
|
+
task.executionEnabled = false;
|
|
237
410
|
task.dispose();
|
|
238
411
|
}
|
|
239
|
-
disposeRenderTargetTexture(shared.depth);
|
|
240
|
-
disposeRenderTargetTexture(shared.normals);
|
|
241
|
-
disposeRenderTargetTexture(shared.velocity);
|
|
242
412
|
}
|
|
243
413
|
/**
|
|
244
414
|
* Takes a task out of the scene's frame graph.
|
|
@@ -316,4 +486,4 @@ function requireAttachment(target, what) {
|
|
|
316
486
|
//#endregion
|
|
317
487
|
export { SCENE_INPUT_TASK_NAMES, createSceneInputsHost, frameGraphTasks };
|
|
318
488
|
|
|
319
|
-
//# sourceMappingURL=scene-inputs-
|
|
489
|
+
//# sourceMappingURL=scene-inputs-CbTkrkOw.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"scene-inputs-CbTkrkOw.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/architecture/07-rendering.md` §2.12): one geometry pass that\n * screen-space effects (TAA, GTAO, contact shadows, SSGI) read instead of each drawing the scene\n * again. Its own chunk: the renderer imports it only when an effect asks for it, so a project with\n * no such effect loads none of it and its frame graph has none of these tasks (`CONSTITUTION.md`\n * §2.5).\n *\n * ```text\n * [shadow] → geometry ─→ normals copy ─→ velocity copy ─→ [albedo copy] ─→ depth pyramid → scene → …\n * ├ depth (depth32float, sampled)\n * ├ world normal ─(copy)─→ normals\n * ├ velocity ─(copy)─→ velocity\n * └ [albedo ─(copy)─→ albedo]\n * ```\n *\n * - **Depth** is a surface-sized `depth32float` target with a sampled facade\n * (`withSampledDepthTexture`) handed to the geometry task as its depth. 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 (`docs/architecture/07-rendering.md` §8, upstream ask \"geometry attachments as\n * `Texture2D`\").\n * - **Albedo** is a third attachment only while a user asked for it ({@link SceneInputsOptions.albedo},\n * SSGI): the first such acquire replaces the geometry task and its copies with ones that also\n * write albedo, keeping every target the other users hold. The old tasks keep drawing until the\n * new geometry task has loaded its material code, so no frame is left without inputs. Albedo\n * stays until the last lease of any kind is released.\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 albedo: \"ignifx:scene-inputs-albedo\",\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 albedo: \"rgba8unorm\";\n readonly depthPyramid: \"r32float\";\n} = {\n depth: \"depth32float\",\n normals: \"rgba16float\",\n velocity: \"rgba16float\",\n albedo: \"rgba8unorm\",\n depthPyramid: \"r32float\",\n};\n\n/**\n * What a user needs beyond depth, normals, velocity and the depth pyramid.\n *\n * @internal\n */\nexport interface SceneInputsOptions {\n /** Whether the user reads {@link SceneInputs.albedo}. Default `false`. */\n readonly albedo?: boolean;\n}\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 diffuse albedo of the nearest surface, `rgba8unorm`; 0 where nothing was drawn. `null`\n * until a lease asked for it ({@link SceneInputsOptions.albedo}); read it again after such a\n * lease was acquired, and expect 0 everywhere for the frames it takes the new geometry task to\n * load.\n *\n * For a PBR material it is Lite's linear `surfaceAlbedo`: the base colour without the metallic\n * and specular share, whether or not the material is unlit. For a Standard material Lite writes\n * the diffuse texture's colour, or white without one, and leaves the material's `diffuse` colour\n * out (`lib/material/standard/standard-geometry-output-shader.js`).\n */\n readonly albedo: Texture2D | null;\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 * @param options - What the user needs beyond the default inputs.\n * @returns A lease; call its `release()` when done. `null` once the host is disposed.\n */\n acquire(isFrameGraphBuilt: boolean, options?: SceneInputsOptions): 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 /** The albedo target, once a user asked for it. */\n albedo: RenderTargetTextureResult | null;\n /** The geometry task and its copies; replaced when albedo is added. */\n geometryTasks: readonly Task[];\n /** `true` once {@link teardown} ran, so a late swap frees its tasks instead of inserting them. */\n isTornDown: boolean;\n readonly pyramidTask: 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 * @param report - Called with a message when work the host does after `acquire` returned fails.\n * @returns The host.\n *\n * @internal\n */\nexport function createSceneInputsHost(\n engine: EngineContext,\n scene: SceneContext,\n report: (message: string) => void,\n): 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, options?: SceneInputsOptions): SceneInputs | null {\n if (isDisposed) {\n return null;\n }\n const wantsAlbedo = options?.albedo === true;\n shared ??= buildSharedInputs(engine, scene, isFrameGraphBuilt, wantsAlbedo);\n const inputs = shared;\n if (wantsAlbedo && inputs.albedo === null) {\n addAlbedo(engine, scene, inputs, isFrameGraphBuilt, report);\n }\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 albedo(): Texture2D | null {\n return inputs.albedo?.texture ?? null;\n },\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 * @param withAlbedo - Whether the geometry pass also writes albedo.\n * @returns The shared state.\n */\nfunction buildSharedInputs(\n engine: EngineContext,\n scene: SceneContext,\n isFrameGraphBuilt: boolean,\n withAlbedo: boolean,\n): 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 albedo = withAlbedo ? createAlbedoTarget(engine) : null;\n const geometryTasks = createGeometryTasks(engine, scene, { depth, normals, velocity, albedo });\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 pyramidTask = createDepthPyramidTask(engine, scene, { pyramid: forward, source: () => depthFacade });\n Reflect.set(pyramidTask, \"name\", SCENE_INPUT_TASK_NAMES.depthPyramid);\n\n const last = insertGeometryTasks(scene, geometryTasks, isFrameGraphBuilt);\n addTaskAfter(scene, pyramidTask, last);\n if (isFrameGraphBuilt) {\n buildFrameGraphTask(getFrameGraph(scene), pyramidTask);\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 {\n depth,\n normals,\n velocity,\n albedo,\n geometryTasks,\n isTornDown: false,\n pyramidTask,\n pyramid,\n listeners,\n stopResizeWatch,\n };\n}\n\n/**\n * Creates the albedo target.\n *\n * @param engine - The engine, which is also the surface.\n * @returns The target and its sampled facade.\n */\nfunction createAlbedoTarget(engine: EngineContext): RenderTargetTextureResult {\n return createSurfaceRenderTargetTexture(engine, {\n lbl: \"ignifx:scene-inputs-albedo\",\n format: SCENE_INPUT_FORMATS.albedo,\n samples: 1,\n size: engine,\n });\n}\n\n/**\n * Creates the geometry task and one copy per colour attachment.\n *\n * @param engine - The engine.\n * @param scene - The scene.\n * @param targets - The depth the pass writes and the targets its attachments are copied into.\n * @param targets.depth - The depth target.\n * @param targets.normals - The normals target.\n * @param targets.velocity - The velocity target.\n * @param targets.albedo - The albedo target, or `null` to leave albedo out of the pass.\n * @returns The tasks, in the order they run.\n */\nfunction createGeometryTasks(\n engine: EngineContext,\n scene: SceneContext,\n targets: {\n readonly depth: RenderTargetTextureResult;\n readonly normals: RenderTargetTextureResult;\n readonly velocity: RenderTargetTextureResult;\n readonly albedo: RenderTargetTextureResult | null;\n },\n): readonly Task[] {\n const textureDescriptions: { type: GeometryTextureType; format: GPUTextureFormat }[] = [\n { type: GeometryTextureType.WORLD_NORMAL, format: SCENE_INPUT_FORMATS.normals },\n { type: GeometryTextureType.LINEAR_VELOCITY, format: SCENE_INPUT_FORMATS.velocity },\n ];\n if (targets.albedo !== null) {\n textureDescriptions.push({ type: GeometryTextureType.ALBEDO, format: SCENE_INPUT_FORMATS.albedo });\n }\n const geometry = createGeometryRendererTask(\n { name: SCENE_INPUT_TASK_NAMES.geometry, size: engine, depthTexture: targets.depth.rt, textureDescriptions },\n engine,\n scene,\n );\n const tasks: Task[] = [\n geometry,\n createCopyToTextureTask(\n {\n name: SCENE_INPUT_TASK_NAMES.normals,\n sourceTexture: requireAttachment(geometry.geometryWorldNormalTexture, \"world normal\"),\n targetTexture: targets.normals.rt,\n },\n engine,\n scene,\n ),\n createCopyToTextureTask(\n {\n name: SCENE_INPUT_TASK_NAMES.velocity,\n sourceTexture: requireAttachment(geometry.geometryLinearVelocityTexture, \"linear velocity\"),\n targetTexture: targets.velocity.rt,\n },\n engine,\n scene,\n ),\n ];\n if (targets.albedo !== null) {\n tasks.push(\n createCopyToTextureTask(\n {\n name: SCENE_INPUT_TASK_NAMES.albedo,\n sourceTexture: requireAttachment(geometry.geometryAlbedoTexture, \"albedo\"),\n targetTexture: targets.albedo.rt,\n },\n engine,\n scene,\n ),\n );\n }\n return tasks;\n}\n\n/**\n * Puts the geometry task at the start of the frame graph and its copies right after it.\n *\n * @param scene - The scene.\n * @param tasks - What {@link createGeometryTasks} made.\n * @param isFrameGraphBuilt - Whether each task must be recorded now.\n * @returns The last task inserted.\n */\nfunction insertGeometryTasks(scene: SceneContext, tasks: readonly Task[], isFrameGraphBuilt: boolean): Task {\n const [geometry, ...copies] = tasks;\n if (geometry === undefined) {\n throw new Error(\"The scene inputs have no geometry task.\");\n }\n addTaskAtStart(scene, geometry);\n let after = geometry;\n for (const copy of copies) {\n addTaskAfter(scene, copy, after);\n after = copy;\n }\n if (isFrameGraphBuilt) {\n const graph = getFrameGraph(scene);\n for (const task of tasks) {\n buildFrameGraphTask(graph, task);\n }\n }\n return after;\n}\n\n/**\n * Replaces the geometry task and its copies with ones that also write albedo.\n *\n * @remarks\n * Lite fixes a geometry task's attachments at creation. The depth, normals and velocity targets,\n * and the pyramid task that reads the depth, stay as they are, so no other user has to rebind.\n *\n * A geometry task draws nothing until its `_preload` has imported the code for the scene's\n * material families. Lite awaits that at scene registration (`lib/scene/scene-core.js`); for a\n * task added later it only starts on the first draw, which leaves that frame empty\n * (`lib/frame-graph/geometry-renderer-task.js`, `resolveSourceMaterial`). So in a registered scene\n * the new tasks are created first and swapped in once that promise settles, and the old ones draw\n * until then. The albedo target exists from the start and holds nothing until the swap.\n *\n * @param engine - The engine.\n * @param scene - The scene.\n * @param shared - The shared state, updated in place.\n * @param isFrameGraphBuilt - Whether the scene is registered.\n * @param report - Called with a message when the swap fails; the old tasks then stay.\n */\nfunction addAlbedo(\n engine: EngineContext,\n scene: SceneContext,\n shared: SharedInputs,\n isFrameGraphBuilt: boolean,\n report: (message: string) => void,\n): void {\n const albedo = createAlbedoTarget(engine);\n shared.albedo = albedo;\n const next = createGeometryTasks(engine, scene, shared);\n const swap = (): void => {\n if (shared.isTornDown) {\n disposeTasks(next);\n return;\n }\n const previous = shared.geometryTasks;\n const textureBefore = albedo.texture.texture;\n carryPreviousViewProjection(previous[0], next[0]);\n try {\n // The new tasks go in before the old ones leave, so a failure keeps the inputs drawn.\n insertGeometryTasks(scene, next, isFrameGraphBuilt);\n } catch (failure) {\n removeTasks(scene, next);\n report(`The scene inputs could not add albedo: ${failure instanceof Error ? failure.message : String(failure)}`);\n return;\n }\n removeTasks(scene, previous);\n shared.geometryTasks = next;\n if (albedo.texture.texture !== textureBefore) {\n // No task kept the albedo target at the surface's size while the swap was pending, so a\n // resize in between is only caught up with now, by the copy's `record`. Users rebind.\n for (const listener of shared.listeners) {\n listener();\n }\n }\n };\n const preload: unknown = isFrameGraphBuilt ? Reflect.get(next[0] ?? {}, \"_preload\") : undefined;\n if (typeof preload !== \"function\") {\n // Not registered yet: `registerScene` preloads every task. Or Lite renamed the method, and the\n // inputs are empty for the frames the task takes to load by itself.\n swap();\n return;\n }\n // A failed load is Lite's to report when the task first draws; the swap happens either way.\n Promise.resolve(Reflect.apply(preload, next[0], [])).then(swap, swap);\n}\n\n/**\n * Hands the previous frame's view-projection from one geometry task to its replacement, so the\n * velocity the new task writes for PBR meshes in its first frame is measured from the last frame\n * drawn. A Standard mesh tracks its own previous matrix per geometry view and writes no velocity\n * for that one frame (`lib/material/standard/standard-geometry-output-shader.js`).\n *\n * @remarks\n * The field is private to Lite (`_previousViewProjection`, `lib/frame-graph/geometry-renderer-task.js`)\n * and starts as zeros. If a later Lite renames it, the first frame's velocity is wrong and TAA\n * drops its history for that frame.\n *\n * @param from - The task being replaced.\n * @param to - The task replacing it.\n */\nfunction carryPreviousViewProjection(from: Task | undefined, to: Task | undefined): void {\n const source: unknown = from === undefined ? undefined : Reflect.get(from, \"_previousViewProjection\");\n const target: unknown = to === undefined ? undefined : Reflect.get(to, \"_previousViewProjection\");\n if (source instanceof Float32Array && target instanceof Float32Array && source.length === target.length) {\n target.set(source);\n }\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.isTornDown = true;\n shared.stopResizeWatch();\n shared.listeners.clear();\n removeTasks(scene, [...shared.geometryTasks, shared.pyramidTask]);\n // Tasks still waiting for their swap were never in the graph: its callback frees them.\n disposeRenderTargetTexture(shared.depth);\n disposeRenderTargetTexture(shared.normals);\n disposeRenderTargetTexture(shared.velocity);\n if (shared.albedo !== null) {\n disposeRenderTargetTexture(shared.albedo);\n }\n}\n\n/**\n * Takes tasks out of the frame graph and disposes them.\n *\n * @param scene - The scene.\n * @param tasks - The tasks.\n */\nfunction removeTasks(scene: SceneContext, tasks: readonly Task[]): void {\n for (const task of tasks) {\n // Disable first: a disposed task that still executes is a use-after-free.\n task.executionEnabled = false;\n removeFrameGraphTask(scene, task);\n }\n disposeTasks(tasks);\n}\n\n/**\n * Disposes tasks that are not in a frame graph.\n *\n * @param tasks - The tasks.\n */\nfunction disposeTasks(tasks: readonly Task[]): void {\n for (const task of tasks) {\n task.executionEnabled = false;\n task.dispose();\n }\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":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAmEA,MAAa,yBAAyB;CACpC,UAAU;CACV,SAAS;CACT,UAAU;CACV,Q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