@babylonjs/lite 1.11.0 → 1.13.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 (105) hide show
  1. package/CHANGELOG.md +35 -0
  2. package/dist/index.js +444 -368
  3. package/dist/index.js.map +1 -1
  4. package/index.d.ts +208 -6
  5. package/lib/asset-container.js.map +1 -1
  6. package/lib/audio/index.js +1 -0
  7. package/lib/audio/index.js.map +1 -1
  8. package/lib/audio/media-stream-output.js +44 -0
  9. package/lib/audio/media-stream-output.js.map +1 -0
  10. package/lib/engine/engine.js +1 -1
  11. package/lib/frame-graph/render-task.js +1 -1
  12. package/lib/frame-graph/render-task.js.map +1 -1
  13. package/lib/frame-graph/shadow-inputs.js +10 -1
  14. package/lib/frame-graph/shadow-inputs.js.map +1 -1
  15. package/lib/frame-graph/transmission.js +1 -16
  16. package/lib/frame-graph/transmission.js.map +1 -1
  17. package/lib/index.js +6 -3
  18. package/lib/index.js.map +1 -1
  19. package/lib/loader-gltf/gltf-json-asset.js +1 -1
  20. package/lib/loader-gltf/gltf-json-asset.js.map +1 -1
  21. package/lib/loader-gltf/gltf-multi-buffer.js +2 -10
  22. package/lib/loader-gltf/gltf-multi-buffer.js.map +1 -1
  23. package/lib/loader-gltf/gltf-pbr-builder-ext.js +4 -18
  24. package/lib/loader-gltf/gltf-pbr-builder-ext.js.map +1 -1
  25. package/lib/loader-gltf/gltf-pbr-builder.js +17 -14
  26. package/lib/loader-gltf/gltf-pbr-builder.js.map +1 -1
  27. package/lib/loader-gltf/gltf-sampler-desc.js +3 -16
  28. package/lib/loader-gltf/gltf-sampler-desc.js.map +1 -1
  29. package/lib/material/node/blocks/ambient-occlusion-block.js +1 -4
  30. package/lib/material/node/blocks/ambient-occlusion-block.js.map +1 -1
  31. package/lib/material/node/blocks/biplanar-block.js +3 -6
  32. package/lib/material/node/blocks/biplanar-block.js.map +1 -1
  33. package/lib/material/node/blocks/image-source.js +2 -5
  34. package/lib/material/node/blocks/image-source.js.map +1 -1
  35. package/lib/material/node/blocks/input-block.js +5 -26
  36. package/lib/material/node/blocks/input-block.js.map +1 -1
  37. package/lib/material/node/blocks/pbr-mr-helper-full.js +5 -8
  38. package/lib/material/node/blocks/pbr-mr-helper-full.js.map +1 -1
  39. package/lib/material/node/blocks/reflection-texture-block.js +1 -4
  40. package/lib/material/node/blocks/reflection-texture-block.js.map +1 -1
  41. package/lib/material/node/blocks/texture-block.js +2 -5
  42. package/lib/material/node/blocks/texture-block.js.map +1 -1
  43. package/lib/material/node/blocks/triplanar-block.js +3 -6
  44. package/lib/material/node/blocks/triplanar-block.js.map +1 -1
  45. package/lib/material/node/node-emitter.js +24 -1
  46. package/lib/material/node/node-emitter.js.map +1 -1
  47. package/lib/material/node/node-geometry-renderable.js +2 -2
  48. package/lib/material/node/node-material.js +1 -22
  49. package/lib/material/node/node-material.js.map +1 -1
  50. package/lib/material/node/node-types.js.map +1 -1
  51. package/lib/material/pbr/fragments/shadow-only-fragment.js +68 -0
  52. package/lib/material/pbr/fragments/shadow-only-fragment.js.map +1 -0
  53. package/lib/material/pbr/pbr-flag-bits.js.map +1 -1
  54. package/lib/material/pbr/pbr-material.js.map +1 -1
  55. package/lib/material/pbr/pbr-primitive-resolver.js +2 -2
  56. package/lib/material/pbr/pbr-primitive-resolver.js.map +1 -1
  57. package/lib/material/pbr/pbr-renderable.js +3 -0
  58. package/lib/material/pbr/pbr-renderable.js.map +1 -1
  59. package/lib/material/pbr/pbr-template.js +1 -0
  60. package/lib/material/pbr/pbr-template.js.map +1 -1
  61. package/lib/mesh/GaussianSplatting/gaussian-splatting-mesh.js +2 -8
  62. package/lib/mesh/GaussianSplatting/gaussian-splatting-mesh.js.map +1 -1
  63. package/lib/mesh/get-mesh-geometry.js +24 -0
  64. package/lib/mesh/get-mesh-geometry.js.map +1 -0
  65. package/lib/mesh/mesh-dispose.js +2 -0
  66. package/lib/mesh/mesh-dispose.js.map +1 -1
  67. package/lib/mesh/mesh.js +2 -8
  68. package/lib/mesh/mesh.js.map +1 -1
  69. package/lib/mesh/thin-instance-cull-binding.js +54 -3
  70. package/lib/mesh/thin-instance-cull-binding.js.map +1 -1
  71. package/lib/mesh/thin-instance-gpu-culling.js +241 -24
  72. package/lib/mesh/thin-instance-gpu-culling.js.map +1 -1
  73. package/lib/mesh/thin-instance.js +112 -1
  74. package/lib/mesh/thin-instance.js.map +1 -1
  75. package/lib/picking/gpu-picker.js +4 -2
  76. package/lib/picking/gpu-picker.js.map +1 -1
  77. package/lib/picking/picking-pipeline.js +1 -1
  78. package/lib/picking/picking-pipeline.js.map +1 -1
  79. package/lib/picking/picking-shader.js +38 -16
  80. package/lib/picking/picking-shader.js.map +1 -1
  81. package/lib/scene/scene-core.js +7 -2
  82. package/lib/scene/scene-core.js.map +1 -1
  83. package/lib/scene/scene-node.js +2 -6
  84. package/lib/scene/scene-node.js.map +1 -1
  85. package/lib/scene/scene-remove.js +70 -1
  86. package/lib/scene/scene-remove.js.map +1 -1
  87. package/lib/scene/transform-node.js +3 -0
  88. package/lib/scene/transform-node.js.map +1 -1
  89. package/lib/scene/world-matrix-state.js +7 -1
  90. package/lib/scene/world-matrix-state.js.map +1 -1
  91. package/lib/shadow/csm-directional-shadow-generator.js +22 -1
  92. package/lib/shadow/csm-directional-shadow-generator.js.map +1 -1
  93. package/lib/shadow/csm-shadow-task-hooks.js +19 -11
  94. package/lib/shadow/csm-shadow-task-hooks.js.map +1 -1
  95. package/lib/shadow/esm-directional-shadow-generator.js +2 -51
  96. package/lib/shadow/esm-directional-shadow-generator.js.map +1 -1
  97. package/lib/shadow/pcf-directional-shadow-generator.js +2 -48
  98. package/lib/shadow/pcf-directional-shadow-generator.js.map +1 -1
  99. package/lib/shadow/shadow-base.js +48 -1
  100. package/lib/shadow/shadow-base.js.map +1 -1
  101. package/lib/text/text-renderable.js +2 -10
  102. package/lib/text/text-renderable.js.map +1 -1
  103. package/lib/texture/texture-array.js +96 -0
  104. package/lib/texture/texture-array.js.map +1 -0
  105. package/package.json +3 -3
@@ -1 +1 @@
1
- {"version":3,"file":"render-task.js","sources":["../../../src/frame-graph/render-task.ts"],"sourcesContent":["/**\n * RenderTask — a frame-graph task that records a single `RenderPass`,\n * binds the scene's `RenderTarget`, and draws renderables into it.\n *\n * - `record()` builds bucketed `DrawBinding` lists from `_renderables`\n * (opaque / direct / transparent), sorts opaque + direct by\n * `order`, then creates a `RenderPass` wired to the task's render target.\n * The pass owns its\n * `GPURenderPassDescriptor` and the per-pass-encoder body lives in a\n * closure passed to `setRenderPassExecuteFunc`.\n * - Before `RenderPass._execute()` begins the GPU pass: writes the scene UBO, refreshes lights, updates\n * per-binding UBOs, mirrors live `scene.clearColor` + `clr` onto the\n * render pass. Shared task execution then calls `_execute()`. The\n * `RenderPass` itself patches the swapchain view + clearColor + loadOp\n * and brackets the body with `beginRenderPass` / `end`.\n *\n * Renderable population:\n * - Explicit: push into `_renderables` directly, or `addMesh(mesh, opts)`\n * which builds a (mesh, material) Renderable at `record()` time.\n * - Auto scene mirror: when `_renderables` is empty at record() time, copy the\n * scene's renderables. Re-sync happens automatically when the scene's\n * `_renderableVersion` changes between frames (mesh add/remove, material swap).\n *\n * The engine `scRT` is just another `RenderTarget` here: a task that\n * targets it (`rt`) or resolves into it (`rst`) re-reads its per-frame color view\n * at execute time (the swap texture is re-acquired each frame). `clr: false`\n * switches color + depth `loadOp` to `\"load\"` so multiple scenes can share the\n * swapchain in one frame (e.g., a 3D scene + a UI overlay scene).\n */\n\nimport { F32 } from \"../engine/typed-arrays.js\";\nimport type { EngineContext } from \"../engine/engine.js\";\nimport { _vis } from \"../engine/engine.js\";\nimport type { Mesh } from \"../mesh/mesh.js\";\nimport type { Camera } from \"../camera/camera.js\";\nimport type { Renderable, DrawBinding, DrawUpdateContext, DrawUpdateBatch } from \"../render/renderable.js\";\nimport type { RenderTargetSignature } from \"../engine/render-target.js\";\nimport type { SceneContext } from \"../scene/scene-core.js\";\nimport type { Material } from \"../material/material.js\";\nimport type { RenderTarget } from \"../engine/render-target.js\";\nimport { buildRenderTarget, disposeRenderTarget } from \"../engine/render-target.js\";\nimport { getViewMatrix } from \"../camera/camera.js\";\nimport { getSceneBindGroupLayout } from \"../render/scene-helpers.js\";\nimport { _packSceneUniforms } from \"./scene-uniforms-pack.js\";\nimport { createEmptyUniformBuffer } from \"../resource/gpu-buffers.js\";\nimport { SCENE_UBO_BYTES } from \"../shader/scene-uniforms-size.js\";\nimport { ensureSceneLightState, refreshSceneLightsUBO } from \"../render/lights-ubo.js\";\nimport type { Task } from \"./task.js\";\n\n/** Configuration for `createRenderTask`: render target, clear state, optional camera override, and transmission settings. */\nexport interface RenderTaskConfig {\n name: string;\n /** TODO: rt should not live in this config long-term. Until texture\n * management is virtualized, callers must provide the concrete target; once\n * virtualized, the task should create/manage its own render target. */\n rt: RenderTarget;\n /** Optional single-sample resolve target. When `rt` is multisampled\n * (`sampleCount > 1`), the color attachment resolves into this target's\n * color texture at end-of-pass — letting an MSAA render feed a post-process\n * that requires a single-sample source, without an extra resolve pass.\n * Caller contract (not validated): must be single-sample with a color\n * format and size matching `rt`; WebGPU errors at pass-encode time if not.\n * Ignored when `rt` is single-sample. */\n rst?: RenderTarget;\n /** Optional separate depth/stencil attachment. The pass binds this target's\n * depth view instead of `rt`'s own, and uses its `depthStencilFormat` for\n * pipeline signature matching. The colour `rt` must omit `depthStencilFormat`\n * (so it allocates no internal depth) and match this target in size + sample\n * count. Two ownership modes, distinguished by `_eager`:\n * - `_eager` depth (e.g. a `GeometryRendererTask` output): the task neither\n * builds nor clears nor disposes it — it loads it (`loadOp: \"load\"`) and the\n * caller owns clearing. This is how scenes reuse a pre-rendered depth buffer.\n * - non-`_eager` depth: the task owns it — builds/rebuilds it in `record()`,\n * clears it (`loadOp: \"clear\"`), and disposes it. Used by the default\n * single-sample scene task, whose colour `rt` is the depth-less\n * engine `scRT`. */\n depth?: RenderTarget;\n /** Background clear color. May be mutated frame-to-frame. */\n clrColor?: GPUColorDict;\n /** When true, color `loadOp` is \"clear\"; when false, \"load\" (overlays previous\n * color content). Depth is always cleared when rt-owned and always loaded when\n * supplied via `depth`. */\n clr?: boolean;\n /** Per-pass camera override. Null/undefined uses `scene.camera`. */\n cam?: Camera | null;\n /** Use canvas dimensions, not render-target dimensions, for this pass's scene UBO aspect. */\n cs?: boolean;\n /** Scene-texture transmission settings. `copyCount: 0` copies before every transmissive draw.\n * `generateMipmaps: false` allocates only mip 0 for the refraction texture and skips mip generation.\n * `mipLevelCount` caps the generated chain when a material only samples low explicit LODs.\n * `grabDepth: true` also snapshots the task's DEPTH attachment at the same mid-pass grab (see\n * `TransmissionOptions.grabDepth`). */\n transmission?: { copyCount?: number; generateMipmaps?: boolean; mipLevelCount?: number; grabDepth?: boolean };\n /** @internal Skip clustered-light preparation for passes that never run forward lighting. */\n _skipClusteredLights?: boolean;\n}\n\n/** A frame-graph task that records a single `RenderPass`, binds the scene's `RenderTarget`, and draws renderables into it. */\nexport interface RenderTask extends Task {\n readonly name: string;\n /** Render tasks are scene-bound because they consume scene camera, lights, and renderables. */\n readonly scene: SceneContext;\n /** Live task configuration. Mutating `clr` or `clrColor` affects subsequent frames. */\n /** @internal */\n readonly _config: RenderTaskConfig;\n /** @internal */\n _autoFromScene: boolean;\n\n /** Source-of-truth renderables. Bucketed binding lists below are derived from\n * this list at `record()` (or re-sync when auto-filled and `_renderableVersion` changes). */\n /** @internal */\n _renderables: Renderable[];\n /** @internal */\n _opaqueBindings: DrawBinding[];\n /** @internal */\n _directBindings: DrawBinding[];\n /** @internal */\n _transparentBindings: DrawBinding[];\n /** Cached opaque render bundle. Invalidated by renderable list mutations\n * (`_lastVersion`) and the global visibility/resource epoch (`_lastVis`). */\n /** @internal */\n _opaqueBundles: GPURenderBundle[];\n /** @internal */\n _lastVersion: number;\n /** @internal */\n _lastVis: number;\n /** @internal True once `record()` has run — the task is \"live\" (GPU target allocated, material batch builders\n * present). A runtime `addMesh` after this resolves + re-buckets THIS task immediately (no frame-graph rebuild). */\n _recorded: boolean;\n\n /** @internal */\n _renderPassDescriptor: GPURenderPassDescriptor;\n /** @internal */\n _colorAttachment: GPURenderPassColorAttachment;\n /** @internal External depth source from `config.depth`. When unset,\n * the pass uses `config.rt._depthView`. */\n _depthSrc?: RenderTarget;\n /** @internal External depth/stencil `loadOp` (\"load\" when `config.depth` is\n * set). When unset, defaults to `\"clear\"`. */\n _depthLoadOp?: GPULoadOp;\n\n /** Per-task scene UBO + bind group. Created eagerly in createRenderTask\n * so renderables can reference `_sceneBG` at `bind()` time. Written each\n * frame by `_writePassSceneUBO`. Destroyed in `dispose()`. */\n /** @internal */\n _sceneUBO: GPUBuffer;\n /** @internal */\n _sceneBG: GPUBindGroup;\n /** @internal */\n _lightsUBO: GPUBuffer;\n /** @internal */\n _suData: Float32Array;\n /** @internal */\n _su: unknown[];\n /** Optional transmission-enabled execute path: copies the scene texture for refraction and draws transmissive\n * renderables. Present only when the task was configured with `transmission`. Returns the number of draw calls issued. */\n /** @internal */\n _executeWithTransmission?(sampleCount: number): number;\n /** @internal */\n _targetSignature: RenderTargetSignature;\n /** @internal Lazy feature work flushed after binding updates and before the render pass. */\n _updateBatches: DrawUpdateBatch[];\n\n /** Add a mesh to this task's explicit render list with an optional per-pass material override. Resolved via\n * `material._buildGroup._rebuildSingle`, so the mesh's material family must already have been registered with the\n * scene (its batch builder has run). BEFORE the first `record()` the add is QUEUED and drained at record() time;\n * AFTER (a live/runtime add) it is resolved + re-bucketed into THIS task immediately, so the mesh renders on the\n * next frame without a `frameGraph.build()` (which would re-allocate shared GPU resources across all tasks). */\n addMesh(mesh: Mesh, opts?: { material?: Material }): void;\n /** @internal */\n _pendingMeshes: { mesh: Mesh; material: Material }[];\n}\n\ninterface MutableDrawUpdateContext {\n targetWidth: number;\n targetHeight: number;\n _camera?: Camera | null;\n}\n\n/** Create a render pass task. GPU resources (target textures + descriptor)\n * are not allocated until `record()` runs (via `frameGraph.build()`).\n *\n * Swapchain-targeted tasks acquire the swap view per-frame at execute time. */\nexport function createRenderTask(config: RenderTaskConfig, engine: EngineContext, scene: SceneContext): RenderTask {\n const sc = scene as SceneContext;\n config.clrColor ??= { r: 0.2, g: 0.2, b: 0.3, a: 1.0 };\n config.clr ??= true;\n const desc = config.rt._descriptor;\n // Render upright: row 0 of the GPU texture is the top of the scene. Every\n // RT (offscreen or swapchain) renders without a projection Y-flip; pipelines\n // use the default ccw front face; downstream samplers see upright pixels.\n const targetSignature = {\n _colorFormat: desc.format,\n _depthStencilFormat: config.depth?._descriptor.dFormat ?? desc.dFormat,\n _depthCompare: desc._depthCompare,\n _sampleCount: desc.samples ?? 1,\n };\n\n const sceneBGL = getSceneBindGroupLayout(engine);\n const sceneUBO = createEmptyUniformBuffer(engine, SCENE_UBO_BYTES);\n const lightsUBO = ensureSceneLightState(engine, sc)._buffer;\n const sceneBG = engine._device.createBindGroup({\n layout: sceneBGL,\n entries: [\n { binding: 0, resource: { buffer: sceneUBO } },\n { binding: 1, resource: { buffer: lightsUBO } },\n ],\n });\n const colorAttachment = { loadOp: \"clear\", storeOp: \"store\" } as GPURenderPassColorAttachment;\n const updateContext: MutableDrawUpdateContext = { targetWidth: 0, targetHeight: 0 };\n const task: RenderTask = {\n name: config.name,\n _config: config,\n engine: engine,\n scene: sc,\n _passes: [],\n _autoFromScene: false,\n _renderables: [],\n _opaqueBindings: [],\n _directBindings: [],\n _transparentBindings: [],\n _opaqueBundles: [],\n _lastVersion: -1,\n _lastVis: 0,\n _recorded: false,\n _renderPassDescriptor: { colorAttachments: [colorAttachment] },\n _colorAttachment: colorAttachment,\n _depthSrc: config.depth,\n _depthLoadOp: config.depth ? (config.depth._eager ? \"load\" : \"clear\") : undefined,\n _sceneUBO: sceneUBO,\n _sceneBG: sceneBG,\n _lightsUBO: lightsUBO,\n _suData: new F32(SCENE_UBO_BYTES / 4),\n _su: [],\n _targetSignature: targetSignature,\n _updateBatches: [],\n _pendingMeshes: [],\n addMesh(mesh, opts) {\n const material = opts?.material ?? mesh.material;\n if (!material) {\n return;\n }\n task._pendingMeshes.push({ mesh, material });\n if (task._recorded) {\n // Live (post-record) add: resolve + re-bucket THIS task now — buildBindings clears its bundle cache\n // so it re-records on the next execute. Deliberately NOT a frame-graph rebuild (that re-allocates the\n // shared scene UBO + every task's render target mid-frame and crashes the in-flight submit).\n resolvePendingMeshes(task, sc);\n // A live add makes the render list explicit (mirrors record(), where a pending mesh forces\n // _autoFromScene = false). Without this, an auto-mirroring task's next scene-version resync in\n // prepareRenderTaskPass would clear _renderables and drop the just-added mesh.\n task._autoFromScene = false;\n buildBindings(task, engine, targetSignature);\n }\n },\n record(): void {\n if (task._autoFromScene) {\n task._renderables.length = 0;\n }\n resolvePendingMeshes(task, sc);\n task._autoFromScene = task._renderables.length === 0;\n if (task._autoFromScene) {\n task._renderables.push(...sc._renderables);\n }\n // Read config.rt dynamically — transmission retargeting swaps it after\n // the task is created, and the engine scRT must never be rebuilt.\n const rt = config.rt;\n buildRenderTarget(rt, engine);\n if (config.rst && (rt._descriptor.samples ?? 1) > 1) {\n buildRenderTarget(config.rst, engine);\n }\n // A non-eager external depth (e.g. the default single-sample scene task's\n // depth, whose colour rt is the depth-less scRT) is task-managed:\n // build/rebuild it here. Eager depths (GeometryRendererTask outputs) are\n // pre-built and skipped by buildRenderTarget.\n if (config.depth && !config.depth._eager) {\n buildRenderTarget(config.depth, engine);\n }\n updateContext.targetWidth = rt._width;\n updateContext.targetHeight = rt._height;\n refreshTaskSceneBindGroup(task, engine);\n buildBindings(task, engine, targetSignature);\n buildRenderPassDescriptor(task, rt);\n task._recorded = true; // task is now live — a subsequent addMesh resolves + re-buckets immediately\n },\n execute(): number {\n return executePass(task, engine, targetSignature, updateContext);\n },\n dispose(): void {\n task._passes.length = 0;\n // disposeRenderTarget no-ops on the engine scRT and on eager\n // GeometryRendererTask depth outputs (both `_eager`), and on an undefined\n // rst/depth — so these can be passed unconditionally.\n disposeRenderTarget(config.rt);\n disposeRenderTarget(config.rst);\n disposeRenderTarget(config.depth);\n task._opaqueBindings.length = 0;\n task._directBindings.length = 0;\n task._transparentBindings.length = 0;\n task._renderables.length = 0;\n task._opaqueBundles.length = 0;\n task._sceneUBO.destroy();\n for (const batch of task._updateBatches) {\n batch.destroy();\n }\n task._updateBatches.length = 0;\n },\n };\n return task;\n}\n\n/** Remove a mesh from this task's renderable + binding lists. Idempotent. */\nexport function removeMeshFromTask(task: RenderTask, mesh: object): void {\n // Not a renderable-bearing task (e.g. a post/effect task that also carries `_config`): nothing to\n // remove. Guard keeps callers that scan all frame-graph tasks (removeFromScene) shape-safe.\n if (!task._renderables) {\n return;\n }\n let removed = false;\n for (let i = task._pendingMeshes.length - 1; i >= 0; i--) {\n if (task._pendingMeshes[i]!.mesh === mesh) {\n task._pendingMeshes.splice(i, 1);\n removed = true;\n }\n }\n for (let i = task._renderables.length - 1; i >= 0; i--) {\n if (task._renderables[i]!.mesh === mesh) {\n task._renderables.splice(i, 1);\n removed = true;\n }\n }\n for (const arr of [task._opaqueBindings, task._directBindings, task._transparentBindings]) {\n for (let i = arr.length - 1; i >= 0; i--) {\n if (arr[i]!.renderable.mesh === mesh) {\n arr.splice(i, 1);\n removed = true;\n }\n }\n }\n if (removed) {\n task._opaqueBundles.length = 0;\n task._lastVersion = -1;\n }\n}\n\n// ─────────────────────────────────────────────────────────────────────────────\n\nfunction resolvePendingMeshes(task: RenderTask, sc: SceneContext): void {\n if (task._pendingMeshes.length === 0) {\n return;\n }\n for (const { mesh, material } of task._pendingMeshes) {\n const rebuild = material._buildGroup?._rebuildSingle;\n if (!rebuild) {\n throw new Error();\n }\n const renderable = rebuild(sc, mesh, material);\n if (!task._renderables.includes(renderable)) {\n task._renderables.push(renderable);\n }\n }\n task._pendingMeshes.length = 0;\n}\n\n/** Per-frame back-to-front sort for transparent bindings using the active camera. */\nfunction sortTransparentBindings(task: RenderTask, camera: Camera | null | undefined): void {\n const arr = task._transparentBindings;\n if (arr.length <= 1 || !camera) {\n return;\n }\n const v = getViewMatrix(camera);\n for (const b of arr) {\n const wc = b.renderable._worldCenter;\n b._sortDistance = wc ? wc[0]! * v[2]! + wc[1]! * v[6]! + wc[2]! * v[10]! + v[14]! : 0;\n }\n arr.sort((a, b) => b._sortDistance! - a._sortDistance! || a.renderable.order - b.renderable.order);\n}\n\n/** (Re)bucket task._renderables into bound lists. */\nfunction buildBindings(task: RenderTask, eng: EngineContext, targetSignature: RenderTargetSignature): void {\n const opaque = task._opaqueBindings;\n const direct = task._directBindings;\n const transparent = task._transparentBindings;\n opaque.length = 0;\n direct.length = 0;\n transparent.length = 0;\n for (const r of task._renderables) {\n const binding = r.bind(eng, targetSignature);\n for (const batch of binding._updateBatches ?? []) {\n if (!task._updateBatches.includes(batch)) {\n task._updateBatches.push(batch);\n }\n }\n if (r.isTransparent || r._transmissive) {\n transparent.push(binding);\n } else if (r._direct) {\n direct.push(binding);\n } else {\n opaque.push(binding);\n }\n }\n opaque.sort((a, b) => a.renderable.order - b.renderable.order);\n direct.sort((a, b) => a.renderable.order - b.renderable.order);\n task._opaqueBundles.length = 0;\n task._lastVersion = (task.scene as SceneContext)._renderableVersion;\n}\n\nfunction buildRenderPassDescriptor(task: RenderTask, rt: RenderTarget): void {\n const att = task._colorAttachment;\n att.view = rt._colorView!;\n // End-of-pass MSAA resolve into a caller-supplied single-sample target.\n // record() only builds the target's color view for an MSAA rt, so its\n // presence is the gate. The swapchain case is wired per-frame in\n // executePass (its view changes each frame); this custom view is stable.\n att.resolveTarget = task._config.rst?._colorView ?? undefined;\n task._renderPassDescriptor.colorAttachments = rt._colorView ? [att] : [];\n\n const depthSrc = task._depthSrc ?? rt;\n const depthView = depthSrc._depthView;\n let depthAttachment: GPURenderPassDepthStencilAttachment | undefined;\n if (depthView) {\n const dd = depthSrc._descriptor;\n const loadOp = task._depthLoadOp ?? \"clear\";\n depthAttachment = {\n view: depthView,\n depthClearValue: dd._depthClearValue ?? 0,\n depthLoadOp: loadOp,\n depthStoreOp: \"store\",\n };\n if (dd.dFormat?.includes(\"stencil\")) {\n depthAttachment.stencilClearValue = 0;\n depthAttachment.stencilLoadOp = loadOp;\n depthAttachment.stencilStoreOp = \"store\";\n }\n }\n\n task._renderPassDescriptor.depthStencilAttachment = depthAttachment;\n}\n\nfunction prepareRenderTaskPass(task: RenderTask, eng: EngineContext, targetSignature: RenderTargetSignature, context: DrawUpdateContext): void {\n const sc = task.scene as SceneContext;\n // Auto-resync when the source scene mutates.\n if (task._autoFromScene && task._lastVersion !== sc._renderableVersion) {\n task._renderables.length = 0;\n task._renderables.push(...sc._renderables);\n buildBindings(task, eng, targetSignature);\n }\n\n // Pre-pass work — runs before beginRenderPass. Updates the task-owned scene\n // UBO, scene-wide lights UBO, and per-binding UBOs. The scene bind group may\n // also need a refresh (lights buffer can be resized when glTF lights\n // extension raises MAX_LIGHTS after this task was first recorded).\n refreshTaskSceneBindGroup(task, eng);\n const camera = task._config.cam ?? sc.camera;\n if (!task._config._skipClusteredLights && targetSignature._colorFormat) {\n sc._clusteredLightUpdater?.(camera, context.targetWidth, context.targetHeight);\n }\n _writePassSceneUBO(task, eng, sc, camera);\n refreshSceneLightsUBO(eng, sc);\n // Expose the active camera to per-binding `update()` calls. Some renderables\n // (e.g. transparent billboard systems) need it to compute view-space sort\n // depths during their update.\n (context as MutableDrawUpdateContext)._camera = camera;\n for (const batch of task._updateBatches) {\n batch.reset();\n }\n updateBindings(task._opaqueBindings, context);\n updateBindings(task._directBindings, context);\n updateBindings(task._transparentBindings, context);\n for (const batch of task._updateBatches) {\n batch.flush(eng);\n }\n // Per-frame back-to-front sort for transparent bindings — must run AFTER\n // updateBindings so renderables that compute `_worldCenter` inside their\n // own `update()` (billboard systems) are seen with current values.\n sortTransparentBindings(task, camera);\n}\n\nfunction executePass(task: RenderTask, eng: EngineContext, targetSignature: RenderTargetSignature, context: DrawUpdateContext): number {\n const sc = task.scene;\n const sampleCount = targetSignature._sampleCount;\n prepareRenderTaskPass(task, eng, targetSignature, context);\n const att = task._colorAttachment;\n const cfg = task._config;\n if (cfg.rt._colorView) {\n // The engine scRT's color view is re-acquired every frame, so re-read\n // it here. Offscreen color views are stable between rebuilds — leaving att.view\n // untouched preserves an external override (swapchain-overlay shares the base\n // scene's MSAA color view). The resolve target (rst) is re-read each frame so an\n // `rst === scRT` picks up its fresh per-frame view.\n if (cfg.rt === eng.scRT) {\n att.view = cfg.rt._colorView;\n }\n att.resolveTarget = cfg.rst?._colorView ?? undefined;\n att.clearValue = task._autoFromScene ? sc.clearColor : cfg.clrColor!;\n att.loadOp = cfg.clr ? \"clear\" : \"load\";\n }\n if (task._executeWithTransmission) {\n return task._executeWithTransmission(sampleCount);\n }\n const pass = eng._currentEncoder.beginRenderPass(task._renderPassDescriptor);\n const draws = executePassBody(task, pass);\n pass.end();\n return draws;\n}\n\n/** Body of the registered `RenderPass`. Receives the live render-pass encoder\n * and issues all draws (viewport/scissor, group(0) bind, opaque bundle replay,\n * then direct-draws non-transparent direct + transparent). Returns the draw count. */\nfunction executePassBody(task: RenderTask, pass: GPURenderPassEncoder): number {\n const eng = task.engine as EngineContext;\n const cfg = task._config;\n const rt = cfg.rt;\n const scene = task.scene as SceneContext;\n const opaqueBindings = task._opaqueBindings;\n const opaqueBundles = task._opaqueBundles;\n const sceneBG = task._sceneBG;\n\n const camera = cfg.cam ?? scene.camera;\n const v = camera?.viewport;\n if (v) {\n const rw = rt._width;\n const rh = rt._height;\n const x = Math.floor(v.x * rw);\n const y = Math.floor((1 - v.y - v.height) * rh);\n const w = Math.ceil((v.x + v.width) * rw) - x;\n const h = Math.ceil((1 - v.y) * rh) - y;\n pass.setViewport(x, y, w, h, 0, 1);\n pass.setScissorRect(x, y, w, h);\n }\n // Scene bind group (group 0) is task-owned and identical for every draw in this pass.\n pass.setBindGroup(0, sceneBG);\n\n // Opaque: cached render bundle. Invalidated by scene mutation (_renderableVersion) or\n // the global visibility/resource epoch (_vis). The bundle records group(0) at its start.\n if (task._lastVersion !== scene._renderableVersion || task._lastVis !== _vis || opaqueBundles.length === 0) {\n const desc = rt._descriptor;\n const be = eng._device.createRenderBundleEncoder({\n colorFormats: desc.format ? [desc.format] : [],\n // Use the task's target signature, not the RT descriptor: a depth\n // override (config.depth) supplies the depth format externally, so\n // the cached opaque pipelines are built with it while the colour RT\n // carries no depthStencilFormat of its own. The bundle encoder's\n // attachment state must match those pipelines exactly.\n depthStencilFormat: task._targetSignature._depthStencilFormat,\n sampleCount: desc.samples ?? 1,\n });\n be.setBindGroup(0, sceneBG);\n drawList(be, opaqueBindings, eng);\n opaqueBundles[0] = be.finish();\n task._lastVersion = scene._renderableVersion;\n task._lastVis = _vis;\n }\n let draws = opaqueBindings.length;\n pass.executeBundles(opaqueBundles);\n // executeBundles invalidates pass bind-group state — rebind group 0 before further draws.\n pass.setBindGroup(0, sceneBG);\n draws += drawList(pass, task._directBindings, eng);\n draws += drawList(pass, task._transparentBindings, eng);\n return draws;\n}\n\nfunction refreshTaskSceneBindGroup(task: RenderTask, eng: EngineContext): void {\n const lightsUBO = ensureSceneLightState(eng, task.scene as SceneContext)._buffer;\n if (lightsUBO === task._lightsUBO) {\n return;\n }\n task._lightsUBO = lightsUBO;\n task._sceneBG = eng._device.createBindGroup({\n layout: getSceneBindGroupLayout(eng),\n entries: [\n { binding: 0, resource: { buffer: task._sceneUBO } },\n { binding: 1, resource: { buffer: lightsUBO } },\n ],\n });\n task._opaqueBundles.length = 0;\n task._lastVersion = -1;\n}\n\n/** Write the canonical SceneUniforms struct to the task-owned scene UBO.\n * Bails before touching scratch/GPU when all inputs are unchanged.\n * @internal Exported for unit testing of the scene-UBO change-detection guard. */\nexport function _writePassSceneUBO(task: RenderTask, eng: EngineContext, scene: SceneContext, camera: Camera | null): void {\n if (!camera) {\n return;\n }\n\n const v = camera.viewport;\n const rt = task._config.rt;\n const aspect = (task._config.cs ? eng.canvas.width / eng.canvas.height : rt._width / rt._height) * (v ? v.width / v.height : 1);\n const fog = scene.fog;\n const img = scene.imageProcessing;\n const envRotationY = scene.envRotationY || 0;\n const wv = camera.worldMatrixVersion;\n // `envTextures` identity is tracked so an environment loaded (or swapped) AFTER the scene has reached\n // steady state invalidates this cache. Its spherical-harmonics irradiance and `lodGenerationScale` are\n // written into the scene UBO below (via `_packSceneUniforms` + the env-SH contributor); without tracking\n // it, a late env load would change none of the other guarded inputs, so the UBO would never be rewritten\n // and the model would keep zero irradiance (dark diffuse, specular-only \"mirror\" look).\n const envTextures = scene._envTextures;\n const s = task._su;\n if (s[0] === camera && s[1] === fog && s[2] === wv && s[3] === aspect && s[4] === envRotationY && s[5] === img.exposure && s[6] === img.contrast && s[7] === envTextures) {\n return;\n }\n s[0] = camera;\n s[1] = fog;\n s[2] = wv;\n s[3] = aspect;\n s[4] = envRotationY;\n s[5] = img.exposure;\n s[6] = img.contrast;\n s[7] = envTextures;\n\n const data = task._suData;\n _packSceneUniforms(data, eng, scene, camera, aspect);\n const contribs = scene._sceneUboContributors;\n if (contribs) {\n for (const c of contribs) {\n c(data, scene);\n }\n }\n eng._device.queue.writeBuffer(task._sceneUBO, 0, data as Float32Array<ArrayBuffer>);\n}\n\nfunction updateBindings(list: readonly DrawBinding[], context: DrawUpdateContext): void {\n for (const b of list) {\n b.update?.(context);\n }\n}\n\n/** Iterate DrawBindings, deduping setPipeline. */\nfunction drawList(enc: GPURenderPassEncoder | GPURenderBundleEncoder, list: readonly DrawBinding[], engine: EngineContext): number {\n let lp: GPURenderPipeline | null = null;\n let draws = 0;\n for (const b of list) {\n const mesh = b.renderable.mesh;\n if (mesh && mesh.visible === false) {\n continue;\n }\n if (b.pipeline !== lp) {\n enc.setPipeline(b.pipeline);\n lp = b.pipeline;\n }\n draws += b.draw(enc, engine);\n }\n return draws;\n}\n"],"names":[],"mappings":";;;;;;;;;;AAuLO,SAAS,gBAAA,CAAiB,MAAA,EAA0B,MAAA,EAAuB,KAAA,EAAiC;AAC/G,EAAA,MAAM,EAAA,GAAK,KAAA;AACX,EAAA,MAAA,CAAO,QAAA,KAAa,EAAE,CAAA,EAAG,GAAA,EAAK,GAA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IAAI,IAAA,IAAQ,IAAA,CAAK,OAAA,KAAY,KAAA,EAAO;AAChC,MAAA;AAAA,IACJ;AACA,IAAA,IAAI,CAAA,CAAE,aAAa,EAAA,EAAI;AACnB,MAAA,GAAA,CAAI,WAAA,CAAY,EAAE,QAAQ,CAAA;AAC1B,MAAA,EAAA,GAAK,CAAA,CAAE,QAAA;AAAA,IACX;AACA,IAAA,KAAA,IAAS,CAAA,CAAE,IAAA,CAAK,GAAA,EAAK,MAAM,CAAA;AAAA,EAC/B;AACA,EAAA,OAAO,KAAA;AACX;;;;"}
1
+ {"version":3,"file":"render-task.js","sources":["../../../src/frame-graph/render-task.ts"],"sourcesContent":["/**\n * RenderTask — a frame-graph task that records a single `RenderPass`,\n * binds the scene's `RenderTarget`, and draws renderables into it.\n *\n * - `record()` builds bucketed `DrawBinding` lists from `_renderables`\n * (opaque / direct / transparent), sorts opaque + direct by\n * `order`, then creates a `RenderPass` wired to the task's render target.\n * The pass owns its\n * `GPURenderPassDescriptor` and the per-pass-encoder body lives in a\n * closure passed to `setRenderPassExecuteFunc`.\n * - Before `RenderPass._execute()` begins the GPU pass: writes the scene UBO, refreshes lights, updates\n * per-binding UBOs, mirrors live `scene.clearColor` + `clr` onto the\n * render pass. Shared task execution then calls `_execute()`. The\n * `RenderPass` itself patches the swapchain view + clearColor + loadOp\n * and brackets the body with `beginRenderPass` / `end`.\n *\n * Renderable population:\n * - Explicit: push into `_renderables` directly, or `addMesh(mesh, opts)`\n * which builds a (mesh, material) Renderable at `record()` time.\n * - Auto scene mirror: when `_renderables` is empty at record() time, copy the\n * scene's renderables. Re-sync happens automatically when the scene's\n * `_renderableVersion` changes between frames (mesh add/remove, material swap).\n *\n * The engine `scRT` is just another `RenderTarget` here: a task that\n * targets it (`rt`) or resolves into it (`rst`) re-reads its per-frame color view\n * at execute time (the swap texture is re-acquired each frame). `clr: false`\n * switches color + depth `loadOp` to `\"load\"` so multiple scenes can share the\n * swapchain in one frame (e.g., a 3D scene + a UI overlay scene).\n */\n\nimport { F32 } from \"../engine/typed-arrays.js\";\nimport type { EngineContext } from \"../engine/engine.js\";\nimport { _vis } from \"../engine/engine.js\";\nimport type { Mesh } from \"../mesh/mesh.js\";\nimport type { Camera } from \"../camera/camera.js\";\nimport type { Renderable, DrawBinding, DrawUpdateContext, DrawUpdateBatch } from \"../render/renderable.js\";\nimport type { RenderTargetSignature } from \"../engine/render-target.js\";\nimport type { SceneContext } from \"../scene/scene-core.js\";\nimport type { Material } from \"../material/material.js\";\nimport type { RenderTarget } from \"../engine/render-target.js\";\nimport { buildRenderTarget, disposeRenderTarget } from \"../engine/render-target.js\";\nimport { getViewMatrix } from \"../camera/camera.js\";\nimport { getSceneBindGroupLayout } from \"../render/scene-helpers.js\";\nimport { _packSceneUniforms } from \"./scene-uniforms-pack.js\";\nimport { createEmptyUniformBuffer } from \"../resource/gpu-buffers.js\";\nimport { SCENE_UBO_BYTES } from \"../shader/scene-uniforms-size.js\";\nimport { ensureSceneLightState, refreshSceneLightsUBO } from \"../render/lights-ubo.js\";\nimport type { Task } from \"./task.js\";\n\n/** Configuration for `createRenderTask`: render target, clear state, optional camera override, and transmission settings. */\nexport interface RenderTaskConfig {\n name: string;\n /** TODO: rt should not live in this config long-term. Until texture\n * management is virtualized, callers must provide the concrete target; once\n * virtualized, the task should create/manage its own render target. */\n rt: RenderTarget;\n /** Optional single-sample resolve target. When `rt` is multisampled\n * (`sampleCount > 1`), the color attachment resolves into this target's\n * color texture at end-of-pass — letting an MSAA render feed a post-process\n * that requires a single-sample source, without an extra resolve pass.\n * Caller contract (not validated): must be single-sample with a color\n * format and size matching `rt`; WebGPU errors at pass-encode time if not.\n * Ignored when `rt` is single-sample. */\n rst?: RenderTarget;\n /** Optional separate depth/stencil attachment. The pass binds this target's\n * depth view instead of `rt`'s own, and uses its `depthStencilFormat` for\n * pipeline signature matching. The colour `rt` must omit `depthStencilFormat`\n * (so it allocates no internal depth) and match this target in size + sample\n * count. Two ownership modes, distinguished by `_eager`:\n * - `_eager` depth (e.g. a `GeometryRendererTask` output): the task neither\n * builds nor clears nor disposes it — it loads it (`loadOp: \"load\"`) and the\n * caller owns clearing. This is how scenes reuse a pre-rendered depth buffer.\n * - non-`_eager` depth: the task owns it — builds/rebuilds it in `record()`,\n * clears it (`loadOp: \"clear\"`), and disposes it. Used by the default\n * single-sample scene task, whose colour `rt` is the depth-less\n * engine `scRT`. */\n depth?: RenderTarget;\n /** Background clear color. May be mutated frame-to-frame. */\n clrColor?: GPUColorDict;\n /** When true, color `loadOp` is \"clear\"; when false, \"load\" (overlays previous\n * color content). Depth is always cleared when rt-owned and always loaded when\n * supplied via `depth`. */\n clr?: boolean;\n /** Per-pass camera override. Null/undefined uses `scene.camera`. */\n cam?: Camera | null;\n /** Use canvas dimensions, not render-target dimensions, for this pass's scene UBO aspect. */\n cs?: boolean;\n /** Scene-texture transmission settings. `copyCount: 0` copies before every transmissive draw.\n * `generateMipmaps: false` allocates only mip 0 for the refraction texture and skips mip generation.\n * `mipLevelCount` caps the generated chain when a material only samples low explicit LODs.\n * `grabDepth: true` also snapshots the task's DEPTH attachment at the same mid-pass grab (see\n * `TransmissionOptions.grabDepth`). */\n transmission?: { copyCount?: number; generateMipmaps?: boolean; mipLevelCount?: number; grabDepth?: boolean };\n /** @internal Skip clustered-light preparation for passes that never run forward lighting. */\n _skipClusteredLights?: boolean;\n}\n\n/** A frame-graph task that records a single `RenderPass`, binds the scene's `RenderTarget`, and draws renderables into it. */\nexport interface RenderTask extends Task {\n readonly name: string;\n /** Render tasks are scene-bound because they consume scene camera, lights, and renderables. */\n readonly scene: SceneContext;\n /** Live task configuration. Mutating `clr` or `clrColor` affects subsequent frames. */\n /** @internal */\n readonly _config: RenderTaskConfig;\n /** @internal */\n _autoFromScene: boolean;\n\n /** Source-of-truth renderables. Bucketed binding lists below are derived from\n * this list at `record()` (or re-sync when auto-filled and `_renderableVersion` changes). */\n /** @internal */\n _renderables: Renderable[];\n /** @internal */\n _opaqueBindings: DrawBinding[];\n /** @internal */\n _directBindings: DrawBinding[];\n /** @internal */\n _transparentBindings: DrawBinding[];\n /** Cached opaque render bundle. Invalidated by renderable list mutations\n * (`_lastVersion`) and the global visibility/resource epoch (`_lastVis`). */\n /** @internal */\n _opaqueBundles: GPURenderBundle[];\n /** @internal */\n _lastVersion: number;\n /** @internal */\n _lastVis: number;\n /** @internal True once `record()` has run — the task is \"live\" (GPU target allocated, material batch builders\n * present). A runtime `addMesh` after this resolves + re-buckets THIS task immediately (no frame-graph rebuild). */\n _recorded: boolean;\n\n /** @internal */\n _renderPassDescriptor: GPURenderPassDescriptor;\n /** @internal */\n _colorAttachment: GPURenderPassColorAttachment;\n /** @internal External depth source from `config.depth`. When unset,\n * the pass uses `config.rt._depthView`. */\n _depthSrc?: RenderTarget;\n /** @internal External depth/stencil `loadOp` (\"load\" when `config.depth` is\n * set). When unset, defaults to `\"clear\"`. */\n _depthLoadOp?: GPULoadOp;\n\n /** Per-task scene UBO + bind group. Created eagerly in createRenderTask\n * so renderables can reference `_sceneBG` at `bind()` time. Written each\n * frame by `_writePassSceneUBO`. Destroyed in `dispose()`. */\n /** @internal */\n _sceneUBO: GPUBuffer;\n /** @internal */\n _sceneBG: GPUBindGroup;\n /** @internal */\n _lightsUBO: GPUBuffer;\n /** @internal */\n _suData: Float32Array;\n /** @internal */\n _su: unknown[];\n /** Optional transmission-enabled execute path: copies the scene texture for refraction and draws transmissive\n * renderables. Present only when the task was configured with `transmission`. Returns the number of draw calls issued. */\n /** @internal */\n _executeWithTransmission?(sampleCount: number): number;\n /** @internal */\n _targetSignature: RenderTargetSignature;\n /** @internal Lazy feature work flushed after binding updates and before the render pass. */\n _updateBatches: DrawUpdateBatch[];\n\n /** Add a mesh to this task's explicit render list with an optional per-pass material override. Resolved via\n * `material._buildGroup._rebuildSingle`, so the mesh's material family must already have been registered with the\n * scene (its batch builder has run). BEFORE the first `record()` the add is QUEUED and drained at record() time;\n * AFTER (a live/runtime add) it is resolved + re-bucketed into THIS task immediately, so the mesh renders on the\n * next frame without a `frameGraph.build()` (which would re-allocate shared GPU resources across all tasks). */\n addMesh(mesh: Mesh, opts?: { material?: Material }): void;\n /** @internal */\n _pendingMeshes: { mesh: Mesh; material: Material }[];\n}\n\ninterface MutableDrawUpdateContext {\n targetWidth: number;\n targetHeight: number;\n _camera?: Camera | null;\n}\n\n/** Create a render pass task. GPU resources (target textures + descriptor)\n * are not allocated until `record()` runs (via `frameGraph.build()`).\n *\n * Swapchain-targeted tasks acquire the swap view per-frame at execute time. */\nexport function createRenderTask(config: RenderTaskConfig, engine: EngineContext, scene: SceneContext): RenderTask {\n const sc = scene as SceneContext;\n config.clrColor ??= { r: 0.2, g: 0.2, b: 0.3, a: 1.0 };\n config.clr ??= true;\n const desc = config.rt._descriptor;\n // Render upright: row 0 of the GPU texture is the top of the scene. Every\n // RT (offscreen or swapchain) renders without a projection Y-flip; pipelines\n // use the default ccw front face; downstream samplers see upright pixels.\n const targetSignature = {\n _colorFormat: desc.format,\n _depthStencilFormat: config.depth?._descriptor.dFormat ?? desc.dFormat,\n _depthCompare: desc._depthCompare,\n _sampleCount: desc.samples ?? 1,\n };\n\n const sceneBGL = getSceneBindGroupLayout(engine);\n const sceneUBO = createEmptyUniformBuffer(engine, SCENE_UBO_BYTES);\n const lightsUBO = ensureSceneLightState(engine, sc)._buffer;\n const sceneBG = engine._device.createBindGroup({\n layout: sceneBGL,\n entries: [\n { binding: 0, resource: { buffer: sceneUBO } },\n { binding: 1, resource: { buffer: lightsUBO } },\n ],\n });\n const colorAttachment = { loadOp: \"clear\", storeOp: \"store\" } as GPURenderPassColorAttachment;\n const updateContext: MutableDrawUpdateContext = { targetWidth: 0, targetHeight: 0 };\n const task: RenderTask = {\n name: config.name,\n _config: config,\n engine: engine,\n scene: sc,\n _passes: [],\n _autoFromScene: false,\n _renderables: [],\n _opaqueBindings: [],\n _directBindings: [],\n _transparentBindings: [],\n _opaqueBundles: [],\n _lastVersion: -1,\n _lastVis: 0,\n _recorded: false,\n _renderPassDescriptor: { colorAttachments: [colorAttachment] },\n _colorAttachment: colorAttachment,\n _depthSrc: config.depth,\n _depthLoadOp: config.depth ? (config.depth._eager ? \"load\" : \"clear\") : undefined,\n _sceneUBO: sceneUBO,\n _sceneBG: sceneBG,\n _lightsUBO: lightsUBO,\n _suData: new F32(SCENE_UBO_BYTES / 4),\n _su: [],\n _targetSignature: targetSignature,\n _updateBatches: [],\n _pendingMeshes: [],\n addMesh(mesh, opts) {\n const material = opts?.material ?? mesh.material;\n if (!material) {\n return;\n }\n task._pendingMeshes.push({ mesh, material });\n if (task._recorded) {\n // Live (post-record) add: resolve + re-bucket THIS task now — buildBindings clears its bundle cache\n // so it re-records on the next execute. Deliberately NOT a frame-graph rebuild (that re-allocates the\n // shared scene UBO + every task's render target mid-frame and crashes the in-flight submit).\n resolvePendingMeshes(task, sc);\n // A live add makes the render list explicit (mirrors record(), where a pending mesh forces\n // _autoFromScene = false). Without this, an auto-mirroring task's next scene-version resync in\n // prepareRenderTaskPass would clear _renderables and drop the just-added mesh.\n task._autoFromScene = false;\n buildBindings(task, engine, targetSignature);\n }\n },\n record(): void {\n if (task._autoFromScene) {\n task._renderables.length = 0;\n }\n resolvePendingMeshes(task, sc);\n task._autoFromScene = task._renderables.length === 0;\n if (task._autoFromScene) {\n task._renderables.push(...sc._renderables);\n }\n // Read config.rt dynamically — transmission retargeting swaps it after\n // the task is created, and the engine scRT must never be rebuilt.\n const rt = config.rt;\n buildRenderTarget(rt, engine);\n if (config.rst && (rt._descriptor.samples ?? 1) > 1) {\n buildRenderTarget(config.rst, engine);\n }\n // A non-eager external depth (e.g. the default single-sample scene task's\n // depth, whose colour rt is the depth-less scRT) is task-managed:\n // build/rebuild it here. Eager depths (GeometryRendererTask outputs) are\n // pre-built and skipped by buildRenderTarget.\n if (config.depth && !config.depth._eager) {\n buildRenderTarget(config.depth, engine);\n }\n updateContext.targetWidth = rt._width;\n updateContext.targetHeight = rt._height;\n refreshTaskSceneBindGroup(task, engine);\n buildBindings(task, engine, targetSignature);\n buildRenderPassDescriptor(task, rt);\n task._recorded = true; // task is now live — a subsequent addMesh resolves + re-buckets immediately\n },\n execute(): number {\n return executePass(task, engine, targetSignature, updateContext);\n },\n dispose(): void {\n task._passes.length = 0;\n // disposeRenderTarget no-ops on the engine scRT and on eager\n // GeometryRendererTask depth outputs (both `_eager`), and on an undefined\n // rst/depth — so these can be passed unconditionally.\n disposeRenderTarget(config.rt);\n disposeRenderTarget(config.rst);\n disposeRenderTarget(config.depth);\n task._opaqueBindings.length = 0;\n task._directBindings.length = 0;\n task._transparentBindings.length = 0;\n task._renderables.length = 0;\n task._opaqueBundles.length = 0;\n task._sceneUBO.destroy();\n for (const batch of task._updateBatches) {\n batch.destroy();\n }\n task._updateBatches.length = 0;\n },\n };\n return task;\n}\n\n/** Remove a mesh from this task's renderable + binding lists. Idempotent. */\nexport function removeMeshFromTask(task: RenderTask, mesh: object): void {\n // Not a renderable-bearing task (e.g. a post/effect task that also carries `_config`): nothing to\n // remove. Guard keeps callers that scan all frame-graph tasks (removeFromScene) shape-safe.\n if (!task._renderables) {\n return;\n }\n let removed = false;\n for (let i = task._pendingMeshes.length - 1; i >= 0; i--) {\n if (task._pendingMeshes[i]!.mesh === mesh) {\n task._pendingMeshes.splice(i, 1);\n removed = true;\n }\n }\n for (let i = task._renderables.length - 1; i >= 0; i--) {\n if (task._renderables[i]!.mesh === mesh) {\n task._renderables.splice(i, 1);\n removed = true;\n }\n }\n for (const arr of [task._opaqueBindings, task._directBindings, task._transparentBindings]) {\n for (let i = arr.length - 1; i >= 0; i--) {\n if (arr[i]!.renderable.mesh === mesh) {\n arr.splice(i, 1);\n removed = true;\n }\n }\n }\n if (removed) {\n task._opaqueBundles.length = 0;\n task._lastVersion = -1;\n }\n}\n\n// ─────────────────────────────────────────────────────────────────────────────\n\nfunction resolvePendingMeshes(task: RenderTask, sc: SceneContext): void {\n if (task._pendingMeshes.length === 0) {\n return;\n }\n for (const { mesh, material } of task._pendingMeshes) {\n const rebuild = material._buildGroup?._rebuildSingle;\n if (!rebuild) {\n throw new Error();\n }\n const renderable = rebuild(sc, mesh, material);\n if (!task._renderables.includes(renderable)) {\n task._renderables.push(renderable);\n }\n }\n task._pendingMeshes.length = 0;\n}\n\n/** Per-frame back-to-front sort for transparent bindings using the active camera. */\nfunction sortTransparentBindings(task: RenderTask, camera: Camera | null | undefined): void {\n const arr = task._transparentBindings;\n if (arr.length <= 1 || !camera) {\n return;\n }\n const v = getViewMatrix(camera);\n for (const b of arr) {\n const wc = b.renderable._worldCenter;\n b._sortDistance = wc ? wc[0]! * v[2]! + wc[1]! * v[6]! + wc[2]! * v[10]! + v[14]! : 0;\n }\n arr.sort((a, b) => b._sortDistance! - a._sortDistance! || a.renderable.order - b.renderable.order);\n}\n\n/** (Re)bucket task._renderables into bound lists. */\nfunction buildBindings(task: RenderTask, eng: EngineContext, targetSignature: RenderTargetSignature): void {\n const opaque = task._opaqueBindings;\n const direct = task._directBindings;\n const transparent = task._transparentBindings;\n opaque.length = 0;\n direct.length = 0;\n transparent.length = 0;\n for (const r of task._renderables) {\n const binding = r.bind(eng, targetSignature);\n for (const batch of binding._updateBatches ?? []) {\n if (!task._updateBatches.includes(batch)) {\n task._updateBatches.push(batch);\n }\n }\n if (r.isTransparent || r._transmissive) {\n transparent.push(binding);\n } else if (r._direct) {\n direct.push(binding);\n } else {\n opaque.push(binding);\n }\n }\n opaque.sort((a, b) => a.renderable.order - b.renderable.order);\n direct.sort((a, b) => a.renderable.order - b.renderable.order);\n task._opaqueBundles.length = 0;\n task._lastVersion = (task.scene as SceneContext)._renderableVersion;\n}\n\nfunction buildRenderPassDescriptor(task: RenderTask, rt: RenderTarget): void {\n const att = task._colorAttachment;\n att.view = rt._colorView!;\n // End-of-pass MSAA resolve into a caller-supplied single-sample target.\n // record() only builds the target's color view for an MSAA rt, so its\n // presence is the gate. The swapchain case is wired per-frame in\n // executePass (its view changes each frame); this custom view is stable.\n att.resolveTarget = task._config.rst?._colorView ?? undefined;\n task._renderPassDescriptor.colorAttachments = rt._colorView ? [att] : [];\n\n const depthSrc = task._depthSrc ?? rt;\n const depthView = depthSrc._depthView;\n let depthAttachment: GPURenderPassDepthStencilAttachment | undefined;\n if (depthView) {\n const dd = depthSrc._descriptor;\n const loadOp = task._depthLoadOp ?? \"clear\";\n depthAttachment = {\n view: depthView,\n depthClearValue: dd._depthClearValue ?? 0,\n depthLoadOp: loadOp,\n depthStoreOp: \"store\",\n };\n if (dd.dFormat?.includes(\"stencil\")) {\n depthAttachment.stencilClearValue = 0;\n depthAttachment.stencilLoadOp = loadOp;\n depthAttachment.stencilStoreOp = \"store\";\n }\n }\n\n task._renderPassDescriptor.depthStencilAttachment = depthAttachment;\n}\n\nfunction prepareRenderTaskPass(task: RenderTask, eng: EngineContext, targetSignature: RenderTargetSignature, context: DrawUpdateContext): void {\n const sc = task.scene as SceneContext;\n // Auto-resync when the source scene mutates.\n if (task._autoFromScene && task._lastVersion !== sc._renderableVersion) {\n task._renderables.length = 0;\n task._renderables.push(...sc._renderables);\n buildBindings(task, eng, targetSignature);\n }\n\n // Pre-pass work — runs before beginRenderPass. Updates the task-owned scene\n // UBO, scene-wide lights UBO, and per-binding UBOs. The scene bind group may\n // also need a refresh (lights buffer can be resized when glTF lights\n // extension raises MAX_LIGHTS after this task was first recorded).\n refreshTaskSceneBindGroup(task, eng);\n const camera = task._config.cam ?? sc.camera;\n if (!task._config._skipClusteredLights && targetSignature._colorFormat) {\n sc._clusteredLightUpdater?.(camera, context.targetWidth, context.targetHeight);\n }\n _writePassSceneUBO(task, eng, sc, camera);\n refreshSceneLightsUBO(eng, sc);\n // Expose the active camera to per-binding `update()` calls. Some renderables\n // (e.g. transparent billboard systems) need it to compute view-space sort\n // depths during their update.\n (context as MutableDrawUpdateContext)._camera = camera;\n for (const batch of task._updateBatches) {\n batch.reset();\n }\n updateBindings(task._opaqueBindings, context);\n updateBindings(task._directBindings, context);\n updateBindings(task._transparentBindings, context);\n for (const batch of task._updateBatches) {\n batch.flush(eng);\n }\n // Per-frame back-to-front sort for transparent bindings — must run AFTER\n // updateBindings so renderables that compute `_worldCenter` inside their\n // own `update()` (billboard systems) are seen with current values.\n sortTransparentBindings(task, camera);\n}\n\nfunction executePass(task: RenderTask, eng: EngineContext, targetSignature: RenderTargetSignature, context: DrawUpdateContext): number {\n const sc = task.scene;\n const sampleCount = targetSignature._sampleCount;\n prepareRenderTaskPass(task, eng, targetSignature, context);\n const att = task._colorAttachment;\n const cfg = task._config;\n if (cfg.rt._colorView) {\n // The engine scRT's color view is re-acquired every frame, so re-read\n // it here. Offscreen color views are stable between rebuilds — leaving att.view\n // untouched preserves an external override (swapchain-overlay shares the base\n // scene's MSAA color view). The resolve target (rst) is re-read each frame so an\n // `rst === scRT` picks up its fresh per-frame view.\n if (cfg.rt === eng.scRT) {\n att.view = cfg.rt._colorView;\n }\n att.resolveTarget = cfg.rst?._colorView ?? undefined;\n att.clearValue = task._autoFromScene ? sc.clearColor : cfg.clrColor!;\n att.loadOp = cfg.clr ? \"clear\" : \"load\";\n }\n if (task._executeWithTransmission) {\n return task._executeWithTransmission(sampleCount);\n }\n const pass = eng._currentEncoder.beginRenderPass(task._renderPassDescriptor);\n const draws = executePassBody(task, pass);\n pass.end();\n return draws;\n}\n\n/** Body of the registered `RenderPass`. Receives the live render-pass encoder\n * and issues all draws (viewport/scissor, group(0) bind, opaque bundle replay,\n * then direct-draws non-transparent direct + transparent). Returns the draw count. */\nfunction executePassBody(task: RenderTask, pass: GPURenderPassEncoder): number {\n const eng = task.engine as EngineContext;\n const cfg = task._config;\n const rt = cfg.rt;\n const scene = task.scene as SceneContext;\n const opaqueBindings = task._opaqueBindings;\n const opaqueBundles = task._opaqueBundles;\n const sceneBG = task._sceneBG;\n\n const camera = cfg.cam ?? scene.camera;\n const v = camera?.viewport;\n if (v) {\n const rw = rt._width;\n const rh = rt._height;\n const x = Math.floor(v.x * rw);\n const y = Math.floor((1 - v.y - v.height) * rh);\n const w = Math.ceil((v.x + v.width) * rw) - x;\n const h = Math.ceil((1 - v.y) * rh) - y;\n pass.setViewport(x, y, w, h, 0, 1);\n pass.setScissorRect(x, y, w, h);\n }\n // Scene bind group (group 0) is task-owned and identical for every draw in this pass.\n pass.setBindGroup(0, sceneBG);\n\n // Opaque: cached render bundle. Invalidated by scene mutation (_renderableVersion) or\n // the global visibility/resource epoch (_vis). The bundle records group(0) at its start.\n if (task._lastVersion !== scene._renderableVersion || task._lastVis !== _vis || opaqueBundles.length === 0) {\n const desc = rt._descriptor;\n const be = eng._device.createRenderBundleEncoder({\n colorFormats: desc.format ? [desc.format] : [],\n // Use the task's target signature, not the RT descriptor: a depth\n // override (config.depth) supplies the depth format externally, so\n // the cached opaque pipelines are built with it while the colour RT\n // carries no depthStencilFormat of its own. The bundle encoder's\n // attachment state must match those pipelines exactly.\n depthStencilFormat: task._targetSignature._depthStencilFormat,\n sampleCount: desc.samples ?? 1,\n });\n be.setBindGroup(0, sceneBG);\n drawList(be, opaqueBindings, eng);\n opaqueBundles[0] = be.finish();\n task._lastVersion = scene._renderableVersion;\n task._lastVis = _vis;\n }\n let draws = opaqueBindings.length;\n pass.executeBundles(opaqueBundles);\n // executeBundles invalidates pass bind-group state — rebind group 0 before further draws.\n pass.setBindGroup(0, sceneBG);\n draws += drawList(pass, task._directBindings, eng);\n draws += drawList(pass, task._transparentBindings, eng);\n return draws;\n}\n\nfunction refreshTaskSceneBindGroup(task: RenderTask, eng: EngineContext): void {\n const lightsUBO = ensureSceneLightState(eng, task.scene as SceneContext)._buffer;\n if (lightsUBO === task._lightsUBO) {\n return;\n }\n task._lightsUBO = lightsUBO;\n task._sceneBG = eng._device.createBindGroup({\n layout: getSceneBindGroupLayout(eng),\n entries: [\n { binding: 0, resource: { buffer: task._sceneUBO } },\n { binding: 1, resource: { buffer: lightsUBO } },\n ],\n });\n task._opaqueBundles.length = 0;\n task._lastVersion = -1;\n}\n\n/** Write the canonical SceneUniforms struct to the task-owned scene UBO.\n * Bails before touching scratch/GPU when all inputs are unchanged.\n * @internal Exported for unit testing of the scene-UBO change-detection guard. */\nexport function _writePassSceneUBO(task: RenderTask, eng: EngineContext, scene: SceneContext, camera: Camera | null): void {\n if (!camera) {\n return;\n }\n\n const v = camera.viewport;\n const rt = task._config.rt;\n const aspect = (task._config.cs ? eng.canvas.width / eng.canvas.height : rt._width / rt._height) * (v ? v.width / v.height : 1);\n const fog = scene.fog;\n const img = scene.imageProcessing;\n const envRotationY = scene.envRotationY || 0;\n const wv = camera.worldMatrixVersion;\n // `envTextures` identity is tracked so an environment loaded (or swapped) AFTER the scene has reached\n // steady state invalidates this cache. Its spherical-harmonics irradiance and `lodGenerationScale` are\n // written into the scene UBO below (via `_packSceneUniforms` + the env-SH contributor); without tracking\n // it, a late env load would change none of the other guarded inputs, so the UBO would never be rewritten\n // and the model would keep zero irradiance (dark diffuse, specular-only \"mirror\" look).\n const envTextures = scene._envTextures;\n const s = task._su;\n if (s[0] === camera && s[1] === fog && s[2] === wv && s[3] === aspect && s[4] === envRotationY && s[5] === img.exposure && s[6] === img.contrast && s[7] === envTextures) {\n return;\n }\n s[0] = camera;\n s[1] = fog;\n s[2] = wv;\n s[3] = aspect;\n s[4] = envRotationY;\n s[5] = img.exposure;\n s[6] = img.contrast;\n s[7] = envTextures;\n\n const data = task._suData;\n _packSceneUniforms(data, eng, scene, camera, aspect);\n const contribs = scene._sceneUboContributors;\n if (contribs) {\n for (const c of contribs) {\n c(data, scene);\n }\n }\n eng._device.queue.writeBuffer(task._sceneUBO, 0, data as Float32Array<ArrayBuffer>);\n}\n\nfunction updateBindings(list: readonly DrawBinding[], context: DrawUpdateContext): void {\n for (const b of list) {\n b.update?.(context);\n }\n}\n\n/** @internal Iterate DrawBindings, deduping setPipeline. */\nexport function drawList(enc: GPURenderPassEncoder | GPURenderBundleEncoder, list: readonly DrawBinding[], engine: EngineContext): number {\n let lp: GPURenderPipeline | null = null;\n let draws = 0;\n for (const b of list) {\n const mesh = b.renderable.mesh;\n if (mesh && mesh.visible === false) {\n continue;\n }\n if (b.pipeline !== lp) {\n enc.setPipeline(b.pipeline);\n lp = b.pipeline;\n }\n draws += b.draw(enc, engine);\n }\n return draws;\n}\n"],"names":[],"mappings":";;;;;;;;;;AAuLO,SAAS,gBAAA,CAAiB,MAAA,EAA0B,MAAA,EAAuB,KAAA,EAAiC;AAC/G,EAAA,MAAM,EAAA,GAAK,KAAA;AACX,EAAA,MAAA,CAAO,QAAA,KAAa,EAAE,CAAA,EAAG,GAAA,EAAK,GAAG,GAAA,EAAK,CAAA,EAAG,GAAA,EAAK,CAAA,EAAG,CAAA,EAAI;AACrD,EAAA,MAAA,CAAO,GAAA,KAAQ,IAAA;AACf,EAAA,MAAM,IAAA,GAAO,OAAO,EAAA,CAAG,WAAA;AAIvB,EAAA,MAAM,eAAA,GAAkB;AAAA,IACpB,cAAc,IAAA,CAAK,MAAA;AAAA,IACnB,mBAAA,EAAqB,MAAA,CAAO,KAAA,EAAO,WAAA,CAAY,WAAW,IAAA,CAAK,OAAA;AAAA,IAC/D,eAAe,IAAA,CAAK,aAAA;AAAA,IACpB,YAAA,EAAc,KAAK,OAAA,IAAW;AAAA,GAClC;AAEA,EAAA,MAAM,QAAA,GAAW,wBAAwB,MAAM,CAAA;AAC/C,EAAA,MAAM,QAAA,GAAW,wBAAA,CAAyB,MAAA,EAAQ,eAAe,CAAA;AACjE,EAAA,MAAM,SAAA,GAAY,qBAAA,CAAsB,MAAA,EAAQ,EAAE,CAAA,CAAE,OAAA;AACpD,EAAA,MAAM,OAAA,GAAU,MAAA,CAAO,OAAA,CAAQ,eAAA,CAAgB;AAAA,IAC3C,MAAA,EAAQ,QAAA;AAAA,IACR,OAAA,EAAS;AAAA,MACL,EAAE,OAAA,EAAS,CAAA,EAAG,UAAU,EAAE,MAAA,EAAQ,UAAS,EAAE;AAAA,MAC7C,EAAE,OAAA,EAAS,CAAA,EAAG,UAAU,EAAE,MAAA,EAAQ,WAAU;AAAE;AAClD,GACH,CAAA;AAC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IAAA,EAAM;AAClB,IAAA,CAAA,CAAE,SAAS,OAAO,CAAA;AAAA,EACtB;AACJ;AAGO,SAAS,QAAA,CAAS,GAAA,EAAoD,IAAA,EAA8B,MAAA,EAA+B;AACtI,EAAA,IAAI,EAAA,GAA+B,IAAA;AACnC,EAAA,IAAI,KAAA,GAAQ,CAAA;AACZ,EAAA,KAAA,MAAW,KAAK,IAAA,EAAM;AAClB,IAAA,MAAM,IAAA,GAAO,EAAE,UAAA,CAAW,IAAA;AAC1B,IAAA,IAAI,IAAA,IAAQ,IAAA,CAAK,OAAA,KAAY,KAAA,EAAO;AAChC,MAAA;AAAA,IACJ;AACA,IAAA,IAAI,CAAA,CAAE,aAAa,EAAA,EAAI;AACnB,MAAA,GAAA,CAAI,WAAA,CAAY,EAAE,QAAQ,CAAA;AAC1B,MAAA,EAAA,GAAK,CAAA,CAAE,QAAA;AAAA,IACX;AACA,IAAA,KAAA,IAAS,CAAA,CAAE,IAAA,CAAK,GAAA,EAAK,MAAM,CAAA;AAAA,EAC/B;AACA,EAAA,OAAO,KAAA;AACX;;;;"}
@@ -13,9 +13,18 @@ function setShadowTaskCasterMeshes(shadowGenerator, casterMeshes) {
13
13
  function _getShadowTaskCasterMeshes(shadowGenerator) {
14
14
  return shadowTaskInputs?.get(shadowGenerator);
15
15
  }
16
+ function setShadowCasterMaxCascade(mesh, maxCascade) {
17
+ if (maxCascade !== Infinity && (!Number.isInteger(maxCascade) || maxCascade < 0)) {
18
+ throw new RangeError("setShadowCasterMaxCascade requires a non-negative integer or Infinity");
19
+ }
20
+ mesh._shadowMaxCascade = maxCascade === Infinity ? void 0 : maxCascade;
21
+ }
22
+ function _getShadowCasterMaxCascade(mesh) {
23
+ return mesh._shadowMaxCascade ?? Infinity;
24
+ }
16
25
  function _setShadowTaskInputPreloader(preloader) {
17
26
  shadowTaskInputPreloader = preloader;
18
27
  }
19
28
 
20
- export { _getShadowTaskCasterMeshes, _setShadowTaskInputPreloader, setShadowTaskCasterMeshes };
29
+ export { _getShadowCasterMaxCascade, _getShadowTaskCasterMeshes, _setShadowTaskInputPreloader, setShadowCasterMaxCascade, setShadowTaskCasterMeshes };
21
30
  //# sourceMappingURL=shadow-inputs.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"shadow-inputs.js","sources":["../../../src/frame-graph/shadow-inputs.ts"],"sourcesContent":["import type { Mesh } from \"../mesh/mesh.js\";\nimport type { ShadowGenerator } from \"../shadow/shadow-generator.js\";\n\nlet shadowTaskInputs: WeakMap<ShadowGenerator, readonly Mesh[]> | null = null;\nlet shadowTaskInputPreloader: ((shadowGenerator: ShadowGenerator, casterMeshes: readonly Mesh[]) => Promise<void>) | null = null;\n\nfunction getShadowTaskInputs(): WeakMap<ShadowGenerator, readonly Mesh[]> {\n shadowTaskInputs ??= new WeakMap<ShadowGenerator, readonly Mesh[]>();\n return shadowTaskInputs;\n}\n\n/** Register scene-owned shadow caster inputs for a generator. */\nexport function setShadowTaskCasterMeshes(shadowGenerator: ShadowGenerator, casterMeshes: readonly Mesh[]): void {\n getShadowTaskInputs().set(shadowGenerator, casterMeshes);\n if (shadowTaskInputPreloader) {\n void shadowTaskInputPreloader(shadowGenerator, casterMeshes);\n }\n}\n\n/** @internal */\nexport function _getShadowTaskCasterMeshes(shadowGenerator: ShadowGenerator): readonly Mesh[] | undefined {\n return shadowTaskInputs?.get(shadowGenerator);\n}\n\n/** @internal */\nexport function _setShadowTaskInputPreloader(preloader: (shadowGenerator: ShadowGenerator, casterMeshes: readonly Mesh[]) => Promise<void>): void {\n shadowTaskInputPreloader = preloader;\n}\n"],"names":[],"mappings":"AAGA,IAAI,gBAAA,GAAqE,IAAA;AACzE,IAAI,wBAAA,GAAwH,IAAA;AAE5H,SAAS,mBAAA,GAAiE;AACtE,EAAA,gBAAA,yBAAyB,OAAA,EAA0C;AACnE,EAAA,OAAO,gBAAA;AACX;AAGO,SAAS,yBAAA,CAA0B,iBAAkC,YAAA,EAAqC;AAC7G,EAAA,mBAAA,EAAoB,CAAE,GAAA,CAAI,eAAA,EAAiB,YAAY,CAAA;AACvD,EAAA,IAAI,wBAAA,EAA0B;AAC1B,IAAA,KAAK,wBAAA,CAAyB,iBAAiB,YAAY,CAAA;AAAA,EAC/D;AACJ;AAGO,SAAS,2BAA2B,eAAA,EAA+D;AACtG,EAAA,OAAO,gBAAA,EAAkB,IAAI,eAAe,CAAA;AAChD;AAGO,SAAS,6BAA6B,SAAA,EAAqG;AAC9I,EAAA,wBAAA,GAA2B,SAAA;AAC/B;;;;"}
1
+ {"version":3,"file":"shadow-inputs.js","sources":["../../../src/frame-graph/shadow-inputs.ts"],"sourcesContent":["import type { Mesh } from \"../mesh/mesh.js\";\nimport type { ShadowGenerator } from \"../shadow/shadow-generator.js\";\n\nlet shadowTaskInputs: WeakMap<ShadowGenerator, readonly Mesh[]> | null = null;\nlet shadowTaskInputPreloader: ((shadowGenerator: ShadowGenerator, casterMeshes: readonly Mesh[]) => Promise<void>) | null = null;\n\nfunction getShadowTaskInputs(): WeakMap<ShadowGenerator, readonly Mesh[]> {\n shadowTaskInputs ??= new WeakMap<ShadowGenerator, readonly Mesh[]>();\n return shadowTaskInputs;\n}\n\n/** Register scene-owned shadow caster inputs for a generator. */\nexport function setShadowTaskCasterMeshes(shadowGenerator: ShadowGenerator, casterMeshes: readonly Mesh[]): void {\n getShadowTaskInputs().set(shadowGenerator, casterMeshes);\n if (shadowTaskInputPreloader) {\n void shadowTaskInputPreloader(shadowGenerator, casterMeshes);\n }\n}\n\n/** @internal */\nexport function _getShadowTaskCasterMeshes(shadowGenerator: ShadowGenerator): readonly Mesh[] | undefined {\n return shadowTaskInputs?.get(shadowGenerator);\n}\n\n/**\n * Cap the cascades a caster mesh renders into: the mesh casts only into cascade layers `0..maxCascade`\n * (0 = the nearest). Lets a scene keep small casters out of the far cascades, where their shadows are\n * sub-texel anyway — each excluded layer saves that caster's draw + pipeline switch per frame.\n *\n * Unset (the default) casts into every cascade. Pass `Infinity` to restore that.\n * The cap is read when a generator's caster set is (re)supplied through\n * {@link setShadowTaskCasterMeshes}; to change it for an already-registered caster, re-supply the\n * caster list (a new array) afterwards. Non-cascaded (single-map) generators ignore the cap.\n */\nexport function setShadowCasterMaxCascade(mesh: Mesh, maxCascade: number): void {\n if (maxCascade !== Infinity && (!Number.isInteger(maxCascade) || maxCascade < 0)) {\n throw new RangeError(\"setShadowCasterMaxCascade requires a non-negative integer or Infinity\");\n }\n mesh._shadowMaxCascade = maxCascade === Infinity ? undefined : maxCascade;\n}\n\n/** @internal Cascade cap for a caster mesh (see {@link setShadowCasterMaxCascade}); Infinity when unset. */\nexport function _getShadowCasterMaxCascade(mesh: Mesh): number {\n return mesh._shadowMaxCascade ?? Infinity;\n}\n\n/** @internal */\nexport function _setShadowTaskInputPreloader(preloader: (shadowGenerator: ShadowGenerator, casterMeshes: readonly Mesh[]) => Promise<void>): void {\n shadowTaskInputPreloader = preloader;\n}\n"],"names":[],"mappings":"AAGA,IAAI,gBAAA,GAAqE,IAAA;AACzE,IAAI,wBAAA,GAAwH,IAAA;AAE5H,SAAS,mBAAA,GAAiE;AACtE,EAAA,gBAAA,yBAAyB,OAAA,EAA0C;AACnE,EAAA,OAAO,gBAAA;AACX;AAGO,SAAS,yBAAA,CAA0B,iBAAkC,YAAA,EAAqC;AAC7G,EAAA,mBAAA,EAAoB,CAAE,GAAA,CAAI,eAAA,EAAiB,YAAY,CAAA;AACvD,EAAA,IAAI,wBAAA,EAA0B;AAC1B,IAAA,KAAK,wBAAA,CAAyB,iBAAiB,YAAY,CAAA;AAAA,EAC/D;AACJ;AAGO,SAAS,2BAA2B,eAAA,EAA+D;AACtG,EAAA,OAAO,gBAAA,EAAkB,IAAI,eAAe,CAAA;AAChD;AAYO,SAAS,yBAAA,CAA0B,MAAY,UAAA,EAA0B;AAC5E,EAAA,IAAI,UAAA,KAAe,aAAa,CAAC,MAAA,CAAO,UAAU,UAAU,CAAA,IAAK,aAAa,CAAA,CAAA,EAAI;AAC9E,IAAA,MAAM,IAAI,WAAW,uEAAuE,CAAA;AAAA,EAChG;AACA,EAAA,IAAA,CAAK,iBAAA,GAAoB,UAAA,KAAe,QAAA,GAAW,MAAA,GAAY,UAAA;AACnE;AAGO,SAAS,2BAA2B,IAAA,EAAoB;AAC3D,EAAA,OAAO,KAAK,iBAAA,IAAqB,QAAA;AACrC;AAGO,SAAS,6BAA6B,SAAA,EAAqG;AAC9I,EAAA,wBAAA,GAA2B,SAAA;AAC/B;;;;"}
@@ -5,6 +5,7 @@ import { getBilinearSampler } from '../resource/samplers.js';
5
5
  import { getTrilinearAnisotropicSampler } from '../resource/trilinear-anisotropic-sampler.js';
6
6
  import { recordMipmaps } from '../texture/generate-mipmaps.js';
7
7
  import { biasedMipLevelCount } from '../texture/mip-count.js';
8
+ import { drawList } from './render-task.js';
8
9
  import { createImageProcessingTask } from './image-processing-task.js';
9
10
 
10
11
  let _depthGrab = null;
@@ -416,22 +417,6 @@ function drawBaseTask(task, pass) {
416
417
  draws += drawList(pass, task._directBindings, eng);
417
418
  return draws;
418
419
  }
419
- function drawList(enc, list, engine) {
420
- let lp = null;
421
- let draws = 0;
422
- for (const b of list) {
423
- const mesh = b.renderable.mesh;
424
- if (mesh && mesh.visible === false) {
425
- continue;
426
- }
427
- if (b.pipeline !== lp) {
428
- enc.setPipeline(b.pipeline);
429
- lp = b.pipeline;
430
- }
431
- draws += b.draw(enc, engine);
432
- }
433
- return draws;
434
- }
435
420
  function normalizeCopyCount(cfg) {
436
421
  const count = cfg?.copyCount ?? 1;
437
422
  return count === Infinity ? 0 : Math.max(0, count | 0);
@@ -1 +1 @@
1
- {"version":3,"file":"transmission.js","sources":["../../../src/frame-graph/transmission.ts"],"sourcesContent":["import { TU, SS } from \"../engine/gpu-flags.js\";\nimport type { EngineContext } from \"../engine/engine.js\";\nimport { _vis } from \"../engine/engine.js\";\nimport { createRenderTarget } from \"../engine/render-target.js\";\nimport { getBilinearSampler } from \"../resource/samplers.js\";\nimport { getTrilinearAnisotropicSampler } from \"../resource/trilinear-anisotropic-sampler.js\";\nimport type { Texture2D } from \"../texture/texture-2d.js\";\nimport { recordMipmaps } from \"../texture/generate-mipmaps.js\";\nimport { biasedMipLevelCount } from \"../texture/mip-count.js\";\nimport type { DrawBinding } from \"../render/renderable.js\";\nimport type { RenderTask } from \"./render-task.js\";\nimport type { SceneContext } from \"../scene/scene-core.js\";\nimport { createImageProcessingTask } from \"./image-processing-task.js\";\n\nexport interface RenderTaskTransmissionState {\n readonly texture: Texture2D;\n /** @internal */\n readonly _baseView: GPUTextureView;\n /** @internal */\n _sourceWidth: number;\n /** @internal */\n _sourceHeight: number;\n /** @internal */\n _sourceTexture: GPUTexture | null;\n /** @internal */\n _blit: TransmissionBlitState | null;\n /** @internal Depth grab (the `grabDepth` option): the task's depth attachment snapshotted at the same\n * mid-pass break as the scene-colour copy, resolved into a single-sample `r32float`. Null when the\n * option is off, the task has no depth attachment, or the target hasn't built yet. */\n _depth: TransmissionDepthGrabState | null;\n /** @internal */\n readonly _copyCount: number;\n /** @internal */\n readonly _generateMipmaps: boolean;\n /** @internal */\n _copies: number;\n}\n\n/** @internal Depth-grab state built by the lazy `transmission-depth-grab` module and consumed by the per-frame\n * grab in `updateTransmissionTexture`. Exported so the lazy module can construct it. */\nexport interface TransmissionDepthGrabState {\n readonly texture: Texture2D;\n /** @internal */\n readonly _view: GPUTextureView;\n /** @internal */\n readonly _blit: TransmissionBlitState;\n}\n\n/** @internal */\nexport interface TransmissionBlitState {\n /** @internal */\n readonly _pipeline: GPURenderPipeline;\n /** @internal */\n readonly _bindGroup: GPUBindGroup;\n}\n\n/** @internal Builds the depth-grab target + resolve blit, and records the per-frame resolve pass. Lives in the\n * lazily-imported `transmission-depth-grab` module so its shaders/pipelines/pass-descriptor cost zero bytes for\n * transmission scenes that never set `grabDepth`. */\nexport interface DepthGrabImpl {\n create: (engine: EngineContext, source: GPUTexture, width: number, height: number, multisampled: boolean) => TransmissionDepthGrabState;\n record: (engine: EngineContext, depth: TransmissionDepthGrabState) => void;\n}\n\nlet _depthGrab: DepthGrabImpl | null = null;\n\n/** @internal Called at the top level of `transmission-depth-grab.ts` (module side-effect) to wire the builder into\n * this shared module. The dynamic `import(\"./transmission-depth-grab.js\")` in a grabDepth task's `_preload` runs\n * before the frame graph builds, so `_depthGrab` is installed by the time `configureTransmissionSource` runs. */\nexport function _installDepthGrab(impl: DepthGrabImpl): void {\n _depthGrab = impl;\n}\n\nconst BLIT_SHADER = `@group(0)@binding(0)var t:texture_2d<f32>;@group(0)@binding(1)var s:sampler;struct V{@builtin(position)p:vec4f,@location(0)u:vec2f};@vertex fn vs(@builtin(vertex_index)i:u32)->V{var p=array<vec2f,3>(vec2f(-1,-1),vec2f(3,-1),vec2f(-1,3));var u=array<vec2f,3>(vec2f(0,1),vec2f(2,1),vec2f(0,-1));return V(vec4f(p[i],0,1),u[i]);}@fragment fn fs(v:V)->@location(0)vec4f{return textureSample(t,s,v.u);}`;\nconst BLIT_MSAA_SHADER = `@group(0)@binding(0)var t:texture_multisampled_2d<f32>;struct V{@builtin(position)p:vec4f,@location(0)u:vec2f};@vertex fn vs(@builtin(vertex_index)i:u32)->V{var p=array<vec2f,3>(vec2f(-1,-1),vec2f(3,-1),vec2f(-1,3));var u=array<vec2f,3>(vec2f(0,1),vec2f(2,1),vec2f(0,-1));return V(vec4f(p[i],0,1),u[i]);}fn l(p:vec2i)->vec4f{let n=textureNumSamples(t);var c=vec4f(0);for(var i=0u;i<n;i++){c+=textureLoad(t,p,i);}return c/f32(n);}@fragment fn fs(v:V)->@location(0)vec4f{let d=vec2i(textureDimensions(t));let q=clamp(v.u*vec2f(d)-.5,vec2f(0),vec2f(d-vec2i(1)));let p=vec2i(floor(q));let f=fract(q);let p1=min(p+vec2i(1),d-vec2i(1));return mix(mix(l(p),l(vec2i(p1.x,p.y)),f.x),mix(l(vec2i(p.x,p1.y)),l(p1),f.x),f.y);}`;\nconst REFRACTION_LOD_BIAS = 4;\nlet blitPipelines: Map<string, GPURenderPipeline> | null = null;\nlet blitShader: GPUShaderModule | null = null;\nlet blitMsaaShader: GPUShaderModule | null = null;\nlet blitBgl: GPUBindGroupLayout | null = null;\nlet blitMsaaBgl: GPUBindGroupLayout | null = null;\nlet blitDevice: GPUDevice | null = null;\n\n/** Enable scene-color transmission for every render task currently registered in a scene. PBR materials are marked for linear transmission, and a trailing image-processing task is appended when needed. */\nexport function enableSceneTransmission(scene: SceneContext, engine: EngineContext): void {\n markPbrMaterialsLinear(scene);\n let lastRenderTask: RenderTask | null = null;\n for (const task of scene._frameGraph._tasks) {\n if (\"_renderables\" in task) {\n const renderTask = task as RenderTask;\n enableRenderTaskTransmission(renderTask, engine);\n lastRenderTask = renderTask;\n }\n }\n if (lastRenderTask && !scene._frameGraph._tasks.some((task) => task.name === \"transmission-image-processing\")) {\n scene._frameGraph._tasks.push(createImageProcessingTask({ name: \"transmission-image-processing\", source: lastRenderTask._config.rt }, engine, scene));\n }\n}\n\n/** Options controlling how a render task exposes opaque scene color to transmissive materials. Use these to opt out of the linear offscreen path, control refresh frequency, and limit mipmap generation cost. */\nexport interface TransmissionOptions {\n /** When true (the default), retarget the task's color buffer to a linear `rgba16float`\n * offscreen and tone-map it in a trailing image-processing pass — the model PBR\n * transmission uses so refractive materials read scene color in *linear* space.\n *\n * Set false to perform ONLY the mid-pass scene-color grab: the task's render target\n * format / sample count / clear are left untouched and no tone-map pass is added. Use\n * this for consumers that own their tone mapping / post (e.g. a custom depth-of-field\n * stack) and just need the opaque scene color exposed to a custom transmissive\n * `ShaderMaterial`. */\n linear?: boolean;\n /** Override how many times the scene-colour grab is refreshed per frame. `0` means before every\n * transmissive draw; the default is once before the first transmissive draw. */\n copyCount?: number;\n /** Set false when the transmissive material never samples the scene-colour grab above mip 0. */\n generateMipmaps?: boolean;\n /** Cap the scene-colour grab mip chain. Use this when the material samples explicit low LODs only, so\n * unused tiny mips are not regenerated every frame. Ignored when `generateMipmaps` is false. */\n mipLevelCount?: number;\n /** When true, ALSO snapshot the task's DEPTH attachment at the same mid-pass grab, into a single-sample\n * `r32float` texture exposed as `SceneColorGrab.depthTexture` — the opaque scene depth as of the moment\n * the first transmissive surface draws. Lets a transmissive material depth-ray-march the opaque scene\n * (screen-space reflection / refraction) without re-rendering a separate depth prepass: the depth\n * attachment itself cannot be sampled while the transmissive draw has it bound (a WebGPU feedback loop),\n * which is exactly why the snapshot is taken at the pass break. MSAA sources resolve sample 0 (matching\n * `createDepthResolveTask`). No-op when the task's render target carries no depth attachment. */\n grabDepth?: boolean;\n}\n\n/** Handle to a render task's scene-color grab, returned by `enableRenderTaskTransmission`. */\nexport interface SceneColorGrab {\n /** The live opaque-scene-color texture sampled by transmissive surfaces, or null before the\n * frame graph has built the task at least once. Its identity changes when the task rebuilds\n * (e.g. on resize), so consumers that bind it to a custom material should re-bind when it\n * changes. */\n readonly texture: Texture2D | null;\n /** The live opaque-scene DEPTH grab (`grabDepth: true`): the task's depth attachment as of the moment\n * the first transmissive surface draws, resolved to a single-sample `r32float` (raw NDC depth as\n * stored; a cleared texel means no geometry). Null before the target builds or when `grabDepth` is\n * off. Identity changes when the task rebuilds (e.g. on resize) — re-bind on change. */\n readonly depthTexture: Texture2D | null;\n}\n\n/** Enable mid-pass scene-color grabs for a single render task and return the live texture handle. The task is wrapped so transmissive draw calls can sample the opaque color rendered earlier in the same pass. */\nexport function enableRenderTaskTransmission(task: RenderTask, engine: EngineContext, options?: TransmissionOptions): SceneColorGrab {\n const linear = options?.linear !== false;\n applyTransmissionOptions(task, options);\n // grabDepth is opt-in: only when set do we dynamic-import the depth-grab shaders/pipelines (installed via the\n // module side-effect). `_preload` is awaited before the frame graph builds, so `_createDepthGrab` is ready by\n // the time `configureTransmissionSource` runs in record(). Transmission scenes without grabDepth never fetch it.\n if (task._config.transmission?.grabDepth) {\n const priorPreload = task._preload?.bind(task);\n task._preload = async (): Promise<void> => {\n if (priorPreload) {\n await priorPreload();\n }\n await import(\"./transmission-depth-grab.js\");\n };\n }\n const grab: SceneColorGrab = {\n get texture(): Texture2D | null {\n return (task._targetSignature as { _transmissionTexture?: Texture2D })._transmissionTexture ?? null;\n },\n get depthTexture(): Texture2D | null {\n return (task._targetSignature as { _transmissionDepthTexture?: Texture2D | null })._transmissionDepthTexture ?? null;\n },\n };\n if (task._executeWithTransmission) {\n return grab;\n }\n if (linear) {\n retargetRenderTaskToLinearOffscreen(task);\n }\n let state: RenderTaskTransmissionState | null = null;\n const record = task.record.bind(task);\n const execute = task.execute?.bind(task);\n const dispose = task.dispose?.bind(task);\n task.record = () => {\n disposeRenderTaskTransmission(state);\n state = createRenderTaskTransmission(task, engine);\n (task._targetSignature as { _transmissionTexture?: Texture2D })._transmissionTexture = state.texture;\n record();\n configureTransmissionSource(state, task, engine);\n };\n if (linear && execute) {\n task.execute = () => executeRenderTaskLinear(task.scene, execute);\n }\n task.dispose = () => {\n disposeRenderTaskTransmission(state);\n state = null;\n dispose?.();\n };\n task._executeWithTransmission = (sampleCount) => executePassWithTransmission(task, engine, state!, sampleCount);\n return grab;\n}\n\nfunction retargetRenderTaskToLinearOffscreen(task: RenderTask): void {\n const cfg = task._config;\n const oldDesc = cfg.rt._descriptor;\n const surface = task.scene.surface;\n const sampleCount = surface.msaaSamples;\n // The scene render task may target the shared engine scRT (single-sample,\n // colour-only — single-sample default path) or an MSAA colour RT that resolves into it\n // via `rst` (MSAA default path). Never mutate the shared scRT descriptor —\n // instead point the task at a fresh offscreen HDR target and stop resolving to swap.\n // Transmission samples this linear HDR result in its own final image-processing pass\n // that writes the tonemapped result to the swapchain.\n //\n // Depth ownership: when the task already carries an external depth (`cfg.depth`, the\n // single-sample default path), keep it; otherwise the new target owns depth (matching\n // the MSAA colour RT it replaces).\n const ownsDepth = !cfg.depth;\n const newRt = createRenderTarget({\n lbl: \"transmission-linear\",\n format: \"rgba16float\",\n dFormat: ownsDepth ? (oldDesc.dFormat ?? \"depth24plus-stencil8\") : undefined,\n _depthClearValue: oldDesc._depthClearValue,\n _depthCompare: oldDesc._depthCompare,\n samples: sampleCount,\n size: surface,\n });\n cfg.rt = newRt;\n cfg.rst = undefined;\n const sig = task._targetSignature as {\n _colorFormat?: GPUTextureFormat;\n _depthStencilFormat?: GPUTextureFormat;\n _depthCompare?: GPUCompareFunction;\n _sampleCount: number;\n };\n sig._colorFormat = \"rgba16float\";\n sig._depthStencilFormat = cfg.depth?._descriptor.dFormat ?? newRt._descriptor.dFormat;\n sig._depthCompare = newRt._descriptor._depthCompare;\n sig._sampleCount = sampleCount;\n task._opaqueBundles.length = 0;\n task._lastVersion = -1;\n}\n\nfunction executeRenderTaskLinear(scene: SceneContext, execute: () => number): number {\n const imageProcessing = scene.imageProcessing as { exposure: number; contrast: number; toneMappingEnabled: boolean | number };\n const toneMappingEnabled = imageProcessing.toneMappingEnabled;\n const clearColor = scene.clearColor;\n const linearClearColor = inverseImageProcessedColor(clearColor, imageProcessing.exposure, imageProcessing.contrast, toneMappingEnabled === true);\n imageProcessing.toneMappingEnabled = -1;\n scene.clearColor = linearClearColor;\n try {\n return execute();\n } finally {\n scene.clearColor = clearColor;\n imageProcessing.toneMappingEnabled = toneMappingEnabled;\n }\n}\n\nfunction inverseImageProcessedColor(color: GPUColorDict, exposure: number, contrast: number, toneMapping: boolean): GPUColorDict {\n return {\n r: inverseImageProcessedChannel(color.r, exposure, contrast, toneMapping),\n g: inverseImageProcessedChannel(color.g, exposure, contrast, toneMapping),\n b: inverseImageProcessedChannel(color.b, exposure, contrast, toneMapping),\n a: color.a,\n };\n}\n\nfunction inverseImageProcessedChannel(value: number, exposure: number, contrast: number, toneMapping: boolean): number {\n let c = clamp01(value);\n if (contrast < 1) {\n c = contrast > 0 ? clamp01((c - 0.5 * (1 - contrast)) / contrast) : 0.5;\n } else if (contrast > 1) {\n const mixAmount = contrast - 1;\n let lo = 0;\n let hi = 1;\n for (let i = 0; i < 16; i++) {\n const mid = (lo + hi) * 0.5;\n const high = mid * mid * (3 - 2 * mid);\n const out = mid + (high - mid) * mixAmount;\n if (out < c) {\n lo = mid;\n } else {\n hi = mid;\n }\n }\n c = (lo + hi) * 0.5;\n }\n c = c ** 2.2;\n if (toneMapping) {\n c = -Math.log2(Math.max(1 - c, 1e-6)) / 1.5905790328979492;\n }\n return exposure > 0 ? c / exposure : c;\n}\n\nfunction clamp01(v: number): number {\n return Math.min(Math.max(v, 0), 1);\n}\n\nfunction markPbrMaterialsLinear(scene: SceneContext): void {\n for (const mesh of scene.meshes) {\n const mat = mesh.material as { _linearImageProcessing?: boolean; _renderFeatures?: unknown } | undefined;\n if (mat) {\n mat._linearImageProcessing = true;\n mat._renderFeatures = undefined;\n }\n }\n}\n\nfunction createRenderTaskTransmission(task: RenderTask, engine: EngineContext): RenderTaskTransmissionState {\n const rt = task._config.rt;\n const width = 1024;\n const height = 1024;\n const format: GPUTextureFormat = \"rgba16float\";\n const mipLevelCount = transmissionMipLevelCount(task._config.transmission, width, height);\n const generateMipmaps = mipLevelCount > 1;\n const texture = engine._device.createTexture({\n label: task.name,\n size: { width, height },\n format,\n mipLevelCount,\n usage: TU.RENDER_ATTACHMENT | TU.TEXTURE_BINDING | TU.COPY_DST,\n });\n const tex: Texture2D = {\n texture,\n view: texture.createView(),\n sampler: getTrilinearAnisotropicSampler(engine),\n width,\n height,\n invertY: false,\n };\n return {\n texture: tex,\n _baseView: texture.createView({ baseMipLevel: 0, mipLevelCount: 1 }),\n _sourceWidth: rt._width,\n _sourceHeight: rt._height,\n _sourceTexture: null,\n _blit: null,\n _depth: null,\n _copyCount: normalizeCopyCount(task._config.transmission),\n _generateMipmaps: generateMipmaps,\n _copies: 0,\n };\n}\n\nfunction configureTransmissionSource(state: RenderTaskTransmissionState, task: RenderTask, engine: EngineContext): void {\n const rt = task._config.rt;\n state._sourceWidth = rt._width;\n state._sourceHeight = rt._height;\n state._sourceTexture = rt._colorTexture;\n const sampleCount = task._targetSignature._sampleCount;\n // Depth grab (grabDepth): (re)build the r32float snapshot + its resolve blit against the task's CURRENT\n // depth attachment, and publish it on the target signature so `SceneColorGrab.depthTexture` stays live.\n const sig = task._targetSignature as { _transmissionDepthTexture?: Texture2D | null };\n sig._transmissionDepthTexture = null;\n const depthSource = rt._depthTexture;\n if (task._config.transmission?.grabDepth && _depthGrab && depthSource && rt._width > 0 && rt._height > 0) {\n state._depth = _depthGrab.create(engine, depthSource, rt._width, rt._height, sampleCount > 1);\n sig._transmissionDepthTexture = state._depth.texture;\n }\n if (!state._sourceTexture) {\n return;\n }\n state._blit = shouldBlitTransmission(state, sampleCount) ? createTransmissionBlit(state, engine, state._sourceTexture, sampleCount > 1) : null;\n}\n\nfunction disposeRenderTaskTransmission(state: RenderTaskTransmissionState | null | undefined): void {\n state?.texture.texture.destroy();\n state?._depth?.texture.texture.destroy();\n}\n\nexport function executePassWithTransmission(task: RenderTask, engine: EngineContext, state: RenderTaskTransmissionState, sampleCount: number): number {\n state._copies = 0;\n const transparent = task._transparentBindings;\n // MSAA: resolve the FINAL scene colour into the task's single-sample resolve target (`rst`) so downstream\n // passes that SAMPLE the scene RTT (e.g. a custom DoF/present stack) get a resolved image. The multisampled\n // colour is preserved across the split segments (store/load), so resolving on every segment leaves the LAST\n // (complete) resolve in `rst`. No-op when single-sample (resolveView stays null) — existing scenes unchanged.\n const resolveView = sampleCount > 1 ? (task._config.rst?._colorView ?? null) : null;\n let pass = beginTaskPass(task, resolveView, sampleCount, false);\n let draws = drawBaseTask(task, pass);\n let lastPipeline: GPURenderPipeline | null = null;\n let overlay: DrawBinding[] | null = null;\n for (let i = 0; i < transparent.length; i++) {\n const binding = transparent[i]!;\n // `Mesh.renderOnTop` surfaces draw last — after the scene-colour grab — so they sit on top of the\n // transmissive surface and are excluded from what it refracts (e.g. lily pads on water).\n if (binding.renderable.mesh?.renderOnTop === true) {\n (overlay ??= []).push(binding);\n continue;\n }\n const transmissive = binding.renderable._transmissive === true;\n if (transmissive && canUpdateTransmission(state)) {\n pass.end();\n updateTransmissionTexture(state, engine);\n pass = beginTaskPass(task, resolveView, sampleCount, true);\n setPassState(task, pass);\n lastPipeline = null;\n }\n const mesh = binding.renderable.mesh;\n if (mesh && mesh.visible === false) {\n continue;\n }\n if (binding.pipeline !== lastPipeline) {\n pass.setPipeline(binding.pipeline);\n lastPipeline = binding.pipeline;\n }\n draws += binding.draw(pass, engine);\n }\n if (overlay) {\n draws += drawList(pass, overlay, engine);\n }\n pass.end();\n return draws;\n}\n\nfunction updateTransmissionTexture(state: RenderTaskTransmissionState, engine: EngineContext): void {\n if (!state._sourceTexture) {\n throw new Error(\"No transmission source\");\n }\n if (state._blit) {\n blitToTransmission(state, engine);\n } else {\n engine._currentEncoder.copyTextureToTexture(\n { texture: state._sourceTexture },\n { texture: state.texture.texture },\n { width: state.texture.width, height: state.texture.height }\n );\n }\n if (state._generateMipmaps) {\n recordMipmaps(engine, state.texture.texture, engine._currentEncoder);\n }\n // Depth grab rides the same mid-pass break: the depth attachment is unbound here (the pass just ended),\n // so it is legal to sample; the resumed segment re-attaches it with loadOp \"load\". The record body lives in\n // the lazy depth-grab module (installed only when grabDepth is enabled), so it costs zero bytes otherwise.\n if (state._depth) {\n _depthGrab?.record(engine, state._depth);\n }\n state._copies++;\n}\n\nfunction getBlitPipeline(engine: EngineContext, format: GPUTextureFormat, multisampled: boolean): GPURenderPipeline {\n const device = engine._device;\n if (device !== blitDevice) {\n blitPipelines?.clear();\n blitPipelines = null;\n blitShader = null;\n blitMsaaShader = null;\n blitBgl = null;\n blitMsaaBgl = null;\n blitDevice = device;\n }\n if (multisampled) {\n blitMsaaShader ??= device.createShaderModule({ code: BLIT_MSAA_SHADER });\n blitMsaaBgl ??= device.createBindGroupLayout({\n entries: [{ binding: 0, visibility: SS.FRAGMENT, texture: { sampleType: \"unfilterable-float\", multisampled: true } }],\n });\n } else {\n blitShader ??= device.createShaderModule({ code: BLIT_SHADER });\n blitBgl ??= device.createBindGroupLayout({\n entries: [\n { binding: 0, visibility: SS.FRAGMENT, texture: { sampleType: \"float\" } },\n { binding: 1, visibility: SS.FRAGMENT, sampler: {} },\n ],\n });\n }\n blitPipelines ??= new Map();\n const key = `${format}:${multisampled ? \"msaa\" : \"\"}`;\n let pipeline = blitPipelines.get(key);\n if (!pipeline) {\n const bgl = multisampled ? blitMsaaBgl! : blitBgl!;\n pipeline = device.createRenderPipeline({\n label: \"transmission-copy\",\n layout: device.createPipelineLayout({ bindGroupLayouts: [bgl] }),\n vertex: { module: multisampled ? blitMsaaShader! : blitShader!, entryPoint: \"vs\" },\n fragment: { module: multisampled ? blitMsaaShader! : blitShader!, entryPoint: \"fs\", targets: [{ format }] },\n primitive: { topology: \"triangle-list\" },\n });\n blitPipelines.set(key, pipeline);\n }\n return pipeline;\n}\n\nfunction shouldBlitTransmission(state: RenderTaskTransmissionState, sampleCount: number): boolean {\n return sampleCount > 1 || state._sourceWidth !== state.texture.width || state._sourceHeight !== state.texture.height;\n}\n\nfunction createTransmissionBlit(state: RenderTaskTransmissionState, engine: EngineContext, source: GPUTexture, multisampled: boolean): TransmissionBlitState {\n const device = engine._device;\n const pipeline = getBlitPipeline(engine, state.texture.texture.format, multisampled);\n const bindGroup = device.createBindGroup({\n layout: multisampled ? blitMsaaBgl! : blitBgl!,\n entries: multisampled\n ? [{ binding: 0, resource: source.createView() }]\n : [\n { binding: 0, resource: source.createView() },\n { binding: 1, resource: getBilinearSampler(engine) },\n ],\n });\n return { _pipeline: pipeline, _bindGroup: bindGroup };\n}\n\nfunction blitToTransmission(state: RenderTaskTransmissionState, engine: EngineContext): void {\n const blit = state._blit!;\n const pass = engine._currentEncoder.beginRenderPass({\n colorAttachments: [{ view: state._baseView, loadOp: \"clear\", storeOp: \"store\", clearValue: { r: 0, g: 0, b: 0, a: 0 } }],\n });\n pass.setPipeline(blit._pipeline);\n pass.setBindGroup(0, blit._bindGroup);\n pass.draw(3);\n pass.end();\n}\n\nfunction canUpdateTransmission(state: RenderTaskTransmissionState): boolean {\n return state._copyCount === 0 || state._copies < state._copyCount;\n}\n\nfunction beginTaskPass(task: RenderTask, resolveTarget: GPUTextureView | null, sampleCount: number, load: boolean): GPURenderPassEncoder {\n const att = task._colorAttachment;\n const depthLoadOp = load || !task._config.clr ? \"load\" : \"clear\";\n if (load) {\n att.loadOp = \"load\";\n }\n const depthAttachment = task._renderPassDescriptor.depthStencilAttachment;\n if (depthAttachment) {\n depthAttachment.depthLoadOp = depthLoadOp;\n if (depthAttachment.stencilLoadOp) {\n depthAttachment.stencilLoadOp = depthLoadOp;\n }\n }\n if (sampleCount > 1) {\n att.resolveTarget = resolveTarget ?? undefined;\n } else {\n att.resolveTarget = undefined;\n }\n return task.engine._currentEncoder.beginRenderPass(task._renderPassDescriptor);\n}\n\nfunction setPassState(task: RenderTask, pass: GPURenderPassEncoder): void {\n const cfg = task._config;\n const rt = cfg.rt;\n const scene = task.scene;\n const camera = cfg.cam ?? scene.camera;\n const v = camera?.viewport;\n if (v) {\n const rw = rt._width;\n const rh = rt._height;\n const x = Math.floor(v.x * rw);\n const y = Math.floor((1 - v.y - v.height) * rh);\n const w = Math.ceil((v.x + v.width) * rw) - x;\n const h = Math.ceil((1 - v.y) * rh) - y;\n pass.setViewport(x, y, w, h, 0, 1);\n pass.setScissorRect(x, y, w, h);\n }\n pass.setBindGroup(0, task._sceneBG);\n}\n\nfunction drawBaseTask(task: RenderTask, pass: GPURenderPassEncoder): number {\n const eng = task.engine;\n const rt = task._config.rt;\n const scene = task.scene;\n const opaqueBindings = task._opaqueBindings;\n const opaqueBundles = task._opaqueBundles;\n\n setPassState(task, pass);\n\n if (task._lastVersion !== scene._renderableVersion || task._lastVis !== _vis || opaqueBundles.length === 0) {\n const desc = rt._descriptor;\n const be = eng._device.createRenderBundleEncoder({\n colorFormats: desc.format ? [desc.format] : [],\n depthStencilFormat: desc.dFormat,\n sampleCount: desc.samples ?? 1,\n });\n be.setBindGroup(0, task._sceneBG);\n drawList(be, opaqueBindings, eng);\n opaqueBundles[0] = be.finish();\n task._lastVersion = scene._renderableVersion;\n task._lastVis = _vis;\n }\n let draws = opaqueBindings.length;\n pass.executeBundles(opaqueBundles);\n pass.setBindGroup(0, task._sceneBG);\n draws += drawList(pass, task._directBindings, eng);\n return draws;\n}\n\nfunction drawList(enc: GPURenderPassEncoder | GPURenderBundleEncoder, list: readonly DrawBinding[], engine: EngineContext): number {\n let lp: GPURenderPipeline | null = null;\n let draws = 0;\n for (const b of list) {\n const mesh = b.renderable.mesh;\n if (mesh && mesh.visible === false) {\n continue;\n }\n if (b.pipeline !== lp) {\n enc.setPipeline(b.pipeline);\n lp = b.pipeline;\n }\n draws += b.draw(enc, engine);\n }\n return draws;\n}\n\nfunction normalizeCopyCount(cfg: RenderTask[\"_config\"][\"transmission\"]): number {\n const count = cfg?.copyCount ?? 1;\n return count === Infinity ? 0 : Math.max(0, count | 0);\n}\n\nfunction applyTransmissionOptions(task: RenderTask, options: TransmissionOptions | undefined): void {\n if (!options) {\n return;\n }\n let next = task._config.transmission;\n let changed = false;\n const set = <K extends keyof NonNullable<RenderTask[\"_config\"][\"transmission\"]>>(key: K, value: NonNullable<RenderTask[\"_config\"][\"transmission\"]>[K] | undefined): void => {\n if (value === undefined) {\n return;\n }\n next = { ...next, [key]: value };\n changed = true;\n };\n set(\"copyCount\", options.copyCount);\n set(\"generateMipmaps\", options.generateMipmaps);\n set(\"mipLevelCount\", options.mipLevelCount);\n set(\"grabDepth\", options.grabDepth);\n if (changed) {\n task._config.transmission = next;\n }\n}\n\nfunction transmissionMipLevelCount(cfg: RenderTask[\"_config\"][\"transmission\"], width: number, height: number): number {\n if (cfg?.generateMipmaps === false) {\n return 1;\n }\n const full = Math.floor(Math.log2(Math.max(width, height))) + 1;\n const defaultCount = biasedMipLevelCount(width, height, REFRACTION_LOD_BIAS);\n const requested = cfg?.mipLevelCount;\n if (requested === undefined) {\n return Math.min(full, defaultCount);\n }\n return Math.min(full, Math.max(1, requested | 0));\n}\n"],"names":[],"mappings":";;;;;;;;;AAgEA,IAAI,UAAA,GAAmC,IAAA;AAKhC,SAAS,kBAAkB,IAAA,EAA2B;AACzD,EAAA,UAAA,GAAa,IA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file":"transmission.js","sources":["../../../src/frame-graph/transmission.ts"],"sourcesContent":["import { TU, SS } from \"../engine/gpu-flags.js\";\nimport type { EngineContext } from \"../engine/engine.js\";\nimport { _vis } from \"../engine/engine.js\";\nimport { createRenderTarget } from \"../engine/render-target.js\";\nimport { getBilinearSampler } from \"../resource/samplers.js\";\nimport { getTrilinearAnisotropicSampler } from \"../resource/trilinear-anisotropic-sampler.js\";\nimport type { Texture2D } from \"../texture/texture-2d.js\";\nimport { recordMipmaps } from \"../texture/generate-mipmaps.js\";\nimport { biasedMipLevelCount } from \"../texture/mip-count.js\";\nimport type { DrawBinding } from \"../render/renderable.js\";\nimport { drawList, type RenderTask } from \"./render-task.js\";\nimport type { SceneContext } from \"../scene/scene-core.js\";\nimport { createImageProcessingTask } from \"./image-processing-task.js\";\n\nexport interface RenderTaskTransmissionState {\n readonly texture: Texture2D;\n /** @internal */\n readonly _baseView: GPUTextureView;\n /** @internal */\n _sourceWidth: number;\n /** @internal */\n _sourceHeight: number;\n /** @internal */\n _sourceTexture: GPUTexture | null;\n /** @internal */\n _blit: TransmissionBlitState | null;\n /** @internal Depth grab (the `grabDepth` option): the task's depth attachment snapshotted at the same\n * mid-pass break as the scene-colour copy, resolved into a single-sample `r32float`. Null when the\n * option is off, the task has no depth attachment, or the target hasn't built yet. */\n _depth: TransmissionDepthGrabState | null;\n /** @internal */\n readonly _copyCount: number;\n /** @internal */\n readonly _generateMipmaps: boolean;\n /** @internal */\n _copies: number;\n}\n\n/** @internal Depth-grab state built by the lazy `transmission-depth-grab` module and consumed by the per-frame\n * grab in `updateTransmissionTexture`. Exported so the lazy module can construct it. */\nexport interface TransmissionDepthGrabState {\n readonly texture: Texture2D;\n /** @internal */\n readonly _view: GPUTextureView;\n /** @internal */\n readonly _blit: TransmissionBlitState;\n}\n\n/** @internal */\nexport interface TransmissionBlitState {\n /** @internal */\n readonly _pipeline: GPURenderPipeline;\n /** @internal */\n readonly _bindGroup: GPUBindGroup;\n}\n\n/** @internal Builds the depth-grab target + resolve blit, and records the per-frame resolve pass. Lives in the\n * lazily-imported `transmission-depth-grab` module so its shaders/pipelines/pass-descriptor cost zero bytes for\n * transmission scenes that never set `grabDepth`. */\nexport interface DepthGrabImpl {\n create: (engine: EngineContext, source: GPUTexture, width: number, height: number, multisampled: boolean) => TransmissionDepthGrabState;\n record: (engine: EngineContext, depth: TransmissionDepthGrabState) => void;\n}\n\nlet _depthGrab: DepthGrabImpl | null = null;\n\n/** @internal Called at the top level of `transmission-depth-grab.ts` (module side-effect) to wire the builder into\n * this shared module. The dynamic `import(\"./transmission-depth-grab.js\")` in a grabDepth task's `_preload` runs\n * before the frame graph builds, so `_depthGrab` is installed by the time `configureTransmissionSource` runs. */\nexport function _installDepthGrab(impl: DepthGrabImpl): void {\n _depthGrab = impl;\n}\n\nconst BLIT_SHADER = `@group(0)@binding(0)var t:texture_2d<f32>;@group(0)@binding(1)var s:sampler;struct V{@builtin(position)p:vec4f,@location(0)u:vec2f};@vertex fn vs(@builtin(vertex_index)i:u32)->V{var p=array<vec2f,3>(vec2f(-1,-1),vec2f(3,-1),vec2f(-1,3));var u=array<vec2f,3>(vec2f(0,1),vec2f(2,1),vec2f(0,-1));return V(vec4f(p[i],0,1),u[i]);}@fragment fn fs(v:V)->@location(0)vec4f{return textureSample(t,s,v.u);}`;\nconst BLIT_MSAA_SHADER = `@group(0)@binding(0)var t:texture_multisampled_2d<f32>;struct V{@builtin(position)p:vec4f,@location(0)u:vec2f};@vertex fn vs(@builtin(vertex_index)i:u32)->V{var p=array<vec2f,3>(vec2f(-1,-1),vec2f(3,-1),vec2f(-1,3));var u=array<vec2f,3>(vec2f(0,1),vec2f(2,1),vec2f(0,-1));return V(vec4f(p[i],0,1),u[i]);}fn l(p:vec2i)->vec4f{let n=textureNumSamples(t);var c=vec4f(0);for(var i=0u;i<n;i++){c+=textureLoad(t,p,i);}return c/f32(n);}@fragment fn fs(v:V)->@location(0)vec4f{let d=vec2i(textureDimensions(t));let q=clamp(v.u*vec2f(d)-.5,vec2f(0),vec2f(d-vec2i(1)));let p=vec2i(floor(q));let f=fract(q);let p1=min(p+vec2i(1),d-vec2i(1));return mix(mix(l(p),l(vec2i(p1.x,p.y)),f.x),mix(l(vec2i(p.x,p1.y)),l(p1),f.x),f.y);}`;\nconst REFRACTION_LOD_BIAS = 4;\nlet blitPipelines: Map<string, GPURenderPipeline> | null = null;\nlet blitShader: GPUShaderModule | null = null;\nlet blitMsaaShader: GPUShaderModule | null = null;\nlet blitBgl: GPUBindGroupLayout | null = null;\nlet blitMsaaBgl: GPUBindGroupLayout | null = null;\nlet blitDevice: GPUDevice | null = null;\n\n/** Enable scene-color transmission for every render task currently registered in a scene. PBR materials are marked for linear transmission, and a trailing image-processing task is appended when needed. */\nexport function enableSceneTransmission(scene: SceneContext, engine: EngineContext): void {\n markPbrMaterialsLinear(scene);\n let lastRenderTask: RenderTask | null = null;\n for (const task of scene._frameGraph._tasks) {\n if (\"_renderables\" in task) {\n const renderTask = task as RenderTask;\n enableRenderTaskTransmission(renderTask, engine);\n lastRenderTask = renderTask;\n }\n }\n if (lastRenderTask && !scene._frameGraph._tasks.some((task) => task.name === \"transmission-image-processing\")) {\n scene._frameGraph._tasks.push(createImageProcessingTask({ name: \"transmission-image-processing\", source: lastRenderTask._config.rt }, engine, scene));\n }\n}\n\n/** Options controlling how a render task exposes opaque scene color to transmissive materials. Use these to opt out of the linear offscreen path, control refresh frequency, and limit mipmap generation cost. */\nexport interface TransmissionOptions {\n /** When true (the default), retarget the task's color buffer to a linear `rgba16float`\n * offscreen and tone-map it in a trailing image-processing pass — the model PBR\n * transmission uses so refractive materials read scene color in *linear* space.\n *\n * Set false to perform ONLY the mid-pass scene-color grab: the task's render target\n * format / sample count / clear are left untouched and no tone-map pass is added. Use\n * this for consumers that own their tone mapping / post (e.g. a custom depth-of-field\n * stack) and just need the opaque scene color exposed to a custom transmissive\n * `ShaderMaterial`. */\n linear?: boolean;\n /** Override how many times the scene-colour grab is refreshed per frame. `0` means before every\n * transmissive draw; the default is once before the first transmissive draw. */\n copyCount?: number;\n /** Set false when the transmissive material never samples the scene-colour grab above mip 0. */\n generateMipmaps?: boolean;\n /** Cap the scene-colour grab mip chain. Use this when the material samples explicit low LODs only, so\n * unused tiny mips are not regenerated every frame. Ignored when `generateMipmaps` is false. */\n mipLevelCount?: number;\n /** When true, ALSO snapshot the task's DEPTH attachment at the same mid-pass grab, into a single-sample\n * `r32float` texture exposed as `SceneColorGrab.depthTexture` — the opaque scene depth as of the moment\n * the first transmissive surface draws. Lets a transmissive material depth-ray-march the opaque scene\n * (screen-space reflection / refraction) without re-rendering a separate depth prepass: the depth\n * attachment itself cannot be sampled while the transmissive draw has it bound (a WebGPU feedback loop),\n * which is exactly why the snapshot is taken at the pass break. MSAA sources resolve sample 0 (matching\n * `createDepthResolveTask`). No-op when the task's render target carries no depth attachment. */\n grabDepth?: boolean;\n}\n\n/** Handle to a render task's scene-color grab, returned by `enableRenderTaskTransmission`. */\nexport interface SceneColorGrab {\n /** The live opaque-scene-color texture sampled by transmissive surfaces, or null before the\n * frame graph has built the task at least once. Its identity changes when the task rebuilds\n * (e.g. on resize), so consumers that bind it to a custom material should re-bind when it\n * changes. */\n readonly texture: Texture2D | null;\n /** The live opaque-scene DEPTH grab (`grabDepth: true`): the task's depth attachment as of the moment\n * the first transmissive surface draws, resolved to a single-sample `r32float` (raw NDC depth as\n * stored; a cleared texel means no geometry). Null before the target builds or when `grabDepth` is\n * off. Identity changes when the task rebuilds (e.g. on resize) — re-bind on change. */\n readonly depthTexture: Texture2D | null;\n}\n\n/** Enable mid-pass scene-color grabs for a single render task and return the live texture handle. The task is wrapped so transmissive draw calls can sample the opaque color rendered earlier in the same pass. */\nexport function enableRenderTaskTransmission(task: RenderTask, engine: EngineContext, options?: TransmissionOptions): SceneColorGrab {\n const linear = options?.linear !== false;\n applyTransmissionOptions(task, options);\n // grabDepth is opt-in: only when set do we dynamic-import the depth-grab shaders/pipelines (installed via the\n // module side-effect). `_preload` is awaited before the frame graph builds, so `_createDepthGrab` is ready by\n // the time `configureTransmissionSource` runs in record(). Transmission scenes without grabDepth never fetch it.\n if (task._config.transmission?.grabDepth) {\n const priorPreload = task._preload?.bind(task);\n task._preload = async (): Promise<void> => {\n if (priorPreload) {\n await priorPreload();\n }\n await import(\"./transmission-depth-grab.js\");\n };\n }\n const grab: SceneColorGrab = {\n get texture(): Texture2D | null {\n return (task._targetSignature as { _transmissionTexture?: Texture2D })._transmissionTexture ?? null;\n },\n get depthTexture(): Texture2D | null {\n return (task._targetSignature as { _transmissionDepthTexture?: Texture2D | null })._transmissionDepthTexture ?? null;\n },\n };\n if (task._executeWithTransmission) {\n return grab;\n }\n if (linear) {\n retargetRenderTaskToLinearOffscreen(task);\n }\n let state: RenderTaskTransmissionState | null = null;\n const record = task.record.bind(task);\n const execute = task.execute?.bind(task);\n const dispose = task.dispose?.bind(task);\n task.record = () => {\n disposeRenderTaskTransmission(state);\n state = createRenderTaskTransmission(task, engine);\n (task._targetSignature as { _transmissionTexture?: Texture2D })._transmissionTexture = state.texture;\n record();\n configureTransmissionSource(state, task, engine);\n };\n if (linear && execute) {\n task.execute = () => executeRenderTaskLinear(task.scene, execute);\n }\n task.dispose = () => {\n disposeRenderTaskTransmission(state);\n state = null;\n dispose?.();\n };\n task._executeWithTransmission = (sampleCount) => executePassWithTransmission(task, engine, state!, sampleCount);\n return grab;\n}\n\nfunction retargetRenderTaskToLinearOffscreen(task: RenderTask): void {\n const cfg = task._config;\n const oldDesc = cfg.rt._descriptor;\n const surface = task.scene.surface;\n const sampleCount = surface.msaaSamples;\n // The scene render task may target the shared engine scRT (single-sample,\n // colour-only — single-sample default path) or an MSAA colour RT that resolves into it\n // via `rst` (MSAA default path). Never mutate the shared scRT descriptor —\n // instead point the task at a fresh offscreen HDR target and stop resolving to swap.\n // Transmission samples this linear HDR result in its own final image-processing pass\n // that writes the tonemapped result to the swapchain.\n //\n // Depth ownership: when the task already carries an external depth (`cfg.depth`, the\n // single-sample default path), keep it; otherwise the new target owns depth (matching\n // the MSAA colour RT it replaces).\n const ownsDepth = !cfg.depth;\n const newRt = createRenderTarget({\n lbl: \"transmission-linear\",\n format: \"rgba16float\",\n dFormat: ownsDepth ? (oldDesc.dFormat ?? \"depth24plus-stencil8\") : undefined,\n _depthClearValue: oldDesc._depthClearValue,\n _depthCompare: oldDesc._depthCompare,\n samples: sampleCount,\n size: surface,\n });\n cfg.rt = newRt;\n cfg.rst = undefined;\n const sig = task._targetSignature as {\n _colorFormat?: GPUTextureFormat;\n _depthStencilFormat?: GPUTextureFormat;\n _depthCompare?: GPUCompareFunction;\n _sampleCount: number;\n };\n sig._colorFormat = \"rgba16float\";\n sig._depthStencilFormat = cfg.depth?._descriptor.dFormat ?? newRt._descriptor.dFormat;\n sig._depthCompare = newRt._descriptor._depthCompare;\n sig._sampleCount = sampleCount;\n task._opaqueBundles.length = 0;\n task._lastVersion = -1;\n}\n\nfunction executeRenderTaskLinear(scene: SceneContext, execute: () => number): number {\n const imageProcessing = scene.imageProcessing as { exposure: number; contrast: number; toneMappingEnabled: boolean | number };\n const toneMappingEnabled = imageProcessing.toneMappingEnabled;\n const clearColor = scene.clearColor;\n const linearClearColor = inverseImageProcessedColor(clearColor, imageProcessing.exposure, imageProcessing.contrast, toneMappingEnabled === true);\n imageProcessing.toneMappingEnabled = -1;\n scene.clearColor = linearClearColor;\n try {\n return execute();\n } finally {\n scene.clearColor = clearColor;\n imageProcessing.toneMappingEnabled = toneMappingEnabled;\n }\n}\n\nfunction inverseImageProcessedColor(color: GPUColorDict, exposure: number, contrast: number, toneMapping: boolean): GPUColorDict {\n return {\n r: inverseImageProcessedChannel(color.r, exposure, contrast, toneMapping),\n g: inverseImageProcessedChannel(color.g, exposure, contrast, toneMapping),\n b: inverseImageProcessedChannel(color.b, exposure, contrast, toneMapping),\n a: color.a,\n };\n}\n\nfunction inverseImageProcessedChannel(value: number, exposure: number, contrast: number, toneMapping: boolean): number {\n let c = clamp01(value);\n if (contrast < 1) {\n c = contrast > 0 ? clamp01((c - 0.5 * (1 - contrast)) / contrast) : 0.5;\n } else if (contrast > 1) {\n const mixAmount = contrast - 1;\n let lo = 0;\n let hi = 1;\n for (let i = 0; i < 16; i++) {\n const mid = (lo + hi) * 0.5;\n const high = mid * mid * (3 - 2 * mid);\n const out = mid + (high - mid) * mixAmount;\n if (out < c) {\n lo = mid;\n } else {\n hi = mid;\n }\n }\n c = (lo + hi) * 0.5;\n }\n c = c ** 2.2;\n if (toneMapping) {\n c = -Math.log2(Math.max(1 - c, 1e-6)) / 1.5905790328979492;\n }\n return exposure > 0 ? c / exposure : c;\n}\n\nfunction clamp01(v: number): number {\n return Math.min(Math.max(v, 0), 1);\n}\n\nfunction markPbrMaterialsLinear(scene: SceneContext): void {\n for (const mesh of scene.meshes) {\n const mat = mesh.material as { _linearImageProcessing?: boolean; _renderFeatures?: unknown } | undefined;\n if (mat) {\n mat._linearImageProcessing = true;\n mat._renderFeatures = undefined;\n }\n }\n}\n\nfunction createRenderTaskTransmission(task: RenderTask, engine: EngineContext): RenderTaskTransmissionState {\n const rt = task._config.rt;\n const width = 1024;\n const height = 1024;\n const format: GPUTextureFormat = \"rgba16float\";\n const mipLevelCount = transmissionMipLevelCount(task._config.transmission, width, height);\n const generateMipmaps = mipLevelCount > 1;\n const texture = engine._device.createTexture({\n label: task.name,\n size: { width, height },\n format,\n mipLevelCount,\n usage: TU.RENDER_ATTACHMENT | TU.TEXTURE_BINDING | TU.COPY_DST,\n });\n const tex: Texture2D = {\n texture,\n view: texture.createView(),\n sampler: getTrilinearAnisotropicSampler(engine),\n width,\n height,\n invertY: false,\n };\n return {\n texture: tex,\n _baseView: texture.createView({ baseMipLevel: 0, mipLevelCount: 1 }),\n _sourceWidth: rt._width,\n _sourceHeight: rt._height,\n _sourceTexture: null,\n _blit: null,\n _depth: null,\n _copyCount: normalizeCopyCount(task._config.transmission),\n _generateMipmaps: generateMipmaps,\n _copies: 0,\n };\n}\n\nfunction configureTransmissionSource(state: RenderTaskTransmissionState, task: RenderTask, engine: EngineContext): void {\n const rt = task._config.rt;\n state._sourceWidth = rt._width;\n state._sourceHeight = rt._height;\n state._sourceTexture = rt._colorTexture;\n const sampleCount = task._targetSignature._sampleCount;\n // Depth grab (grabDepth): (re)build the r32float snapshot + its resolve blit against the task's CURRENT\n // depth attachment, and publish it on the target signature so `SceneColorGrab.depthTexture` stays live.\n const sig = task._targetSignature as { _transmissionDepthTexture?: Texture2D | null };\n sig._transmissionDepthTexture = null;\n const depthSource = rt._depthTexture;\n if (task._config.transmission?.grabDepth && _depthGrab && depthSource && rt._width > 0 && rt._height > 0) {\n state._depth = _depthGrab.create(engine, depthSource, rt._width, rt._height, sampleCount > 1);\n sig._transmissionDepthTexture = state._depth.texture;\n }\n if (!state._sourceTexture) {\n return;\n }\n state._blit = shouldBlitTransmission(state, sampleCount) ? createTransmissionBlit(state, engine, state._sourceTexture, sampleCount > 1) : null;\n}\n\nfunction disposeRenderTaskTransmission(state: RenderTaskTransmissionState | null | undefined): void {\n state?.texture.texture.destroy();\n state?._depth?.texture.texture.destroy();\n}\n\nexport function executePassWithTransmission(task: RenderTask, engine: EngineContext, state: RenderTaskTransmissionState, sampleCount: number): number {\n state._copies = 0;\n const transparent = task._transparentBindings;\n // MSAA: resolve the FINAL scene colour into the task's single-sample resolve target (`rst`) so downstream\n // passes that SAMPLE the scene RTT (e.g. a custom DoF/present stack) get a resolved image. The multisampled\n // colour is preserved across the split segments (store/load), so resolving on every segment leaves the LAST\n // (complete) resolve in `rst`. No-op when single-sample (resolveView stays null) — existing scenes unchanged.\n const resolveView = sampleCount > 1 ? (task._config.rst?._colorView ?? null) : null;\n let pass = beginTaskPass(task, resolveView, sampleCount, false);\n let draws = drawBaseTask(task, pass);\n let lastPipeline: GPURenderPipeline | null = null;\n let overlay: DrawBinding[] | null = null;\n for (let i = 0; i < transparent.length; i++) {\n const binding = transparent[i]!;\n // `Mesh.renderOnTop` surfaces draw last — after the scene-colour grab — so they sit on top of the\n // transmissive surface and are excluded from what it refracts (e.g. lily pads on water).\n if (binding.renderable.mesh?.renderOnTop === true) {\n (overlay ??= []).push(binding);\n continue;\n }\n const transmissive = binding.renderable._transmissive === true;\n if (transmissive && canUpdateTransmission(state)) {\n pass.end();\n updateTransmissionTexture(state, engine);\n pass = beginTaskPass(task, resolveView, sampleCount, true);\n setPassState(task, pass);\n lastPipeline = null;\n }\n const mesh = binding.renderable.mesh;\n if (mesh && mesh.visible === false) {\n continue;\n }\n if (binding.pipeline !== lastPipeline) {\n pass.setPipeline(binding.pipeline);\n lastPipeline = binding.pipeline;\n }\n draws += binding.draw(pass, engine);\n }\n if (overlay) {\n draws += drawList(pass, overlay, engine);\n }\n pass.end();\n return draws;\n}\n\nfunction updateTransmissionTexture(state: RenderTaskTransmissionState, engine: EngineContext): void {\n if (!state._sourceTexture) {\n throw new Error(\"No transmission source\");\n }\n if (state._blit) {\n blitToTransmission(state, engine);\n } else {\n engine._currentEncoder.copyTextureToTexture(\n { texture: state._sourceTexture },\n { texture: state.texture.texture },\n { width: state.texture.width, height: state.texture.height }\n );\n }\n if (state._generateMipmaps) {\n recordMipmaps(engine, state.texture.texture, engine._currentEncoder);\n }\n // Depth grab rides the same mid-pass break: the depth attachment is unbound here (the pass just ended),\n // so it is legal to sample; the resumed segment re-attaches it with loadOp \"load\". The record body lives in\n // the lazy depth-grab module (installed only when grabDepth is enabled), so it costs zero bytes otherwise.\n if (state._depth) {\n _depthGrab?.record(engine, state._depth);\n }\n state._copies++;\n}\n\nfunction getBlitPipeline(engine: EngineContext, format: GPUTextureFormat, multisampled: boolean): GPURenderPipeline {\n const device = engine._device;\n if (device !== blitDevice) {\n blitPipelines?.clear();\n blitPipelines = null;\n blitShader = null;\n blitMsaaShader = null;\n blitBgl = null;\n blitMsaaBgl = null;\n blitDevice = device;\n }\n if (multisampled) {\n blitMsaaShader ??= device.createShaderModule({ code: BLIT_MSAA_SHADER });\n blitMsaaBgl ??= device.createBindGroupLayout({\n entries: [{ binding: 0, visibility: SS.FRAGMENT, texture: { sampleType: \"unfilterable-float\", multisampled: true } }],\n });\n } else {\n blitShader ??= device.createShaderModule({ code: BLIT_SHADER });\n blitBgl ??= device.createBindGroupLayout({\n entries: [\n { binding: 0, visibility: SS.FRAGMENT, texture: { sampleType: \"float\" } },\n { binding: 1, visibility: SS.FRAGMENT, sampler: {} },\n ],\n });\n }\n blitPipelines ??= new Map();\n const key = `${format}:${multisampled ? \"msaa\" : \"\"}`;\n let pipeline = blitPipelines.get(key);\n if (!pipeline) {\n const bgl = multisampled ? blitMsaaBgl! : blitBgl!;\n pipeline = device.createRenderPipeline({\n label: \"transmission-copy\",\n layout: device.createPipelineLayout({ bindGroupLayouts: [bgl] }),\n vertex: { module: multisampled ? blitMsaaShader! : blitShader!, entryPoint: \"vs\" },\n fragment: { module: multisampled ? blitMsaaShader! : blitShader!, entryPoint: \"fs\", targets: [{ format }] },\n primitive: { topology: \"triangle-list\" },\n });\n blitPipelines.set(key, pipeline);\n }\n return pipeline;\n}\n\nfunction shouldBlitTransmission(state: RenderTaskTransmissionState, sampleCount: number): boolean {\n return sampleCount > 1 || state._sourceWidth !== state.texture.width || state._sourceHeight !== state.texture.height;\n}\n\nfunction createTransmissionBlit(state: RenderTaskTransmissionState, engine: EngineContext, source: GPUTexture, multisampled: boolean): TransmissionBlitState {\n const device = engine._device;\n const pipeline = getBlitPipeline(engine, state.texture.texture.format, multisampled);\n const bindGroup = device.createBindGroup({\n layout: multisampled ? blitMsaaBgl! : blitBgl!,\n entries: multisampled\n ? [{ binding: 0, resource: source.createView() }]\n : [\n { binding: 0, resource: source.createView() },\n { binding: 1, resource: getBilinearSampler(engine) },\n ],\n });\n return { _pipeline: pipeline, _bindGroup: bindGroup };\n}\n\nfunction blitToTransmission(state: RenderTaskTransmissionState, engine: EngineContext): void {\n const blit = state._blit!;\n const pass = engine._currentEncoder.beginRenderPass({\n colorAttachments: [{ view: state._baseView, loadOp: \"clear\", storeOp: \"store\", clearValue: { r: 0, g: 0, b: 0, a: 0 } }],\n });\n pass.setPipeline(blit._pipeline);\n pass.setBindGroup(0, blit._bindGroup);\n pass.draw(3);\n pass.end();\n}\n\nfunction canUpdateTransmission(state: RenderTaskTransmissionState): boolean {\n return state._copyCount === 0 || state._copies < state._copyCount;\n}\n\nfunction beginTaskPass(task: RenderTask, resolveTarget: GPUTextureView | null, sampleCount: number, load: boolean): GPURenderPassEncoder {\n const att = task._colorAttachment;\n const depthLoadOp = load || !task._config.clr ? \"load\" : \"clear\";\n if (load) {\n att.loadOp = \"load\";\n }\n const depthAttachment = task._renderPassDescriptor.depthStencilAttachment;\n if (depthAttachment) {\n depthAttachment.depthLoadOp = depthLoadOp;\n if (depthAttachment.stencilLoadOp) {\n depthAttachment.stencilLoadOp = depthLoadOp;\n }\n }\n if (sampleCount > 1) {\n att.resolveTarget = resolveTarget ?? undefined;\n } else {\n att.resolveTarget = undefined;\n }\n return task.engine._currentEncoder.beginRenderPass(task._renderPassDescriptor);\n}\n\nfunction setPassState(task: RenderTask, pass: GPURenderPassEncoder): void {\n const cfg = task._config;\n const rt = cfg.rt;\n const scene = task.scene;\n const camera = cfg.cam ?? scene.camera;\n const v = camera?.viewport;\n if (v) {\n const rw = rt._width;\n const rh = rt._height;\n const x = Math.floor(v.x * rw);\n const y = Math.floor((1 - v.y - v.height) * rh);\n const w = Math.ceil((v.x + v.width) * rw) - x;\n const h = Math.ceil((1 - v.y) * rh) - y;\n pass.setViewport(x, y, w, h, 0, 1);\n pass.setScissorRect(x, y, w, h);\n }\n pass.setBindGroup(0, task._sceneBG);\n}\n\nfunction drawBaseTask(task: RenderTask, pass: GPURenderPassEncoder): number {\n const eng = task.engine;\n const rt = task._config.rt;\n const scene = task.scene;\n const opaqueBindings = task._opaqueBindings;\n const opaqueBundles = task._opaqueBundles;\n\n setPassState(task, pass);\n\n if (task._lastVersion !== scene._renderableVersion || task._lastVis !== _vis || opaqueBundles.length === 0) {\n const desc = rt._descriptor;\n const be = eng._device.createRenderBundleEncoder({\n colorFormats: desc.format ? [desc.format] : [],\n depthStencilFormat: desc.dFormat,\n sampleCount: desc.samples ?? 1,\n });\n be.setBindGroup(0, task._sceneBG);\n drawList(be, opaqueBindings, eng);\n opaqueBundles[0] = be.finish();\n task._lastVersion = scene._renderableVersion;\n task._lastVis = _vis;\n }\n let draws = opaqueBindings.length;\n pass.executeBundles(opaqueBundles);\n pass.setBindGroup(0, task._sceneBG);\n draws += drawList(pass, task._directBindings, eng);\n return draws;\n}\n\nfunction normalizeCopyCount(cfg: RenderTask[\"_config\"][\"transmission\"]): number {\n const count = cfg?.copyCount ?? 1;\n return count === Infinity ? 0 : Math.max(0, count | 0);\n}\n\nfunction applyTransmissionOptions(task: RenderTask, options: TransmissionOptions | undefined): void {\n if (!options) {\n return;\n }\n let next = task._config.transmission;\n let changed = false;\n const set = <K extends keyof NonNullable<RenderTask[\"_config\"][\"transmission\"]>>(key: K, value: NonNullable<RenderTask[\"_config\"][\"transmission\"]>[K] | undefined): void => {\n if (value === undefined) {\n return;\n }\n next = { ...next, [key]: value };\n changed = true;\n };\n set(\"copyCount\", options.copyCount);\n set(\"generateMipmaps\", options.generateMipmaps);\n set(\"mipLevelCount\", options.mipLevelCount);\n set(\"grabDepth\", options.grabDepth);\n if (changed) {\n task._config.transmission = next;\n }\n}\n\nfunction transmissionMipLevelCount(cfg: RenderTask[\"_config\"][\"transmission\"], width: number, height: number): number {\n if (cfg?.generateMipmaps === false) {\n return 1;\n }\n const full = Math.floor(Math.log2(Math.max(width, height))) + 1;\n const defaultCount = biasedMipLevelCount(width, height, REFRACTION_LOD_BIAS);\n const requested = cfg?.mipLevelCount;\n if (requested === undefined) {\n return Math.min(full, defaultCount);\n }\n return Math.min(full, Math.max(1, requested | 0));\n}\n"],"names":[],"mappings":";;;;;;;;;;AAgEA,IAAI,UAAA,GAAmC,IAAA;AAKhC,SAAS,kBAAkB,IAAA,EAA2B;AACzD,EAAA,UAAA,GAAa,IAAA;AACjB;AAEA,MAAM,WAA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AClH,EAAA,IAAI,GAAA,EAAK,oBAAoB,KAAA,EAAO;AAChC,IAAA,OAAO,CAAA;AAAA,EACX;AACA,EAAA,MAAM,IAAA,GAAO,IAAA,CAAK,KAAA,CAAM,IAAA,CAAK,IAAA,CAAK,IAAA,CAAK,GAAA,CAAI,KAAA,EAAO,MAAM,CAAC,CAAC,CAAA,GAAI,CAAA;AAC9D,EAAA,MAAM,YAAA,GAAe,mBAAA,CAAoB,KAAA,EAAO,MAAA,EAAQ,mBAAmB,CAAA;AAC3E,EAAA,MAAM,YAAY,GAAA,EAAK,aAAA;AACvB,EAAA,IAAI,cAAc,MAAA,EAAW;AACzB,IAAA,OAAO,IAAA,CAAK,GAAA,CAAI,IAAA,EAAM,YAAY,CAAA;AAAA,EACtC;AACA,EAAA,OAAO,IAAA,CAAK,IAAI,IAAA,EAAM,IAAA,CAAK,IAAI,CAAA,EAAG,SAAA,GAAY,CAAC,CAAC,CAAA;AACpD;;;;"}
package/lib/index.js CHANGED
@@ -51,6 +51,7 @@ export { createSpotLight } from './light/spot-light.js';
51
51
  export { addClusteredLightContainer, createClusteredLightContainer, createClusteredPointLight, markClusteredLightContainerDirty } from './light/clustered.js';
52
52
  export { MAX_LIGHTS, setMaxLights } from './light/types.js';
53
53
  export { createBox, createCapsule, createCylinder, createDisc, createExtrudeShape, createGround, createGroundFromHeightMap, createMeshFromData, createPlane, createPolyhedron, createRibbon, createSphere, createTorus, createTorusKnot, createTube, invalidateRenderBundles, resizeMeshGeometry, updateMeshColors, updateMeshGeometry, updateMeshGeometryCapacity, updateMeshNormals, updateMeshPositions, updateMeshTangents, updateMeshUv2, updateMeshUvs } from './mesh/mesh-factories.js';
54
+ export { getMeshGeometry } from './mesh/get-mesh-geometry.js';
54
55
  export { createBoxData } from './mesh/create-box.js';
55
56
  export { createSphereData } from './mesh/create-sphere.js';
56
57
  export { createCylinderData } from './mesh/create-cylinder.js';
@@ -61,6 +62,7 @@ export { createCsg2FromMesh, createMeshFromCsg2, createMeshesFromCsg2, csg2Add,
61
62
  export { createStorageBuffer, disposeStorageBuffer, updateStorageBuffer } from './resource/storage-buffer.js';
62
63
  export { createSolidTexture2D } from './texture/solid-texture.js';
63
64
  export { createRenderTexture2D, createTexture2DFromPixels, createTexture3DFromPixels, updateTexture2DFromPixels } from './texture/pixels-texture.js';
65
+ export { createTexture2DArray, createTexture2DArrayFromUrls, loadImageToArrayLayer, uploadImageToArrayLayer } from './texture/texture-array.js';
64
66
  export { loadKtxTexture2D } from './texture/ktx-loader.js';
65
67
  export { loadBasisTexture2D } from './texture/basis-loader.js';
66
68
  export { loadKtx2Texture2D, setKtx2DecoderUrl } from './texture/ktx2-loader.js';
@@ -113,8 +115,8 @@ export { createLinearDepthMaterial } from './render/linear-depth-material.js';
113
115
  export { createEsmDirectionalShadowGenerator } from './shadow/esm-directional-shadow-generator.js';
114
116
  export { createPcfSpotlightShadowGenerator } from './shadow/pcf-spotlight-shadow-generator.js';
115
117
  export { createPcfDirectionalShadowGenerator } from './shadow/pcf-directional-shadow-generator.js';
116
- export { createCsmDirectionalShadowGenerator, onCsmReceiverUpdate } from './shadow/csm-directional-shadow-generator.js';
117
- export { setShadowTaskCasterMeshes } from './frame-graph/shadow-inputs.js';
118
+ export { createCsmDirectionalShadowGenerator, getCsmReceiverTexture, onCsmReceiverUpdate } from './shadow/csm-directional-shadow-generator.js';
119
+ export { setShadowCasterMaxCascade, setShadowTaskCasterMeshes } from './frame-graph/shadow-inputs.js';
118
120
  export { createAnimationController } from './skeleton/skeleton-updater.js';
119
121
  export { clearBoneOverride, enableBoneControl, getBoneByName, setBonePosition, setBoneRotationQuaternion, setBoneScaling, setBoneVisible } from './skeleton/bone-control.js';
120
122
  export { createAnimationGroups, goToFrame, pauseAnimation, playAnimation, stopAnimation } from './animation/animation-group.js';
@@ -158,7 +160,7 @@ export { quatFromLookDirectionRH } from './math/quat-from-look-direction-rh.js';
158
160
  export { mat4Decompose } from './math/mat4-decompose.js';
159
161
  export { computeAabb } from './math/compute-aabb.js';
160
162
  export { linearToSrgbByte, packedSrgbToLinearRgba, srgbByteToLinear } from './math/color.js';
161
- export { addThinInstance, enableThinInstanceDynamicDrawCount, enableThinInstanceGpuCulling, flushThinInstances, removeThinInstance, setThinInstanceColor, setThinInstanceColors, setThinInstanceCount, setThinInstanceCullBoundsPad, setThinInstanceDrawCount, setThinInstanceMatrix, setThinInstances } from './mesh/thin-instance.js';
163
+ export { addThinInstance, clearThinInstanceLodPartner, enableThinInstanceDynamicDrawCount, enableThinInstanceGpuCulling, flushThinInstances, removeThinInstance, setThinInstanceColor, setThinInstanceColors, setThinInstanceCount, setThinInstanceCullBoundsPad, setThinInstanceDrawCount, setThinInstanceLodPartner, setThinInstanceMatrix, setThinInstances } from './mesh/thin-instance.js';
162
164
  export { addHierarchyInstance, createHierarchyInstancePool, removeHierarchyInstance, setHierarchyInstanceCount, setHierarchyInstanceMatrix } from './mesh/hierarchy-instance-pool.js';
163
165
  export { getCameraPosition, getEffectiveAspectRatio, getProjectionMatrix, getViewMatrix, getViewProjectionMatrix } from './camera/camera.js';
164
166
  export { resolveCameraViewport } from './camera/viewport.js';
@@ -224,6 +226,7 @@ export { createPhysicsViewer, disposePhysicsViewer, hidePhysicsBody, showPhysics
224
226
  export { CharacterCollisionObservable, CharacterSupportedState, PhysicsCharacterController, createPhysicsCharacterController } from './physics/character-controller.js';
225
227
  export { addAgent, addBoxObstacle, addCylinderObstacle, agentGoto, computePath, createDebugNavMeshGeometry, createNavCrowd, createNavMesh, createNavMeshFromSources, createNavigationPluginAsync, disposeNavigationPlugin, findClosestPointWithin, findRandomPoint, findRandomPointAroundCircle, getAgentPosition, getAgentVelocity, getClosestPoint, getNavigationRandomSeed, raycast, removeObstacle, setNavigationRandomSeed, updateNavCrowd, updateNavMeshObstacles } from './navigation/navigation.js';
226
228
  export { createAudioEngineAsync, disposeAudioEngine, getMasterVolume, setMasterVolume, unlockAudioEngineAsync } from './audio/audio-engine.js';
229
+ export { createAudioEngineMediaStream, disposeAudioEngineMediaStream } from './audio/media-stream-output.js';
227
230
  export { SoundState, createSoundAsync, disposeSound, pauseSound, playSound, resumeSound, setSoundVolume, stopSound } from './audio/static-sound.js';
228
231
  export { createStreamingSoundAsync, disposeStreamingSound, pauseStreamingSound, playStreamingSound, preloadStreamingInstanceAsync, preloadStreamingInstancesAsync, resumeStreamingSound, setStreamingSoundVolume, stopStreamingSound } from './audio/streaming-sound.js';
229
232
  export { createAudioBusAsync, disposeAudioBus, setBusVolume } from './audio/audio-bus.js';
package/lib/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
@@ -30,5 +30,5 @@ function resolveBufferUri(uri, baseUrl) {
30
30
  }
31
31
  }
32
32
 
33
- export { parseGltfJsonAsset, resolveExternalImage };
33
+ export { parseGltfJsonAsset, resolveBufferUri, resolveExternalImage };
34
34
  //# sourceMappingURL=gltf-json-asset.js.map