@babylonjs/lite 1.11.0 → 1.12.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +22 -0
- package/dist/index.js +444 -368
- package/dist/index.js.map +1 -1
- package/index.d.ts +191 -4
- package/lib/audio/index.js +1 -0
- package/lib/audio/index.js.map +1 -1
- package/lib/audio/media-stream-output.js +44 -0
- package/lib/audio/media-stream-output.js.map +1 -0
- package/lib/engine/engine.js +1 -1
- package/lib/frame-graph/render-task.js +1 -1
- package/lib/frame-graph/render-task.js.map +1 -1
- package/lib/frame-graph/shadow-inputs.js +10 -1
- package/lib/frame-graph/shadow-inputs.js.map +1 -1
- package/lib/frame-graph/transmission.js +1 -16
- package/lib/frame-graph/transmission.js.map +1 -1
- package/lib/index.js +5 -3
- package/lib/index.js.map +1 -1
- package/lib/loader-gltf/gltf-json-asset.js +1 -1
- package/lib/loader-gltf/gltf-json-asset.js.map +1 -1
- package/lib/loader-gltf/gltf-multi-buffer.js +2 -10
- package/lib/loader-gltf/gltf-multi-buffer.js.map +1 -1
- package/lib/loader-gltf/gltf-pbr-builder-ext.js +4 -18
- package/lib/loader-gltf/gltf-pbr-builder-ext.js.map +1 -1
- package/lib/loader-gltf/gltf-pbr-builder.js +17 -14
- package/lib/loader-gltf/gltf-pbr-builder.js.map +1 -1
- package/lib/loader-gltf/gltf-sampler-desc.js +3 -16
- package/lib/loader-gltf/gltf-sampler-desc.js.map +1 -1
- package/lib/material/node/blocks/ambient-occlusion-block.js +1 -4
- package/lib/material/node/blocks/ambient-occlusion-block.js.map +1 -1
- package/lib/material/node/blocks/biplanar-block.js +3 -6
- package/lib/material/node/blocks/biplanar-block.js.map +1 -1
- package/lib/material/node/blocks/image-source.js +2 -5
- package/lib/material/node/blocks/image-source.js.map +1 -1
- package/lib/material/node/blocks/input-block.js +5 -26
- package/lib/material/node/blocks/input-block.js.map +1 -1
- package/lib/material/node/blocks/pbr-mr-helper-full.js +5 -8
- package/lib/material/node/blocks/pbr-mr-helper-full.js.map +1 -1
- package/lib/material/node/blocks/reflection-texture-block.js +1 -4
- package/lib/material/node/blocks/reflection-texture-block.js.map +1 -1
- package/lib/material/node/blocks/texture-block.js +2 -5
- package/lib/material/node/blocks/texture-block.js.map +1 -1
- package/lib/material/node/blocks/triplanar-block.js +3 -6
- package/lib/material/node/blocks/triplanar-block.js.map +1 -1
- package/lib/material/node/node-emitter.js +24 -1
- package/lib/material/node/node-emitter.js.map +1 -1
- package/lib/material/node/node-geometry-renderable.js +2 -2
- package/lib/material/node/node-material.js +1 -22
- package/lib/material/node/node-material.js.map +1 -1
- package/lib/material/node/node-types.js.map +1 -1
- package/lib/material/pbr/fragments/shadow-only-fragment.js +68 -0
- package/lib/material/pbr/fragments/shadow-only-fragment.js.map +1 -0
- package/lib/material/pbr/pbr-flag-bits.js.map +1 -1
- package/lib/material/pbr/pbr-material.js.map +1 -1
- package/lib/material/pbr/pbr-renderable.js +3 -0
- package/lib/material/pbr/pbr-renderable.js.map +1 -1
- package/lib/material/pbr/pbr-template.js +1 -0
- package/lib/material/pbr/pbr-template.js.map +1 -1
- package/lib/mesh/GaussianSplatting/gaussian-splatting-mesh.js +2 -8
- package/lib/mesh/GaussianSplatting/gaussian-splatting-mesh.js.map +1 -1
- package/lib/mesh/mesh-dispose.js +2 -0
- package/lib/mesh/mesh-dispose.js.map +1 -1
- package/lib/mesh/mesh.js +2 -8
- package/lib/mesh/mesh.js.map +1 -1
- package/lib/mesh/thin-instance-cull-binding.js +54 -3
- package/lib/mesh/thin-instance-cull-binding.js.map +1 -1
- package/lib/mesh/thin-instance-gpu-culling.js +241 -24
- package/lib/mesh/thin-instance-gpu-culling.js.map +1 -1
- package/lib/mesh/thin-instance.js +112 -1
- package/lib/mesh/thin-instance.js.map +1 -1
- package/lib/picking/gpu-picker.js +4 -2
- package/lib/picking/gpu-picker.js.map +1 -1
- package/lib/picking/picking-pipeline.js +1 -1
- package/lib/picking/picking-pipeline.js.map +1 -1
- package/lib/picking/picking-shader.js +38 -16
- package/lib/picking/picking-shader.js.map +1 -1
- package/lib/scene/scene-core.js +3 -0
- package/lib/scene/scene-core.js.map +1 -1
- package/lib/scene/scene-node.js +2 -6
- package/lib/scene/scene-node.js.map +1 -1
- package/lib/scene/transform-node.js +3 -0
- package/lib/scene/transform-node.js.map +1 -1
- package/lib/scene/world-matrix-state.js +7 -1
- package/lib/scene/world-matrix-state.js.map +1 -1
- package/lib/shadow/csm-directional-shadow-generator.js +22 -1
- package/lib/shadow/csm-directional-shadow-generator.js.map +1 -1
- package/lib/shadow/csm-shadow-task-hooks.js +19 -11
- package/lib/shadow/csm-shadow-task-hooks.js.map +1 -1
- package/lib/shadow/esm-directional-shadow-generator.js +2 -51
- package/lib/shadow/esm-directional-shadow-generator.js.map +1 -1
- package/lib/shadow/pcf-directional-shadow-generator.js +2 -48
- package/lib/shadow/pcf-directional-shadow-generator.js.map +1 -1
- package/lib/shadow/shadow-base.js +48 -1
- package/lib/shadow/shadow-base.js.map +1 -1
- package/lib/text/text-renderable.js +2 -10
- package/lib/text/text-renderable.js.map +1 -1
- package/lib/texture/texture-array.js +96 -0
- package/lib/texture/texture-array.js.map +1 -0
- package/package.json +3 -3
|
@@ -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,IAAA;AACjB;AAEA,MAAM,WAAA,GAAc,CAAA,4YAAA,CAAA;AACpB,MAAM,gBAAA,GAAmB,CAAA,0sBAAA,CAAA;AACzB,MAAM,mBAAA,GAAsB,CAAA;AAC5B,IAAI,aAAA,GAAuD,IAAA;AAC3D,IAAI,UAAA,GAAqC,IAAA;AACzC,IAAI,cAAA,GAAyC,IAAA;AAC7C,IAAI,OAAA,GAAqC,IAAA;AACzC,IAAI,WAAA,GAAyC,IAAA;AAC7C,IAAI,UAAA,GAA+B,IAAA;AAG5B,SAAS,uBAAA,CAAwB,OAAqB,MAAA,EAA6B;AACtF,EAAA,sBAAA,CAAuB,KAAK,CAAA;AAC5B,EAAA,IAAI,cAAA,GAAoC,IAAA;AACxC,EAAA,KAAA,MAAW,IAAA,IAAQ,KAAA,CAAM,WAAA,CAAY,MAAA,EAAQ;AACzC,IAAA,IAAI,kBAAkB,IAAA,EAAM;AACxB,MAAA,MAAM,UAAA,GAAa,IAAA;AACnB,MAAA,4BAAA,CAA6B,YAAY,MAAM,CAAA;AAC/C,MAAA,cAAA,GAAiB,UAAA;AAAA,IACrB;AAAA,EACJ;AACA,EAAA,IAAI,cAAA,IAAkB,CAAC,KAAA,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AAK,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;;;;"}
|
|
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 { 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,WAAA,GAAc,CAAA,4YAAA,CAAA;AACpB,MAAM,gBAAA,GAAmB,CAAA,0sBAAA,CAAA;AACzB,MAAM,mBAAA,GAAsB,CAAA;AAC5B,IAAI,aAAA,GAAuD,IAAA;AAC3D,IAAI,UAAA,GAAqC,IAAA;AACzC,IAAI,cAAA,GAAyC,IAAA;AAC7C,IAAI,OAAA,GAAqC,IAAA;AACzC,IAAI,WAAA,GAAyC,IAAA;AAC7C,IAAI,UAAA,GAA+B,IAAA;AAG5B,SAAS,uBAAA,CAAwB,OAAqB,MAAA,EAA6B;AACtF,EAAA,sBAAA,CAAuB,KAAK,CAAA;AAC5B,EAAA,IAAI,cAAA,GAAoC,IAAA;AACxC,EAAA,KAAA,MAAW,IAAA,IAAQ,KAAA,CAAM,WAAA,CAAY,MAAA,EAAQ;AACzC,IAAA,IAAI,kBAAkB,IAAA,EAAM;AACxB,MAAA,MAAM,UAAA,GAAa,IAAA;AACnB,MAAA,4BAAA,CAA6B,YAAY,MAAM,CAAA;AAC/C,MAAA,cAAA,GAAiB,UAAA;AAAA,IACrB;AAAA,EACJ;AACA,EAAA,IAAI,cAAA,IAAkB,CAAC,KAAA,CAAM,WAAA,CAAY,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orageBuffer } from './resource/storage-buffer.js';
|
|
62
62
|
export { createSolidTexture2D } from './texture/solid-texture.js';
|
|
63
63
|
export { createRenderTexture2D, createTexture2DFromPixels, createTexture3DFromPixels, updateTexture2DFromPixels } from './texture/pixels-texture.js';
|
|
64
|
+
export { createTexture2DArray, createTexture2DArrayFromUrls, loadImageToArrayLayer, uploadImageToArrayLayer } from './texture/texture-array.js';
|
|
64
65
|
export { loadKtxTexture2D } from './texture/ktx-loader.js';
|
|
65
66
|
export { loadBasisTexture2D } from './texture/basis-loader.js';
|
|
66
67
|
export { loadKtx2Texture2D, setKtx2DecoderUrl } from './texture/ktx2-loader.js';
|
|
@@ -113,8 +114,8 @@ export { createLinearDepthMaterial } from './render/linear-depth-material.js';
|
|
|
113
114
|
export { createEsmDirectionalShadowGenerator } from './shadow/esm-directional-shadow-generator.js';
|
|
114
115
|
export { createPcfSpotlightShadowGenerator } from './shadow/pcf-spotlight-shadow-generator.js';
|
|
115
116
|
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';
|
|
117
|
+
export { createCsmDirectionalShadowGenerator, getCsmReceiverTexture, onCsmReceiverUpdate } from './shadow/csm-directional-shadow-generator.js';
|
|
118
|
+
export { setShadowCasterMaxCascade, setShadowTaskCasterMeshes } from './frame-graph/shadow-inputs.js';
|
|
118
119
|
export { createAnimationController } from './skeleton/skeleton-updater.js';
|
|
119
120
|
export { clearBoneOverride, enableBoneControl, getBoneByName, setBonePosition, setBoneRotationQuaternion, setBoneScaling, setBoneVisible } from './skeleton/bone-control.js';
|
|
120
121
|
export { createAnimationGroups, goToFrame, pauseAnimation, playAnimation, stopAnimation } from './animation/animation-group.js';
|
|
@@ -158,7 +159,7 @@ export { quatFromLookDirectionRH } from './math/quat-from-look-direction-rh.js';
|
|
|
158
159
|
export { mat4Decompose } from './math/mat4-decompose.js';
|
|
159
160
|
export { computeAabb } from './math/compute-aabb.js';
|
|
160
161
|
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';
|
|
162
|
+
export { addThinInstance, clearThinInstanceLodPartner, enableThinInstanceDynamicDrawCount, enableThinInstanceGpuCulling, flushThinInstances, removeThinInstance, setThinInstanceColor, setThinInstanceColors, setThinInstanceCount, setThinInstanceCullBoundsPad, setThinInstanceDrawCount, setThinInstanceLodPartner, setThinInstanceMatrix, setThinInstances } from './mesh/thin-instance.js';
|
|
162
163
|
export { addHierarchyInstance, createHierarchyInstancePool, removeHierarchyInstance, setHierarchyInstanceCount, setHierarchyInstanceMatrix } from './mesh/hierarchy-instance-pool.js';
|
|
163
164
|
export { getCameraPosition, getEffectiveAspectRatio, getProjectionMatrix, getViewMatrix, getViewProjectionMatrix } from './camera/camera.js';
|
|
164
165
|
export { resolveCameraViewport } from './camera/viewport.js';
|
|
@@ -224,6 +225,7 @@ export { createPhysicsViewer, disposePhysicsViewer, hidePhysicsBody, showPhysics
|
|
|
224
225
|
export { CharacterCollisionObservable, CharacterSupportedState, PhysicsCharacterController, createPhysicsCharacterController } from './physics/character-controller.js';
|
|
225
226
|
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
227
|
export { createAudioEngineAsync, disposeAudioEngine, getMasterVolume, setMasterVolume, unlockAudioEngineAsync } from './audio/audio-engine.js';
|
|
228
|
+
export { createAudioEngineMediaStream, disposeAudioEngineMediaStream } from './audio/media-stream-output.js';
|
|
227
229
|
export { SoundState, createSoundAsync, disposeSound, pauseSound, playSound, resumeSound, setSoundVolume, stopSound } from './audio/static-sound.js';
|
|
228
230
|
export { createStreamingSoundAsync, disposeStreamingSound, pauseStreamingSound, playStreamingSound, preloadStreamingInstanceAsync, preloadStreamingInstancesAsync, resumeStreamingSound, setStreamingSoundVolume, stopStreamingSound } from './audio/streaming-sound.js';
|
|
229
231
|
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":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"gltf-json-asset.js","sources":["../../../src/loader-gltf/gltf-json-asset.ts"],"sourcesContent":["/** Parse a JSON glTF asset and resolve its buffer data. GLB scenes never load this module. */\nexport async function parseGltfJsonAsset(buffer: ArrayBuffer, baseUrl: string): Promise<{ json: any; binChunk: DataView; baseUrl: string }> {\n const json = JSON.parse(new TextDecoder().decode(buffer));\n const buffers = json.buffers ?? [];\n let binChunk: DataView;\n if (buffers.length > 1) {\n const multiBuffer = await import(\"./gltf-multi-buffer.js\");\n binChunk = await multiBuffer.loadMultiBuffer(json, baseUrl);\n } else if (buffers[0]?.uri) {\n binChunk = new DataView(await fetch(resolveBufferUri(buffers[0].uri, baseUrl)).then((r) => r.arrayBuffer()));\n } else {\n binChunk = new DataView(new ArrayBuffer(0));\n }\n return { json, binChunk, baseUrl };\n}\n\n/** Fetch and decode an image referenced by an external glTF URI. */\nexport async function resolveExternalImage(uri: string, baseUrl: string): Promise<ImageBitmap> {\n const response = await fetch(new URL(uri, baseUrl + \"x\"));\n if (!response.ok) {\n throw new Error(`Failed to load image: ${response.status} ${response.statusText}`);\n }\n return createImageBitmap(await response.blob(), { premultiplyAlpha: \"none\", colorSpaceConversion: \"none\" });\n}\n\n/** Resolve a glTF buffer `uri` to a fetchable URL. With a base URL (the source was a URL string), relative\n * `.bin` paths resolve against it. Without one (ArrayBuffer/Blob source), only self-contained `data:`/\n * absolute URIs are resolvable — a bare relative path has no base and throws a clear error.\n * @internal */\
|
|
1
|
+
{"version":3,"file":"gltf-json-asset.js","sources":["../../../src/loader-gltf/gltf-json-asset.ts"],"sourcesContent":["/** Parse a JSON glTF asset and resolve its buffer data. GLB scenes never load this module. */\nexport async function parseGltfJsonAsset(buffer: ArrayBuffer, baseUrl: string): Promise<{ json: any; binChunk: DataView; baseUrl: string }> {\n const json = JSON.parse(new TextDecoder().decode(buffer));\n const buffers = json.buffers ?? [];\n let binChunk: DataView;\n if (buffers.length > 1) {\n const multiBuffer = await import(\"./gltf-multi-buffer.js\");\n binChunk = await multiBuffer.loadMultiBuffer(json, baseUrl);\n } else if (buffers[0]?.uri) {\n binChunk = new DataView(await fetch(resolveBufferUri(buffers[0].uri, baseUrl)).then((r) => r.arrayBuffer()));\n } else {\n binChunk = new DataView(new ArrayBuffer(0));\n }\n return { json, binChunk, baseUrl };\n}\n\n/** Fetch and decode an image referenced by an external glTF URI. */\nexport async function resolveExternalImage(uri: string, baseUrl: string): Promise<ImageBitmap> {\n const response = await fetch(new URL(uri, baseUrl + \"x\"));\n if (!response.ok) {\n throw new Error(`Failed to load image: ${response.status} ${response.statusText}`);\n }\n return createImageBitmap(await response.blob(), { premultiplyAlpha: \"none\", colorSpaceConversion: \"none\" });\n}\n\n/** Resolve a glTF buffer `uri` to a fetchable URL. With a base URL (the source was a URL string), relative\n * `.bin` paths resolve against it. Without one (ArrayBuffer/Blob source), only self-contained `data:`/\n * absolute URIs are resolvable — a bare relative path has no base and throws a clear error.\n * @internal */\nexport function resolveBufferUri(uri: string, baseUrl: string): string {\n if (baseUrl) {\n return new URL(uri, baseUrl + \"x\").href;\n }\n try {\n // No base: succeeds for data:/absolute URIs, throws for a relative path (which `new URL` rejects).\n return new URL(uri).href;\n } catch {\n throw new Error(\"loadGltf: relative buffer URI needs a base URL.\");\n }\n}\n"],"names":[],"mappings":"AACA,eAAsB,kBAAA,CAAmB,QAAqB,OAAA,EAA8E;AACxI,EAAA,MAAM,IAAA,GAAO,KAAK,KAAA,CAAM,IAAI,aAAY,CAAE,MAAA,CAAO,MAAM,CAAC,CAAA;AACxD,EAAA,MAAM,OAAA,GAAU,IAAA,CAAK,OAAA,IAAW,EAAC;AACjC,EAAA,IAAI,QAAA;AACJ,EAAA,IAAI,OAAA,CAAQ,SAAS,CAAA,EAAG;AACpB,IAAA,MAAM,WAAA,GAAc,MAAM,OAAO,wBAAwB,CAAA;AACzD,IAAA,QAAA,GAAW,MAAM,WAAA,CAAY,eAAA,CAAgB,IAAA,EAAM,OAAO,CAAA;AAAA,EAC9D,CAAA,MAAA,IAAW,OAAA,CAAQ,CAAC,CAAA,EAAG,GAAA,EAAK;AACxB,IAAA,QAAA,GAAW,IAAI,QAAA,CAAS,MAAM,MAAM,gBAAA,CAAiB,OAAA,CAAQ,CAAC,CAAA,CAAE,GAAA,EAAK,OAAO,CAAC,EAAE,IAAA,CAAK,CAAC,MAAM,CAAA,CAAE,WAAA,EAAa,CAAC,CAAA;AAAA,EAC/G,CAAA,MAAO;AACH,IAAA,QAAA,GAAW,IAAI,QAAA,CAAS,IAAI,WAAA,CAAY,CAAC,CAAC,CAAA;AAAA,EAC9C;AACA,EAAA,OAAO,EAAE,IAAA,EAAM,QAAA,EAAU,OAAA,EAAQ;AACrC;AAGA,eAAsB,oBAAA,CAAqB,KAAa,OAAA,EAAuC;AAC3F,EAAA,MAAM,QAAA,GAAW,MAAM,KAAA,CAAM,IAAI,IAAI,GAAA,EAAK,OAAA,GAAU,GAAG,CAAC,CAAA;AACxD,EAAA,IAAI,CAAC,SAAS,EAAA,EAAI;AACd,IAAA,MAAM,IAAI,MAAM,CAAA,sBAAA,EAAyB,QAAA,CAAS,MAAM,CAAA,CAAA,EAAI,QAAA,CAAS,UAAU,CAAA,CAAE,CAAA;AAAA,EACrF;AACA,EAAA,OAAO,iBAAA,CAAkB,MAAM,QAAA,CAAS,IAAA,EAAK,EAAG,EAAE,gBAAA,EAAkB,MAAA,EAAQ,oBAAA,EAAsB,MAAA,EAAQ,CAAA;AAC9G;AAMO,SAAS,gBAAA,CAAiB,KAAa,OAAA,EAAyB;AACnE,EAAA,IAAI,OAAA,EAAS;AACT,IAAA,OAAO,IAAI,GAAA,CAAI,GAAA,EAAK,OAAA,GAAU,GAAG,CAAA,CAAE,IAAA;AAAA,EACvC;AACA,EAAA,IAAI;AAEA,IAAA,OAAO,IAAI,GAAA,CAAI,GAAG,CAAA,CAAE,IAAA;AAAA,EACxB,CAAA,CAAA,MAAQ;AACJ,IAAA,MAAM,IAAI,MAAM,iDAAiD,CAAA;AAAA,EACrE;AACJ;;;;"}
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { resolveBufferUri } from './gltf-json-asset.js';
|
|
2
|
+
|
|
1
3
|
async function loadMultiBuffer(json, baseUrl) {
|
|
2
4
|
const buffers = json.buffers ?? [];
|
|
3
5
|
const arrays = await Promise.all(buffers.map((b) => b?.uri ? fetch(resolveBufferUri(b.uri, baseUrl)).then((r) => r.arrayBuffer()) : Promise.resolve(new ArrayBuffer(0))));
|
|
@@ -18,16 +20,6 @@ async function loadMultiBuffer(json, baseUrl) {
|
|
|
18
20
|
}
|
|
19
21
|
return new DataView(out.buffer);
|
|
20
22
|
}
|
|
21
|
-
function resolveBufferUri(uri, baseUrl) {
|
|
22
|
-
if (baseUrl) {
|
|
23
|
-
return new URL(uri, baseUrl + "x").href;
|
|
24
|
-
}
|
|
25
|
-
try {
|
|
26
|
-
return new URL(uri).href;
|
|
27
|
-
} catch {
|
|
28
|
-
throw new Error("loadGltf: relative buffer URI needs a base URL.");
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
23
|
|
|
32
24
|
export { loadMultiBuffer };
|
|
33
25
|
//# sourceMappingURL=gltf-multi-buffer.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"gltf-multi-buffer.js","sources":["../../../src/loader-gltf/gltf-multi-buffer.ts"],"sourcesContent":["/** Multi-buffer glTF support.\n *\n * Dynamic-imported by load-gltf.ts ONLY when an asset declares more than one\n * buffer (separate geometry / animation / skin `.bin` files — e.g. Khronos\n * AnimatedTriangle, SimpleSkin). Single-buffer glTF and GLB assets never load\n * this module, so they pay zero bytes for it.\n *\n * Lite reads every accessor through one `binChunk` DataView and ignores\n * `bufferView.buffer`. To keep that fast single-chunk reader unchanged, this\n * fetches all buffers, concatenates them (each 4-byte aligned so float\n * accessors stay aligned), and rewrites every `bufferView.byteOffset` to its\n * global position in the concatenated chunk (and resets `buffer` to 0). */\n\nexport async function loadMultiBuffer(json: any, baseUrl: string): Promise<DataView> {\n const buffers: any[] = json.buffers ?? [];\n const arrays = await Promise.all(buffers.map((b) => (b?.uri ? fetch(resolveBufferUri(b.uri, baseUrl)).then((r) => r.arrayBuffer()) : Promise.resolve(new ArrayBuffer(0)))));\n\n // Place each buffer at a 4-byte-aligned offset; record starts for the rewrite.\n const offsets: number[] = [];\n let total = 0;\n for (const a of arrays) {\n offsets.push(total);\n total += a.byteLength;\n total = (total + 3) & ~3;\n }\n\n const out = new Uint8Array(total);\n for (let i = 0; i < arrays.length; i++) {\n out.set(new Uint8Array(arrays[i]!), offsets[i]!);\n }\n\n for (const bv of json.bufferViews ?? []) {\n bv.byteOffset = (bv.byteOffset ?? 0) + offsets[bv.buffer ?? 0]!;\n bv.buffer = 0;\n }\n\n return new DataView(out.buffer);\n}\n
|
|
1
|
+
{"version":3,"file":"gltf-multi-buffer.js","sources":["../../../src/loader-gltf/gltf-multi-buffer.ts"],"sourcesContent":["/** Multi-buffer glTF support.\n *\n * Dynamic-imported by load-gltf.ts ONLY when an asset declares more than one\n * buffer (separate geometry / animation / skin `.bin` files — e.g. Khronos\n * AnimatedTriangle, SimpleSkin). Single-buffer glTF and GLB assets never load\n * this module, so they pay zero bytes for it.\n *\n * Lite reads every accessor through one `binChunk` DataView and ignores\n * `bufferView.buffer`. To keep that fast single-chunk reader unchanged, this\n * fetches all buffers, concatenates them (each 4-byte aligned so float\n * accessors stay aligned), and rewrites every `bufferView.byteOffset` to its\n * global position in the concatenated chunk (and resets `buffer` to 0). */\n\nimport { resolveBufferUri } from \"./gltf-json-asset.js\";\n\nexport async function loadMultiBuffer(json: any, baseUrl: string): Promise<DataView> {\n const buffers: any[] = json.buffers ?? [];\n const arrays = await Promise.all(buffers.map((b) => (b?.uri ? fetch(resolveBufferUri(b.uri, baseUrl)).then((r) => r.arrayBuffer()) : Promise.resolve(new ArrayBuffer(0)))));\n\n // Place each buffer at a 4-byte-aligned offset; record starts for the rewrite.\n const offsets: number[] = [];\n let total = 0;\n for (const a of arrays) {\n offsets.push(total);\n total += a.byteLength;\n total = (total + 3) & ~3;\n }\n\n const out = new Uint8Array(total);\n for (let i = 0; i < arrays.length; i++) {\n out.set(new Uint8Array(arrays[i]!), offsets[i]!);\n }\n\n for (const bv of json.bufferViews ?? []) {\n bv.byteOffset = (bv.byteOffset ?? 0) + offsets[bv.buffer ?? 0]!;\n bv.buffer = 0;\n }\n\n return new DataView(out.buffer);\n}\n"],"names":[],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AEA,EAAA,OAAO,IAAI,QAAA,CAAS,GAAA,CAAI,MAAM,CAAA;AAClC;;;;"}
|
|
@@ -1,8 +1,6 @@
|
|
|
1
|
-
import { U8 } from '../engine/typed-arrays.js';
|
|
2
1
|
import { cloneTexture2D } from '../texture/texture-2d.js';
|
|
3
2
|
import { getPbrGroupBuilder } from '../material/pbr/pbr-material.js';
|
|
4
|
-
import {
|
|
5
|
-
import { uploadTex } from './gltf-pbr-builder.js';
|
|
3
|
+
import { uploadBaseColorFactorTexture, uploadOrmFactorTexture, uploadTex } from './gltf-pbr-builder.js';
|
|
6
4
|
|
|
7
5
|
function wrapTexCoord(tex, texInfo) {
|
|
8
6
|
if (!texInfo) {
|
|
@@ -51,17 +49,7 @@ function buildDefaultPbrTexturesExt(engine, mat, sampler, generateMipmaps, getCa
|
|
|
51
49
|
};
|
|
52
50
|
const raw = mat._rawMatDef ?? {};
|
|
53
51
|
const pbr = raw.pbrMetallicRoughness ?? {};
|
|
54
|
-
const baseColorTexture = mat._baseColorImage ? wrap(pickTex(mat._baseColorImage, true, pbr.baseColorTexture), pbr.baseColorTexture) : (
|
|
55
|
-
const f = mat._baseColorFactor;
|
|
56
|
-
return uploadTex(
|
|
57
|
-
engine,
|
|
58
|
-
null,
|
|
59
|
-
true,
|
|
60
|
-
sampler,
|
|
61
|
-
generateMipmaps,
|
|
62
|
-
new U8([linearToSrgbByte(f[0]), linearToSrgbByte(f[1]), linearToSrgbByte(f[2]), Math.round(Math.max(0, Math.min(1, f[3])) * 255)])
|
|
63
|
-
);
|
|
64
|
-
})();
|
|
52
|
+
const baseColorTexture = mat._baseColorImage ? wrap(pickTex(mat._baseColorImage, true, pbr.baseColorTexture), pbr.baseColorTexture) : uploadBaseColorFactorTexture(engine, mat._baseColorFactor, sampler, generateMipmaps);
|
|
65
53
|
const normalTexture = mat._normalImage ? wrap(pickTex(mat._normalImage, false, raw.normalTexture), raw.normalTexture) : void 0;
|
|
66
54
|
const emissiveTexture = mat._emissiveImage ? wrap(pickTex(mat._emissiveImage, true, raw.emissiveTexture), raw.emissiveTexture) : void 0;
|
|
67
55
|
const occlusionOnUv2 = mat._occlusionTexCoord !== 0 && mat._occlusionImage && !mat._metallicRoughnessImage;
|
|
@@ -69,15 +57,13 @@ function buildDefaultPbrTexturesExt(engine, mat, sampler, generateMipmaps, getCa
|
|
|
69
57
|
const single = mat._metallicRoughnessImage ?? (occlusionOnUv2 ? null : mat._occlusionImage);
|
|
70
58
|
let ormTexture;
|
|
71
59
|
if (occlusionOnUv2) {
|
|
72
|
-
|
|
73
|
-
ormTexture = uploadTex(engine, null, false, sampler, generateMipmaps, new U8([255, clamp(mat._roughnessFactor), clamp(mat._metallicFactor), 255]));
|
|
60
|
+
ormTexture = uploadOrmFactorTexture(engine, mat._roughnessFactor, mat._metallicFactor, sampler, generateMipmaps);
|
|
74
61
|
occlusionTexture = wrap(pickTex(mat._occlusionImage, false, raw.occlusionTexture), raw.occlusionTexture);
|
|
75
62
|
} else if (single && (!mat._metallicRoughnessImage || !mat._occlusionImage || mat._metallicRoughnessImage === mat._occlusionImage)) {
|
|
76
63
|
const ormTi = mat._metallicRoughnessImage ? pbr.metallicRoughnessTexture : raw.occlusionTexture;
|
|
77
64
|
ormTexture = wrap(pickTex(single, false, ormTi), ormTi);
|
|
78
65
|
} else if (!single) {
|
|
79
|
-
|
|
80
|
-
ormTexture = uploadTex(engine, null, false, sampler, generateMipmaps, new U8([255, clamp(mat._roughnessFactor), clamp(mat._metallicFactor), 255]));
|
|
66
|
+
ormTexture = uploadOrmFactorTexture(engine, mat._roughnessFactor, mat._metallicFactor, sampler, generateMipmaps);
|
|
81
67
|
} else {
|
|
82
68
|
ormTexture = wrap(pickTex(mat._metallicRoughnessImage, false, pbr.metallicRoughnessTexture), pbr.metallicRoughnessTexture);
|
|
83
69
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"gltf-pbr-builder-ext.js","sources":["../../../src/loader-gltf/gltf-pbr-builder-ext.ts"],"sourcesContent":["/** Lazy-loaded slow path for PBR material assembly.\n * Only pulled into bundles whose glTF uses features that require per-texture\n * wrapping (e.g. KHR_texture_transform) or occlusion on UV2 (texCoord=1 with\n * no shared MR image). Scene1 (BoomBox) and any vanilla-PBR glTF skip this\n * module entirely. */\n\nimport { U8 } from \"../engine/typed-arrays.js\";\nimport type { EngineContext } from \"../engine/engine.js\";\nimport type { Texture2D } from \"../texture/texture-2d.js\";\nimport { cloneTexture2D } from \"../texture/texture-2d.js\";\nimport type { PbrMaterialProps } from \"../material/pbr/pbr-material.js\";\nimport { getPbrGroupBuilder } from \"../material/pbr/pbr-material.js\";\nimport type { GltfMaterialData } from \"./gltf-material.js\";\nimport { linearToSrgbByte } from \"../math/color.js\";\nimport type { TextureWrapFn, GenerateMipmapsFn } from \"./gltf-pbr-builder.js\";\nimport { uploadTex } from \"./gltf-pbr-builder.js\";\n\nexport interface PbrTexturesExt {\n baseColorTexture: Texture2D;\n ormTexture: Texture2D;\n normalTexture: Texture2D | undefined;\n emissiveTexture: Texture2D | undefined;\n occlusionTexture: Texture2D | undefined;\n}\n\n/** Stamp `_texCoord=1` on a clone when textureInfo selects UV1 and the\n * wrapTex layer didn't already set it (i.e. scene has no KHR_texture_transform). */\nfunction wrapTexCoord(tex: Texture2D, texInfo: unknown): Texture2D {\n if (!texInfo) {\n return tex;\n }\n if ((tex as { _texCoord?: 0 | 1 })._texCoord === 1) {\n return tex;\n }\n const ti = texInfo as { texCoord?: number; extensions?: { KHR_texture_transform?: { texCoord?: number } } };\n const tc = ti.extensions?.KHR_texture_transform?.texCoord ?? ti.texCoord;\n return tc === 1 ? cloneTexture2D(tex, { _texCoord: 1 }) : tex;\n}\n\n/** True when occlusion shares the ORM image with metallic-roughness but must be sampled\n * with its OWN UV transform — i.e. occlusion references a distinct glTF texture object,\n * or it carries its own KHR_texture_transform that an animation pointer can drive apart\n * from the MR transform. Drives the orm-unpack split in buildDefaultPbrTexturesExt. */\nfunction occlusionNeedsSplit(raw: {\n occlusionTexture?: { index?: number; extensions?: { KHR_texture_transform?: unknown } };\n pbrMetallicRoughness?: { metallicRoughnessTexture?: { index?: number } };\n}): boolean {\n const occ = raw.occlusionTexture;\n const mr = raw.pbrMetallicRoughness?.metallicRoughnessTexture;\n if (!occ || !mr) {\n return false;\n }\n return occ.index !== mr.index || occ.extensions?.KHR_texture_transform != null;\n}\n\n/** Build textures with wrapTex + occlusionOnUv2 support. Mirrors master's\n * default texture building but honors per-textureInfo wrapping so\n * KHR_texture_transform can attach per-texture UV state. */\nexport function buildDefaultPbrTexturesExt(\n engine: EngineContext,\n mat: GltfMaterialData,\n sampler: GPUSampler,\n generateMipmaps: GenerateMipmapsFn,\n getCachedTex: (bitmap: ImageBitmap, srgb: boolean) => Texture2D,\n wrapTex: TextureWrapFn,\n samplerFor?: (texInfo: unknown) => GPUSampler\n): PbrTexturesExt {\n const wrap: TextureWrapFn = (tex, ti) => wrapTexCoord(wrapTex(tex, ti), ti);\n // When the asset declares non-default glTF samplers, upload each texture with its own\n // sampler (wrap/filter), caching per (sampler, image, srgb) exactly like the fast-path\n // buildSampledPbrTextures. Without samplerFor (common case) reuse the shared default-\n // sampler cache. A GPUTexture is sampler-independent, so the same image with two\n // samplers yields two Texture2D wrappers, matching the fast path.\n const _localCache = samplerFor ? new Map<GPUSampler, Map<number, Texture2D>>() : null;\n const _ids = samplerFor ? new Map<ImageBitmap, number>() : null;\n let _nextId = 0;\n const pickTex = (image: ImageBitmap, srgb: boolean, texInfo: unknown): Texture2D => {\n if (!samplerFor) {\n return getCachedTex(image, srgb);\n }\n const s = samplerFor(texInfo);\n let bySampler = _localCache!.get(s);\n if (!bySampler) {\n _localCache!.set(s, (bySampler = new Map()));\n }\n let id = _ids!.get(image);\n if (id === undefined) {\n _ids!.set(image, (id = _nextId++));\n }\n const key = id * 2 + (srgb ? 1 : 0);\n let tex = bySampler.get(key);\n if (!tex) {\n tex = uploadTex(engine, image, srgb, s, generateMipmaps);\n bySampler.set(key, tex);\n }\n return tex;\n };\n const raw = mat._rawMatDef ?? {};\n const pbr = raw.pbrMetallicRoughness ?? {};\n const baseColorTexture = mat._baseColorImage\n ? wrap(pickTex(mat._baseColorImage, true, pbr.baseColorTexture), pbr.baseColorTexture)\n : (() => {\n const f = mat._baseColorFactor;\n return uploadTex(\n engine,\n null,\n true,\n sampler,\n generateMipmaps,\n new U8([linearToSrgbByte(f[0]), linearToSrgbByte(f[1]), linearToSrgbByte(f[2]), Math.round(Math.max(0, Math.min(1, f[3])) * 255)])\n );\n })();\n const normalTexture = mat._normalImage ? wrap(pickTex(mat._normalImage, false, raw.normalTexture), raw.normalTexture) : undefined;\n const emissiveTexture = mat._emissiveImage ? wrap(pickTex(mat._emissiveImage, true, raw.emissiveTexture), raw.emissiveTexture) : undefined;\n\n const occlusionOnUv2 = mat._occlusionTexCoord !== 0 && mat._occlusionImage && !mat._metallicRoughnessImage;\n let occlusionTexture: Texture2D | undefined;\n const single = mat._metallicRoughnessImage ?? (occlusionOnUv2 ? null : mat._occlusionImage);\n let ormTexture: Texture2D;\n if (occlusionOnUv2) {\n const clamp = (v: number) => Math.round(Math.max(0, Math.min(1, v)) * 255);\n ormTexture = uploadTex(engine, null, false, sampler, generateMipmaps, new U8([255, clamp(mat._roughnessFactor), clamp(mat._metallicFactor), 255]));\n occlusionTexture = wrap(pickTex(mat._occlusionImage!, false, raw.occlusionTexture), raw.occlusionTexture);\n } else if (single && (!mat._metallicRoughnessImage || !mat._occlusionImage || mat._metallicRoughnessImage === mat._occlusionImage)) {\n const ormTi = mat._metallicRoughnessImage ? pbr.metallicRoughnessTexture : raw.occlusionTexture;\n ormTexture = wrap(pickTex(single, false, ormTi), ormTi);\n } else if (!single) {\n const clamp = (v: number) => Math.round(Math.max(0, Math.min(1, v)) * 255);\n ormTexture = uploadTex(engine, null, false, sampler, generateMipmaps, new U8([255, clamp(mat._roughnessFactor), clamp(mat._metallicFactor), 255]));\n } else {\n ormTexture = wrap(pickTex(mat._metallicRoughnessImage!, false, pbr.metallicRoughnessTexture), pbr.metallicRoughnessTexture);\n }\n // Independent-occlusion UV transform (orm-unpack): occlusion and metallic-roughness\n // share the ORM texture (same image), but the glTF gives occlusion its OWN\n // KHR_texture_transform (or a distinct texture object) so the two can be animated\n // independently via KHR_animation_pointer. Sampling occlusion with MR's transform\n // (the single ormUV) would wrongly animate it. Build a transform-carrying occlusion\n // texture (shares the ORM GPU image) so the shader can sample occlusion with occlUV.\n // Requires the same underlying image as the ORM texture, since the shader re-samples\n // ormTexture at occlUV.\n if (!occlusionTexture && mat._occlusionImage && mat._occlusionImage === mat._metallicRoughnessImage && occlusionNeedsSplit(raw)) {\n occlusionTexture = wrap(pickTex(mat._occlusionImage, false, raw.occlusionTexture), raw.occlusionTexture);\n }\n return { baseColorTexture, ormTexture, normalTexture, emissiveTexture, occlusionTexture };\n}\n\n/** Slow-path assembly: adds occlusionTexCoord and occlusionTexture props. */\nexport function assemblePbrPropsExt(mat: GltfMaterialData, tex: PbrTexturesExt, extLayers: Partial<PbrMaterialProps> | undefined): PbrMaterialProps {\n const ef = mat._emissiveFactor;\n // See gltf-pbr-builder.ts: emissiveFactor [1,1,1] is a no-op only with an emissive texture;\n // with no texture it is a real full-white emissive that must be applied (Material_03).\n const defaultFactor = (ef[0] === 0 && ef[1] === 0 && ef[2] === 0) || (!!tex.emissiveTexture && ef[0] === 1 && ef[1] === 1 && ef[2] === 1);\n // Precompute UV-transform presence so the renderer doesn't scan 5 textures\n // per mesh. Any wrapped texture with `_hasTx=true` (set by gltf-ext-uv-transform)\n // flips this once at build time; omitted entirely on fast path.\n const hasAnyUvTx =\n !!(tex.baseColorTexture as { _hasTx?: true })._hasTx ||\n !!(tex.normalTexture as { _hasTx?: true } | undefined)?._hasTx ||\n !!(tex.ormTexture as { _hasTx?: true })._hasTx ||\n !!(tex.emissiveTexture as { _hasTx?: true } | undefined)?._hasTx ||\n !!(tex.occlusionTexture as { _hasTx?: true } | undefined)?._hasTx;\n // Per-channel UV1 (TEXCOORD_1) selection bitmask. Computed here on the slow path — the only\n // place a texture can carry texCoord:1 — so the always-loaded fast path just reads `_uv2Mask`.\n // Bit literals are a private contract with createPbrTemplateExt's decode (baseColor=1, orm=2,\n // normal=4, emissive=8, specGloss=16, occlusion=32). specGloss arrives via extLayers. Occlusion\n // reads `mat._occlusionTexCoord` (set from the glTF material's occlusionTexture.texCoord for\n // every path, including KHR_texture_basisu, since occlusion-on-UV1 always routes through here).\n const tc1 = (t: unknown): boolean => (t as { _texCoord?: number } | undefined)?._texCoord === 1;\n const uv2Mask =\n (tc1(tex.baseColorTexture) ? 1 : 0) |\n (tc1(tex.ormTexture) ? 2 : 0) |\n (tc1(tex.normalTexture) ? 4 : 0) |\n (tc1(tex.emissiveTexture) ? 8 : 0) |\n (tc1((extLayers as { specGlossTexture?: unknown } | undefined)?.specGlossTexture) ? 16 : 0) |\n (mat._occlusionTexCoord === 1 ? 32 : 0);\n return {\n baseColorTexture: tex.baseColorTexture,\n normalTexture: tex.normalTexture,\n ormTexture: tex.ormTexture,\n emissiveTexture: tex.emissiveTexture,\n ...(mat._baseColorImage && !isDefaultBaseColorFactor(mat._baseColorFactor) ? { baseColorFactor: mat._baseColorFactor } : undefined),\n doubleSided: mat._doubleSided,\n occlusionStrength: mat._occlusionImage ? 1.0 : 0,\n ...(mat._occlusionTexCoord ? { occlusionTexCoord: mat._occlusionTexCoord } : undefined),\n ...(tex.occlusionTexture ? { occlusionTexture: tex.occlusionTexture } : undefined),\n ...(mat._normalScale !== 1 ? { normalTextureScale: mat._normalScale } : undefined),\n ...(mat._metallicRoughnessImage ? { metallicFactor: mat._metallicFactor, roughnessFactor: mat._roughnessFactor } : undefined),\n ...(!defaultFactor ? { emissiveColor: [ef[0], ef[1], ef[2]] as [number, number, number] } : undefined),\n enableSpecularAA: true,\n ...(mat._alphaMode === \"BLEND\" ? { alphaBlend: true, alpha: mat._baseColorFactor[3] } : undefined),\n ...(mat._alphaMode === \"MASK\" ? { alpha: mat._baseColorFactor[3], alphaCutOff: mat._alphaCutoff } : undefined),\n ...(hasAnyUvTx ? { _hasUvTx: true } : undefined),\n ...(mat._rawMatDef?.name ? { name: mat._rawMatDef.name as string } : undefined),\n ...extLayers,\n ...(uv2Mask ? { _uv2Mask: uv2Mask } : undefined),\n _buildGroup: getPbrGroupBuilder(),\n _uboVersion: 0,\n } as PbrMaterialProps;\n}\n\nfunction isDefaultBaseColorFactor(f: readonly number[]): boolean {\n return f[0] === 1 && f[1] === 1 && f[2] === 1 && f[3] === 1;\n}\n"],"names":[],"mappings":";;;;;;AA2BA,SAAS,YAAA,CAAa,KAAgB,OAAA,EAA6B;AAC/D,EAAA,IAAI,CAAC,OAAA,EAAS;AACV,IAAA,OAAO,GAAA;AAAA,EACX;AACA,EAAA,IAAK,GAAA,CAA8B,cAAc,CAAA,EAAG;AAChD,IAAA,OAAO,GAAA;AAAA,EACX;AACA,EAAA,MAAM,EAAA,GAAK,OAAA;AACX,EAAA,MAAM,EAAA,GAAK,EAAA,CAAG,UAAA,EAAY,qBAAA,EAAuB,YAAY,EAAA,CAAG,QAAA;AAChE,EAAA,OAAO,EAAA,KAAO,IAAI,cAAA,CAAe,GAAA,EAAK,EAAE,SAAA,EAAW,CAAA,EAAG,CAAA,GAAI,GAAA;AAC9D;AAMA,SAAS,oBAAoB,GAAA,EAGjB;AACR,EAAA,MAAM,MAAM,GAAA,CAAI,gBAAA;AAChB,EAAA,MAAM,EAAA,GAAK,IAAI,oBAAA,EAAsB,wBAAA;AACrC,EAAA,IAAI,CAAC,GAAA,IAAO,CAAC,EAAA,EAAI;AACb,IAAA,OAAO,KAAA;AAAA,EACX;AACA,EAAA,OAAO,IAAI,KAAA,KAAU,EAAA,CAAG,KAAA,IAAS,GAAA,CAAI,YAAY,qBAAA,IAAyB,IAAA;AAC9E;AAKO,SAAS,2BACZ,MAAA,EACA,GAAA,EACA,SACA,eAAA,EACA,YAAA,EACA,SACA,UAAA,EACc;AACd,EAAA,MAAM,IAAA,GAAsB,CAAC,G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H,GAAI,OAAA,GAAU,EAAE,QAAA,EAAU,SAAQ,GAAI,MAAA;AAAA,IACtC,aAAa,kBAAA,EAAmB;AAAA,IAChC,WAAA,EAAa;AAAA,GACjB;AACJ;AAEA,SAAS,yBAAyB,CAAA,EAA+B;AAC7D,EAAA,OAAO,CAAA,CAAE,CAAC,CAAA,KAAM,CAAA,IAAK,EAAE,CAAC,CAAA,KAAM,CAAA,IAAK,CAAA,CAAE,CAAC,CAAA,KAAM,CAAA,IAAK,CAAA,CAAE,CAAC,CAAA,KAAM,CAAA;AAC9D;;;;"}
|
|
1
|
+
{"version":3,"file":"gltf-pbr-builder-ext.js","sources":["../../../src/loader-gltf/gltf-pbr-builder-ext.ts"],"sourcesContent":["/** Lazy-loaded slow path for PBR material assembly.\n * Only pulled into bundles whose glTF uses features that require per-texture\n * wrapping (e.g. KHR_texture_transform) or occlusion on UV2 (texCoord=1 with\n * no shared MR image). Scene1 (BoomBox) and any vanilla-PBR glTF skip this\n * module entirely. */\n\nimport type { EngineContext } from \"../engine/engine.js\";\nimport type { Texture2D } from \"../texture/texture-2d.js\";\nimport { cloneTexture2D } from \"../texture/texture-2d.js\";\nimport type { PbrMaterialProps } from \"../material/pbr/pbr-material.js\";\nimport { getPbrGroupBuilder } from \"../material/pbr/pbr-material.js\";\nimport type { GltfMaterialData } from \"./gltf-material.js\";\nimport type { TextureWrapFn, GenerateMipmapsFn } from \"./gltf-pbr-builder.js\";\nimport { uploadBaseColorFactorTexture, uploadOrmFactorTexture, uploadTex } from \"./gltf-pbr-builder.js\";\n\nexport interface PbrTexturesExt {\n baseColorTexture: Texture2D;\n ormTexture: Texture2D;\n normalTexture: Texture2D | undefined;\n emissiveTexture: Texture2D | undefined;\n occlusionTexture: Texture2D | undefined;\n}\n\n/** Stamp `_texCoord=1` on a clone when textureInfo selects UV1 and the\n * wrapTex layer didn't already set it (i.e. scene has no KHR_texture_transform). */\nfunction wrapTexCoord(tex: Texture2D, texInfo: unknown): Texture2D {\n if (!texInfo) {\n return tex;\n }\n if ((tex as { _texCoord?: 0 | 1 })._texCoord === 1) {\n return tex;\n }\n const ti = texInfo as { texCoord?: number; extensions?: { KHR_texture_transform?: { texCoord?: number } } };\n const tc = ti.extensions?.KHR_texture_transform?.texCoord ?? ti.texCoord;\n return tc === 1 ? cloneTexture2D(tex, { _texCoord: 1 }) : tex;\n}\n\n/** True when occlusion shares the ORM image with metallic-roughness but must be sampled\n * with its OWN UV transform — i.e. occlusion references a distinct glTF texture object,\n * or it carries its own KHR_texture_transform that an animation pointer can drive apart\n * from the MR transform. Drives the orm-unpack split in buildDefaultPbrTexturesExt. */\nfunction occlusionNeedsSplit(raw: {\n occlusionTexture?: { index?: number; extensions?: { KHR_texture_transform?: unknown } };\n pbrMetallicRoughness?: { metallicRoughnessTexture?: { index?: number } };\n}): boolean {\n const occ = raw.occlusionTexture;\n const mr = raw.pbrMetallicRoughness?.metallicRoughnessTexture;\n if (!occ || !mr) {\n return false;\n }\n return occ.index !== mr.index || occ.extensions?.KHR_texture_transform != null;\n}\n\n/** Build textures with wrapTex + occlusionOnUv2 support. Mirrors master's\n * default texture building but honors per-textureInfo wrapping so\n * KHR_texture_transform can attach per-texture UV state. */\nexport function buildDefaultPbrTexturesExt(\n engine: EngineContext,\n mat: GltfMaterialData,\n sampler: GPUSampler,\n generateMipmaps: GenerateMipmapsFn,\n getCachedTex: (bitmap: ImageBitmap, srgb: boolean) => Texture2D,\n wrapTex: TextureWrapFn,\n samplerFor?: (texInfo: unknown) => GPUSampler\n): PbrTexturesExt {\n const wrap: TextureWrapFn = (tex, ti) => wrapTexCoord(wrapTex(tex, ti), ti);\n // When the asset declares non-default glTF samplers, upload each texture with its own\n // sampler (wrap/filter), caching per (sampler, image, srgb) exactly like the fast-path\n // buildSampledPbrTextures. Without samplerFor (common case) reuse the shared default-\n // sampler cache. A GPUTexture is sampler-independent, so the same image with two\n // samplers yields two Texture2D wrappers, matching the fast path.\n const _localCache = samplerFor ? new Map<GPUSampler, Map<number, Texture2D>>() : null;\n const _ids = samplerFor ? new Map<ImageBitmap, number>() : null;\n let _nextId = 0;\n const pickTex = (image: ImageBitmap, srgb: boolean, texInfo: unknown): Texture2D => {\n if (!samplerFor) {\n return getCachedTex(image, srgb);\n }\n const s = samplerFor(texInfo);\n let bySampler = _localCache!.get(s);\n if (!bySampler) {\n _localCache!.set(s, (bySampler = new Map()));\n }\n let id = _ids!.get(image);\n if (id === undefined) {\n _ids!.set(image, (id = _nextId++));\n }\n const key = id * 2 + (srgb ? 1 : 0);\n let tex = bySampler.get(key);\n if (!tex) {\n tex = uploadTex(engine, image, srgb, s, generateMipmaps);\n bySampler.set(key, tex);\n }\n return tex;\n };\n const raw = mat._rawMatDef ?? {};\n const pbr = raw.pbrMetallicRoughness ?? {};\n const baseColorTexture = mat._baseColorImage\n ? wrap(pickTex(mat._baseColorImage, true, pbr.baseColorTexture), pbr.baseColorTexture)\n : uploadBaseColorFactorTexture(engine, mat._baseColorFactor, sampler, generateMipmaps);\n const normalTexture = mat._normalImage ? wrap(pickTex(mat._normalImage, false, raw.normalTexture), raw.normalTexture) : undefined;\n const emissiveTexture = mat._emissiveImage ? wrap(pickTex(mat._emissiveImage, true, raw.emissiveTexture), raw.emissiveTexture) : undefined;\n\n const occlusionOnUv2 = mat._occlusionTexCoord !== 0 && mat._occlusionImage && !mat._metallicRoughnessImage;\n let occlusionTexture: Texture2D | undefined;\n const single = mat._metallicRoughnessImage ?? (occlusionOnUv2 ? null : mat._occlusionImage);\n let ormTexture: Texture2D;\n if (occlusionOnUv2) {\n ormTexture = uploadOrmFactorTexture(engine, mat._roughnessFactor, mat._metallicFactor, sampler, generateMipmaps);\n occlusionTexture = wrap(pickTex(mat._occlusionImage!, false, raw.occlusionTexture), raw.occlusionTexture);\n } else if (single && (!mat._metallicRoughnessImage || !mat._occlusionImage || mat._metallicRoughnessImage === mat._occlusionImage)) {\n const ormTi = mat._metallicRoughnessImage ? pbr.metallicRoughnessTexture : raw.occlusionTexture;\n ormTexture = wrap(pickTex(single, false, ormTi), ormTi);\n } else if (!single) {\n ormTexture = uploadOrmFactorTexture(engine, mat._roughnessFactor, mat._metallicFactor, sampler, generateMipmaps);\n } else {\n ormTexture = wrap(pickTex(mat._metallicRoughnessImage!, false, pbr.metallicRoughnessTexture), pbr.metallicRoughnessTexture);\n }\n // Independent-occlusion UV transform (orm-unpack): occlusion and metallic-roughness\n // share the ORM texture (same image), but the glTF gives occlusion its OWN\n // KHR_texture_transform (or a distinct texture object) so the two can be animated\n // independently via KHR_animation_pointer. Sampling occlusion with MR's transform\n // (the single ormUV) would wrongly animate it. Build a transform-carrying occlusion\n // texture (shares the ORM GPU image) so the shader can sample occlusion with occlUV.\n // Requires the same underlying image as the ORM texture, since the shader re-samples\n // ormTexture at occlUV.\n if (!occlusionTexture && mat._occlusionImage && mat._occlusionImage === mat._metallicRoughnessImage && occlusionNeedsSplit(raw)) {\n occlusionTexture = wrap(pickTex(mat._occlusionImage, false, raw.occlusionTexture), raw.occlusionTexture);\n }\n return { baseColorTexture, ormTexture, normalTexture, emissiveTexture, occlusionTexture };\n}\n\n/** Slow-path assembly: adds occlusionTexCoord and occlusionTexture props. */\nexport function assemblePbrPropsExt(mat: GltfMaterialData, tex: PbrTexturesExt, extLayers: Partial<PbrMaterialProps> | undefined): PbrMaterialProps {\n const ef = mat._emissiveFactor;\n // See gltf-pbr-builder.ts: emissiveFactor [1,1,1] is a no-op only with an emissive texture;\n // with no texture it is a real full-white emissive that must be applied (Material_03).\n const defaultFactor = (ef[0] === 0 && ef[1] === 0 && ef[2] === 0) || (!!tex.emissiveTexture && ef[0] === 1 && ef[1] === 1 && ef[2] === 1);\n // Precompute UV-transform presence so the renderer doesn't scan 5 textures\n // per mesh. Any wrapped texture with `_hasTx=true` (set by gltf-ext-uv-transform)\n // flips this once at build time; omitted entirely on fast path.\n const hasAnyUvTx =\n !!(tex.baseColorTexture as { _hasTx?: true })._hasTx ||\n !!(tex.normalTexture as { _hasTx?: true } | undefined)?._hasTx ||\n !!(tex.ormTexture as { _hasTx?: true })._hasTx ||\n !!(tex.emissiveTexture as { _hasTx?: true } | undefined)?._hasTx ||\n !!(tex.occlusionTexture as { _hasTx?: true } | undefined)?._hasTx;\n // Per-channel UV1 (TEXCOORD_1) selection bitmask. Computed here on the slow path — the only\n // place a texture can carry texCoord:1 — so the always-loaded fast path just reads `_uv2Mask`.\n // Bit literals are a private contract with createPbrTemplateExt's decode (baseColor=1, orm=2,\n // normal=4, emissive=8, specGloss=16, occlusion=32). specGloss arrives via extLayers. Occlusion\n // reads `mat._occlusionTexCoord` (set from the glTF material's occlusionTexture.texCoord for\n // every path, including KHR_texture_basisu, since occlusion-on-UV1 always routes through here).\n const tc1 = (t: unknown): boolean => (t as { _texCoord?: number } | undefined)?._texCoord === 1;\n const uv2Mask =\n (tc1(tex.baseColorTexture) ? 1 : 0) |\n (tc1(tex.ormTexture) ? 2 : 0) |\n (tc1(tex.normalTexture) ? 4 : 0) |\n (tc1(tex.emissiveTexture) ? 8 : 0) |\n (tc1((extLayers as { specGlossTexture?: unknown } | undefined)?.specGlossTexture) ? 16 : 0) |\n (mat._occlusionTexCoord === 1 ? 32 : 0);\n return {\n baseColorTexture: tex.baseColorTexture,\n normalTexture: tex.normalTexture,\n ormTexture: tex.ormTexture,\n emissiveTexture: tex.emissiveTexture,\n ...(mat._baseColorImage && !isDefaultBaseColorFactor(mat._baseColorFactor) ? { baseColorFactor: mat._baseColorFactor } : undefined),\n doubleSided: mat._doubleSided,\n occlusionStrength: mat._occlusionImage ? 1.0 : 0,\n ...(mat._occlusionTexCoord ? { occlusionTexCoord: mat._occlusionTexCoord } : undefined),\n ...(tex.occlusionTexture ? { occlusionTexture: tex.occlusionTexture } : undefined),\n ...(mat._normalScale !== 1 ? { normalTextureScale: mat._normalScale } : undefined),\n ...(mat._metallicRoughnessImage ? { metallicFactor: mat._metallicFactor, roughnessFactor: mat._roughnessFactor } : undefined),\n ...(!defaultFactor ? { emissiveColor: [ef[0], ef[1], ef[2]] as [number, number, number] } : undefined),\n enableSpecularAA: true,\n ...(mat._alphaMode === \"BLEND\" ? { alphaBlend: true, alpha: mat._baseColorFactor[3] } : undefined),\n ...(mat._alphaMode === \"MASK\" ? { alpha: mat._baseColorFactor[3], alphaCutOff: mat._alphaCutoff } : undefined),\n ...(hasAnyUvTx ? { _hasUvTx: true } : undefined),\n ...(mat._rawMatDef?.name ? { name: mat._rawMatDef.name as string } : undefined),\n ...extLayers,\n ...(uv2Mask ? { _uv2Mask: uv2Mask } : undefined),\n _buildGroup: getPbrGroupBuilder(),\n _uboVersion: 0,\n } as PbrMaterialProps;\n}\n\nfunction isDefaultBaseColorFactor(f: readonly number[]): boolean {\n return f[0] === 1 && f[1] === 1 && f[2] === 1 && f[3] === 1;\n}\n"],"names":[],"mappings":";;;;AAyBA,SAAS,YAAA,CAAa,KAAgB,OAAA,EAA6B;AAC/D,EAAA,IAAI,CAAC,OAAA,EAAS;AACV,IAAA,OAAO,GAAA;AAAA,EACX;AACA,EAAA,IAAK,GAAA,CAA8B,cAAc,CAAA,EAAG;AAChD,IAAA,OAAO,GAAA;AAAA,EACX;AACA,EAAA,MAAM,EAAA,GAAK,OAAA;AACX,EAAA,MAAM,EAAA,GAAK,EAAA,CAAG,UAAA,EAAY,qBAAA,EAAuB,YAAY,EAAA,CAAG,QAAA;AAChE,EAAA,OAAO,EAAA,KAAO,IAAI,cAAA,CAAe,GAAA,EAAK,EAAE,SAAA,EAAW,CAAA,EAAG,CAAA,GAAI,GAAA;AAC9D;AAMA,SAAS,oBAAoB,GAAA,EAGjB;AACR,EAAA,MAAM,MAAM,GAAA,CAAI,gBAAA;AAChB,EAAA,MAAM,EAAA,GAAK,IAAI,oBAAA,EAAsB,wBAAA;AACrC,EAAA,IAAI,CAAC,GAAA,IAAO,CAAC,EAAA,EAAI;AACb,IAAA,OAAO,KAAA;AAAA,EACX;AACA,EAAA,OAAO,IAAI,KAAA,KAAU,EAAA,CAAG,KAAA,IAAS,GAAA,CAAI,Y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