@babylonjs/loaders 9.30.0 → 9.31.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (59) hide show
  1. package/SPLAT/gaussianSplattingDownloadManager.d.ts +10 -9
  2. package/SPLAT/gaussianSplattingDownloadManager.js +64 -53
  3. package/SPLAT/gaussianSplattingDownloadManager.js.map +1 -1
  4. package/SPLAT/gaussianSplattingResidencyPages.d.ts +49 -0
  5. package/SPLAT/gaussianSplattingResidencyPages.js +93 -0
  6. package/SPLAT/gaussianSplattingResidencyPages.js.map +1 -0
  7. package/SPLAT/gaussianSplattingStream.d.ts +154 -15
  8. package/SPLAT/gaussianSplattingStream.js +407 -25
  9. package/SPLAT/gaussianSplattingStream.js.map +1 -1
  10. package/SPLAT/gaussianSplattingWorkBuffer.d.ts +3 -1
  11. package/SPLAT/gaussianSplattingWorkBuffer.js +51 -14
  12. package/SPLAT/gaussianSplattingWorkBuffer.js.map +1 -1
  13. package/SPLAT/gaussianSplattingWorkBufferShaders.d.ts +6 -6
  14. package/SPLAT/gaussianSplattingWorkBufferShaders.js +12 -6
  15. package/SPLAT/gaussianSplattingWorkBufferShaders.js.map +1 -1
  16. package/glTF/2.0/Extensions/KHR_animation_pointer.data.pure.js +24 -9
  17. package/glTF/2.0/Extensions/KHR_animation_pointer.data.pure.js.map +1 -1
  18. package/glTF/2.0/Extensions/KHR_interactivity/declarationMapper.d.ts +6 -1
  19. package/glTF/2.0/Extensions/KHR_interactivity/declarationMapper.js +66 -40
  20. package/glTF/2.0/Extensions/KHR_interactivity/declarationMapper.js.map +1 -1
  21. package/glTF/2.0/Extensions/KHR_interactivity/flowGraphDelayReferenceBlock.d.ts +26 -0
  22. package/glTF/2.0/Extensions/KHR_interactivity/flowGraphDelayReferenceBlock.js +44 -0
  23. package/glTF/2.0/Extensions/KHR_interactivity/flowGraphDelayReferenceBlock.js.map +1 -0
  24. package/glTF/2.0/Extensions/KHR_interactivity/index.d.ts +1 -0
  25. package/glTF/2.0/Extensions/KHR_interactivity/index.js +1 -0
  26. package/glTF/2.0/Extensions/KHR_interactivity/index.js.map +1 -1
  27. package/glTF/2.0/Extensions/KHR_interactivity/interactivityGraphExporter.js +7 -1
  28. package/glTF/2.0/Extensions/KHR_interactivity/interactivityGraphExporter.js.map +1 -1
  29. package/glTF/2.0/Extensions/KHR_interactivity/interactivityGraphModel.d.ts +2 -1
  30. package/glTF/2.0/Extensions/KHR_interactivity/interactivityGraphModel.js +75 -6
  31. package/glTF/2.0/Extensions/KHR_interactivity/interactivityGraphModel.js.map +1 -1
  32. package/glTF/2.0/Extensions/KHR_interactivity/interactivityGraphParser.d.ts +9 -0
  33. package/glTF/2.0/Extensions/KHR_interactivity/interactivityGraphParser.js +35 -5
  34. package/glTF/2.0/Extensions/KHR_interactivity/interactivityGraphParser.js.map +1 -1
  35. package/glTF/2.0/Extensions/KHR_interactivity/pure.d.ts +1 -0
  36. package/glTF/2.0/Extensions/KHR_interactivity/pure.js +1 -0
  37. package/glTF/2.0/Extensions/KHR_interactivity/pure.js.map +1 -1
  38. package/glTF/2.0/Extensions/KHR_interactivity.pure.js +27 -6
  39. package/glTF/2.0/Extensions/KHR_interactivity.pure.js.map +1 -1
  40. package/glTF/2.0/Extensions/KHR_node_hoverability.pure.js +2 -0
  41. package/glTF/2.0/Extensions/KHR_node_hoverability.pure.js.map +1 -1
  42. package/glTF/2.0/Extensions/KHR_node_selectability.pure.js +11 -0
  43. package/glTF/2.0/Extensions/KHR_node_selectability.pure.js.map +1 -1
  44. package/glTF/2.0/Extensions/gltfAreaLightDimensions.d.ts +26 -0
  45. package/glTF/2.0/Extensions/gltfAreaLightDimensions.js +49 -0
  46. package/glTF/2.0/Extensions/gltfAreaLightDimensions.js.map +1 -0
  47. package/glTF/2.0/Extensions/gltfPathToObjectConverter.js +3 -0
  48. package/glTF/2.0/Extensions/gltfPathToObjectConverter.js.map +1 -1
  49. package/glTF/2.0/Extensions/interactivityAssetPathToObjectConverter.d.ts +1 -1
  50. package/glTF/2.0/Extensions/interactivityAssetPathToObjectConverter.js +5 -2
  51. package/glTF/2.0/Extensions/interactivityAssetPathToObjectConverter.js.map +1 -1
  52. package/glTF/2.0/Extensions/interactivityRefPathToObjectConverter.js +1 -2
  53. package/glTF/2.0/Extensions/interactivityRefPathToObjectConverter.js.map +1 -1
  54. package/glTF/2.0/Extensions/objectModelMapping.d.ts +16 -13
  55. package/glTF/2.0/Extensions/objectModelMapping.js +157 -108
  56. package/glTF/2.0/Extensions/objectModelMapping.js.map +1 -1
  57. package/glTF/2.0/glTFLoaderInterfaces.d.ts +2 -0
  58. package/glTF/2.0/glTFLoaderInterfaces.js.map +1 -1
  59. package/package.json +3 -3
@@ -1 +1 @@
1
- {"version":3,"file":"gaussianSplattingWorkBuffer.js","sourceRoot":"","sources":["../../../../dev/loaders/src/SPLAT/gaussianSplattingWorkBuffer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAC1C,OAAO,EAAE,iBAAiB,EAAE,MAAM,2CAA2C,CAAC;AAC9E,OAAO,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAC;AAE/D,OAAO,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AACnD,OAAO,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AACxC,OAAO,EAAE,UAAU,EAAE,MAAM,6BAA6B,CAAC;AACzD,OAAO,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAC/C,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAC;AAM1D,OAAO,EACH,2CAA2C,EAC3C,6CAA6C,EAC7C,2CAA2C,EAC3C,6CAA6C,EAC7C,qDAAqD,EACrD,qDAAqD,EACrD,6CAA6C,EAC7C,6CAA6C,EAC7C,qDAAqD,EACrD,qDAAqD,EACrD,2CAA2C,EAC3C,mDAAmD,EACnD,mDAAmD,EACnD,mDAAmD,EACnD,2D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,CAAC;QACxD,QAAQ,CAAC,UAAU,CAAC,aAAa,EAAE,IAAI,CAAC,YAAY,CAAC,CAAC;QACtD,iGAAiG;QACjG,QAAQ,CAAC,UAAU,CAAC,gBAAgB,EAAE,IAAI,CAAC,eAAe,IAAI,IAAI,CAAC,aAAa,CAAC,CAAC;QAClF,MAAM,IAAI,GAAG,IAAI,CAAC,SAAS,IAAI,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;QACzC,MAAM,IAAI,GAAG,IAAI,CAAC,SAAS,IAAI,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;QACzC,QAAQ,CAAC,UAAU,CAAC,cAAc,EAAE,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;QAC5E,QAAQ,CAAC,UAAU,CAAC,cAAc,EAAE,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;QAC5E,QAAQ,CAAC,MAAM,CAAC,UAAU,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC;QAC1C,8EAA8E;QAC9E,QAAQ,CAAC,MAAM,CAAC,QAAQ,EAAE,IAAI,CAAC,UAAU,CAAC,CAAC;QAC3C,QAAQ,CAAC,MAAM,CAAC,YAAY,EAAE,IAAI,CAAC,YAAY,CAAC,CAAC;QACjD,QAAQ,CAAC,MAAM,CAAC,WAAW,EAAE,QAAQ,CAAC,CAAC;IAC3C,CAAC;CACJ","sourcesContent":["import { Logger } from \"core/Misc/logger\";\r\nimport { MultiRenderTarget } from \"core/Materials/Textures/multiRenderTarget\";\r\nimport { ShaderMaterial } from \"core/Materials/shaderMaterial\";\r\nimport { ShaderLanguage } from \"core/Materials/shaderLanguage\";\r\nimport { Constants } from \"core/Engines/constants\";\r\nimport { Mesh } from \"core/Meshes/mesh\";\r\nimport { VertexData } from \"core/Meshes/mesh.vertexData\";\r\nimport { Color4 } from \"core/Maths/math.color\";\r\nimport { Vector3, Vector4 } from \"core/Maths/math.vector\";\r\nimport { type Texture } from \"core/Materials/Textures/texture\";\r\nimport { type BaseTexture } from \"core/Materials/Textures/baseTexture\";\r\nimport { type Scene } from \"core/scene\";\r\nimport { type Nullable } from \"core/types\";\r\nimport { type ISogTexturePack } from \"./splatDefs\";\r\nimport {\r\n GaussianSplattingWorkBufferVertexShaderGLSL,\r\n GaussianSplattingWorkBufferFragmentShaderGLSL,\r\n GaussianSplattingWorkBufferVertexShaderWGSL,\r\n GaussianSplattingWorkBufferFragmentShaderWGSL,\r\n GaussianSplattingWorkBufferRelayoutFragmentShaderGLSL,\r\n GaussianSplattingWorkBufferRelayoutFragmentShaderWGSL,\r\n GaussianSplattingWorkBufferRelayoutShaderName,\r\n GaussianSplattingWorkBufferShDecodeShaderName,\r\n GaussianSplattingWorkBufferShDecodeFragmentShaderGLSL,\r\n GaussianSplattingWorkBufferShDecodeFragmentShaderWGSL,\r\n GaussianSplattingWorkBufferShCopyShaderName,\r\n GaussianSplattingWorkBufferShCopyFragmentShaderGLSL,\r\n GaussianSplattingWorkBufferShCopyFragmentShaderWGSL,\r\n GaussianSplattingWorkBufferRotationDecodeShaderName,\r\n GaussianSplattingWorkBufferRotationDecodeFragmentShaderGLSL,\r\n GaussianSplattingWorkBufferRotationDecodeFragmentShaderWGSL,\r\n GaussianSplattingWorkBufferRotCopyShaderName,\r\n GaussianSplattingWorkBufferRotCopyFragmentShaderGLSL,\r\n GaussianSplattingWorkBufferRotCopyFragmentShaderWGSL,\r\n} from \"./gaussianSplattingWorkBufferShaders\";\r\nimport { RawTexture } from \"core/Materials/Textures/rawTexture\";\r\n\r\n/**\r\n * A unified, GPU-decoded Gaussian Splatting work buffer.\r\n *\r\n * Holds a square MRT texture set (centers / covA / covB / colors) sized to a fixed splat capacity\r\n * (`ceil(sqrt(capacity))`). Each streamed SOG file is decoded directly on the GPU\r\n * (no CPU readback) into its allocated pixel range. The decoded textures are consumed unchanged by the\r\n * standard (non-SOG) Gaussian Splatting draw path.\r\n *\r\n * @experimental\r\n */\r\nexport class GaussianSplattingWorkBuffer {\r\n private readonly _scene: Scene;\r\n // Not readonly: a hosted work buffer is rebound to the compound's NEW atlas MRT after a grow (see rebindAtlas).\r\n private _mrt: MultiRenderTarget;\r\n private readonly _textureSize: number;\r\n private readonly _shaderLanguage: ShaderLanguage;\r\n private readonly _material: ShaderMaterial;\r\n private readonly _quad: Mesh;\r\n // When true this work buffer owns (and disposes) its MRT. False when it wraps an external atlas (a compound\r\n // mesh's MRT) it must not dispose. In the external case the MRT is wide (dstWidth x atlasHeight), decodes are\r\n // offset by _baseOffset (the reserved region's first splat), and _textureSize is the atlas WIDTH.\r\n private readonly _ownsMrt: boolean;\r\n // Not readonly: a hosted region can be RELOCATED to a new base when the compound compacts its atlas\r\n // (reclaiming a removed part's rows). backupRegion() reads from the old base, setBaseOffset() updates it,\r\n // then rebindAtlas() + restoreRegion() writes to the new base.\r\n private _baseOffset: number;\r\n // Splat count this work buffer addresses. Standalone: the whole (square) buffer. Hosted: the reserved\r\n // region's (row-aligned) capacity — used to scope a relayout to the region's atlas rows.\r\n private readonly _capacity: number;\r\n // Relayout (defrag) copy material, created lazily on first relayout.\r\n private _copyMaterial: Nullable<ShaderMaterial> = null;\r\n // Reusable destination->source index map for the relayout pass (created lazily, sized to the work buffer).\r\n private _relayoutMapData: Nullable<Float32Array> = null;\r\n private _relayoutMapTexture: Nullable<RawTexture> = null;\r\n // Transient backup of a hosted region's four textures, held between backupRegion() and restoreRegion() so the\r\n // GPU-decoded data survives the compound recreating its atlas on a grow (adding a part / a second stream).\r\n private _backupMrt: Nullable<MultiRenderTarget> = null;\r\n private _disposed = false;\r\n // Reused WebGL framebuffer for the async centers readback (created lazily, freed in dispose).\r\n private _readFbo: Nullable<WebGLFramebuffer> = null;\r\n\r\n // Higher-order spherical-harmonics. Each SH texture is its own single-attachment integer render target\r\n // (RGBA_INTEGER/UNSIGNED_INTEGER, 16 SH scalar-bytes per texel) so a decode/relayout pass writes exactly one\r\n // attachment, keeping within WebGPU's per-sample color-attachment byte budget. Empty when SH is off.\r\n private _shMrts: MultiRenderTarget[] = [];\r\n // True when this work buffer owns (and disposes) its SH render targets (standalone). False when they are the\r\n // hosting compound's shared SH atlas (hosted) — borrowed, not disposed. Rebound alongside the core atlas.\r\n private _ownsShMrts = false;\r\n // The SH decode material (packed-u32 dequant), created only when SH is requested. Reused across files/passes.\r\n private _shMaterial: Nullable<ShaderMaterial> = null;\r\n // Integer SH relayout/backup copy material (usampler2D -> uvec4), created lazily alongside the float copy.\r\n private _shCopyMaterial: Nullable<ShaderMaterial> = null;\r\n // Transient region-sized integer backups of the SH textures, held between backupRegion() and restoreRegion()\r\n // so the baked SH survives the compound recreating its SH atlas on a grow/compaction (parallel to _backupMrt).\r\n private _backupShMrts: Nullable<MultiRenderTarget[]> = null;\r\n\r\n // Rotation/scale. One 3-attachment half-float render target (rotA / rotB / rotScale) holding the per-splat\r\n // rotation matrix + scale that voxel-based IBL shadowing consumes. Null when rotation decode is off.\r\n private _rotMrt: Nullable<MultiRenderTarget> = null;\r\n // True when this work buffer owns (and disposes) its rotation target (standalone). False when it is the hosting\r\n // compound's shared rotation atlas (hosted) — borrowed, rebound alongside the core atlas, never disposed here.\r\n private _ownsRotMrt = false;\r\n // The rotation/scale decode material, created only when rotation is requested. Reused across files.\r\n private _rotMaterial: Nullable<ShaderMaterial> = null;\r\n // Rotation/scale relayout/backup copy material (3-out float copy), created lazily alongside the float copy.\r\n private _rotCopyMaterial: Nullable<ShaderMaterial> = null;\r\n // Transient region-sized backup of the rotation textures, held between backupRegion() and restoreRegion() so the\r\n // decoded rotation/scale survives the compound recreating its rotation atlas on a grow/compaction.\r\n private _backupRotMrt: Nullable<MultiRenderTarget> = null;\r\n\r\n /**\r\n * True when the engine supports the non-blocking GPU readback used by {@link readCentersRangeAsync}:\r\n * WebGL2 (PBO + fence) or WebGPU (copyTextureToBuffer + mapAsync). When false (e.g. WebGL1), callers must\r\n * decode positions on the CPU instead.\r\n */\r\n public get supportsAsyncCentersReadback(): boolean {\r\n const engine = this._scene.getEngine();\r\n if (engine.isWebGPU) {\r\n return true;\r\n }\r\n const glEngine = engine as unknown as { _gl?: WebGL2RenderingContext; _readPixelsAsync?: unknown; webGLVersion?: number };\r\n return !!glEngine._gl && typeof glEngine._readPixelsAsync === \"function\" && (glEngine.webGLVersion ?? 0) >= 2;\r\n }\r\n\r\n /**\r\n * Square edge length (in pixels) of the work-buffer textures.\r\n */\r\n public get textureSize(): number {\r\n return this._textureSize;\r\n }\r\n\r\n /**\r\n * The decoded work-buffer textures: [centers, covA, covB, colors].\r\n */\r\n public get textures(): Texture[] {\r\n return this._mrt.textures;\r\n }\r\n\r\n /**\r\n * The baked higher-order SH textures (packed-u32, one per `ceil(coeffs*3/16)`), consumed by the draw path's\r\n * `computeSHWeighted`/`decompose` as `shTexture0..N`. Empty when SH decoding is not enabled.\r\n */\r\n public get shTextures(): Texture[] {\r\n return this._shMrts.map((m) => m.textures[0]);\r\n }\r\n\r\n /**\r\n * The decoded rotation/scale textures ([rotationsA, rotationsB, rotationScale], half-float), consumed by the\r\n * voxel-IBL path as `rotationsATexture`/`rotationsBTexture`/`rotationScaleTexture`. Empty when rotation decode\r\n * is not enabled.\r\n */\r\n public get rotationTextures(): Texture[] {\r\n return this._rotMrt ? this._rotMrt.textures : [];\r\n }\r\n\r\n /**\r\n * Creates a work buffer sized to hold `capacity` splats.\r\n *\r\n * Standalone (default): the work buffer creates and owns a square MRT sized `ceil(sqrt(capacity))`, with\r\n * decodes addressed from splat 0.\r\n *\r\n * Hosted (`externalAtlas` provided): the work buffer decodes/reads back into an externally-owned MRT (a\r\n * compound mesh's shared atlas) instead of creating its own. Decodes are placed at `externalAtlas.baseOffset`\r\n * (the reserved region's first splat) and addressed over `externalAtlas.width` (the wide atlas width), so the\r\n * streamed splats land in the compound's atlas and sort/draw together with the static parts.\r\n * @param scene hosting scene\r\n * @param capacity total number of splats the work buffer must address\r\n * @param externalAtlas optional external atlas to decode into instead of creating an owned square MRT\r\n * @param sh optional higher-order SH decode configuration. `textureCount = ceil(coeffs*3/16)` for the max SH\r\n * degree across the streamed files. Standalone: the work buffer creates that many owned single-attachment\r\n * integer render targets. Hosted: `externalMrts` are the compound's shared SH atlas targets (borrowed).\r\n * @param rotationScale optional rotation/scale decode configuration (for voxel-IBL shadows). When present the\r\n * work buffer decodes each splat's rotation matrix + scale into a 3-attachment half-float target. Standalone:\r\n * the work buffer creates and owns that target. Hosted: `externalMrt` is the compound's shared rotation atlas.\r\n */\r\n constructor(\r\n scene: Scene,\r\n capacity: number,\r\n externalAtlas?: { mrt: MultiRenderTarget; width: number; baseOffset: number },\r\n sh?: { textureCount: number; externalMrts?: MultiRenderTarget[] },\r\n rotationScale?: { externalMrt?: MultiRenderTarget }\r\n ) {\r\n this._scene = scene;\r\n this._shaderLanguage = scene.getEngine().isWebGPU ? ShaderLanguage.WGSL : ShaderLanguage.GLSL;\r\n this._capacity = Math.max(1, capacity);\r\n\r\n if (externalAtlas) {\r\n this._mrt = externalAtlas.mrt;\r\n this._textureSize = externalAtlas.width;\r\n this._baseOffset = externalAtlas.baseOffset;\r\n this._ownsMrt = false;\r\n } else {\r\n this._textureSize = Math.max(1, Math.ceil(Math.sqrt(Math.max(1, capacity))));\r\n this._baseOffset = 0;\r\n this._ownsMrt = true;\r\n // The decode buffer accumulates (clear disabled) so each decode preserves previously-decoded files.\r\n this._mrt = this._createMrt(\"gsWorkBuffer\", true);\r\n }\r\n\r\n // Higher-order SH: one single-attachment integer target per packed-u32 SH texture. Standalone owns square\r\n // targets sized like the core atlas; hosted borrows the compound's wide shared SH atlas targets.\r\n if (sh && sh.textureCount > 0) {\r\n if (sh.externalMrts) {\r\n this._shMrts = sh.externalMrts.slice(0, sh.textureCount);\r\n this._ownsShMrts = false;\r\n } else {\r\n for (let k = 0; k < sh.textureCount; k++) {\r\n this._shMrts.push(this._createShMrt(`gsWorkBufferSh${k}`, true));\r\n }\r\n this._ownsShMrts = true;\r\n }\r\n this._shMaterial = this._createShMaterial();\r\n }\r\n\r\n // Rotation/scale: one 3-attachment half-float target. Standalone owns a square target sized like the core\r\n // atlas; hosted borrows the compound's wide shared rotation atlas.\r\n if (rotationScale) {\r\n if (rotationScale.externalMrt) {\r\n this._rotMrt = rotationScale.externalMrt;\r\n this._ownsRotMrt = false;\r\n } else {\r\n this._rotMrt = this._createRotMrt(\"gsWorkBufferRot\", true);\r\n this._ownsRotMrt = true;\r\n }\r\n this._rotMaterial = this._createRotMaterial();\r\n }\r\n\r\n // One persistent decode material + fullscreen-triangle quad, reused (with per-file uniforms)\r\n // for every decode so the shader is compiled only once.\r\n this._material = this._createMaterial();\r\n this._quad = this._createQuad();\r\n this._quad.material = this._material;\r\n\r\n // Hosted: start compiling the copy shader now so backupRegion()/restoreRegion() are ready by the time\r\n // the compound grows its atlas (a synchronous, non-frame-driven event we can't wait on).\r\n if (!this._ownsMrt) {\r\n this.isRelayoutReady();\r\n }\r\n }\r\n\r\n /**\r\n * Rebinds a hosted work buffer to a new atlas MRT (after the compound recreated it on a grow). No-op for a\r\n * standalone work buffer, which owns its MRT.\r\n * @param mrt the compound's new shared atlas\r\n */\r\n public rebindAtlas(mrt: MultiRenderTarget): void {\r\n if (!this._ownsMrt) {\r\n this._mrt = mrt;\r\n }\r\n }\r\n\r\n /**\r\n * Rebinds a hosted work buffer to the compound's NEW shared SH atlas (after the compound recreated it on a\r\n * grow/compaction). No-op when SH isn't in use or the work buffer owns its SH targets (standalone).\r\n * @param shMrts the compound's new shared SH render targets (one per packed-u32 SH texture)\r\n */\r\n public rebindShAtlas(shMrts: Nullable<MultiRenderTarget[]>): void {\r\n if (!this._ownsShMrts && shMrts && this._shMrts.length) {\r\n this._shMrts = shMrts.slice(0, this._shMrts.length);\r\n }\r\n }\r\n\r\n /**\r\n * Rebinds a hosted work buffer to the compound's NEW shared rotation atlas (after the compound recreated it on a\r\n * grow/compaction). No-op when rotation isn't in use or the work buffer owns its rotation target (standalone).\r\n * @param rotMrt the compound's new shared rotation atlas\r\n */\r\n public rebindRotAtlas(rotMrt: Nullable<MultiRenderTarget>): void {\r\n if (!this._ownsRotMrt && rotMrt && this._rotMrt) {\r\n this._rotMrt = rotMrt;\r\n }\r\n }\r\n\r\n /**\r\n * Relocates this hosted region to a new base splat offset in the shared atlas (used when the compound\r\n * compacts its atlas and this region's rows move). Subsequent decode/render/readback and\r\n * {@link restoreRegion} all address from the new base. Call between {@link backupRegion} (which read from\r\n * the old base) and {@link restoreRegion} (which will write to the new base). No-op for a standalone\r\n * work buffer, which owns its square MRT at base 0.\r\n * @param baseOffset the region's new first splat index in the atlas\r\n */\r\n public setBaseOffset(baseOffset: number): void {\r\n if (!this._ownsMrt) {\r\n this._baseOffset = baseOffset;\r\n }\r\n }\r\n\r\n /**\r\n * True once the backup/restore/relayout copy shaders are compiled, so {@link backupRegion} can preserve the\r\n * region across an atlas rebuild. Callers that decode into a hosted region should await this before writing\r\n * data, so a later grow/compaction can never race shader compilation and drop the region.\r\n */\r\n public get canBackup(): boolean {\r\n return this._disposed || this._ownsMrt ? false : this.isRelayoutReady();\r\n }\r\n\r\n /**\r\n * Copies this hosted region's four decoded textures out of the shared atlas into an internal backup MRT so\r\n * they survive the compound recreating the atlas on a grow. Call immediately before the atlas is recreated,\r\n * then {@link rebindAtlas} + {@link restoreRegion} after.\r\n */\r\n public backupRegion(): void {\r\n if (this._disposed || this._ownsMrt) {\r\n return;\r\n }\r\n if (!this.isRelayoutReady()) {\r\n // The copy shaders should be compiled well before any grow (callers warm them before decoding), so this\r\n // path means a grow raced compilation; warn rather than silently drop the region's GPU data on the restore.\r\n Logger.Warn(\"GaussianSplattingWorkBuffer: backup skipped because the copy shaders are not ready; streamed region data may be lost on the atlas rebuild.\");\r\n return;\r\n }\r\n const width = this._textureSize;\r\n const regionRows = Math.max(1, Math.floor(this._capacity / width));\r\n const baseRow = Math.floor(this._baseOffset / width);\r\n if (!this._backupMrt) {\r\n this._backupMrt = this._createMrt(\"gsAtlasBackup\", false, width, regionRows);\r\n }\r\n // Identity copy of the region out of the atlas: with useMap=0 and dstBaseRow=-baseRow the shader reads\r\n // atlas texel ((p.y + baseRow) * width + p.x) — the region's global texel — into backup texel p.\r\n this._renderRelayoutPass(this._backupMrt, this._mrt.textures, this._mrt.textures[0], 0, width, width, 0, -baseRow);\r\n // Same for each baked SH texture (one integer copy pass per texture).\r\n if (this._shMrts.length && this._shCopyMaterial) {\r\n if (!this._backupShMrts) {\r\n this._backupShMrts = this._shMrts.map((_, k) => this._createShMrt(`gsShAtlasBackup${k}`, false, width, regionRows));\r\n }\r\n for (let k = 0; k < this._shMrts.length; k++) {\r\n this._renderShCopyPass(this._backupShMrts[k], this._shMrts[k].textures[0], this._mrt.textures[0], 0, width, width, 0, -baseRow);\r\n }\r\n }\r\n // Same for the rotation/scale textures (one 3-out float copy pass).\r\n if (this._rotMrt && this._rotCopyMaterial) {\r\n if (!this._backupRotMrt) {\r\n this._backupRotMrt = this._createRotMrt(\"gsRotAtlasBackup\", false, width, regionRows);\r\n }\r\n this._renderRotCopyPass(this._backupRotMrt, this._rotMrt.textures, this._mrt.textures[0], 0, width, width, 0, -baseRow);\r\n }\r\n this._quad.material = this._material;\r\n }\r\n\r\n /**\r\n * Restores the backed-up region into the (new) atlas, confined by a scissor to the region's rows so no other\r\n * part is touched. Call {@link rebindAtlas} to the new atlas first. Frees the backup afterwards.\r\n */\r\n public restoreRegion(): void {\r\n if (this._disposed || this._ownsMrt || !this._backupMrt || !this._copyMaterial) {\r\n return;\r\n }\r\n const width = this._textureSize;\r\n const regionRows = Math.max(1, Math.floor(this._capacity / width));\r\n const baseRow = Math.floor(this._baseOffset / width);\r\n const engine = this._scene.getEngine();\r\n engine.enableScissor(0, baseRow, width, regionRows);\r\n try {\r\n // useMap=0 identity with dstBaseRow=baseRow: atlas texel p reads backup texel ((p.y - baseRow)*width + p.x).\r\n this._renderRelayoutPass(this._mrt, this._backupMrt.textures, this._backupMrt.textures[0], 0, width, width, 0, baseRow);\r\n // Restore each baked SH texture the same way (scissored to the region's rows). The map placeholder must\r\n // be a FLOAT texture (uMapTex is texture_2d<f32>) even though useMap=0 doesn't sample it — WebGPU still\r\n // validates the bound texture's sample type against the layout. Use the atlas centers (F32).\r\n if (this._backupShMrts && this._shMrts.length && this._shCopyMaterial) {\r\n for (let k = 0; k < this._shMrts.length && k < this._backupShMrts.length; k++) {\r\n this._renderShCopyPass(this._shMrts[k], this._backupShMrts[k].textures[0], this._mrt.textures[0], 0, width, width, 0, baseRow);\r\n }\r\n }\r\n // Restore the rotation/scale textures the same way (3-out float copy, scissored to the region's rows).\r\n if (this._backupRotMrt && this._rotMrt && this._rotCopyMaterial) {\r\n this._renderRotCopyPass(this._rotMrt, this._backupRotMrt.textures, this._mrt.textures[0], 0, width, width, 0, baseRow);\r\n }\r\n } finally {\r\n engine.disableScissor();\r\n this._quad.material = this._material;\r\n }\r\n this._backupMrt.dispose();\r\n this._backupMrt = null;\r\n if (this._backupShMrts) {\r\n for (const mrt of this._backupShMrts) {\r\n mrt.dispose();\r\n }\r\n this._backupShMrts = null;\r\n }\r\n this._backupRotMrt?.dispose();\r\n this._backupRotMrt = null;\r\n }\r\n\r\n /**\r\n * Creates a 4-attachment MRT (centers F32 / covA / covB / colors U8) sized to the work buffer. covA/covB\r\n * use HALF_FLOAT when the engine can render to it, matching the precision the non-streamed\r\n * GaussianSplattingMesh path already uses for these same two textures (see\r\n * `gaussianSplattingMeshBase.pure.ts`'s `createTextureFromDataF16` covA/covB textures); centers stays F32\r\n * and colors stays U8 in both paths.\r\n * @param name MRT and attachment base name\r\n * @param disableClear when true, clearing is suppressed so renders accumulate (the decode buffer); when\r\n * false the MRT clears to zero on each render (the temporary relayout buffer, so gaps stay zeroed)\r\n * @param width texture width (defaults to the work-buffer size; the region row width for a scoped relayout)\r\n * @param height texture height (defaults to the work-buffer size; the region row count for a scoped relayout)\r\n * @returns the created MRT\r\n */\r\n private _createMrt(name: string, disableClear: boolean, width: number = this._textureSize, height: number = this._textureSize): MultiRenderTarget {\r\n const covType = this._scene.getEngine()._caps.textureHalfFloatRender ? Constants.TEXTURETYPE_HALF_FLOAT : Constants.TEXTURETYPE_FLOAT;\r\n const mrt = new MultiRenderTarget(\r\n name,\r\n { width, height },\r\n 4,\r\n this._scene,\r\n {\r\n types: [Constants.TEXTURETYPE_FLOAT, covType, covType, Constants.TEXTURETYPE_UNSIGNED_BYTE],\r\n samplingModes: [\r\n Constants.TEXTURE_NEAREST_SAMPLINGMODE,\r\n Constants.TEXTURE_NEAREST_SAMPLINGMODE,\r\n Constants.TEXTURE_NEAREST_SAMPLINGMODE,\r\n Constants.TEXTURE_NEAREST_SAMPLINGMODE,\r\n ],\r\n formats: [Constants.TEXTUREFORMAT_RGBA, Constants.TEXTUREFORMAT_RGBA, Constants.TEXTUREFORMAT_RGBA, Constants.TEXTUREFORMAT_RGBA],\r\n generateDepthBuffer: false,\r\n generateDepthTexture: false,\r\n generateMipMaps: false,\r\n },\r\n [`${name}Centers`, `${name}CovA`, `${name}CovB`, `${name}Colors`]\r\n );\r\n mrt.clearColor = new Color4(0, 0, 0, 0);\r\n mrt.renderList = [];\r\n if (disableClear) {\r\n mrt.onClearObservable.add(() => {});\r\n }\r\n return mrt;\r\n }\r\n\r\n /**\r\n * Creates a single-attachment integer render target (RGBA_INTEGER / UNSIGNED_INTEGER) that holds one packed-u32\r\n * baked-SH texture. One attachment per pass keeps within WebGPU's per-sample color-attachment byte budget and\r\n * matches the format/type of the draw path's `shTexture0..N` samplers (`_GaussianSplattingBytesPerShTexel`).\r\n * @param name attachment name\r\n * @param disableClear when true, clearing is suppressed so SH decodes accumulate across files\r\n * @param width texture width (defaults to the work-buffer size)\r\n * @param height texture height (defaults to the work-buffer size)\r\n * @returns the created single-attachment integer MRT\r\n */\r\n private _createShMrt(name: string, disableClear: boolean, width: number = this._textureSize, height: number = this._textureSize): MultiRenderTarget {\r\n const mrt = new MultiRenderTarget(\r\n name,\r\n { width, height },\r\n 1,\r\n this._scene,\r\n {\r\n types: [Constants.TEXTURETYPE_UNSIGNED_INTEGER],\r\n formats: [Constants.TEXTUREFORMAT_RGBA_INTEGER],\r\n samplingModes: [Constants.TEXTURE_NEAREST_SAMPLINGMODE],\r\n generateDepthBuffer: false,\r\n generateDepthTexture: false,\r\n generateMipMaps: false,\r\n },\r\n [name]\r\n );\r\n mrt.clearColor = new Color4(0, 0, 0, 0);\r\n mrt.renderList = [];\r\n if (disableClear) {\r\n mrt.onClearObservable.add(() => {});\r\n }\r\n return mrt;\r\n }\r\n\r\n /**\r\n * Creates a 3-attachment half-float MRT ([rotA, rotB, rotScale]) holding the per-splat rotation matrix + scale\r\n * consumed by voxel-IBL shadowing. RGBA half-float when the engine can render to it (matching the covariance\r\n * precision), else full float. 3 attachments = 24 B/sample, within WebGPU's per-sample budget (its own pass).\r\n * @param name MRT and attachment base name\r\n * @param disableClear when true, clearing is suppressed so decodes accumulate (the decode buffer)\r\n * @param width texture width (defaults to the work-buffer size; the region row width for a scoped relayout)\r\n * @param height texture height (defaults to the work-buffer size; the region row count for a scoped relayout)\r\n * @returns the created MRT\r\n */\r\n private _createRotMrt(name: string, disableClear: boolean, width: number = this._textureSize, height: number = this._textureSize): MultiRenderTarget {\r\n const rotType = this._scene.getEngine()._caps.textureHalfFloatRender ? Constants.TEXTURETYPE_HALF_FLOAT : Constants.TEXTURETYPE_FLOAT;\r\n const mrt = new MultiRenderTarget(\r\n name,\r\n { width, height },\r\n 3,\r\n this._scene,\r\n {\r\n types: [rotType, rotType, rotType],\r\n formats: [Constants.TEXTUREFORMAT_RGBA, Constants.TEXTUREFORMAT_RGBA, Constants.TEXTUREFORMAT_RGBA],\r\n samplingModes: [Constants.TEXTURE_NEAREST_SAMPLINGMODE, Constants.TEXTURE_NEAREST_SAMPLINGMODE, Constants.TEXTURE_NEAREST_SAMPLINGMODE],\r\n generateDepthBuffer: false,\r\n generateDepthTexture: false,\r\n generateMipMaps: false,\r\n },\r\n [`${name}A`, `${name}B`, `${name}Scale`]\r\n );\r\n mrt.clearColor = new Color4(0, 0, 0, 0);\r\n mrt.renderList = [];\r\n if (disableClear) {\r\n mrt.onClearObservable.add(() => {});\r\n }\r\n return mrt;\r\n }\r\n\r\n /**\r\n * Decodes one SOG file into the work buffer at the given splat offset (accumulating; previously\r\n * decoded files are preserved). Resolves once the GPU decode has been issued. The caller may\r\n * dispose the source pack textures after this resolves.\r\n * @param pack the SOG texture pack (GPU source textures + per-file decode parameters)\r\n * @param offset first splat index (pixel offset) for this file in the work buffer\r\n */\r\n public async decodeAsync(pack: ISogTexturePack, offset: number): Promise<void> {\r\n if (this._disposed) {\r\n return;\r\n }\r\n this._applyPack(pack);\r\n // When SH is enabled, bake EVERY file's region — even a file with no higher-order SH (a coarse LOD may drop\r\n // it): those get uCoeffs=0 so the whole region neutral-fills (128), keeping mixed-degree files consistent.\r\n const decodeSh = this._shMaterial !== null && this._shMrts.length > 0;\r\n if (decodeSh) {\r\n this._applyShPack(pack);\r\n }\r\n const decodeRot = this._rotMaterial !== null && this._rotMrt !== null;\r\n if (decodeRot) {\r\n this._applyRotPack(pack);\r\n }\r\n // Render the decode pass at the start of a frame (the safe point for custom render targets),\r\n // once the shader is compiled — never re-entrantly from a promise/observable continuation.\r\n await new Promise<void>((resolve) => {\r\n const attempt = () => {\r\n if (this._disposed) {\r\n resolve();\r\n return;\r\n }\r\n if (!this._material.isReady(this._quad) || (decodeSh && !this._shMaterial!.isReady(this._quad)) || (decodeRot && !this._rotMaterial!.isReady(this._quad))) {\r\n this._scene.onBeforeRenderObservable.addOnce(attempt);\r\n return;\r\n }\r\n // Scissor every pass to just this file's atlas rows so the fullscreen triangle only shades the region\r\n // it writes, not the whole (wide) atlas. Correct because the shaders already discard outside the exact\r\n // splat range, and the row band is a superset of it.\r\n const width = this._textureSize;\r\n // Bind uOffset at render time from the live _baseOffset so it shares one value with the scissor below:\r\n // compactAtlas() can relocate this region (via setBaseOffset) during the defer window.\r\n const globalOffset = this._baseOffset + offset;\r\n this._material.setInt(\"uOffset\", globalOffset);\r\n if (decodeSh) {\r\n this._shMaterial!.setInt(\"uOffset\", globalOffset);\r\n }\r\n if (decodeRot) {\r\n this._rotMaterial!.setInt(\"uOffset\", globalOffset);\r\n }\r\n const firstRow = Math.floor(globalOffset / width);\r\n const rowCount = Math.max(1, Math.ceil((globalOffset + pack.splatCount) / width) - firstRow);\r\n const engine = this._scene.getEngine();\r\n engine.enableScissor(0, firstRow, width, rowCount);\r\n try {\r\n this._quad.material = this._material;\r\n this._mrt.renderList = [this._quad];\r\n this._mrt.render();\r\n // Bake this file's higher-order SH: one pass per packed-u32 SH texture (uShTextureIndex selects the\r\n // 16 SH scalars written this pass). Files with fewer coefficients neutral-fill (128) higher bands.\r\n if (decodeSh) {\r\n for (let k = 0; k < this._shMrts.length; k++) {\r\n this._shMaterial!.setInt(\"uShTextureIndex\", k);\r\n this._quad.material = this._shMaterial!;\r\n this._shMrts[k].renderList = [this._quad];\r\n this._shMrts[k].render();\r\n }\r\n this._quad.material = this._material;\r\n }\r\n // Bake this file's rotation/scale into the 3-attachment half-float rotation target (one pass).\r\n if (decodeRot) {\r\n this._quad.material = this._rotMaterial!;\r\n this._rotMrt!.renderList = [this._quad];\r\n this._rotMrt!.render();\r\n this._quad.material = this._material;\r\n }\r\n } finally {\r\n engine.disableScissor();\r\n }\r\n resolve();\r\n };\r\n this._scene.onBeforeRenderObservable.addOnce(attempt);\r\n });\r\n }\r\n\r\n /**\r\n * Whether the relayout copy shader is compiled and ready. Lazily creates the copy material on first call.\r\n * Callers should poll this before {@link relayoutSync} (which must only run when ready).\r\n * @returns true when {@link relayoutSync} can run this frame\r\n */\r\n public isRelayoutReady(): boolean {\r\n if (this._disposed) {\r\n return false;\r\n }\r\n if (!this._copyMaterial) {\r\n this._copyMaterial = this._createCopyMaterial();\r\n }\r\n // When SH is in use, the integer copy shader must also be compiled before a backup/restore/relayout can run.\r\n if (this._shMrts.length && !this._shCopyMaterial) {\r\n this._shCopyMaterial = this._createShCopyMaterial();\r\n }\r\n // Same for the rotation/scale 3-out float copy shader when rotation is in use.\r\n if (this._rotMrt && !this._rotCopyMaterial) {\r\n this._rotCopyMaterial = this._createRotCopyMaterial();\r\n }\r\n // `isReady` reports \"not ready\" when a bound sampler points at a disposed texture (a previous backup/relayout\r\n // binds its temp MRTs as sources, then frees them). The copy passes bind fresh textures every call, so re-point\r\n // the materials at the live atlas textures first; the check then reflects only whether the shader compiled.\r\n this._bindCopyMaterialsToAtlas();\r\n const shReady = this._shMrts.length === 0 || (this._shCopyMaterial !== null && this._shCopyMaterial.isReady(this._quad));\r\n const rotReady = !this._rotMrt || (this._rotCopyMaterial !== null && this._rotCopyMaterial.isReady(this._quad));\r\n return this._copyMaterial.isReady(this._quad) && shReady && rotReady;\r\n }\r\n\r\n /**\r\n * Re-points the relayout/backup copy materials' samplers at the live atlas textures (valid, never freed), so a\r\n * later {@link isRelayoutReady} check isn't tripped by a stale binding to a disposed temp/backup MRT.\r\n */\r\n private _bindCopyMaterialsToAtlas(): void {\r\n const t = this._mrt.textures;\r\n if (this._copyMaterial) {\r\n this._copyMaterial.setTexture(\"uMapTex\", t[0]);\r\n this._copyMaterial.setTexture(\"uSrc0\", t[0]);\r\n this._copyMaterial.setTexture(\"uSrc1\", t[1]);\r\n this._copyMaterial.setTexture(\"uSrc2\", t[2]);\r\n this._copyMaterial.setTexture(\"uSrc3\", t[3]);\r\n }\r\n if (this._shCopyMaterial && this._shMrts.length) {\r\n this._shCopyMaterial.setTexture(\"uMapTex\", t[0]);\r\n this._shCopyMaterial.setTexture(\"uSrcSh\", this._shMrts[0].textures[0]);\r\n }\r\n if (this._rotCopyMaterial && this._rotMrt) {\r\n const r = this._rotMrt.textures;\r\n this._rotCopyMaterial.setTexture(\"uMapTex\", t[0]);\r\n this._rotCopyMaterial.setTexture(\"uSrc0\", r[0]);\r\n this._rotCopyMaterial.setTexture(\"uSrc1\", r[1]);\r\n this._rotCopyMaterial.setTexture(\"uSrc2\", r[2]);\r\n }\r\n }\r\n\r\n /**\r\n * Relayouts the decoded work-buffer textures to a new (defragmented) splat layout, keeping the same\r\n * texture instances so the consuming mesh does not need to re-bind. `srcIndexByDst[d]` is the source splat\r\n * index whose decoded data should end up at destination index `d`, or a negative value for a gap (left\r\n * zeroed). Uses a temporary MRT ping-pong (old -> temp via the map, then temp -> old identity) so\r\n * overlapping moves stay correct. Must be called at a frame-safe point (inside `onBeforeRender`) and only\r\n * when {@link isRelayoutReady} returns true.\r\n * @param srcIndexByDst per-destination source splat index (negative = gap)\r\n */\r\n public relayoutSync(srcIndexByDst: Float32Array): void {\r\n if (this._disposed || !this._copyMaterial) {\r\n return;\r\n }\r\n // Map dimensions: standalone maps the whole square buffer; hosted maps just the region's rows.\r\n const width = this._textureSize;\r\n const mapW = width;\r\n const mapH = this._ownsMrt ? width : Math.max(1, Math.floor(this._capacity / width));\r\n // Reuse the map buffer + its GPU texture across relayouts (dimensions are fixed for a work buffer).\r\n if (!this._relayoutMapData) {\r\n this._relayoutMapData = new Float32Array(mapW * mapH);\r\n }\r\n const mapData = this._relayoutMapData;\r\n mapData.fill(-1);\r\n mapData.set(srcIndexByDst.subarray(0, Math.min(srcIndexByDst.length, mapData.length)));\r\n if (!this._relayoutMapTexture) {\r\n this._relayoutMapTexture = new RawTexture(\r\n mapData,\r\n mapW,\r\n mapH,\r\n Constants.TEXTUREFORMAT_R,\r\n this._scene,\r\n false,\r\n false,\r\n Constants.TEXTURE_NEAREST_SAMPLINGMODE,\r\n Constants.TEXTURETYPE_FLOAT\r\n );\r\n } else {\r\n this._relayoutMapTexture.update(mapData);\r\n }\r\n const mapTexture = this._relayoutMapTexture;\r\n\r\n if (this._ownsMrt) {\r\n // Standalone: the work buffer owns the whole square texture, so a full ping-pong is safe.\r\n const temp = this._createMrt(\"gsRelayoutTemp\", false);\r\n try {\r\n this._renderRelayoutPass(temp, this._mrt.textures, mapTexture, 1); // old -> temp via map (gaps cleared)\r\n this._renderRelayoutPass(this._mrt, temp.textures, mapTexture, 0); // temp -> old, identity full overwrite\r\n } finally {\r\n temp.dispose();\r\n }\r\n // Same ping-pong for each baked SH texture (integer copy, one temp per texture).\r\n if (this._shMrts.length && this._shCopyMaterial) {\r\n for (let k = 0; k < this._shMrts.length; k++) {\r\n const shTemp = this._createShMrt(\"gsShRelayoutTemp\", false);\r\n try {\r\n this._renderShCopyPass(shTemp, this._shMrts[k].textures[0], mapTexture, 1);\r\n this._renderShCopyPass(this._shMrts[k], shTemp.textures[0], mapTexture, 0);\r\n } finally {\r\n shTemp.dispose();\r\n }\r\n }\r\n }\r\n // Same ping-pong for the rotation/scale textures (3-out float copy).\r\n if (this._rotMrt && this._rotCopyMaterial) {\r\n const rotTemp = this._createRotMrt(\"gsRotRelayoutTemp\", false);\r\n try {\r\n this._renderRotCopyPass(rotTemp, this._rotMrt.textures, mapTexture, 1);\r\n this._renderRotCopyPass(this._rotMrt, rotTemp.textures, mapTexture, 0);\r\n } finally {\r\n rotTemp.dispose();\r\n }\r\n }\r\n this._quad.material = this._material;\r\n return;\r\n }\r\n\r\n // Hosted (shared compound atlas): scope the ping-pong to THIS region's row band so other parts are never\r\n // touched. `_baseOffset` and `_capacity` are row-aligned (reserveStreamingPart), so the band is exact.\r\n const baseRow = Math.floor(this._baseOffset / width);\r\n const regionRows = mapH;\r\n const engine = this._scene.getEngine();\r\n // Region-sized temp (width x regionRows) — memory stays proportional to the region, not the whole atlas.\r\n const temp = this._createMrt(\"gsRelayoutTemp\", false, width, regionRows);\r\n // One region-sized integer temp per baked SH texture (same ping-pong, integer format).\r\n const shTemps = this._shMrts.length && this._shCopyMaterial ? this._shMrts.map((_, k) => this._createShMrt(`gsShRelayoutTemp${k}`, false, width, regionRows)) : [];\r\n // One region-sized rotation temp (3-attachment float) when rotation is in use.\r\n const rotTemp = this._rotMrt && this._rotCopyMaterial ? this._createRotMrt(\"gsRotRelayoutTemp\", false, width, regionRows) : null;\r\n try {\r\n // Pass 1: atlas region -> temp via map. The map is region-local; uSrcBaseOffset shifts each source\r\n // index to its GLOBAL atlas texel (uSrcWidth = atlas width). Temp is exactly the band, so no scissor.\r\n this._renderRelayoutPass(temp, this._mrt.textures, mapTexture, 1, /*dstWidth*/ width, /*srcWidth*/ width, /*srcBaseOffset*/ this._baseOffset, /*dstBaseRow*/ 0);\r\n for (let k = 0; k < shTemps.length; k++) {\r\n this._renderShCopyPass(shTemps[k], this._shMrts[k].textures[0], mapTexture, 1, width, width, this._baseOffset, 0);\r\n }\r\n if (rotTemp) {\r\n this._renderRotCopyPass(rotTemp, this._rotMrt!.textures, mapTexture, 1, width, width, this._baseOffset, 0);\r\n }\r\n // Pass 2: temp -> atlas region, identity within the band. uDstBaseRow maps the atlas destination row\r\n // back into the region-local temp; the scissor confines writes to the band so static parts are safe.\r\n engine.enableScissor(0, baseRow, width, regionRows);\r\n try {\r\n this._renderRelayoutPass(this._mrt, temp.textures, mapTexture, 0, /*dstWidth*/ width, /*srcWidth*/ width, /*srcBaseOffset*/ 0, /*dstBaseRow*/ baseRow);\r\n for (let k = 0; k < shTemps.length; k++) {\r\n this._renderShCopyPass(this._shMrts[k], shTemps[k].textures[0], mapTexture, 0, width, width, 0, baseRow);\r\n }\r\n if (rotTemp) {\r\n this._renderRotCopyPass(this._rotMrt!, rotTemp.textures, mapTexture, 0, width, width, 0, baseRow);\r\n }\r\n } finally {\r\n engine.disableScissor();\r\n }\r\n } finally {\r\n temp.dispose();\r\n for (const t of shTemps) {\r\n t.dispose();\r\n }\r\n rotTemp?.dispose();\r\n this._quad.material = this._material;\r\n }\r\n }\r\n\r\n /**\r\n * Renders one relayout copy pass into the target MRT, sampling the given source textures.\r\n * @param target destination MRT\r\n * @param sources the four source work-buffer textures\r\n * @param mapTexture the R32F destination-to-source index map (only sampled when `useMap` is 1; any bound texture otherwise)\r\n * @param useMap 1 to read source indices from the map (gaps discarded), 0 for an identity copy\r\n * @param dstWidth destination width used to linearize the destination texel (defaults to the work-buffer size)\r\n * @param srcWidth source width used to convert a linear source index to a texel (defaults to the work-buffer size)\r\n * @param srcBaseOffset added to each mapped source index so a region-local map reads the correct global atlas texel (hosted relayout)\r\n * @param dstBaseRow subtracted from the destination row so an identity copy reads the region-local temp (hosted relayout)\r\n */\r\n private _renderRelayoutPass(\r\n target: MultiRenderTarget,\r\n sources: Texture[],\r\n mapTexture: BaseTexture,\r\n useMap: number,\r\n dstWidth: number = this._textureSize,\r\n srcWidth: number = this._textureSize,\r\n srcBaseOffset: number = 0,\r\n dstBaseRow: number = 0\r\n ): void {\r\n const material = this._copyMaterial!;\r\n material.setTexture(\"uMapTex\", mapTexture);\r\n material.setTexture(\"uSrc0\", sources[0]);\r\n material.setTexture(\"uSrc1\", sources[1]);\r\n material.setTexture(\"uSrc2\", sources[2]);\r\n material.setTexture(\"uSrc3\", sources[3]);\r\n material.setInt(\"uDstWidth\", dstWidth);\r\n material.setInt(\"uSrcWidth\", srcWidth);\r\n material.setInt(\"uUseMap\", useMap);\r\n material.setInt(\"uSrcBaseOffset\", srcBaseOffset);\r\n material.setInt(\"uDstBaseRow\", dstBaseRow);\r\n this._quad.material = material;\r\n target.renderList = [this._quad];\r\n target.render();\r\n }\r\n\r\n private _createCopyMaterial(): ShaderMaterial {\r\n const isWGSL = this._shaderLanguage === ShaderLanguage.WGSL;\r\n const material = new ShaderMaterial(\r\n GaussianSplattingWorkBufferRelayoutShaderName,\r\n this._scene,\r\n {\r\n vertexSource: isWGSL ? GaussianSplattingWorkBufferVertexShaderWGSL : GaussianSplattingWorkBufferVertexShaderGLSL,\r\n fragmentSource: isWGSL ? GaussianSplattingWorkBufferRelayoutFragmentShaderWGSL : GaussianSplattingWorkBufferRelayoutFragmentShaderGLSL,\r\n },\r\n {\r\n attributes: [\"position\"],\r\n uniforms: [\"uDstWidth\", \"uSrcWidth\", \"uUseMap\", \"uSrcBaseOffset\", \"uDstBaseRow\"],\r\n samplers: [\"uMapTex\", \"uSrc0\", \"uSrc1\", \"uSrc2\", \"uSrc3\"],\r\n shaderLanguage: this._shaderLanguage,\r\n }\r\n );\r\n material.backFaceCulling = false;\r\n material.disableDepthWrite = true;\r\n return material;\r\n }\r\n\r\n /**\r\n * Renders one INTEGER SH copy pass (one packed-u32 SH texture) into the target, sampling one integer source.\r\n * Same index/map/base math as {@link _renderRelayoutPass} but for the integer SH format.\r\n * @param target destination single-attachment integer MRT\r\n * @param srcSh the integer SH source texture\r\n * @param mapTexture the R32F destination-to-source index map (sampled only when `useMap` is 1)\r\n * @param useMap 1 to read source indices from the map (gaps discarded), 0 for an identity copy\r\n * @param dstWidth destination width used to linearize the destination texel\r\n * @param srcWidth source width used to convert a linear source index to a texel\r\n * @param srcBaseOffset added to each mapped source index (region-local map -> global atlas texel)\r\n * @param dstBaseRow subtracted from the destination row for an identity copy of a region-local temp\r\n */\r\n private _renderShCopyPass(\r\n target: MultiRenderTarget,\r\n srcSh: Texture,\r\n mapTexture: BaseTexture,\r\n useMap: number,\r\n dstWidth: number = this._textureSize,\r\n srcWidth: number = this._textureSize,\r\n srcBaseOffset: number = 0,\r\n dstBaseRow: number = 0\r\n ): void {\r\n const material = this._shCopyMaterial!;\r\n material.setTexture(\"uMapTex\", mapTexture);\r\n material.setTexture(\"uSrcSh\", srcSh);\r\n material.setInt(\"uDstWidth\", dstWidth);\r\n material.setInt(\"uSrcWidth\", srcWidth);\r\n material.setInt(\"uUseMap\", useMap);\r\n material.setInt(\"uSrcBaseOffset\", srcBaseOffset);\r\n material.setInt(\"uDstBaseRow\", dstBaseRow);\r\n this._quad.material = material;\r\n target.renderList = [this._quad];\r\n target.render();\r\n }\r\n\r\n private _createShCopyMaterial(): ShaderMaterial {\r\n const isWGSL = this._shaderLanguage === ShaderLanguage.WGSL;\r\n const material = new ShaderMaterial(\r\n GaussianSplattingWorkBufferShCopyShaderName,\r\n this._scene,\r\n {\r\n vertexSource: isWGSL ? GaussianSplattingWorkBufferVertexShaderWGSL : GaussianSplattingWorkBufferVertexShaderGLSL,\r\n fragmentSource: isWGSL ? GaussianSplattingWorkBufferShCopyFragmentShaderWGSL : GaussianSplattingWorkBufferShCopyFragmentShaderGLSL,\r\n },\r\n {\r\n attributes: [\"position\"],\r\n uniforms: [\"uDstWidth\", \"uSrcWidth\", \"uUseMap\", \"uSrcBaseOffset\", \"uDstBaseRow\"],\r\n samplers: [\"uMapTex\", \"uSrcSh\"],\r\n shaderLanguage: this._shaderLanguage,\r\n }\r\n );\r\n material.backFaceCulling = false;\r\n material.disableDepthWrite = true;\r\n return material;\r\n }\r\n\r\n /**\r\n * Renders one rotation/scale copy pass (the three half-float rotation textures) into the target. Same\r\n * index/map/base math as {@link _renderRelayoutPass} but with three attachments.\r\n * @param target destination 3-attachment MRT\r\n * @param sources the three source rotation textures ([rotA, rotB, rotScale])\r\n * @param mapTexture the R32F destination-to-source index map (sampled only when `useMap` is 1)\r\n * @param useMap 1 to read source indices from the map (gaps discarded), 0 for an identity copy\r\n * @param dstWidth destination width used to linearize the destination texel\r\n * @param srcWidth source width used to convert a linear source index to a texel\r\n * @param srcBaseOffset added to each mapped source index (region-local map -> global atlas texel)\r\n * @param dstBaseRow subtracted from the destination row for an identity copy of a region-local temp\r\n */\r\n private _renderRotCopyPass(\r\n target: MultiRenderTarget,\r\n sources: Texture[],\r\n mapTexture: BaseTexture,\r\n useMap: number,\r\n dstWidth: number = this._textureSize,\r\n srcWidth: number = this._textureSize,\r\n srcBaseOffset: number = 0,\r\n dstBaseRow: number = 0\r\n ): void {\r\n const material = this._rotCopyMaterial!;\r\n material.setTexture(\"uMapTex\", mapTexture);\r\n material.setTexture(\"uSrc0\", sources[0]);\r\n material.setTexture(\"uSrc1\", sources[1]);\r\n material.setTexture(\"uSrc2\", sources[2]);\r\n material.setInt(\"uDstWidth\", dstWidth);\r\n material.setInt(\"uSrcWidth\", srcWidth);\r\n material.setInt(\"uUseMap\", useMap);\r\n material.setInt(\"uSrcBaseOffset\", srcBaseOffset);\r\n material.setInt(\"uDstBaseRow\", dstBaseRow);\r\n this._quad.material = material;\r\n target.renderList = [this._quad];\r\n target.render();\r\n }\r\n\r\n private _createRotCopyMaterial(): ShaderMaterial {\r\n const isWGSL = this._shaderLanguage === ShaderLanguage.WGSL;\r\n const material = new ShaderMaterial(\r\n GaussianSplattingWorkBufferRotCopyShaderName,\r\n this._scene,\r\n {\r\n vertexSource: isWGSL ? GaussianSplattingWorkBufferVertexShaderWGSL : GaussianSplattingWorkBufferVertexShaderGLSL,\r\n fragmentSource: isWGSL ? GaussianSplattingWorkBufferRotCopyFragmentShaderWGSL : GaussianSplattingWorkBufferRotCopyFragmentShaderGLSL,\r\n },\r\n {\r\n attributes: [\"position\"],\r\n uniforms: [\"uDstWidth\", \"uSrcWidth\", \"uUseMap\", \"uSrcBaseOffset\", \"uDstBaseRow\"],\r\n samplers: [\"uMapTex\", \"uSrc0\", \"uSrc1\", \"uSrc2\"],\r\n shaderLanguage: this._shaderLanguage,\r\n }\r\n );\r\n material.backFaceCulling = false;\r\n material.disableDepthWrite = true;\r\n return material;\r\n }\r\n\r\n /**\r\n * Asynchronously reads back the decoded splat centers (stride-4 xyzw, w=1) for a contiguous splat range\r\n * from the work buffer's centers texture, using a non-blocking GPU readback (WebGL2 PBO + fence, or WebGPU\r\n * copyTextureToBuffer + mapAsync) so it never stalls the frame the way a CPU image decode does. The centers\r\n * texture already holds the GPU-decoded positions (identical to the CPU decode), so this replaces decoding\r\n * positions on the CPU from the means images. Returns null when async readback is unsupported (caller should\r\n * fall back to CPU decoding).\r\n * @param splatOffset first splat index of the range\r\n * @param splatCount number of splats in the range\r\n * @returns a stride-4 Float32Array of length `splatCount * 4`, or null when unsupported/failed\r\n */\r\n public async readCentersRangeAsync(splatOffset: number, splatCount: number): Promise<Nullable<Float32Array>> {\r\n if (this._disposed || splatCount <= 0 || !this.supportsAsyncCentersReadback) {\r\n return null;\r\n }\r\n\r\n const width = this._textureSize;\r\n // Shift the region-local offset by the atlas base so the readback targets the same global texels the\r\n // decode wrote (0 base for a standalone work buffer).\r\n const globalOffset = this._baseOffset + splatOffset;\r\n // The range maps to whole texel rows [rowStart, rowEnd); read that rectangle and slice the exact range.\r\n // Splat i lives at texel (i % width, floor(i / width)) in both decode and draw, so the readback (which\r\n // indexes the same texture storage directly, with no UV/flip) yields splat i at buffer position\r\n // i - rowStart * width on every backend.\r\n const rowStart = Math.floor(globalOffset / width);\r\n const rowEnd = Math.ceil((globalOffset + splatCount) / width);\r\n const rowCount = rowEnd - rowStart;\r\n const startInBuffer = (globalOffset - rowStart * width) * 4;\r\n const sliceEnd = startInBuffer + splatCount * 4;\r\n const centers = this._mrt.textures[0];\r\n\r\n const engine = this._scene.getEngine();\r\n\r\n if (engine.isWebGPU) {\r\n // WebGPU: copyTextureToBuffer of the row span + mapAsync (genuinely non-blocking). noDataConversion\r\n // returns the raw RGBA32F floats tightly packed (the 256-byte row alignment is removed internally).\r\n const result = await centers.readPixels(0, 0, null, true, true, 0, rowStart, width, rowCount);\r\n if (this._disposed || !result) {\r\n return null;\r\n }\r\n const floats = result instanceof Float32Array ? result : new Float32Array(result.buffer, result.byteOffset, result.byteLength / 4);\r\n return floats.length >= sliceEnd ? (floats.subarray(startInBuffer, sliceEnd) as Float32Array) : null;\r\n }\r\n\r\n // WebGL2: read directly from the centers texture via a reused FBO + async PBO readback.\r\n const glEngine = engine as unknown as {\r\n _gl: WebGL2RenderingContext;\r\n _currentFramebuffer: Nullable<WebGLFramebuffer>;\r\n _readPixelsAsync(x: number, y: number, w: number, h: number, format: number, type: number, o: ArrayBufferView): Nullable<Promise<ArrayBufferView>>;\r\n };\r\n const gl = glEngine._gl;\r\n const hardware = centers.getInternalTexture()?._hardwareTexture?.underlyingResource as Nullable<WebGLTexture>;\r\n if (!hardware) {\r\n return null;\r\n }\r\n const buffer = new Float32Array(width * rowCount * 4);\r\n if (!this._readFbo) {\r\n this._readFbo = gl.createFramebuffer();\r\n }\r\n const previousFbo = glEngine._currentFramebuffer;\r\n gl.bindFramebuffer(gl.FRAMEBUFFER, this._readFbo);\r\n gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_2D, hardware, 0);\r\n gl.readBuffer(gl.COLOR_ATTACHMENT0);\r\n\r\n // _readPixelsAsync issues the readPixels into a PBO synchronously, then resolves once the GPU fence\r\n // signals — so the framebuffer can be restored immediately while the transfer completes off-thread.\r\n const promise = glEngine._readPixelsAsync(0, rowStart, width, rowCount, gl.RGBA, gl.FLOAT, buffer);\r\n gl.bindFramebuffer(gl.FRAMEBUFFER, previousFbo);\r\n // gl.readBuffer is global state: restore the default-framebuffer read source (BACK) so later\r\n // readPixels on the default framebuffer aren't left pointing at COLOR_ATTACHMENT0. When restoring to\r\n // another FBO, COLOR_ATTACHMENT0 is the correct default read buffer, so only reset for the default one.\r\n if (!previousFbo) {\r\n gl.readBuffer(gl.BACK);\r\n }\r\n if (!promise) {\r\n return null;\r\n }\r\n await promise;\r\n if (this._disposed || buffer.length < sliceEnd) {\r\n return null;\r\n }\r\n return buffer.subarray(startInBuffer, sliceEnd) as Float32Array;\r\n }\r\n\r\n /**\r\n * Disposes the work buffer and its decode resources.\r\n */\r\n public dispose(): void {\r\n this._disposed = true;\r\n if (this._readFbo) {\r\n (this._scene.getEngine() as unknown as { _gl?: WebGL2RenderingContext })._gl?.deleteFramebuffer(this._readFbo);\r\n this._readFbo = null;\r\n }\r\n this._quad.dispose();\r\n this._material.dispose(true, false);\r\n this._shMaterial?.dispose(true, false);\r\n this._rotMaterial?.dispose(true, false);\r\n this._copyMaterial?.dispose(true, false);\r\n this._shCopyMaterial?.dispose(true, false);\r\n this._rotCopyMaterial?.dispose(true, false);\r\n this._relayoutMapTexture?.dispose();\r\n this._backupMrt?.dispose();\r\n this._backupMrt = null;\r\n if (this._backupShMrts) {\r\n for (const mrt of this._backupShMrts) {\r\n mrt.dispose();\r\n }\r\n this._backupShMrts = null;\r\n }\r\n this._backupRotMrt?.dispose();\r\n this._backupRotMrt = null;\r\n // Only dispose the MRT when we own it; an external atlas belongs to the hosting compound mesh.\r\n if (this._ownsMrt) {\r\n this._mrt.dispose();\r\n }\r\n // Same ownership rule for the SH targets (standalone owns; hosted borrows the compound's shared SH atlas).\r\n if (this._ownsShMrts) {\r\n for (const mrt of this._shMrts) {\r\n mrt.dispose();\r\n }\r\n }\r\n this._shMrts = [];\r\n // Same ownership rule for the rotation target.\r\n if (this._ownsRotMrt) {\r\n this._rotMrt?.dispose();\r\n }\r\n this._rotMrt = null;\r\n }\r\n\r\n private _createQuad(): Mesh {\r\n const quad = new Mesh(\"gsWorkBufferQuad\", this._scene);\r\n const vertexData = new VertexData();\r\n // Fullscreen triangle in clip space (the vertex shader passes positions straight through).\r\n vertexData.positions = [-1, -1, 0, 3, -1, 0, -1, 3, 0];\r\n vertexData.indices = [0, 1, 2];\r\n vertexData.applyToMesh(quad);\r\n // Render only inside the work-buffer MRT, never in the main scene pass.\r\n this._scene.removeMesh(quad);\r\n return quad;\r\n }\r\n\r\n private _createMaterial(): ShaderMaterial {\r\n const isWGSL = this._shaderLanguage === ShaderLanguage.WGSL;\r\n const material = new ShaderMaterial(\r\n \"gsSogDecode\",\r\n this._scene,\r\n {\r\n vertexSource: isWGSL ? GaussianSplattingWorkBufferVertexShaderWGSL : GaussianSplattingWorkBufferVertexShaderGLSL,\r\n fragmentSource: isWGSL ? GaussianSplattingWorkBufferFragmentShaderWGSL : GaussianSplattingWorkBufferFragmentShaderGLSL,\r\n },\r\n {\r\n attributes: [\"position\"],\r\n uniforms: [\"sogMeansMin\", \"sogMeansMax\", \"sogScalesMin\", \"sogScalesMax\", \"sogSh0Min\", \"sogSh0Max\", \"uVersion\", \"uOffset\", \"uCount\", \"uDestWidth\", \"uSrcWidth\"],\r\n samplers: [\"sogMeansLTex\", \"sogMeansUTex\", \"sogScalesTex\", \"sogQuatsTex\", \"sogSh0Tex\", \"sogCodebookTex\"],\r\n shaderLanguage: this._shaderLanguage,\r\n }\r\n );\r\n material.backFaceCulling = false;\r\n material.disableDepthWrite = true;\r\n return material;\r\n }\r\n\r\n private _applyPack(pack: ISogTexturePack): void {\r\n const material = this._material;\r\n const srcWidth = (pack.meansTextureL as Texture).getSize().width;\r\n\r\n material.setTexture(\"sogMeansLTex\", pack.meansTextureL);\r\n material.setTexture(\"sogMeansUTex\", pack.meansTextureU);\r\n material.setTexture(\"sogScalesTex\", pack.scalesTexture);\r\n material.setTexture(\"sogQuatsTex\", pack.quatsTexture);\r\n material.setTexture(\"sogSh0Tex\", pack.sh0Texture);\r\n // Codebook only used for v2; bind a harmless placeholder otherwise so the sampler is always set.\r\n material.setTexture(\"sogCodebookTex\", pack.codebookTexture ?? pack.sh0Texture);\r\n\r\n material.setVector3(\"sogMeansMin\", new Vector3(pack.meansMin[0], pack.meansMin[1], pack.meansMin[2]));\r\n material.setVector3(\"sogMeansMax\", new Vector3(pack.meansMax[0], pack.meansMax[1], pack.meansMax[2]));\r\n const sMin = pack.scalesMin ?? [0, 0, 0];\r\n const sMax = pack.scalesMax ?? [0, 0, 0];\r\n material.setVector3(\"sogScalesMin\", new Vector3(sMin[0], sMin[1], sMin[2]));\r\n material.setVector3(\"sogScalesMax\", new Vector3(sMax[0], sMax[1], sMax[2]));\r\n const c0Min = pack.sh0Min ?? [0, 0, 0, 0];\r\n const c0Max = pack.sh0Max ?? [0, 0, 0, 0];\r\n material.setVector4(\"sogSh0Min\", new Vector4(c0Min[0], c0Min[1], c0Min[2], c0Min[3]));\r\n material.setVector4(\"sogSh0Max\", new Vector4(c0Max[0], c0Max[1], c0Max[2], c0Max[3]));\r\n\r\n material.setInt(\"uVersion\", pack.version);\r\n // uOffset is bound at render time in decodeAsync (from the live _baseOffset).\r\n material.setInt(\"uCount\", pack.splatCount);\r\n material.setInt(\"uDestWidth\", this._textureSize);\r\n material.setInt(\"uSrcWidth\", srcWidth);\r\n }\r\n\r\n private _createShMaterial(): ShaderMaterial {\r\n const isWGSL = this._shaderLanguage === ShaderLanguage.WGSL;\r\n const material = new ShaderMaterial(\r\n GaussianSplattingWorkBufferShDecodeShaderName,\r\n this._scene,\r\n {\r\n vertexSource: isWGSL ? GaussianSplattingWorkBufferVertexShaderWGSL : GaussianSplattingWorkBufferVertexShaderGLSL,\r\n fragmentSource: isWGSL ? GaussianSplattingWorkBufferShDecodeFragmentShaderWGSL : GaussianSplattingWorkBufferShDecodeFragmentShaderGLSL,\r\n },\r\n {\r\n attributes: [\"position\"],\r\n uniforms: [\"sogShnMin\", \"sogShnMax\", \"uVersion\", \"uOffset\", \"uCount\", \"uDestWidth\", \"uSrcWidth\", \"uCoeffs\", \"uShTextureIndex\"],\r\n samplers: [\"sogShLabelsTex\", \"sogShCentroidsTex\", \"sogCodebookTex\"],\r\n shaderLanguage: this._shaderLanguage,\r\n }\r\n );\r\n material.backFaceCulling = false;\r\n material.disableDepthWrite = true;\r\n return material;\r\n }\r\n\r\n private _applyShPack(pack: ISogTexturePack): void {\r\n const material = this._shMaterial!;\r\n // A file may carry no higher-order SH (coarse LOD): fall back to sh0Texture as a harmless placeholder for the\r\n // label/centroid samplers and set uCoeffs=0 so the shader neutral-fills every coefficient (128 -> 0 lighting).\r\n const hasSh = !!pack.shLabelsTexture && !!pack.shCentroidsTexture;\r\n const labels = pack.shLabelsTexture ?? pack.sh0Texture;\r\n const centroids = pack.shCentroidsTexture ?? pack.sh0Texture;\r\n material.setTexture(\"sogShLabelsTex\", labels);\r\n material.setTexture(\"sogShCentroidsTex\", centroids);\r\n // Codebook only used for v2; bind a harmless placeholder otherwise so the sampler is always set.\r\n material.setTexture(\"sogCodebookTex\", pack.codebookTexture ?? labels);\r\n material.setFloat(\"sogShnMin\", pack.shnMin ?? 0);\r\n material.setFloat(\"sogShnMax\", pack.shnMax ?? 0);\r\n material.setInt(\"uVersion\", pack.version);\r\n // uOffset is bound at render time in decodeAsync (from the live _baseOffset).\r\n material.setInt(\"uCount\", pack.splatCount);\r\n material.setInt(\"uDestWidth\", this._textureSize);\r\n material.setInt(\"uSrcWidth\", (labels as Texture).getSize().width);\r\n // Higher-order coefficient count for THIS file (bands=3 -> 15). 0 when the file has no SH -> full neutral fill.\r\n material.setInt(\"uCoeffs\", hasSh ? pack.shCoeffCount : 0);\r\n }\r\n\r\n private _createRotMaterial(): ShaderMaterial {\r\n const isWGSL = this._shaderLanguage === ShaderLanguage.WGSL;\r\n const material = new ShaderMaterial(\r\n GaussianSplattingWorkBufferRotationDecodeShaderName,\r\n this._scene,\r\n {\r\n vertexSource: isWGSL ? GaussianSplattingWorkBufferVertexShaderWGSL : GaussianSplattingWorkBufferVertexShaderGLSL,\r\n fragmentSource: isWGSL ? GaussianSplattingWorkBufferRotationDecodeFragmentShaderWGSL : GaussianSplattingWorkBufferRotationDecodeFragmentShaderGLSL,\r\n },\r\n {\r\n attributes: [\"position\"],\r\n uniforms: [\"sogScalesMin\", \"sogScalesMax\", \"uVersion\", \"uOffset\", \"uCount\", \"uDestWidth\", \"uSrcWidth\"],\r\n samplers: [\"sogScalesTex\", \"sogQuatsTex\", \"sogCodebookTex\"],\r\n shaderLanguage: this._shaderLanguage,\r\n }\r\n );\r\n material.backFaceCulling = false;\r\n material.disableDepthWrite = true;\r\n return material;\r\n }\r\n\r\n private _applyRotPack(pack: ISogTexturePack): void {\r\n const material = this._rotMaterial!;\r\n const srcWidth = (pack.scalesTexture as Texture).getSize().width;\r\n material.setTexture(\"sogScalesTex\", pack.scalesTexture);\r\n material.setTexture(\"sogQuatsTex\", pack.quatsTexture);\r\n // Codebook only used for v2; bind a harmless placeholder otherwise so the sampler is always set.\r\n material.setTexture(\"sogCodebookTex\", pack.codebookTexture ?? pack.scalesTexture);\r\n const sMin = pack.scalesMin ?? [0, 0, 0];\r\n const sMax = pack.scalesMax ?? [0, 0, 0];\r\n material.setVector3(\"sogScalesMin\", new Vector3(sMin[0], sMin[1], sMin[2]));\r\n material.setVector3(\"sogScalesMax\", new Vector3(sMax[0], sMax[1], sMax[2]));\r\n material.setInt(\"uVersion\", pack.version);\r\n // uOffset is bound at render time in decodeAsync (from the live _baseOffset).\r\n material.setInt(\"uCount\", pack.splatCount);\r\n material.setInt(\"uDestWidth\", this._textureSize);\r\n material.setInt(\"uSrcWidth\", srcWidth);\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"gaussianSplattingWorkBuffer.js","sourceRoot":"","sources":["../../../../dev/loaders/src/SPLAT/gaussianSplattingWorkBuffer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAC1C,OAAO,EAAE,iBAAiB,EAAE,MAAM,2CAA2C,CAAC;AAC9E,OAAO,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAC;AAE/D,OAAO,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AACnD,OAAO,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AACxC,OAAO,EAAE,UAAU,EAAE,MAAM,6BAA6B,CAAC;AACzD,OAAO,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAC/C,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAC;AAM1D,OAAO,EACH,2CAA2C,EAC3C,6CAA6C,EAC7C,2CAA2C,EAC3C,6CAA6C,EAC7C,qDAAqD,EACrD,qDAAqD,EACrD,6CAA6C,EAC7C,6CAA6C,EAC7C,qDAAqD,EACrD,qDAAqD,EACrD,2CAA2C,EAC3C,mDAAmD,EACnD,mDAAmD,EACnD,mDAAmD,EACnD,2DAA2D,EAC3D,2DAA2D,EAC3D,4CAA4C,EAC5C,oDAAoD,EACpD,oDAAoD,GACvD,MAAM,sCAAsC,CAAC;AAC9C,OAAO,EAAE,UAAU,EAAE,MAAM,oCAAoC,CAAC;AAEhE;;;;;;;;;GASG;AACH,MAAM,OAAO,2BAA2B;IA4DpC;;;;OAIG;IACH,IAAW,4BAA4B;QACnC,MAAM,MAAM,GAAG,IAAI,CAAC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O,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;QAC5E,QAAQ,CAAC,UAAU,CAAC,cAAc,EAAE,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;QAC5E,QAAQ,CAAC,MAAM,CAAC,UAAU,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC;QAC1C,8EAA8E;QAC9E,QAAQ,CAAC,MAAM,CAAC,eAAe,EAAE,YAAY,CAAC,CAAC;QAC/C,QAAQ,CAAC,MAAM,CAAC,QAAQ,EAAE,KAAK,CAAC,CAAC;QACjC,QAAQ,CAAC,MAAM,CAAC,YAAY,EAAE,IAAI,CAAC,YAAY,CAAC,CAAC;QACjD,QAAQ,CAAC,MAAM,CAAC,WAAW,EAAE,QAAQ,CAAC,CAAC;IAC3C,CAAC;CACJ","sourcesContent":["import { Logger } from \"core/Misc/logger\";\r\nimport { MultiRenderTarget } from \"core/Materials/Textures/multiRenderTarget\";\r\nimport { ShaderMaterial } from \"core/Materials/shaderMaterial\";\r\nimport { ShaderLanguage } from \"core/Materials/shaderLanguage\";\r\nimport { Constants } from \"core/Engines/constants\";\r\nimport { Mesh } from \"core/Meshes/mesh\";\r\nimport { VertexData } from \"core/Meshes/mesh.vertexData\";\r\nimport { Color4 } from \"core/Maths/math.color\";\r\nimport { Vector3, Vector4 } from \"core/Maths/math.vector\";\r\nimport { type Texture } from \"core/Materials/Textures/texture\";\r\nimport { type BaseTexture } from \"core/Materials/Textures/baseTexture\";\r\nimport { type Scene } from \"core/scene\";\r\nimport { type Nullable } from \"core/types\";\r\nimport { type ISogTexturePack } from \"./splatDefs\";\r\nimport {\r\n GaussianSplattingWorkBufferVertexShaderGLSL,\r\n GaussianSplattingWorkBufferFragmentShaderGLSL,\r\n GaussianSplattingWorkBufferVertexShaderWGSL,\r\n GaussianSplattingWorkBufferFragmentShaderWGSL,\r\n GaussianSplattingWorkBufferRelayoutFragmentShaderGLSL,\r\n GaussianSplattingWorkBufferRelayoutFragmentShaderWGSL,\r\n GaussianSplattingWorkBufferRelayoutShaderName,\r\n GaussianSplattingWorkBufferShDecodeShaderName,\r\n GaussianSplattingWorkBufferShDecodeFragmentShaderGLSL,\r\n GaussianSplattingWorkBufferShDecodeFragmentShaderWGSL,\r\n GaussianSplattingWorkBufferShCopyShaderName,\r\n GaussianSplattingWorkBufferShCopyFragmentShaderGLSL,\r\n GaussianSplattingWorkBufferShCopyFragmentShaderWGSL,\r\n GaussianSplattingWorkBufferRotationDecodeShaderName,\r\n GaussianSplattingWorkBufferRotationDecodeFragmentShaderGLSL,\r\n GaussianSplattingWorkBufferRotationDecodeFragmentShaderWGSL,\r\n GaussianSplattingWorkBufferRotCopyShaderName,\r\n GaussianSplattingWorkBufferRotCopyFragmentShaderGLSL,\r\n GaussianSplattingWorkBufferRotCopyFragmentShaderWGSL,\r\n} from \"./gaussianSplattingWorkBufferShaders\";\r\nimport { RawTexture } from \"core/Materials/Textures/rawTexture\";\r\n\r\n/**\r\n * A unified, GPU-decoded Gaussian Splatting work buffer.\r\n *\r\n * Holds a square MRT texture set (centers / covA / covB / colors) sized to a fixed splat capacity\r\n * (`ceil(sqrt(capacity))`). Each streamed SOG file is decoded directly on the GPU\r\n * (no CPU readback) into its allocated pixel range. The decoded textures are consumed unchanged by the\r\n * standard (non-SOG) Gaussian Splatting draw path.\r\n *\r\n * @experimental\r\n */\r\nexport class GaussianSplattingWorkBuffer {\r\n private readonly _scene: Scene;\r\n // Not readonly: a hosted work buffer is rebound to the compound's NEW atlas MRT after a grow (see rebindAtlas).\r\n private _mrt: MultiRenderTarget;\r\n private readonly _textureSize: number;\r\n private readonly _shaderLanguage: ShaderLanguage;\r\n private readonly _material: ShaderMaterial;\r\n private readonly _quad: Mesh;\r\n // When true this work buffer owns (and disposes) its MRT. False when it wraps an external atlas (a compound\r\n // mesh's MRT) it must not dispose. In the external case the MRT is wide (dstWidth x atlasHeight), decodes are\r\n // offset by _baseOffset (the reserved region's first splat), and _textureSize is the atlas WIDTH.\r\n private readonly _ownsMrt: boolean;\r\n // Not readonly: a hosted region can be RELOCATED to a new base when the compound compacts its atlas\r\n // (reclaiming a removed part's rows). backupRegion() reads from the old base, setBaseOffset() updates it,\r\n // then rebindAtlas() + restoreRegion() writes to the new base.\r\n private _baseOffset: number;\r\n // Splat count this work buffer addresses. Standalone: the whole (square) buffer. Hosted: the reserved\r\n // region's (row-aligned) capacity — used to scope a relayout to the region's atlas rows.\r\n private readonly _capacity: number;\r\n // Relayout (defrag) copy material, created lazily on first relayout.\r\n private _copyMaterial: Nullable<ShaderMaterial> = null;\r\n // Reusable destination->source index map for the relayout pass (created lazily, sized to the work buffer).\r\n private _relayoutMapData: Nullable<Float32Array> = null;\r\n private _relayoutMapTexture: Nullable<RawTexture> = null;\r\n // Transient backup of a hosted region's four textures, held between backupRegion() and restoreRegion() so the\r\n // GPU-decoded data survives the compound recreating its atlas on a grow (adding a part / a second stream).\r\n private _backupMrt: Nullable<MultiRenderTarget> = null;\r\n private _disposed = false;\r\n // Reused WebGL framebuffer for the async centers readback (created lazily, freed in dispose).\r\n private _readFbo: Nullable<WebGLFramebuffer> = null;\r\n\r\n // Higher-order spherical-harmonics. Each SH texture is its own single-attachment integer render target\r\n // (RGBA_INTEGER/UNSIGNED_INTEGER, 16 SH scalar-bytes per texel) so a decode/relayout pass writes exactly one\r\n // attachment, keeping within WebGPU's per-sample color-attachment byte budget. Empty when SH is off.\r\n private _shMrts: MultiRenderTarget[] = [];\r\n // True when this work buffer owns (and disposes) its SH render targets (standalone). False when they are the\r\n // hosting compound's shared SH atlas (hosted) — borrowed, not disposed. Rebound alongside the core atlas.\r\n private _ownsShMrts = false;\r\n // The SH decode material (packed-u32 dequant), created only when SH is requested. Reused across files/passes.\r\n private _shMaterial: Nullable<ShaderMaterial> = null;\r\n // Integer SH relayout/backup copy material (usampler2D -> uvec4), created lazily alongside the float copy.\r\n private _shCopyMaterial: Nullable<ShaderMaterial> = null;\r\n // Transient region-sized integer backups of the SH textures, held between backupRegion() and restoreRegion()\r\n // so the baked SH survives the compound recreating its SH atlas on a grow/compaction (parallel to _backupMrt).\r\n private _backupShMrts: Nullable<MultiRenderTarget[]> = null;\r\n\r\n // Rotation/scale. One 3-attachment half-float render target (rotA / rotB / rotScale) holding the per-splat\r\n // rotation matrix + scale that voxel-based IBL shadowing consumes. Null when rotation decode is off.\r\n private _rotMrt: Nullable<MultiRenderTarget> = null;\r\n // True when this work buffer owns (and disposes) its rotation target (standalone). False when it is the hosting\r\n // compound's shared rotation atlas (hosted) — borrowed, rebound alongside the core atlas, never disposed here.\r\n private _ownsRotMrt = false;\r\n // The rotation/scale decode material, created only when rotation is requested. Reused across files.\r\n private _rotMaterial: Nullable<ShaderMaterial> = null;\r\n // Rotation/scale relayout/backup copy material (3-out float copy), created lazily alongside the float copy.\r\n private _rotCopyMaterial: Nullable<ShaderMaterial> = null;\r\n // Transient region-sized backup of the rotation textures, held between backupRegion() and restoreRegion() so the\r\n // decoded rotation/scale survives the compound recreating its rotation atlas on a grow/compaction.\r\n private _backupRotMrt: Nullable<MultiRenderTarget> = null;\r\n\r\n /**\r\n * True when the engine supports the non-blocking GPU readback used by {@link readCentersRangeAsync}:\r\n * WebGL2 (PBO + fence) or WebGPU (copyTextureToBuffer + mapAsync). When false (e.g. WebGL1), callers must\r\n * decode positions on the CPU instead.\r\n */\r\n public get supportsAsyncCentersReadback(): boolean {\r\n const engine = this._scene.getEngine();\r\n if (engine.isWebGPU) {\r\n return true;\r\n }\r\n const glEngine = engine as unknown as { _gl?: WebGL2RenderingContext; _readPixelsAsync?: unknown; webGLVersion?: number };\r\n return !!glEngine._gl && typeof glEngine._readPixelsAsync === \"function\" && (glEngine.webGLVersion ?? 0) >= 2;\r\n }\r\n\r\n /**\r\n * Square edge length (in pixels) of the work-buffer textures.\r\n */\r\n public get textureSize(): number {\r\n return this._textureSize;\r\n }\r\n\r\n /**\r\n * The decoded work-buffer textures: [centers, covA, covB, colors].\r\n */\r\n public get textures(): Texture[] {\r\n return this._mrt.textures;\r\n }\r\n\r\n /**\r\n * The baked higher-order SH textures (packed-u32, one per `ceil(coeffs*3/16)`), consumed by the draw path's\r\n * `computeSHWeighted`/`decompose` as `shTexture0..N`. Empty when SH decoding is not enabled.\r\n */\r\n public get shTextures(): Texture[] {\r\n return this._shMrts.map((m) => m.textures[0]);\r\n }\r\n\r\n /**\r\n * The decoded rotation/scale textures ([rotationsA, rotationsB, rotationScale], half-float), consumed by the\r\n * voxel-IBL path as `rotationsATexture`/`rotationsBTexture`/`rotationScaleTexture`. Empty when rotation decode\r\n * is not enabled.\r\n */\r\n public get rotationTextures(): Texture[] {\r\n return this._rotMrt ? this._rotMrt.textures : [];\r\n }\r\n\r\n /**\r\n * Creates a work buffer sized to hold `capacity` splats.\r\n *\r\n * Standalone (default): the work buffer creates and owns a square MRT sized `ceil(sqrt(capacity))`, with\r\n * decodes addressed from splat 0.\r\n *\r\n * Hosted (`externalAtlas` provided): the work buffer decodes/reads back into an externally-owned MRT (a\r\n * compound mesh's shared atlas) instead of creating its own. Decodes are placed at `externalAtlas.baseOffset`\r\n * (the reserved region's first splat) and addressed over `externalAtlas.width` (the wide atlas width), so the\r\n * streamed splats land in the compound's atlas and sort/draw together with the static parts.\r\n * @param scene hosting scene\r\n * @param capacity total number of splats the work buffer must address\r\n * @param externalAtlas optional external atlas to decode into instead of creating an owned square MRT\r\n * @param sh optional higher-order SH decode configuration. `textureCount = ceil(coeffs*3/16)` for the max SH\r\n * degree across the streamed files. Standalone: the work buffer creates that many owned single-attachment\r\n * integer render targets. Hosted: `externalMrts` are the compound's shared SH atlas targets (borrowed).\r\n * @param rotationScale optional rotation/scale decode configuration (for voxel-IBL shadows). When present the\r\n * work buffer decodes each splat's rotation matrix + scale into a 3-attachment half-float target. Standalone:\r\n * the work buffer creates and owns that target. Hosted: `externalMrt` is the compound's shared rotation atlas.\r\n */\r\n constructor(\r\n scene: Scene,\r\n capacity: number,\r\n externalAtlas?: { mrt: MultiRenderTarget; width: number; baseOffset: number },\r\n sh?: { textureCount: number; externalMrts?: MultiRenderTarget[] },\r\n rotationScale?: { externalMrt?: MultiRenderTarget }\r\n ) {\r\n this._scene = scene;\r\n this._shaderLanguage = scene.getEngine().isWebGPU ? ShaderLanguage.WGSL : ShaderLanguage.GLSL;\r\n this._capacity = Math.max(1, capacity);\r\n\r\n if (externalAtlas) {\r\n this._mrt = externalAtlas.mrt;\r\n this._textureSize = externalAtlas.width;\r\n this._baseOffset = externalAtlas.baseOffset;\r\n this._ownsMrt = false;\r\n } else {\r\n this._textureSize = Math.max(1, Math.ceil(Math.sqrt(Math.max(1, capacity))));\r\n this._baseOffset = 0;\r\n this._ownsMrt = true;\r\n // The decode buffer accumulates (clear disabled) so each decode preserves previously-decoded files.\r\n this._mrt = this._createMrt(\"gsWorkBuffer\", true);\r\n }\r\n\r\n // Higher-order SH: one single-attachment integer target per packed-u32 SH texture. Standalone owns square\r\n // targets sized like the core atlas; hosted borrows the compound's wide shared SH atlas targets.\r\n if (sh && sh.textureCount > 0) {\r\n if (sh.externalMrts) {\r\n this._shMrts = sh.externalMrts.slice(0, sh.textureCount);\r\n this._ownsShMrts = false;\r\n } else {\r\n for (let k = 0; k < sh.textureCount; k++) {\r\n this._shMrts.push(this._createShMrt(`gsWorkBufferSh${k}`, true));\r\n }\r\n this._ownsShMrts = true;\r\n }\r\n this._shMaterial = this._createShMaterial();\r\n }\r\n\r\n // Rotation/scale: one 3-attachment half-float target. Standalone owns a square target sized like the core\r\n // atlas; hosted borrows the compound's wide shared rotation atlas.\r\n if (rotationScale) {\r\n if (rotationScale.externalMrt) {\r\n this._rotMrt = rotationScale.externalMrt;\r\n this._ownsRotMrt = false;\r\n } else {\r\n this._rotMrt = this._createRotMrt(\"gsWorkBufferRot\", true);\r\n this._ownsRotMrt = true;\r\n }\r\n this._rotMaterial = this._createRotMaterial();\r\n }\r\n\r\n // One persistent decode material + fullscreen-triangle quad, reused (with per-file uniforms)\r\n // for every decode so the shader is compiled only once.\r\n this._material = this._createMaterial();\r\n this._quad = this._createQuad();\r\n this._quad.material = this._material;\r\n\r\n // Hosted: start compiling the copy shader now so backupRegion()/restoreRegion() are ready by the time\r\n // the compound grows its atlas (a synchronous, non-frame-driven event we can't wait on).\r\n if (!this._ownsMrt) {\r\n this.isRelayoutReady();\r\n }\r\n }\r\n\r\n /**\r\n * Rebinds a hosted work buffer to a new atlas MRT (after the compound recreated it on a grow). No-op for a\r\n * standalone work buffer, which owns its MRT.\r\n * @param mrt the compound's new shared atlas\r\n */\r\n public rebindAtlas(mrt: MultiRenderTarget): void {\r\n if (!this._ownsMrt) {\r\n this._mrt = mrt;\r\n }\r\n }\r\n\r\n /**\r\n * Rebinds a hosted work buffer to the compound's NEW shared SH atlas (after the compound recreated it on a\r\n * grow/compaction). No-op when SH isn't in use or the work buffer owns its SH targets (standalone).\r\n * @param shMrts the compound's new shared SH render targets (one per packed-u32 SH texture)\r\n */\r\n public rebindShAtlas(shMrts: Nullable<MultiRenderTarget[]>): void {\r\n if (!this._ownsShMrts && shMrts && this._shMrts.length) {\r\n this._shMrts = shMrts.slice(0, this._shMrts.length);\r\n }\r\n }\r\n\r\n /**\r\n * Rebinds a hosted work buffer to the compound's NEW shared rotation atlas (after the compound recreated it on a\r\n * grow/compaction). No-op when rotation isn't in use or the work buffer owns its rotation target (standalone).\r\n * @param rotMrt the compound's new shared rotation atlas\r\n */\r\n public rebindRotAtlas(rotMrt: Nullable<MultiRenderTarget>): void {\r\n if (!this._ownsRotMrt && rotMrt && this._rotMrt) {\r\n this._rotMrt = rotMrt;\r\n }\r\n }\r\n\r\n /**\r\n * Relocates this hosted region to a new base splat offset in the shared atlas (used when the compound\r\n * compacts its atlas and this region's rows move). Subsequent decode/render/readback and\r\n * {@link restoreRegion} all address from the new base. Call between {@link backupRegion} (which read from\r\n * the old base) and {@link restoreRegion} (which will write to the new base). No-op for a standalone\r\n * work buffer, which owns its square MRT at base 0.\r\n * @param baseOffset the region's new first splat index in the atlas\r\n */\r\n public setBaseOffset(baseOffset: number): void {\r\n if (!this._ownsMrt) {\r\n this._baseOffset = baseOffset;\r\n }\r\n }\r\n\r\n /**\r\n * True once the backup/restore/relayout copy shaders are compiled, so {@link backupRegion} can preserve the\r\n * region across an atlas rebuild. Callers that decode into a hosted region should await this before writing\r\n * data, so a later grow/compaction can never race shader compilation and drop the region.\r\n */\r\n public get canBackup(): boolean {\r\n return this._disposed || this._ownsMrt ? false : this.isRelayoutReady();\r\n }\r\n\r\n /**\r\n * Copies this hosted region's four decoded textures out of the shared atlas into an internal backup MRT so\r\n * they survive the compound recreating the atlas on a grow. Call immediately before the atlas is recreated,\r\n * then {@link rebindAtlas} + {@link restoreRegion} after.\r\n */\r\n public backupRegion(): void {\r\n if (this._disposed || this._ownsMrt) {\r\n return;\r\n }\r\n if (!this.isRelayoutReady()) {\r\n // The copy shaders should be compiled well before any grow (callers warm them before decoding), so this\r\n // path means a grow raced compilation; warn rather than silently drop the region's GPU data on the restore.\r\n Logger.Warn(\"GaussianSplattingWorkBuffer: backup skipped because the copy shaders are not ready; streamed region data may be lost on the atlas rebuild.\");\r\n return;\r\n }\r\n const width = this._textureSize;\r\n const regionRows = Math.max(1, Math.floor(this._capacity / width));\r\n const baseRow = Math.floor(this._baseOffset / width);\r\n if (!this._backupMrt) {\r\n this._backupMrt = this._createMrt(\"gsAtlasBackup\", false, width, regionRows);\r\n }\r\n // Identity copy of the region out of the atlas: with useMap=0 and dstBaseRow=-baseRow the shader reads\r\n // atlas texel ((p.y + baseRow) * width + p.x) — the region's global texel — into backup texel p.\r\n this._renderRelayoutPass(this._backupMrt, this._mrt.textures, this._mrt.textures[0], 0, width, width, 0, -baseRow);\r\n // Same for each baked SH texture (one integer copy pass per texture).\r\n if (this._shMrts.length && this._shCopyMaterial) {\r\n if (!this._backupShMrts) {\r\n this._backupShMrts = this._shMrts.map((_, k) => this._createShMrt(`gsShAtlasBackup${k}`, false, width, regionRows));\r\n }\r\n for (let k = 0; k < this._shMrts.length; k++) {\r\n this._renderShCopyPass(this._backupShMrts[k], this._shMrts[k].textures[0], this._mrt.textures[0], 0, width, width, 0, -baseRow);\r\n }\r\n }\r\n // Same for the rotation/scale textures (one 3-out float copy pass).\r\n if (this._rotMrt && this._rotCopyMaterial) {\r\n if (!this._backupRotMrt) {\r\n this._backupRotMrt = this._createRotMrt(\"gsRotAtlasBackup\", false, width, regionRows);\r\n }\r\n this._renderRotCopyPass(this._backupRotMrt, this._rotMrt.textures, this._mrt.textures[0], 0, width, width, 0, -baseRow);\r\n }\r\n this._quad.material = this._material;\r\n }\r\n\r\n /**\r\n * Restores the backed-up region into the (new) atlas, confined by a scissor to the region's rows so no other\r\n * part is touched. Call {@link rebindAtlas} to the new atlas first. Frees the backup afterwards.\r\n */\r\n public restoreRegion(): void {\r\n if (this._disposed || this._ownsMrt || !this._backupMrt || !this._copyMaterial) {\r\n return;\r\n }\r\n const width = this._textureSize;\r\n const regionRows = Math.max(1, Math.floor(this._capacity / width));\r\n const baseRow = Math.floor(this._baseOffset / width);\r\n const engine = this._scene.getEngine();\r\n engine.enableScissor(0, baseRow, width, regionRows);\r\n try {\r\n // useMap=0 identity with dstBaseRow=baseRow: atlas texel p reads backup texel ((p.y - baseRow)*width + p.x).\r\n this._renderRelayoutPass(this._mrt, this._backupMrt.textures, this._backupMrt.textures[0], 0, width, width, 0, baseRow);\r\n // Restore each baked SH texture the same way (scissored to the region's rows). The map placeholder must\r\n // be a FLOAT texture (uMapTex is texture_2d<f32>) even though useMap=0 doesn't sample it — WebGPU still\r\n // validates the bound texture's sample type against the layout. Use the atlas centers (F32).\r\n if (this._backupShMrts && this._shMrts.length && this._shCopyMaterial) {\r\n for (let k = 0; k < this._shMrts.length && k < this._backupShMrts.length; k++) {\r\n this._renderShCopyPass(this._shMrts[k], this._backupShMrts[k].textures[0], this._mrt.textures[0], 0, width, width, 0, baseRow);\r\n }\r\n }\r\n // Restore the rotation/scale textures the same way (3-out float copy, scissored to the region's rows).\r\n if (this._backupRotMrt && this._rotMrt && this._rotCopyMaterial) {\r\n this._renderRotCopyPass(this._rotMrt, this._backupRotMrt.textures, this._mrt.textures[0], 0, width, width, 0, baseRow);\r\n }\r\n } finally {\r\n engine.disableScissor();\r\n this._quad.material = this._material;\r\n }\r\n this._backupMrt.dispose();\r\n this._backupMrt = null;\r\n if (this._backupShMrts) {\r\n for (const mrt of this._backupShMrts) {\r\n mrt.dispose();\r\n }\r\n this._backupShMrts = null;\r\n }\r\n this._backupRotMrt?.dispose();\r\n this._backupRotMrt = null;\r\n }\r\n\r\n /**\r\n * Creates a 4-attachment MRT (centers F32 / covA / covB / colors U8) sized to the work buffer. covA/covB\r\n * use HALF_FLOAT when the engine can render to it, matching the precision the non-streamed\r\n * GaussianSplattingMesh path already uses for these same two textures (see\r\n * `gaussianSplattingMeshBase.pure.ts`'s `createTextureFromDataF16` covA/covB textures); centers stays F32\r\n * and colors stays U8 in both paths.\r\n * @param name MRT and attachment base name\r\n * @param disableClear when true, clearing is suppressed so renders accumulate (the decode buffer); when\r\n * false the MRT clears to zero on each render (the temporary relayout buffer, so gaps stay zeroed)\r\n * @param width texture width (defaults to the work-buffer size; the region row width for a scoped relayout)\r\n * @param height texture height (defaults to the work-buffer size; the region row count for a scoped relayout)\r\n * @returns the created MRT\r\n */\r\n private _createMrt(name: string, disableClear: boolean, width: number = this._textureSize, height: number = this._textureSize): MultiRenderTarget {\r\n const covType = this._scene.getEngine()._caps.textureHalfFloatRender ? Constants.TEXTURETYPE_HALF_FLOAT : Constants.TEXTURETYPE_FLOAT;\r\n const mrt = new MultiRenderTarget(\r\n name,\r\n { width, height },\r\n 4,\r\n this._scene,\r\n {\r\n types: [Constants.TEXTURETYPE_FLOAT, covType, covType, Constants.TEXTURETYPE_UNSIGNED_BYTE],\r\n samplingModes: [\r\n Constants.TEXTURE_NEAREST_SAMPLINGMODE,\r\n Constants.TEXTURE_NEAREST_SAMPLINGMODE,\r\n Constants.TEXTURE_NEAREST_SAMPLINGMODE,\r\n Constants.TEXTURE_NEAREST_SAMPLINGMODE,\r\n ],\r\n formats: [Constants.TEXTUREFORMAT_RGBA, Constants.TEXTUREFORMAT_RGBA, Constants.TEXTUREFORMAT_RGBA, Constants.TEXTUREFORMAT_RGBA],\r\n generateDepthBuffer: false,\r\n generateDepthTexture: false,\r\n generateMipMaps: false,\r\n },\r\n [`${name}Centers`, `${name}CovA`, `${name}CovB`, `${name}Colors`]\r\n );\r\n mrt.clearColor = new Color4(0, 0, 0, 0);\r\n mrt.renderList = [];\r\n if (disableClear) {\r\n mrt.onClearObservable.add(() => {});\r\n }\r\n return mrt;\r\n }\r\n\r\n /**\r\n * Creates a single-attachment integer render target (RGBA_INTEGER / UNSIGNED_INTEGER) that holds one packed-u32\r\n * baked-SH texture. One attachment per pass keeps within WebGPU's per-sample color-attachment byte budget and\r\n * matches the format/type of the draw path's `shTexture0..N` samplers (`_GaussianSplattingBytesPerShTexel`).\r\n * @param name attachment name\r\n * @param disableClear when true, clearing is suppressed so SH decodes accumulate across files\r\n * @param width texture width (defaults to the work-buffer size)\r\n * @param height texture height (defaults to the work-buffer size)\r\n * @returns the created single-attachment integer MRT\r\n */\r\n private _createShMrt(name: string, disableClear: boolean, width: number = this._textureSize, height: number = this._textureSize): MultiRenderTarget {\r\n const mrt = new MultiRenderTarget(\r\n name,\r\n { width, height },\r\n 1,\r\n this._scene,\r\n {\r\n types: [Constants.TEXTURETYPE_UNSIGNED_INTEGER],\r\n formats: [Constants.TEXTUREFORMAT_RGBA_INTEGER],\r\n samplingModes: [Constants.TEXTURE_NEAREST_SAMPLINGMODE],\r\n generateDepthBuffer: false,\r\n generateDepthTexture: false,\r\n generateMipMaps: false,\r\n },\r\n [name]\r\n );\r\n mrt.clearColor = new Color4(0, 0, 0, 0);\r\n mrt.renderList = [];\r\n if (disableClear) {\r\n mrt.onClearObservable.add(() => {});\r\n }\r\n return mrt;\r\n }\r\n\r\n /**\r\n * Creates a 3-attachment half-float MRT ([rotA, rotB, rotScale]) holding the per-splat rotation matrix + scale\r\n * consumed by voxel-IBL shadowing. RGBA half-float when the engine can render to it (matching the covariance\r\n * precision), else full float. 3 attachments = 24 B/sample, within WebGPU's per-sample budget (its own pass).\r\n * @param name MRT and attachment base name\r\n * @param disableClear when true, clearing is suppressed so decodes accumulate (the decode buffer)\r\n * @param width texture width (defaults to the work-buffer size; the region row width for a scoped relayout)\r\n * @param height texture height (defaults to the work-buffer size; the region row count for a scoped relayout)\r\n * @returns the created MRT\r\n */\r\n private _createRotMrt(name: string, disableClear: boolean, width: number = this._textureSize, height: number = this._textureSize): MultiRenderTarget {\r\n const rotType = this._scene.getEngine()._caps.textureHalfFloatRender ? Constants.TEXTURETYPE_HALF_FLOAT : Constants.TEXTURETYPE_FLOAT;\r\n const mrt = new MultiRenderTarget(\r\n name,\r\n { width, height },\r\n 3,\r\n this._scene,\r\n {\r\n types: [rotType, rotType, rotType],\r\n formats: [Constants.TEXTUREFORMAT_RGBA, Constants.TEXTUREFORMAT_RGBA, Constants.TEXTUREFORMAT_RGBA],\r\n samplingModes: [Constants.TEXTURE_NEAREST_SAMPLINGMODE, Constants.TEXTURE_NEAREST_SAMPLINGMODE, Constants.TEXTURE_NEAREST_SAMPLINGMODE],\r\n generateDepthBuffer: false,\r\n generateDepthTexture: false,\r\n generateMipMaps: false,\r\n },\r\n [`${name}A`, `${name}B`, `${name}Scale`]\r\n );\r\n mrt.clearColor = new Color4(0, 0, 0, 0);\r\n mrt.renderList = [];\r\n if (disableClear) {\r\n mrt.onClearObservable.add(() => {});\r\n }\r\n return mrt;\r\n }\r\n\r\n /**\r\n * Decodes one SOG file into the work buffer at the given splat offset (accumulating; previously\r\n * decoded files are preserved). Resolves once the GPU decode has been issued. The caller may\r\n * dispose the source pack textures after this resolves.\r\n * @param pack the SOG texture pack (GPU source textures + per-file decode parameters)\r\n * @param offset first splat index (pixel offset) for this file in the work buffer\r\n * @param sourceOffset first splat of the pack to decode, defaults to 0\r\n * @param count number of splats to decode, defaults to the rest of the pack\r\n */\r\n public async decodeAsync(pack: ISogTexturePack, offset: number, sourceOffset?: number, count?: number): Promise<void> {\r\n if (this._disposed) {\r\n return;\r\n }\r\n const first = sourceOffset ?? 0;\r\n const n = count ?? pack.splatCount - first;\r\n if (sourceOffset !== undefined || count !== undefined) {\r\n if (\r\n !Number.isSafeInteger(pack.splatCount) ||\r\n pack.splatCount < 0 ||\r\n !Number.isSafeInteger(first) ||\r\n first < 0 ||\r\n !Number.isSafeInteger(n) ||\r\n n < 0 ||\r\n first + n > pack.splatCount ||\r\n !Number.isSafeInteger(offset) ||\r\n offset < 0 ||\r\n offset + n > this._capacity\r\n ) {\r\n throw new RangeError(\"GaussianSplattingWorkBuffer: invalid source or destination decode range.\");\r\n }\r\n if (n === 0) {\r\n return;\r\n }\r\n }\r\n this._applyPack(pack, first, n);\r\n // When SH is enabled, bake EVERY file's region — even a file with no higher-order SH (a coarse LOD may drop\r\n // it): those get uCoeffs=0 so the whole region neutral-fills (128), keeping mixed-degree files consistent.\r\n const decodeSh = this._shMaterial !== null && this._shMrts.length > 0;\r\n if (decodeSh) {\r\n this._applyShPack(pack, first, n);\r\n }\r\n const decodeRot = this._rotMaterial !== null && this._rotMrt !== null;\r\n if (decodeRot) {\r\n this._applyRotPack(pack, first, n);\r\n }\r\n // Render the decode pass at the start of a frame (the safe point for custom render targets),\r\n // once the shader is compiled — never re-entrantly from a promise/observable continuation.\r\n await new Promise<void>((resolve) => {\r\n const attempt = () => {\r\n if (this._disposed) {\r\n resolve();\r\n return;\r\n }\r\n if (!this._material.isReady(this._quad) || (decodeSh && !this._shMaterial!.isReady(this._quad)) || (decodeRot && !this._rotMaterial!.isReady(this._quad))) {\r\n this._scene.onBeforeRenderObservable.addOnce(attempt);\r\n return;\r\n }\r\n // Scissor every pass to just this file's atlas rows so the fullscreen triangle only shades the region\r\n // it writes, not the whole (wide) atlas. Correct because the shaders already discard outside the exact\r\n // splat range, and the row band is a superset of it.\r\n const width = this._textureSize;\r\n // Bind uOffset at render time from the live _baseOffset so it shares one value with the scissor below:\r\n // compactAtlas() can relocate this region (via setBaseOffset) during the defer window.\r\n const globalOffset = this._baseOffset + offset;\r\n this._material.setInt(\"uOffset\", globalOffset);\r\n if (decodeSh) {\r\n this._shMaterial!.setInt(\"uOffset\", globalOffset);\r\n }\r\n if (decodeRot) {\r\n this._rotMaterial!.setInt(\"uOffset\", globalOffset);\r\n }\r\n const firstRow = Math.floor(globalOffset / width);\r\n const rowCount = Math.max(1, Math.ceil((globalOffset + n) / width) - firstRow);\r\n const engine = this._scene.getEngine();\r\n engine.enableScissor(0, firstRow, width, rowCount);\r\n try {\r\n this._quad.material = this._material;\r\n this._mrt.renderList = [this._quad];\r\n this._mrt.render();\r\n // Bake this file's higher-order SH: one pass per packed-u32 SH texture (uShTextureIndex selects the\r\n // 16 SH scalars written this pass). Files with fewer coefficients neutral-fill (128) higher bands.\r\n if (decodeSh) {\r\n for (let k = 0; k < this._shMrts.length; k++) {\r\n this._shMaterial!.setInt(\"uShTextureIndex\", k);\r\n this._quad.material = this._shMaterial!;\r\n this._shMrts[k].renderList = [this._quad];\r\n this._shMrts[k].render();\r\n }\r\n this._quad.material = this._material;\r\n }\r\n // Bake this file's rotation/scale into the 3-attachment half-float rotation target (one pass).\r\n if (decodeRot) {\r\n this._quad.material = this._rotMaterial!;\r\n this._rotMrt!.renderList = [this._quad];\r\n this._rotMrt!.render();\r\n this._quad.material = this._material;\r\n }\r\n } finally {\r\n engine.disableScissor();\r\n }\r\n resolve();\r\n };\r\n this._scene.onBeforeRenderObservable.addOnce(attempt);\r\n });\r\n }\r\n\r\n /**\r\n * Whether the relayout copy shader is compiled and ready. Lazily creates the copy material on first call.\r\n * Callers should poll this before {@link relayoutSync} (which must only run when ready).\r\n * @returns true when {@link relayoutSync} can run this frame\r\n */\r\n public isRelayoutReady(): boolean {\r\n if (this._disposed) {\r\n return false;\r\n }\r\n if (!this._copyMaterial) {\r\n this._copyMaterial = this._createCopyMaterial();\r\n }\r\n // When SH is in use, the integer copy shader must also be compiled before a backup/restore/relayout can run.\r\n if (this._shMrts.length && !this._shCopyMaterial) {\r\n this._shCopyMaterial = this._createShCopyMaterial();\r\n }\r\n // Same for the rotation/scale 3-out float copy shader when rotation is in use.\r\n if (this._rotMrt && !this._rotCopyMaterial) {\r\n this._rotCopyMaterial = this._createRotCopyMaterial();\r\n }\r\n // `isReady` reports \"not ready\" when a bound sampler points at a disposed texture (a previous backup/relayout\r\n // binds its temp MRTs as sources, then frees them). The copy passes bind fresh textures every call, so re-point\r\n // the materials at the live atlas textures first; the check then reflects only whether the shader compiled.\r\n this._bindCopyMaterialsToAtlas();\r\n const shReady = this._shMrts.length === 0 || (this._shCopyMaterial !== null && this._shCopyMaterial.isReady(this._quad));\r\n const rotReady = !this._rotMrt || (this._rotCopyMaterial !== null && this._rotCopyMaterial.isReady(this._quad));\r\n return this._copyMaterial.isReady(this._quad) && shReady && rotReady;\r\n }\r\n\r\n /**\r\n * Re-points the relayout/backup copy materials' samplers at the live atlas textures (valid, never freed), so a\r\n * later {@link isRelayoutReady} check isn't tripped by a stale binding to a disposed temp/backup MRT.\r\n */\r\n private _bindCopyMaterialsToAtlas(): void {\r\n const t = this._mrt.textures;\r\n if (this._copyMaterial) {\r\n this._copyMaterial.setTexture(\"uMapTex\", t[0]);\r\n this._copyMaterial.setTexture(\"uSrc0\", t[0]);\r\n this._copyMaterial.setTexture(\"uSrc1\", t[1]);\r\n this._copyMaterial.setTexture(\"uSrc2\", t[2]);\r\n this._copyMaterial.setTexture(\"uSrc3\", t[3]);\r\n }\r\n if (this._shCopyMaterial && this._shMrts.length) {\r\n this._shCopyMaterial.setTexture(\"uMapTex\", t[0]);\r\n this._shCopyMaterial.setTexture(\"uSrcSh\", this._shMrts[0].textures[0]);\r\n }\r\n if (this._rotCopyMaterial && this._rotMrt) {\r\n const r = this._rotMrt.textures;\r\n this._rotCopyMaterial.setTexture(\"uMapTex\", t[0]);\r\n this._rotCopyMaterial.setTexture(\"uSrc0\", r[0]);\r\n this._rotCopyMaterial.setTexture(\"uSrc1\", r[1]);\r\n this._rotCopyMaterial.setTexture(\"uSrc2\", r[2]);\r\n }\r\n }\r\n\r\n /**\r\n * Relayouts the decoded work-buffer textures to a new (defragmented) splat layout, keeping the same\r\n * texture instances so the consuming mesh does not need to re-bind. `srcIndexByDst[d]` is the source splat\r\n * index whose decoded data should end up at destination index `d`, or a negative value for a gap (left\r\n * zeroed). Uses a temporary MRT ping-pong (old -> temp via the map, then temp -> old identity) so\r\n * overlapping moves stay correct. Must be called at a frame-safe point (inside `onBeforeRender`) and only\r\n * when {@link isRelayoutReady} returns true.\r\n * @param srcIndexByDst per-destination source splat index (negative = gap)\r\n */\r\n public relayoutSync(srcIndexByDst: Float32Array): void {\r\n if (this._disposed || !this._copyMaterial) {\r\n return;\r\n }\r\n // Map dimensions: standalone maps the whole square buffer; hosted maps just the region's rows.\r\n const width = this._textureSize;\r\n const mapW = width;\r\n const mapH = this._ownsMrt ? width : Math.max(1, Math.floor(this._capacity / width));\r\n // Reuse the map buffer + its GPU texture across relayouts (dimensions are fixed for a work buffer).\r\n if (!this._relayoutMapData) {\r\n this._relayoutMapData = new Float32Array(mapW * mapH);\r\n }\r\n const mapData = this._relayoutMapData;\r\n mapData.fill(-1);\r\n mapData.set(srcIndexByDst.subarray(0, Math.min(srcIndexByDst.length, mapData.length)));\r\n if (!this._relayoutMapTexture) {\r\n this._relayoutMapTexture = new RawTexture(\r\n mapData,\r\n mapW,\r\n mapH,\r\n Constants.TEXTUREFORMAT_R,\r\n this._scene,\r\n false,\r\n false,\r\n Constants.TEXTURE_NEAREST_SAMPLINGMODE,\r\n Constants.TEXTURETYPE_FLOAT\r\n );\r\n } else {\r\n this._relayoutMapTexture.update(mapData);\r\n }\r\n const mapTexture = this._relayoutMapTexture;\r\n\r\n if (this._ownsMrt) {\r\n // Standalone: the work buffer owns the whole square texture, so a full ping-pong is safe.\r\n const temp = this._createMrt(\"gsRelayoutTemp\", false);\r\n try {\r\n this._renderRelayoutPass(temp, this._mrt.textures, mapTexture, 1); // old -> temp via map (gaps cleared)\r\n this._renderRelayoutPass(this._mrt, temp.textures, mapTexture, 0); // temp -> old, identity full overwrite\r\n } finally {\r\n temp.dispose();\r\n }\r\n // Same ping-pong for each baked SH texture (integer copy, one temp per texture).\r\n if (this._shMrts.length && this._shCopyMaterial) {\r\n for (let k = 0; k < this._shMrts.length; k++) {\r\n const shTemp = this._createShMrt(\"gsShRelayoutTemp\", false);\r\n try {\r\n this._renderShCopyPass(shTemp, this._shMrts[k].textures[0], mapTexture, 1);\r\n this._renderShCopyPass(this._shMrts[k], shTemp.textures[0], mapTexture, 0);\r\n } finally {\r\n shTemp.dispose();\r\n }\r\n }\r\n }\r\n // Same ping-pong for the rotation/scale textures (3-out float copy).\r\n if (this._rotMrt && this._rotCopyMaterial) {\r\n const rotTemp = this._createRotMrt(\"gsRotRelayoutTemp\", false);\r\n try {\r\n this._renderRotCopyPass(rotTemp, this._rotMrt.textures, mapTexture, 1);\r\n this._renderRotCopyPass(this._rotMrt, rotTemp.textures, mapTexture, 0);\r\n } finally {\r\n rotTemp.dispose();\r\n }\r\n }\r\n this._quad.material = this._material;\r\n return;\r\n }\r\n\r\n // Hosted (shared compound atlas): scope the ping-pong to THIS region's row band so other parts are never\r\n // touched. `_baseOffset` and `_capacity` are row-aligned (reserveStreamingPart), so the band is exact.\r\n const baseRow = Math.floor(this._baseOffset / width);\r\n const regionRows = mapH;\r\n const engine = this._scene.getEngine();\r\n // Region-sized temp (width x regionRows) — memory stays proportional to the region, not the whole atlas.\r\n const temp = this._createMrt(\"gsRelayoutTemp\", false, width, regionRows);\r\n // One region-sized integer temp per baked SH texture (same ping-pong, integer format).\r\n const shTemps = this._shMrts.length && this._shCopyMaterial ? this._shMrts.map((_, k) => this._createShMrt(`gsShRelayoutTemp${k}`, false, width, regionRows)) : [];\r\n // One region-sized rotation temp (3-attachment float) when rotation is in use.\r\n const rotTemp = this._rotMrt && this._rotCopyMaterial ? this._createRotMrt(\"gsRotRelayoutTemp\", false, width, regionRows) : null;\r\n try {\r\n // Pass 1: atlas region -> temp via map. The map is region-local; uSrcBaseOffset shifts each source\r\n // index to its GLOBAL atlas texel (uSrcWidth = atlas width). Temp is exactly the band, so no scissor.\r\n this._renderRelayoutPass(temp, this._mrt.textures, mapTexture, 1, /*dstWidth*/ width, /*srcWidth*/ width, /*srcBaseOffset*/ this._baseOffset, /*dstBaseRow*/ 0);\r\n for (let k = 0; k < shTemps.length; k++) {\r\n this._renderShCopyPass(shTemps[k], this._shMrts[k].textures[0], mapTexture, 1, width, width, this._baseOffset, 0);\r\n }\r\n if (rotTemp) {\r\n this._renderRotCopyPass(rotTemp, this._rotMrt!.textures, mapTexture, 1, width, width, this._baseOffset, 0);\r\n }\r\n // Pass 2: temp -> atlas region, identity within the band. uDstBaseRow maps the atlas destination row\r\n // back into the region-local temp; the scissor confines writes to the band so static parts are safe.\r\n engine.enableScissor(0, baseRow, width, regionRows);\r\n try {\r\n this._renderRelayoutPass(this._mrt, temp.textures, mapTexture, 0, /*dstWidth*/ width, /*srcWidth*/ width, /*srcBaseOffset*/ 0, /*dstBaseRow*/ baseRow);\r\n for (let k = 0; k < shTemps.length; k++) {\r\n this._renderShCopyPass(this._shMrts[k], shTemps[k].textures[0], mapTexture, 0, width, width, 0, baseRow);\r\n }\r\n if (rotTemp) {\r\n this._renderRotCopyPass(this._rotMrt!, rotTemp.textures, mapTexture, 0, width, width, 0, baseRow);\r\n }\r\n } finally {\r\n engine.disableScissor();\r\n }\r\n } finally {\r\n temp.dispose();\r\n for (const t of shTemps) {\r\n t.dispose();\r\n }\r\n rotTemp?.dispose();\r\n this._quad.material = this._material;\r\n }\r\n }\r\n\r\n /**\r\n * Renders one relayout copy pass into the target MRT, sampling the given source textures.\r\n * @param target destination MRT\r\n * @param sources the four source work-buffer textures\r\n * @param mapTexture the R32F destination-to-source index map (only sampled when `useMap` is 1; any bound texture otherwise)\r\n * @param useMap 1 to read source indices from the map (gaps discarded), 0 for an identity copy\r\n * @param dstWidth destination width used to linearize the destination texel (defaults to the work-buffer size)\r\n * @param srcWidth source width used to convert a linear source index to a texel (defaults to the work-buffer size)\r\n * @param srcBaseOffset added to each mapped source index so a region-local map reads the correct global atlas texel (hosted relayout)\r\n * @param dstBaseRow subtracted from the destination row so an identity copy reads the region-local temp (hosted relayout)\r\n */\r\n private _renderRelayoutPass(\r\n target: MultiRenderTarget,\r\n sources: Texture[],\r\n mapTexture: BaseTexture,\r\n useMap: number,\r\n dstWidth: number = this._textureSize,\r\n srcWidth: number = this._textureSize,\r\n srcBaseOffset: number = 0,\r\n dstBaseRow: number = 0\r\n ): void {\r\n const material = this._copyMaterial!;\r\n material.setTexture(\"uMapTex\", mapTexture);\r\n material.setTexture(\"uSrc0\", sources[0]);\r\n material.setTexture(\"uSrc1\", sources[1]);\r\n material.setTexture(\"uSrc2\", sources[2]);\r\n material.setTexture(\"uSrc3\", sources[3]);\r\n material.setInt(\"uDstWidth\", dstWidth);\r\n material.setInt(\"uSrcWidth\", srcWidth);\r\n material.setInt(\"uUseMap\", useMap);\r\n material.setInt(\"uSrcBaseOffset\", srcBaseOffset);\r\n material.setInt(\"uDstBaseRow\", dstBaseRow);\r\n this._quad.material = material;\r\n target.renderList = [this._quad];\r\n target.render();\r\n }\r\n\r\n private _createCopyMaterial(): ShaderMaterial {\r\n const isWGSL = this._shaderLanguage === ShaderLanguage.WGSL;\r\n const material = new ShaderMaterial(\r\n GaussianSplattingWorkBufferRelayoutShaderName,\r\n this._scene,\r\n {\r\n vertexSource: isWGSL ? GaussianSplattingWorkBufferVertexShaderWGSL : GaussianSplattingWorkBufferVertexShaderGLSL,\r\n fragmentSource: isWGSL ? GaussianSplattingWorkBufferRelayoutFragmentShaderWGSL : GaussianSplattingWorkBufferRelayoutFragmentShaderGLSL,\r\n },\r\n {\r\n attributes: [\"position\"],\r\n uniforms: [\"uDstWidth\", \"uSrcWidth\", \"uUseMap\", \"uSrcBaseOffset\", \"uDstBaseRow\"],\r\n samplers: [\"uMapTex\", \"uSrc0\", \"uSrc1\", \"uSrc2\", \"uSrc3\"],\r\n shaderLanguage: this._shaderLanguage,\r\n }\r\n );\r\n material.backFaceCulling = false;\r\n material.disableDepthWrite = true;\r\n return material;\r\n }\r\n\r\n /**\r\n * Renders one INTEGER SH copy pass (one packed-u32 SH texture) into the target, sampling one integer source.\r\n * Same index/map/base math as {@link _renderRelayoutPass} but for the integer SH format.\r\n * @param target destination single-attachment integer MRT\r\n * @param srcSh the integer SH source texture\r\n * @param mapTexture the R32F destination-to-source index map (sampled only when `useMap` is 1)\r\n * @param useMap 1 to read source indices from the map (gaps discarded), 0 for an identity copy\r\n * @param dstWidth destination width used to linearize the destination texel\r\n * @param srcWidth source width used to convert a linear source index to a texel\r\n * @param srcBaseOffset added to each mapped source index (region-local map -> global atlas texel)\r\n * @param dstBaseRow subtracted from the destination row for an identity copy of a region-local temp\r\n */\r\n private _renderShCopyPass(\r\n target: MultiRenderTarget,\r\n srcSh: Texture,\r\n mapTexture: BaseTexture,\r\n useMap: number,\r\n dstWidth: number = this._textureSize,\r\n srcWidth: number = this._textureSize,\r\n srcBaseOffset: number = 0,\r\n dstBaseRow: number = 0\r\n ): void {\r\n const material = this._shCopyMaterial!;\r\n material.setTexture(\"uMapTex\", mapTexture);\r\n material.setTexture(\"uSrcSh\", srcSh);\r\n material.setInt(\"uDstWidth\", dstWidth);\r\n material.setInt(\"uSrcWidth\", srcWidth);\r\n material.setInt(\"uUseMap\", useMap);\r\n material.setInt(\"uSrcBaseOffset\", srcBaseOffset);\r\n material.setInt(\"uDstBaseRow\", dstBaseRow);\r\n this._quad.material = material;\r\n target.renderList = [this._quad];\r\n target.render();\r\n }\r\n\r\n private _createShCopyMaterial(): ShaderMaterial {\r\n const isWGSL = this._shaderLanguage === ShaderLanguage.WGSL;\r\n const material = new ShaderMaterial(\r\n GaussianSplattingWorkBufferShCopyShaderName,\r\n this._scene,\r\n {\r\n vertexSource: isWGSL ? GaussianSplattingWorkBufferVertexShaderWGSL : GaussianSplattingWorkBufferVertexShaderGLSL,\r\n fragmentSource: isWGSL ? GaussianSplattingWorkBufferShCopyFragmentShaderWGSL : GaussianSplattingWorkBufferShCopyFragmentShaderGLSL,\r\n },\r\n {\r\n attributes: [\"position\"],\r\n uniforms: [\"uDstWidth\", \"uSrcWidth\", \"uUseMap\", \"uSrcBaseOffset\", \"uDstBaseRow\"],\r\n samplers: [\"uMapTex\", \"uSrcSh\"],\r\n shaderLanguage: this._shaderLanguage,\r\n }\r\n );\r\n material.backFaceCulling = false;\r\n material.disableDepthWrite = true;\r\n return material;\r\n }\r\n\r\n /**\r\n * Renders one rotation/scale copy pass (the three half-float rotation textures) into the target. Same\r\n * index/map/base math as {@link _renderRelayoutPass} but with three attachments.\r\n * @param target destination 3-attachment MRT\r\n * @param sources the three source rotation textures ([rotA, rotB, rotScale])\r\n * @param mapTexture the R32F destination-to-source index map (sampled only when `useMap` is 1)\r\n * @param useMap 1 to read source indices from the map (gaps discarded), 0 for an identity copy\r\n * @param dstWidth destination width used to linearize the destination texel\r\n * @param srcWidth source width used to convert a linear source index to a texel\r\n * @param srcBaseOffset added to each mapped source index (region-local map -> global atlas texel)\r\n * @param dstBaseRow subtracted from the destination row for an identity copy of a region-local temp\r\n */\r\n private _renderRotCopyPass(\r\n target: MultiRenderTarget,\r\n sources: Texture[],\r\n mapTexture: BaseTexture,\r\n useMap: number,\r\n dstWidth: number = this._textureSize,\r\n srcWidth: number = this._textureSize,\r\n srcBaseOffset: number = 0,\r\n dstBaseRow: number = 0\r\n ): void {\r\n const material = this._rotCopyMaterial!;\r\n material.setTexture(\"uMapTex\", mapTexture);\r\n material.setTexture(\"uSrc0\", sources[0]);\r\n material.setTexture(\"uSrc1\", sources[1]);\r\n material.setTexture(\"uSrc2\", sources[2]);\r\n material.setInt(\"uDstWidth\", dstWidth);\r\n material.setInt(\"uSrcWidth\", srcWidth);\r\n material.setInt(\"uUseMap\", useMap);\r\n material.setInt(\"uSrcBaseOffset\", srcBaseOffset);\r\n material.setInt(\"uDstBaseRow\", dstBaseRow);\r\n this._quad.material = material;\r\n target.renderList = [this._quad];\r\n target.render();\r\n }\r\n\r\n private _createRotCopyMaterial(): ShaderMaterial {\r\n const isWGSL = this._shaderLanguage === ShaderLanguage.WGSL;\r\n const material = new ShaderMaterial(\r\n GaussianSplattingWorkBufferRotCopyShaderName,\r\n this._scene,\r\n {\r\n vertexSource: isWGSL ? GaussianSplattingWorkBufferVertexShaderWGSL : GaussianSplattingWorkBufferVertexShaderGLSL,\r\n fragmentSource: isWGSL ? GaussianSplattingWorkBufferRotCopyFragmentShaderWGSL : GaussianSplattingWorkBufferRotCopyFragmentShaderGLSL,\r\n },\r\n {\r\n attributes: [\"position\"],\r\n uniforms: [\"uDstWidth\", \"uSrcWidth\", \"uUseMap\", \"uSrcBaseOffset\", \"uDstBaseRow\"],\r\n samplers: [\"uMapTex\", \"uSrc0\", \"uSrc1\", \"uSrc2\"],\r\n shaderLanguage: this._shaderLanguage,\r\n }\r\n );\r\n material.backFaceCulling = false;\r\n material.disableDepthWrite = true;\r\n return material;\r\n }\r\n\r\n /**\r\n * Asynchronously reads back the decoded splat centers (stride-4 xyzw, w=1) for a contiguous splat range\r\n * from the work buffer's centers texture, using a non-blocking GPU readback (WebGL2 PBO + fence, or WebGPU\r\n * copyTextureToBuffer + mapAsync) so it never stalls the frame the way a CPU image decode does. The centers\r\n * texture already holds the GPU-decoded positions (identical to the CPU decode), so this replaces decoding\r\n * positions on the CPU from the means images. Returns null when async readback is unsupported (caller should\r\n * fall back to CPU decoding).\r\n * @param splatOffset first splat index of the range\r\n * @param splatCount number of splats in the range\r\n * @returns a stride-4 Float32Array of length `splatCount * 4`, or null when unsupported/failed\r\n */\r\n public async readCentersRangeAsync(splatOffset: number, splatCount: number): Promise<Nullable<Float32Array>> {\r\n if (this._disposed || splatCount <= 0 || !this.supportsAsyncCentersReadback) {\r\n return null;\r\n }\r\n\r\n const width = this._textureSize;\r\n // Shift the region-local offset by the atlas base so the readback targets the same global texels the\r\n // decode wrote (0 base for a standalone work buffer).\r\n const globalOffset = this._baseOffset + splatOffset;\r\n // The range maps to whole texel rows [rowStart, rowEnd); read that rectangle and slice the exact range.\r\n // Splat i lives at texel (i % width, floor(i / width)) in both decode and draw, so the readback (which\r\n // indexes the same texture storage directly, with no UV/flip) yields splat i at buffer position\r\n // i - rowStart * width on every backend.\r\n const rowStart = Math.floor(globalOffset / width);\r\n const rowEnd = Math.ceil((globalOffset + splatCount) / width);\r\n const rowCount = rowEnd - rowStart;\r\n const startInBuffer = (globalOffset - rowStart * width) * 4;\r\n const sliceEnd = startInBuffer + splatCount * 4;\r\n const centers = this._mrt.textures[0];\r\n\r\n const engine = this._scene.getEngine();\r\n\r\n if (engine.isWebGPU) {\r\n // WebGPU: copyTextureToBuffer of the row span + mapAsync (genuinely non-blocking). noDataConversion\r\n // returns the raw RGBA32F floats tightly packed (the 256-byte row alignment is removed internally).\r\n const result = await centers.readPixels(0, 0, null, true, true, 0, rowStart, width, rowCount);\r\n if (this._disposed || !result) {\r\n return null;\r\n }\r\n const floats = result instanceof Float32Array ? result : new Float32Array(result.buffer, result.byteOffset, result.byteLength / 4);\r\n return floats.length >= sliceEnd ? (floats.subarray(startInBuffer, sliceEnd) as Float32Array) : null;\r\n }\r\n\r\n // WebGL2: read directly from the centers texture via a reused FBO + async PBO readback.\r\n const glEngine = engine as unknown as {\r\n _gl: WebGL2RenderingContext;\r\n _currentFramebuffer: Nullable<WebGLFramebuffer>;\r\n _readPixelsAsync(x: number, y: number, w: number, h: number, format: number, type: number, o: ArrayBufferView): Nullable<Promise<ArrayBufferView>>;\r\n };\r\n const gl = glEngine._gl;\r\n const hardware = centers.getInternalTexture()?._hardwareTexture?.underlyingResource as Nullable<WebGLTexture>;\r\n if (!hardware) {\r\n return null;\r\n }\r\n const buffer = new Float32Array(width * rowCount * 4);\r\n if (!this._readFbo) {\r\n this._readFbo = gl.createFramebuffer();\r\n }\r\n const previousFbo = glEngine._currentFramebuffer;\r\n gl.bindFramebuffer(gl.FRAMEBUFFER, this._readFbo);\r\n gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_2D, hardware, 0);\r\n gl.readBuffer(gl.COLOR_ATTACHMENT0);\r\n\r\n // _readPixelsAsync issues the readPixels into a PBO synchronously, then resolves once the GPU fence\r\n // signals — so the framebuffer can be restored immediately while the transfer completes off-thread.\r\n const promise = glEngine._readPixelsAsync(0, rowStart, width, rowCount, gl.RGBA, gl.FLOAT, buffer);\r\n gl.bindFramebuffer(gl.FRAMEBUFFER, previousFbo);\r\n // gl.readBuffer is global state: restore the default-framebuffer read source (BACK) so later\r\n // readPixels on the default framebuffer aren't left pointing at COLOR_ATTACHMENT0. When restoring to\r\n // another FBO, COLOR_ATTACHMENT0 is the correct default read buffer, so only reset for the default one.\r\n if (!previousFbo) {\r\n gl.readBuffer(gl.BACK);\r\n }\r\n if (!promise) {\r\n return null;\r\n }\r\n await promise;\r\n if (this._disposed || buffer.length < sliceEnd) {\r\n return null;\r\n }\r\n return buffer.subarray(startInBuffer, sliceEnd) as Float32Array;\r\n }\r\n\r\n /**\r\n * Disposes the work buffer and its decode resources.\r\n */\r\n public dispose(): void {\r\n this._disposed = true;\r\n if (this._readFbo) {\r\n (this._scene.getEngine() as unknown as { _gl?: WebGL2RenderingContext })._gl?.deleteFramebuffer(this._readFbo);\r\n this._readFbo = null;\r\n }\r\n this._quad.dispose();\r\n this._material.dispose(true, false);\r\n this._shMaterial?.dispose(true, false);\r\n this._rotMaterial?.dispose(true, false);\r\n this._copyMaterial?.dispose(true, false);\r\n this._shCopyMaterial?.dispose(true, false);\r\n this._rotCopyMaterial?.dispose(true, false);\r\n this._relayoutMapTexture?.dispose();\r\n this._backupMrt?.dispose();\r\n this._backupMrt = null;\r\n if (this._backupShMrts) {\r\n for (const mrt of this._backupShMrts) {\r\n mrt.dispose();\r\n }\r\n this._backupShMrts = null;\r\n }\r\n this._backupRotMrt?.dispose();\r\n this._backupRotMrt = null;\r\n // Only dispose the MRT when we own it; an external atlas belongs to the hosting compound mesh.\r\n if (this._ownsMrt) {\r\n this._mrt.dispose();\r\n }\r\n // Same ownership rule for the SH targets (standalone owns; hosted borrows the compound's shared SH atlas).\r\n if (this._ownsShMrts) {\r\n for (const mrt of this._shMrts) {\r\n mrt.dispose();\r\n }\r\n }\r\n this._shMrts = [];\r\n // Same ownership rule for the rotation target.\r\n if (this._ownsRotMrt) {\r\n this._rotMrt?.dispose();\r\n }\r\n this._rotMrt = null;\r\n }\r\n\r\n private _createQuad(): Mesh {\r\n const quad = new Mesh(\"gsWorkBufferQuad\", this._scene);\r\n const vertexData = new VertexData();\r\n // Fullscreen triangle in clip space (the vertex shader passes positions straight through).\r\n vertexData.positions = [-1, -1, 0, 3, -1, 0, -1, 3, 0];\r\n vertexData.indices = [0, 1, 2];\r\n vertexData.applyToMesh(quad);\r\n // Render only inside the work-buffer MRT, never in the main scene pass.\r\n this._scene.removeMesh(quad);\r\n return quad;\r\n }\r\n\r\n private _createMaterial(): ShaderMaterial {\r\n const isWGSL = this._shaderLanguage === ShaderLanguage.WGSL;\r\n const material = new ShaderMaterial(\r\n \"gsSogDecode\",\r\n this._scene,\r\n {\r\n vertexSource: isWGSL ? GaussianSplattingWorkBufferVertexShaderWGSL : GaussianSplattingWorkBufferVertexShaderGLSL,\r\n fragmentSource: isWGSL ? GaussianSplattingWorkBufferFragmentShaderWGSL : GaussianSplattingWorkBufferFragmentShaderGLSL,\r\n },\r\n {\r\n attributes: [\"position\"],\r\n uniforms: [\r\n \"sogMeansMin\",\r\n \"sogMeansMax\",\r\n \"sogScalesMin\",\r\n \"sogScalesMax\",\r\n \"sogSh0Min\",\r\n \"sogSh0Max\",\r\n \"uVersion\",\r\n \"uOffset\",\r\n \"uSourceOffset\",\r\n \"uCount\",\r\n \"uDestWidth\",\r\n \"uSrcWidth\",\r\n ],\r\n samplers: [\"sogMeansLTex\", \"sogMeansUTex\", \"sogScalesTex\", \"sogQuatsTex\", \"sogSh0Tex\", \"sogCodebookTex\"],\r\n shaderLanguage: this._shaderLanguage,\r\n }\r\n );\r\n material.backFaceCulling = false;\r\n material.disableDepthWrite = true;\r\n return material;\r\n }\r\n\r\n private _applyPack(pack: ISogTexturePack, sourceOffset: number, count: number): void {\r\n const material = this._material;\r\n const srcWidth = (pack.meansTextureL as Texture).getSize().width;\r\n\r\n material.setTexture(\"sogMeansLTex\", pack.meansTextureL);\r\n material.setTexture(\"sogMeansUTex\", pack.meansTextureU);\r\n material.setTexture(\"sogScalesTex\", pack.scalesTexture);\r\n material.setTexture(\"sogQuatsTex\", pack.quatsTexture);\r\n material.setTexture(\"sogSh0Tex\", pack.sh0Texture);\r\n // Codebook only used for v2; bind a harmless placeholder otherwise so the sampler is always set.\r\n material.setTexture(\"sogCodebookTex\", pack.codebookTexture ?? pack.sh0Texture);\r\n\r\n material.setVector3(\"sogMeansMin\", new Vector3(pack.meansMin[0], pack.meansMin[1], pack.meansMin[2]));\r\n material.setVector3(\"sogMeansMax\", new Vector3(pack.meansMax[0], pack.meansMax[1], pack.meansMax[2]));\r\n const sMin = pack.scalesMin ?? [0, 0, 0];\r\n const sMax = pack.scalesMax ?? [0, 0, 0];\r\n material.setVector3(\"sogScalesMin\", new Vector3(sMin[0], sMin[1], sMin[2]));\r\n material.setVector3(\"sogScalesMax\", new Vector3(sMax[0], sMax[1], sMax[2]));\r\n const c0Min = pack.sh0Min ?? [0, 0, 0, 0];\r\n const c0Max = pack.sh0Max ?? [0, 0, 0, 0];\r\n material.setVector4(\"sogSh0Min\", new Vector4(c0Min[0], c0Min[1], c0Min[2], c0Min[3]));\r\n material.setVector4(\"sogSh0Max\", new Vector4(c0Max[0], c0Max[1], c0Max[2], c0Max[3]));\r\n\r\n material.setInt(\"uVersion\", pack.version);\r\n // uOffset is bound at render time in decodeAsync (from the live _baseOffset).\r\n material.setInt(\"uSourceOffset\", sourceOffset);\r\n material.setInt(\"uCount\", count);\r\n material.setInt(\"uDestWidth\", this._textureSize);\r\n material.setInt(\"uSrcWidth\", srcWidth);\r\n }\r\n\r\n private _createShMaterial(): ShaderMaterial {\r\n const isWGSL = this._shaderLanguage === ShaderLanguage.WGSL;\r\n const material = new ShaderMaterial(\r\n GaussianSplattingWorkBufferShDecodeShaderName,\r\n this._scene,\r\n {\r\n vertexSource: isWGSL ? GaussianSplattingWorkBufferVertexShaderWGSL : GaussianSplattingWorkBufferVertexShaderGLSL,\r\n fragmentSource: isWGSL ? GaussianSplattingWorkBufferShDecodeFragmentShaderWGSL : GaussianSplattingWorkBufferShDecodeFragmentShaderGLSL,\r\n },\r\n {\r\n attributes: [\"position\"],\r\n uniforms: [\"sogShnMin\", \"sogShnMax\", \"uVersion\", \"uOffset\", \"uSourceOffset\", \"uCount\", \"uDestWidth\", \"uSrcWidth\", \"uCoeffs\", \"uShTextureIndex\"],\r\n samplers: [\"sogShLabelsTex\", \"sogShCentroidsTex\", \"sogCodebookTex\"],\r\n shaderLanguage: this._shaderLanguage,\r\n }\r\n );\r\n material.backFaceCulling = false;\r\n material.disableDepthWrite = true;\r\n return material;\r\n }\r\n\r\n private _applyShPack(pack: ISogTexturePack, sourceOffset: number, count: number): void {\r\n const material = this._shMaterial!;\r\n // A file may carry no higher-order SH (coarse LOD): fall back to sh0Texture as a harmless placeholder for the\r\n // label/centroid samplers and set uCoeffs=0 so the shader neutral-fills every coefficient (128 -> 0 lighting).\r\n const hasSh = !!pack.shLabelsTexture && !!pack.shCentroidsTexture;\r\n const labels = pack.shLabelsTexture ?? pack.sh0Texture;\r\n const centroids = pack.shCentroidsTexture ?? pack.sh0Texture;\r\n material.setTexture(\"sogShLabelsTex\", labels);\r\n material.setTexture(\"sogShCentroidsTex\", centroids);\r\n // Codebook only used for v2; bind a harmless placeholder otherwise so the sampler is always set.\r\n material.setTexture(\"sogCodebookTex\", pack.codebookTexture ?? labels);\r\n material.setFloat(\"sogShnMin\", pack.shnMin ?? 0);\r\n material.setFloat(\"sogShnMax\", pack.shnMax ?? 0);\r\n material.setInt(\"uVersion\", pack.version);\r\n // uOffset is bound at render time in decodeAsync (from the live _baseOffset).\r\n material.setInt(\"uSourceOffset\", sourceOffset);\r\n material.setInt(\"uCount\", count);\r\n material.setInt(\"uDestWidth\", this._textureSize);\r\n material.setInt(\"uSrcWidth\", (labels as Texture).getSize().width);\r\n // Higher-order coefficient count for THIS file (bands=3 -> 15). 0 when the file has no SH -> full neutral fill.\r\n material.setInt(\"uCoeffs\", hasSh ? pack.shCoeffCount : 0);\r\n }\r\n\r\n private _createRotMaterial(): ShaderMaterial {\r\n const isWGSL = this._shaderLanguage === ShaderLanguage.WGSL;\r\n const material = new ShaderMaterial(\r\n GaussianSplattingWorkBufferRotationDecodeShaderName,\r\n this._scene,\r\n {\r\n vertexSource: isWGSL ? GaussianSplattingWorkBufferVertexShaderWGSL : GaussianSplattingWorkBufferVertexShaderGLSL,\r\n fragmentSource: isWGSL ? GaussianSplattingWorkBufferRotationDecodeFragmentShaderWGSL : GaussianSplattingWorkBufferRotationDecodeFragmentShaderGLSL,\r\n },\r\n {\r\n attributes: [\"position\"],\r\n uniforms: [\"sogScalesMin\", \"sogScalesMax\", \"uVersion\", \"uOffset\", \"uSourceOffset\", \"uCount\", \"uDestWidth\", \"uSrcWidth\"],\r\n samplers: [\"sogScalesTex\", \"sogQuatsTex\", \"sogCodebookTex\"],\r\n shaderLanguage: this._shaderLanguage,\r\n }\r\n );\r\n material.backFaceCulling = false;\r\n material.disableDepthWrite = true;\r\n return material;\r\n }\r\n\r\n private _applyRotPack(pack: ISogTexturePack, sourceOffset: number, count: number): void {\r\n const material = this._rotMaterial!;\r\n const srcWidth = (pack.scalesTexture as Texture).getSize().width;\r\n material.setTexture(\"sogScalesTex\", pack.scalesTexture);\r\n material.setTexture(\"sogQuatsTex\", pack.quatsTexture);\r\n // Codebook only used for v2; bind a harmless placeholder otherwise so the sampler is always set.\r\n material.setTexture(\"sogCodebookTex\", pack.codebookTexture ?? pack.scalesTexture);\r\n const sMin = pack.scalesMin ?? [0, 0, 0];\r\n const sMax = pack.scalesMax ?? [0, 0, 0];\r\n material.setVector3(\"sogScalesMin\", new Vector3(sMin[0], sMin[1], sMin[2]));\r\n material.setVector3(\"sogScalesMax\", new Vector3(sMax[0], sMax[1], sMax[2]));\r\n material.setInt(\"uVersion\", pack.version);\r\n // uOffset is bound at render time in decodeAsync (from the live _baseOffset).\r\n material.setInt(\"uSourceOffset\", sourceOffset);\r\n material.setInt(\"uCount\", count);\r\n material.setInt(\"uDestWidth\", this._textureSize);\r\n material.setInt(\"uSrcWidth\", srcWidth);\r\n }\r\n}\r\n"]}