@onerjs/core 8.51.8 → 8.52.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.
- package/AudioV2/abstractAudio/audioEngineV2.d.ts +34 -1
- package/AudioV2/abstractAudio/audioEngineV2.js +54 -0
- package/AudioV2/abstractAudio/audioEngineV2.js.map +1 -1
- package/AudioV2/abstractAudio/components/spatialAudioAttacherComponent.d.ts +12 -0
- package/AudioV2/abstractAudio/components/spatialAudioAttacherComponent.js +18 -0
- package/AudioV2/abstractAudio/components/spatialAudioAttacherComponent.js.map +1 -1
- package/AudioV2/abstractAudio/index.d.ts +1 -0
- package/AudioV2/abstractAudio/index.js +1 -0
- package/AudioV2/abstractAudio/index.js.map +1 -1
- package/AudioV2/abstractAudio/pure.d.ts +1 -0
- package/AudioV2/abstractAudio/pure.js +1 -0
- package/AudioV2/abstractAudio/pure.js.map +1 -1
- package/AudioV2/abstractAudio/subNodes/spatialAudioSubNode.d.ts +7 -1
- package/AudioV2/abstractAudio/subNodes/spatialAudioSubNode.js +12 -0
- package/AudioV2/abstractAudio/subNodes/spatialAudioSubNode.js.map +1 -1
- package/AudioV2/abstractAudio/subProperties/abstractSpatialAudio.d.ts +14 -0
- package/AudioV2/abstractAudio/subProperties/abstractSpatialAudio.js.map +1 -1
- package/AudioV2/abstractAudio/subProperties/abstractSpatialAudioListener.d.ts +4 -0
- package/AudioV2/abstractAudio/subProperties/abstractSpatialAudioListener.js.map +1 -1
- package/AudioV2/abstractAudio/subProperties/spatialAudio.d.ts +6 -0
- package/AudioV2/abstractAudio/subProperties/spatialAudio.js +12 -0
- package/AudioV2/abstractAudio/subProperties/spatialAudio.js.map +1 -1
- package/AudioV2/abstractAudio/subProperties/spatialAudioListener.d.ts +2 -0
- package/AudioV2/abstractAudio/subProperties/spatialAudioListener.js +4 -0
- package/AudioV2/abstractAudio/subProperties/spatialAudioListener.js.map +1 -1
- package/AudioV2/webAudio/webAudioEngine.js +2 -1
- package/AudioV2/webAudio/webAudioEngine.js.map +1 -1
- package/Gizmos/index.d.ts +1 -0
- package/Gizmos/index.js +1 -0
- package/Gizmos/index.js.map +1 -1
- package/Gizmos/pure.d.ts +1 -0
- package/Gizmos/pure.js +1 -0
- package/Gizmos/pure.js.map +1 -1
- package/Gizmos/spatialAudioGizmo.d.ts +55 -0
- package/Gizmos/spatialAudioGizmo.js +151 -0
- package/Gizmos/spatialAudioGizmo.js.map +1 -0
- package/Layers/thinSelectionOutlineLayer.js +1 -1
- package/Layers/thinSelectionOutlineLayer.js.map +1 -1
- package/Materials/GaussianSplatting/gaussianSplattingMaterial.pure.d.ts +5 -0
- package/Materials/GaussianSplatting/gaussianSplattingMaterial.pure.js +54 -1
- package/Materials/GaussianSplatting/gaussianSplattingMaterial.pure.js.map +1 -1
- package/Meshes/GaussianSplatting/gaussianSplattingMeshBase.pure.d.ts +42 -0
- package/Meshes/GaussianSplatting/gaussianSplattingMeshBase.pure.js +93 -0
- package/Meshes/GaussianSplatting/gaussianSplattingMeshBase.pure.js.map +1 -1
- package/Meshes/instancedMesh.pure.js +1 -1
- package/Meshes/instancedMesh.pure.js.map +1 -1
- package/Shaders/ShadersInclude/gaussianSplatting.js +54 -5
- package/Shaders/ShadersInclude/gaussianSplatting.js.map +1 -1
- package/Shaders/gaussianSplatting.vertex.js +14 -3
- package/Shaders/gaussianSplatting.vertex.js.map +1 -1
- package/ShadersWGSL/ShadersInclude/gaussianSplatting.js +56 -5
- package/ShadersWGSL/ShadersInclude/gaussianSplatting.js.map +1 -1
- package/ShadersWGSL/gaussianSplatting.vertex.js +14 -3
- package/ShadersWGSL/gaussianSplatting.vertex.js.map +1 -1
- package/package.json +1 -1
|
@@ -640,7 +640,7 @@ export function RegisterInstancedMesh() {
|
|
|
640
640
|
while (size < expectedSize) {
|
|
641
641
|
size *= 2;
|
|
642
642
|
}
|
|
643
|
-
if (this._userInstancedBuffersStorage.data[kind].length != size) {
|
|
643
|
+
if (!this._userInstancedBuffersStorage.data[kind] || this._userInstancedBuffersStorage.data[kind].length != size) {
|
|
644
644
|
this._userInstancedBuffersStorage.data[kind] = new Float32Array(size);
|
|
645
645
|
this._userInstancedBuffersStorage.sizes[kind] = size;
|
|
646
646
|
if (usePerPassStorage) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"instancedMesh.pure.js","sourceRoot":"","sources":["../../../../dev/core/src/Meshes/instancedMesh.pure.ts"],"names":[],"mappings":"AAAA,6DAA6D;AAG7D,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;AAE/D,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAGxC,OAAO,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAE3D,OAAO,EAAE,IAAI,EAAE,MAAM,qBAAqB,CAAC;AAG3C,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAChD,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAErD,OAAO,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AAItD,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAElD;;GAEG;AACH,MAAM,OAAO,aAAc,SAAQ,YAAY;IAY3C;;;;OAIG;IACH,YAAY,IAAY,EAAE,MAAY;QAClC,KAAK,CAAC,IAAI,EAAE,MAAM,CAAC,QAAQ,EAAE,CAAC,CAAC;QAbnC,gBAAgB;QACT,oCAA+B,GAAG,CAAC,CAAC,CAAC;QAC5C,gBAAgB;QACT,sBAAiB,GAAW,CAAC,CAAC;QAYjC,MAAM,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC;QAEzB,IAAI,CAAC,WAAW,GAAG,MAAM,CAAC;QAE1B,IAAI,CAAC,UAAU,GAAG,MAAM,CAAC,UAAU,CAAC;QAEpC,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;QACxC,IAAI,CAAC,QAAQ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B,CAAC,aAAa,CAAC,IAAI,CAAC,EAAE,CAAC;oBACxD,IAAI,CAAC,4BAA4B,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC,OAAO,EAAE,CAAC;gBACpE,CAAC;YACL,CAAC;YAED,IAAI,CAAC,oCAAoC,EAAE,CAAC;YAE5C,IAAI,CAAC,gBAAgB,GAAG,EAAE,CAAC;QAC/B,CAAC,CAAC;QAEF,sBAAsB;QACtB,aAAa,CAAC,uBAAuB,EAAE,aAAa,CAAC,CAAC;IAC1D,CAAC,CAAC;AACN,CAAC","sourcesContent":["/** This file must only contain pure code and pure imports */\r\n\r\nimport { type FloatArray, type IndicesArray, type Nullable } from \"../types\";\r\nimport { Matrix, TmpVectors } from \"../Maths/math.vector.pure\";\r\nimport { type Vector3 } from \"../Maths/math.vector\";\r\nimport { Logger } from \"../Misc/logger\";\r\nimport { type Camera } from \"../Cameras/camera.pure\";\r\nimport { type Node } from \"../node\";\r\nimport { AbstractMesh } from \"../Meshes/abstractMesh.pure\";\r\nimport { type IMeshDataOptions } from \"../Meshes/abstractMesh\";\r\nimport { Mesh } from \"../Meshes/mesh.pure\";\r\nimport { type Material } from \"../Materials/material.pure\";\r\nimport { type Skeleton } from \"../Bones/skeleton\";\r\nimport { DeepCopier } from \"../Misc/deepCopier\";\r\nimport { TransformNode } from \"./transformNode.pure\";\r\nimport { type Light } from \"../Lights/light\";\r\nimport { VertexBuffer } from \"../Buffers/buffer.pure\";\r\nimport { type Geometry } from \"./geometry\";\r\n\r\nimport { type ThinEngine } from \"../Engines/thinEngine.pure\";\r\nimport { RegisterClass } from \"../Misc/typeStore\";\r\n\r\n/**\r\n * Creates an instance based on a source mesh.\r\n */\r\nexport class InstancedMesh extends AbstractMesh {\r\n private _sourceMesh: Mesh;\r\n private _currentLOD: Mesh;\r\n private _billboardWorldMatrix: Matrix;\r\n\r\n /** @internal */\r\n public _indexInSourceMeshInstanceArray = -1;\r\n /** @internal */\r\n public _distanceToCamera: number = 0;\r\n /** @internal */\r\n public _previousWorldMatrix: Nullable<Matrix>;\r\n\r\n /**\r\n * Creates a new InstancedMesh object from the mesh source.\r\n * @param name defines the name of the instance\r\n * @param source the mesh to create the instance from\r\n */\r\n constructor(name: string, source: Mesh) {\r\n super(name, source.getScene());\r\n\r\n source.addInstance(this);\r\n\r\n this._sourceMesh = source;\r\n\r\n this._unIndexed = source._unIndexed;\r\n\r\n this.position.copyFrom(source.position);\r\n this.rotation.copyFrom(source.rotation);\r\n this.scaling.copyFrom(source.scaling);\r\n\r\n if (source.rotationQuaternion) {\r\n this.rotationQuaternion = source.rotationQuaternion.clone();\r\n }\r\n\r\n this.animations = source.animations.slice();\r\n for (const range of source.getAnimationRanges()) {\r\n if (range != null) {\r\n this.createAnimationRange(range.name, range.from, range.to);\r\n }\r\n }\r\n\r\n this.infiniteDistance = source.infiniteDistance;\r\n\r\n this.setPivotMatrix(source.getPivotMatrix());\r\n\r\n if (!source.skeleton && !source.morphTargetManager && source.hasBoundingInfo) {\r\n // without skeleton or morphTargetManager, use bounding info of source mesh directly\r\n const boundingInfo = source.getBoundingInfo();\r\n this.buildBoundingInfo(boundingInfo.minimum, boundingInfo.maximum);\r\n } else {\r\n this.refreshBoundingInfo(true, true);\r\n }\r\n this._syncSubMeshes();\r\n }\r\n\r\n /**\r\n * @returns the string \"InstancedMesh\".\r\n */\r\n public override getClassName(): string {\r\n return \"InstancedMesh\";\r\n }\r\n\r\n /** Gets the list of lights affecting that mesh */\r\n public override get lightSources(): Light[] {\r\n return this._sourceMesh._lightSources;\r\n }\r\n\r\n /** @internal */\r\n public override _resyncLightSources(): void {\r\n // Do nothing as all the work will be done by source mesh\r\n }\r\n\r\n /** @internal */\r\n public override _resyncLightSource(): void {\r\n // Do nothing as all the work will be done by source mesh\r\n }\r\n\r\n /** @internal */\r\n public override _removeLightSource(): void {\r\n // Do nothing as all the work will be done by source mesh\r\n }\r\n\r\n // Methods\r\n /**\r\n * If the source mesh receives shadows\r\n */\r\n public override get receiveShadows(): boolean {\r\n return this._sourceMesh.receiveShadows;\r\n }\r\n\r\n public override set receiveShadows(_value: boolean) {\r\n if (this._sourceMesh?.receiveShadows !== _value) {\r\n Logger.Warn(\"Setting receiveShadows on an instanced mesh has no effect\");\r\n }\r\n }\r\n\r\n /**\r\n * The material of the source mesh\r\n */\r\n public override get material(): Nullable<Material> {\r\n return this._sourceMesh.material;\r\n }\r\n\r\n public override set material(_value: Nullable<Material>) {\r\n if (this._sourceMesh?.material !== _value) {\r\n Logger.Warn(\"Setting material on an instanced mesh has no effect\");\r\n }\r\n }\r\n\r\n /**\r\n * Visibility of the source mesh\r\n */\r\n public override get visibility(): number {\r\n return this._sourceMesh.visibility;\r\n }\r\n\r\n public override set visibility(_value: number) {\r\n if (this._sourceMesh?.visibility !== _value) {\r\n Logger.Warn(\"Setting visibility on an instanced mesh has no effect\");\r\n }\r\n }\r\n\r\n /**\r\n * Skeleton of the source mesh\r\n */\r\n public override get skeleton(): Nullable<Skeleton> {\r\n return this._sourceMesh.skeleton;\r\n }\r\n\r\n public override set skeleton(_value: Nullable<Skeleton>) {\r\n if (this._sourceMesh?.skeleton !== _value) {\r\n Logger.Warn(\"Setting skeleton on an instanced mesh has no effect\");\r\n }\r\n }\r\n\r\n /**\r\n * Rendering ground id of the source mesh\r\n */\r\n public override get renderingGroupId(): number {\r\n return this._sourceMesh.renderingGroupId;\r\n }\r\n\r\n public override set renderingGroupId(value: number) {\r\n if (!this._sourceMesh || value === this._sourceMesh.renderingGroupId) {\r\n return;\r\n }\r\n\r\n //no-op with warning\r\n Logger.Warn(\"Note - setting renderingGroupId of an instanced mesh has no effect on the scene\");\r\n }\r\n\r\n /**\r\n * @returns the total number of vertices (integer).\r\n */\r\n public override getTotalVertices(): number {\r\n return this._sourceMesh ? this._sourceMesh.getTotalVertices() : 0;\r\n }\r\n\r\n /**\r\n * Returns a positive integer : the total number of indices in this mesh geometry.\r\n * @returns the number of indices or zero if the mesh has no geometry.\r\n */\r\n public override getTotalIndices(): number {\r\n return this._sourceMesh.getTotalIndices();\r\n }\r\n\r\n /**\r\n * The source mesh of the instance\r\n */\r\n public get sourceMesh(): Mesh {\r\n return this._sourceMesh;\r\n }\r\n\r\n /**\r\n * Gets the mesh internal Geometry object\r\n */\r\n public override get geometry(): Nullable<Geometry> {\r\n return this._sourceMesh._geometry;\r\n }\r\n\r\n /**\r\n * Creates a new InstancedMesh object from the mesh model.\r\n * @see https://doc.babylonjs.com/features/featuresDeepDive/mesh/copies/instances\r\n * @param name defines the name of the new instance\r\n * @returns a new InstancedMesh\r\n */\r\n public createInstance(name: string): InstancedMesh {\r\n return this._sourceMesh.createInstance(name);\r\n }\r\n\r\n /**\r\n * Is this node ready to be used/rendered\r\n * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)\r\n * @returns is it ready\r\n */\r\n public override isReady(completeCheck = false): boolean {\r\n return this._sourceMesh.isReady(completeCheck, true);\r\n }\r\n\r\n /**\r\n * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.\r\n * @param kind kind of verticies to retrieve (eg. positions, normals, uvs, etc.)\r\n * @param copyWhenShared If true (default false) and and if the mesh geometry is shared among some other meshes, the returned array is a copy of the internal one.\r\n * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is\r\n * @returns a float array or a Float32Array of the requested kind of data : positions, normals, uvs, etc.\r\n */\r\n public override getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray> {\r\n return this._sourceMesh.getVerticesData(kind, copyWhenShared, forceCopy);\r\n }\r\n\r\n /** @internal */\r\n public override copyVerticesData(kind: string, vertexData: { [kind: string]: Float32Array }): void {\r\n this._sourceMesh.copyVerticesData(kind, vertexData);\r\n }\r\n\r\n /** @internal */\r\n public override getVertexBuffer(kind: string, bypassInstanceData?: boolean): Nullable<VertexBuffer> {\r\n return this._sourceMesh.getVertexBuffer(kind, bypassInstanceData);\r\n }\r\n\r\n /**\r\n * Sets the vertex data of the mesh geometry for the requested `kind`.\r\n * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.\r\n * The `data` are either a numeric array either a Float32Array.\r\n * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initially none) or updater.\r\n * The parameter `stride` is an optional positive integer, it is usually automatically deducted from the `kind` (3 for positions or normals, 2 for UV, etc).\r\n * Note that a new underlying VertexBuffer object is created each call.\r\n * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.\r\n *\r\n * Possible `kind` values :\r\n * - VertexBuffer.PositionKind\r\n * - VertexBuffer.UVKind\r\n * - VertexBuffer.UV2Kind\r\n * - VertexBuffer.UV3Kind\r\n * - VertexBuffer.UV4Kind\r\n * - VertexBuffer.UV5Kind\r\n * - VertexBuffer.UV6Kind\r\n * - VertexBuffer.ColorKind\r\n * - VertexBuffer.MatricesIndicesKind\r\n * - VertexBuffer.MatricesIndicesExtraKind\r\n * - VertexBuffer.MatricesWeightsKind\r\n * - VertexBuffer.MatricesWeightsExtraKind\r\n *\r\n * Returns the Mesh.\r\n * @param kind defines vertex data kind\r\n * @param data defines the data source\r\n * @param updatable defines if the data must be flagged as updatable (false as default)\r\n * @param stride defines the vertex stride (optional)\r\n * @returns the current mesh\r\n */\r\n public override setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh {\r\n if (this.sourceMesh) {\r\n this.sourceMesh.setVerticesData(kind, data, updatable, stride);\r\n }\r\n return this.sourceMesh;\r\n }\r\n\r\n /**\r\n * Updates the existing vertex data of the mesh geometry for the requested `kind`.\r\n * If the mesh has no geometry, it is simply returned as it is.\r\n * The `data` are either a numeric array either a Float32Array.\r\n * No new underlying VertexBuffer object is created.\r\n * If the `kind` is the `PositionKind` and if `updateExtends` is true, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.\r\n * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.\r\n *\r\n * Possible `kind` values :\r\n * - VertexBuffer.PositionKind\r\n * - VertexBuffer.UVKind\r\n * - VertexBuffer.UV2Kind\r\n * - VertexBuffer.UV3Kind\r\n * - VertexBuffer.UV4Kind\r\n * - VertexBuffer.UV5Kind\r\n * - VertexBuffer.UV6Kind\r\n * - VertexBuffer.ColorKind\r\n * - VertexBuffer.MatricesIndicesKind\r\n * - VertexBuffer.MatricesIndicesExtraKind\r\n * - VertexBuffer.MatricesWeightsKind\r\n * - VertexBuffer.MatricesWeightsExtraKind\r\n *\r\n * Returns the Mesh.\r\n * @param kind defines vertex data kind\r\n * @param data defines the data source\r\n * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for \"position\" kind\r\n * @param makeItUnique defines it the updated vertex buffer must be flagged as unique (false by default)\r\n * @returns the source mesh\r\n */\r\n public override updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh {\r\n if (this.sourceMesh) {\r\n this.sourceMesh.updateVerticesData(kind, data, updateExtends, makeItUnique);\r\n }\r\n return this.sourceMesh;\r\n }\r\n\r\n /**\r\n * Sets the mesh indices.\r\n * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).\r\n * If the mesh has no geometry, a new Geometry object is created and set to the mesh.\r\n * This method creates a new index buffer each call.\r\n * Returns the Mesh.\r\n * @param indices the source data\r\n * @param totalVertices defines the total number of vertices referenced by indices (could be null)\r\n * @returns source mesh\r\n */\r\n public override setIndices(indices: IndicesArray, totalVertices: Nullable<number> = null): Mesh {\r\n if (this.sourceMesh) {\r\n this.sourceMesh.setIndices(indices, totalVertices);\r\n }\r\n return this.sourceMesh;\r\n }\r\n\r\n /**\r\n * Boolean : True if the mesh owns the requested kind of data.\r\n * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :\r\n * - VertexBuffer.PositionKind\r\n * - VertexBuffer.UVKind\r\n * - VertexBuffer.UV2Kind\r\n * - VertexBuffer.UV3Kind\r\n * - VertexBuffer.UV4Kind\r\n * - VertexBuffer.UV5Kind\r\n * - VertexBuffer.UV6Kind\r\n * - VertexBuffer.ColorKind\r\n * - VertexBuffer.MatricesIndicesKind\r\n * - VertexBuffer.MatricesIndicesExtraKind\r\n * - VertexBuffer.MatricesWeightsKind\r\n * - VertexBuffer.MatricesWeightsExtraKind\r\n * @returns true if data kind is present\r\n */\r\n public override isVerticesDataPresent(kind: string): boolean {\r\n return this._sourceMesh.isVerticesDataPresent(kind);\r\n }\r\n\r\n /**\r\n * @returns an array of indices (IndicesArray).\r\n */\r\n public override getIndices(): Nullable<IndicesArray> {\r\n return this._sourceMesh.getIndices();\r\n }\r\n\r\n /** @internal */\r\n public override get _positions(): Nullable<Vector3[]> {\r\n return this._sourceMesh._positions;\r\n }\r\n\r\n /** @internal */\r\n public override refreshBoundingInfo(applySkeletonOrOptions: boolean | IMeshDataOptions = false, applyMorph: boolean = false): InstancedMesh {\r\n if (this.hasBoundingInfo && this.getBoundingInfo().isLocked) {\r\n return this;\r\n }\r\n\r\n let options: IMeshDataOptions;\r\n if (typeof applySkeletonOrOptions === \"object\") {\r\n options = applySkeletonOrOptions;\r\n } else {\r\n options = {\r\n applySkeleton: applySkeletonOrOptions,\r\n applyMorph: applyMorph,\r\n };\r\n }\r\n\r\n const bias = this._sourceMesh.geometry ? this._sourceMesh.geometry.boundingBias : null;\r\n this._refreshBoundingInfo(this._sourceMesh._getData(options, null, VertexBuffer.PositionKind), bias);\r\n return this;\r\n }\r\n\r\n /** @internal */\r\n public override _preActivate(): InstancedMesh {\r\n if (this._currentLOD) {\r\n this._currentLOD._preActivate();\r\n }\r\n return this;\r\n }\r\n\r\n /**\r\n * @internal\r\n */\r\n public override _activate(renderId: number, intermediateRendering: boolean): boolean {\r\n super._activate(renderId, intermediateRendering);\r\n\r\n if (!this._sourceMesh.subMeshes) {\r\n Logger.Warn(\"Instances should only be created for meshes with geometry.\");\r\n }\r\n\r\n if (this._currentLOD) {\r\n const differentSign = this._currentLOD._getWorldMatrixDeterminant() >= 0 !== this._getWorldMatrixDeterminant() >= 0;\r\n if (differentSign) {\r\n this._internalAbstractMeshDataInfo._actAsRegularMesh = true;\r\n return true;\r\n }\r\n this._internalAbstractMeshDataInfo._actAsRegularMesh = false;\r\n\r\n this._currentLOD._registerInstanceForRenderId(this, renderId);\r\n\r\n if (intermediateRendering) {\r\n if (!this._currentLOD._internalAbstractMeshDataInfo._isActiveIntermediate) {\r\n this._currentLOD._internalAbstractMeshDataInfo._onlyForInstancesIntermediate = true;\r\n return true;\r\n }\r\n } else {\r\n if (!this._currentLOD._internalAbstractMeshDataInfo._isActive) {\r\n this._currentLOD._internalAbstractMeshDataInfo._onlyForInstances = true;\r\n return true;\r\n }\r\n }\r\n }\r\n return false;\r\n }\r\n\r\n /** @internal */\r\n public override _postActivate(): void {\r\n if (this._sourceMesh.edgesShareWithInstances && this._sourceMesh._edgesRenderer && this._sourceMesh._edgesRenderer.isEnabled && this._sourceMesh._renderingGroup) {\r\n // we are using the edge renderer of the source mesh\r\n this._sourceMesh._renderingGroup._edgesRenderers.pushNoDuplicate(this._sourceMesh._edgesRenderer);\r\n this._sourceMesh._edgesRenderer.customInstances.push(this.getWorldMatrix());\r\n } else if (this._edgesRenderer && this._edgesRenderer.isEnabled && this._sourceMesh._renderingGroup) {\r\n // we are using the edge renderer defined for this instance\r\n this._sourceMesh._renderingGroup._edgesRenderers.push(this._edgesRenderer);\r\n }\r\n }\r\n\r\n /** @internal */\r\n public override getWorldMatrix(): Matrix {\r\n if (\r\n this._currentLOD &&\r\n this._currentLOD !== this._sourceMesh &&\r\n this._currentLOD.billboardMode !== TransformNode.BILLBOARDMODE_NONE &&\r\n this._currentLOD._masterMesh !== this\r\n ) {\r\n if (!this._billboardWorldMatrix) {\r\n this._billboardWorldMatrix = new Matrix();\r\n }\r\n const tempMaster = this._currentLOD._masterMesh;\r\n this._currentLOD._masterMesh = this;\r\n TmpVectors.Vector3[7].copyFrom(this._currentLOD.position);\r\n this._currentLOD.position.set(0, 0, 0);\r\n this._billboardWorldMatrix.copyFrom(this._currentLOD.computeWorldMatrix(true));\r\n this._currentLOD.position.copyFrom(TmpVectors.Vector3[7]);\r\n this._currentLOD._masterMesh = tempMaster;\r\n return this._billboardWorldMatrix;\r\n }\r\n\r\n return super.getWorldMatrix();\r\n }\r\n\r\n /** @internal */\r\n public override get isAnInstance(): boolean {\r\n return true;\r\n }\r\n\r\n /**\r\n * Returns the current associated LOD AbstractMesh.\r\n * @param camera defines the camera to use to pick the LOD level\r\n * @returns a Mesh or `null` if no LOD is associated with the AbstractMesh\r\n */\r\n public override getLOD(camera: Camera): AbstractMesh {\r\n if (!camera) {\r\n return this;\r\n }\r\n\r\n const sourceMeshLODLevels = this.sourceMesh.getLODLevels();\r\n if (!sourceMeshLODLevels || sourceMeshLODLevels.length === 0) {\r\n this._currentLOD = this.sourceMesh;\r\n } else {\r\n const boundingInfo = this.getBoundingInfo();\r\n this._currentLOD = <Mesh>this.sourceMesh.getLOD(camera, boundingInfo.boundingSphere);\r\n }\r\n\r\n return this._currentLOD;\r\n }\r\n\r\n /**\r\n * @internal\r\n */\r\n public override _preActivateForIntermediateRendering(renderId: number): Mesh {\r\n return this.sourceMesh._preActivateForIntermediateRendering(renderId);\r\n }\r\n\r\n /** @internal */\r\n public _syncSubMeshes(): InstancedMesh {\r\n this.releaseSubMeshes();\r\n if (this._sourceMesh.subMeshes) {\r\n for (let index = 0; index < this._sourceMesh.subMeshes.length; index++) {\r\n this._sourceMesh.subMeshes[index].clone(this, this._sourceMesh);\r\n }\r\n }\r\n return this;\r\n }\r\n\r\n /** @internal */\r\n public override _generatePointsArray(): boolean {\r\n return this._sourceMesh._generatePointsArray();\r\n }\r\n\r\n /** @internal */\r\n public override _updateBoundingInfo(): AbstractMesh {\r\n if (this.hasBoundingInfo) {\r\n this.getBoundingInfo().update(this.worldMatrixFromCache);\r\n } else {\r\n this.buildBoundingInfo(this.absolutePosition, this.absolutePosition, this.worldMatrixFromCache);\r\n }\r\n this._updateSubMeshesBoundingInfo(this.worldMatrixFromCache);\r\n return this;\r\n }\r\n\r\n /**\r\n * Creates a new InstancedMesh from the current mesh.\r\n *\r\n * Returns the clone.\r\n * @param name the cloned mesh name\r\n * @param newParent the optional Node to parent the clone to.\r\n * @param doNotCloneChildren if `true` the model children aren't cloned.\r\n * @param newSourceMesh if set this mesh will be used as the source mesh instead of ths instance's one\r\n * @returns the clone\r\n */\r\n public override clone(name: string, newParent: Nullable<Node> = null, doNotCloneChildren?: boolean, newSourceMesh?: Mesh): InstancedMesh {\r\n const result = (newSourceMesh || this._sourceMesh).createInstance(name);\r\n\r\n // Deep copy\r\n DeepCopier.DeepCopy(\r\n this,\r\n result,\r\n [\r\n \"name\",\r\n \"subMeshes\",\r\n \"uniqueId\",\r\n \"parent\",\r\n \"lightSources\",\r\n \"receiveShadows\",\r\n \"material\",\r\n \"visibility\",\r\n \"skeleton\",\r\n \"sourceMesh\",\r\n \"isAnInstance\",\r\n \"facetNb\",\r\n \"isFacetDataEnabled\",\r\n \"isBlocked\",\r\n \"useBones\",\r\n \"hasInstances\",\r\n \"collider\",\r\n \"edgesRenderer\",\r\n \"forward\",\r\n \"up\",\r\n \"right\",\r\n \"absolutePosition\",\r\n \"absoluteScaling\",\r\n \"absoluteRotationQuaternion\",\r\n \"isWorldMatrixFrozen\",\r\n \"nonUniformScaling\",\r\n \"behaviors\",\r\n \"worldMatrixFromCache\",\r\n \"hasThinInstances\",\r\n \"hasBoundingInfo\",\r\n \"geometry\",\r\n ],\r\n []\r\n );\r\n\r\n // Parent\r\n if (newParent) {\r\n result.parent = newParent;\r\n }\r\n\r\n if (!doNotCloneChildren) {\r\n // Children\r\n for (let index = 0; index < this.getScene().meshes.length; index++) {\r\n const mesh = this.getScene().meshes[index];\r\n\r\n if (mesh.parent === this) {\r\n mesh.clone(mesh.name, result);\r\n }\r\n }\r\n }\r\n\r\n result.computeWorldMatrix(true);\r\n\r\n this.onClonedObservable.notifyObservers(result);\r\n\r\n return result;\r\n }\r\n\r\n /**\r\n * Disposes the InstancedMesh.\r\n * Returns nothing.\r\n * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)\r\n * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)\r\n */\r\n public override dispose(doNotRecurse?: boolean, disposeMaterialAndTextures = false): void {\r\n // Remove from mesh\r\n this._sourceMesh.removeInstance(this);\r\n super.dispose(doNotRecurse, disposeMaterialAndTextures);\r\n }\r\n\r\n /**\r\n * @internal\r\n */\r\n public override _serializeAsParent(serializationObject: any) {\r\n super._serializeAsParent(serializationObject);\r\n\r\n serializationObject.parentId = this._sourceMesh.uniqueId;\r\n serializationObject.parentInstanceIndex = this._indexInSourceMeshInstanceArray;\r\n }\r\n\r\n /**\r\n * Instantiate (when possible) or clone that node with its hierarchy\r\n * @param newParent defines the new parent to use for the instance (or clone)\r\n * @param options defines options to configure how copy is done\r\n * @param onNewNodeCreated defines an option callback to call when a clone or an instance is created\r\n * @returns an instance (or a clone) of the current node with its hierarchy\r\n */\r\n public override instantiateHierarchy(\r\n newParent: Nullable<TransformNode> = null,\r\n options?: { doNotInstantiate: boolean | ((node: TransformNode) => boolean); newSourcedMesh?: Mesh },\r\n onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void\r\n ): Nullable<TransformNode> {\r\n const clone = this.clone(\"Clone of \" + (this.name || this.id), newParent || this.parent, true, options && options.newSourcedMesh);\r\n\r\n if (clone) {\r\n if (onNewNodeCreated) {\r\n onNewNodeCreated(this, clone);\r\n }\r\n }\r\n\r\n for (const child of this.getChildTransformNodes(true)) {\r\n child.instantiateHierarchy(clone, options, onNewNodeCreated);\r\n }\r\n\r\n return clone;\r\n }\r\n}\r\n\r\nlet _Registered = false;\r\n/**\r\n * Register side effects for instancedMesh.\r\n * Safe to call multiple times; only the first call has an effect.\r\n */\r\nexport function RegisterInstancedMesh(): void {\r\n if (_Registered) {\r\n return;\r\n }\r\n _Registered = true;\r\n\r\n Mesh._instancedMeshFactory = (name: string, mesh: Mesh): InstancedMesh => {\r\n const instance = new InstancedMesh(name, mesh);\r\n\r\n if (mesh.instancedBuffers) {\r\n instance.instancedBuffers = {};\r\n\r\n for (const key in mesh.instancedBuffers) {\r\n instance.instancedBuffers[key] = mesh.instancedBuffers[key];\r\n }\r\n }\r\n\r\n return instance;\r\n };\r\n\r\n Mesh.prototype.registerInstancedBuffer = function (kind: string, stride: number): void {\r\n // Remove existing one (shared VBO)\r\n this._userInstancedBuffersStorage?.vertexBuffers[kind]?.dispose();\r\n\r\n // Remove existing per-pass VBOs (WebGPU)\r\n if (this._userInstancedBuffersStorage?.renderPasses) {\r\n for (const passId in this._userInstancedBuffersStorage.renderPasses) {\r\n const passVBOs = this._userInstancedBuffersStorage.renderPasses[passId];\r\n passVBOs[kind]?.dispose();\r\n delete passVBOs[kind];\r\n }\r\n }\r\n\r\n // Creates the instancedBuffer field if not present\r\n if (!this.instancedBuffers) {\r\n this.instancedBuffers = {};\r\n }\r\n\r\n for (const instance of this.instances) {\r\n if (!instance.instancedBuffers) {\r\n instance.instancedBuffers = {};\r\n }\r\n }\r\n\r\n if (!this._userInstancedBuffersStorage) {\r\n this._userInstancedBuffersStorage = {\r\n data: {},\r\n vertexBuffers: {},\r\n strides: {},\r\n sizes: {},\r\n vertexArrayObjects: this.getEngine().getCaps().vertexArrayObject ? {} : undefined,\r\n };\r\n }\r\n\r\n // Creates an empty property for this kind\r\n this.instancedBuffers[kind] = null;\r\n\r\n this._userInstancedBuffersStorage.strides[kind] = stride;\r\n this._userInstancedBuffersStorage.sizes[kind] = stride * 32; // Initial size\r\n this._userInstancedBuffersStorage.data[kind] = new Float32Array(this._userInstancedBuffersStorage.sizes[kind]);\r\n // In WebGPU, per-pass VBOs are used instead of a shared one (created on demand in _processInstancedBuffers)\r\n this._userInstancedBuffersStorage.vertexBuffers[kind] = this._instanceDataStorage.useMonoDataStorageRenderPass\r\n ? new VertexBuffer(this.getEngine(), this._userInstancedBuffersStorage.data[kind], kind, true, false, stride, true)\r\n : null;\r\n\r\n for (const instance of this.instances) {\r\n instance.instancedBuffers[kind] = null;\r\n }\r\n\r\n this._invalidateInstanceVertexArrayObject();\r\n\r\n this._markSubMeshesAsAttributesDirty();\r\n };\r\n\r\n Mesh.prototype._processInstancedBuffers = function (visibleInstances: Nullable<InstancedMesh[]>, renderSelf: boolean) {\r\n const instanceCount = visibleInstances ? visibleInstances.length : 0;\r\n\r\n // In WebGPU, queue.writeBuffer() writes are all applied before the command buffer executes,\r\n // so a shared VBO written by multiple render passes (e.g. effect layer + main scene) will\r\n // only reflect the last write for ALL passes. Use per-render-pass VBOs instead.\r\n const usePerPassStorage = !this._instanceDataStorage.useMonoDataStorageRenderPass;\r\n let perPassVertexBuffers: { [kind: string]: Nullable<VertexBuffer> } | undefined;\r\n if (usePerPassStorage) {\r\n const currentRenderPassId = this._instanceDataStorage.engine.currentRenderPassId;\r\n if (!this._userInstancedBuffersStorage.renderPasses) {\r\n this._userInstancedBuffersStorage.renderPasses = {};\r\n }\r\n if (!this._userInstancedBuffersStorage.renderPasses[currentRenderPassId]) {\r\n this._userInstancedBuffersStorage.renderPasses[currentRenderPassId] = {};\r\n }\r\n perPassVertexBuffers = this._userInstancedBuffersStorage.renderPasses[currentRenderPassId];\r\n }\r\n\r\n for (const kind in this.instancedBuffers) {\r\n let size = this._userInstancedBuffersStorage.sizes[kind];\r\n const stride = this._userInstancedBuffersStorage.strides[kind];\r\n\r\n // Resize if required\r\n const expectedSize = (instanceCount + 1) * stride;\r\n\r\n while (size < expectedSize) {\r\n size *= 2;\r\n }\r\n\r\n if (this._userInstancedBuffersStorage.data[kind].length != size) {\r\n this._userInstancedBuffersStorage.data[kind] = new Float32Array(size);\r\n this._userInstancedBuffersStorage.sizes[kind] = size;\r\n if (usePerPassStorage) {\r\n if (perPassVertexBuffers![kind]) {\r\n perPassVertexBuffers![kind]!.dispose();\r\n perPassVertexBuffers![kind] = null;\r\n }\r\n } else if (this._userInstancedBuffersStorage.vertexBuffers[kind]) {\r\n this._userInstancedBuffersStorage.vertexBuffers[kind].dispose();\r\n this._userInstancedBuffersStorage.vertexBuffers[kind] = null;\r\n }\r\n }\r\n\r\n const data = this._userInstancedBuffersStorage.data[kind];\r\n\r\n if (data) {\r\n // Update data buffer\r\n let offset = 0;\r\n if (renderSelf) {\r\n const value = this.instancedBuffers[kind] ?? 0;\r\n\r\n if (value.toArray) {\r\n value.toArray(data, offset);\r\n } else if (value.copyToArray) {\r\n value.copyToArray(data, offset);\r\n } else {\r\n data[offset] = value;\r\n }\r\n\r\n offset += stride;\r\n }\r\n\r\n for (let instanceIndex = 0; instanceIndex < instanceCount; instanceIndex++) {\r\n const instance = visibleInstances![instanceIndex];\r\n\r\n const value = instance.instancedBuffers[kind] ?? 0;\r\n\r\n if (value.toArray) {\r\n value.toArray(data, offset);\r\n } else if (value.copyToArray) {\r\n value.copyToArray(data, offset);\r\n } else {\r\n data[offset] = value;\r\n }\r\n\r\n offset += stride;\r\n }\r\n\r\n // Update vertex buffer (per-pass in WebGPU, shared in WebGL)\r\n if (usePerPassStorage) {\r\n if (!perPassVertexBuffers![kind]) {\r\n perPassVertexBuffers![kind] = new VertexBuffer(this.getEngine(), data, kind, true, false, stride, true);\r\n this._invalidateInstanceVertexArrayObject();\r\n } else {\r\n perPassVertexBuffers![kind]!.updateDirectly(data, 0);\r\n }\r\n } else {\r\n if (!this._userInstancedBuffersStorage.vertexBuffers[kind]) {\r\n this._userInstancedBuffersStorage.vertexBuffers[kind] = new VertexBuffer(this.getEngine(), data, kind, true, false, stride, true);\r\n this._invalidateInstanceVertexArrayObject();\r\n } else {\r\n this._userInstancedBuffersStorage.vertexBuffers[kind].updateDirectly(data, 0);\r\n }\r\n }\r\n }\r\n }\r\n\r\n Mesh.prototype._invalidateInstanceVertexArrayObject = function () {\r\n if (!this._userInstancedBuffersStorage || this._userInstancedBuffersStorage.vertexArrayObjects === undefined) {\r\n return;\r\n }\r\n\r\n for (const kind in this._userInstancedBuffersStorage.vertexArrayObjects) {\r\n (this.getEngine() as ThinEngine).releaseVertexArrayObject(this._userInstancedBuffersStorage.vertexArrayObjects[kind]);\r\n }\r\n\r\n this._userInstancedBuffersStorage.vertexArrayObjects = {};\r\n };\r\n\r\n Mesh.prototype._disposeInstanceSpecificData = function () {\r\n for (const renderPassId in this._instanceDataStorage.renderPasses) {\r\n this._instanceDataStorage.renderPasses[renderPassId].instancesBuffer?.dispose();\r\n }\r\n this._instanceDataStorage.renderPasses = {};\r\n this._instanceDataStorage.dataStorageRenderPass?.instancesBuffer?.dispose();\r\n\r\n while (this.instances.length) {\r\n this.instances[0].dispose();\r\n }\r\n\r\n for (const kind in this.instancedBuffers) {\r\n if (this._userInstancedBuffersStorage.vertexBuffers[kind]) {\r\n this._userInstancedBuffersStorage.vertexBuffers[kind].dispose();\r\n }\r\n }\r\n\r\n this._invalidateInstanceVertexArrayObject();\r\n\r\n this.instancedBuffers = {};\r\n };\r\n\r\n // Register Class Name\r\n RegisterClass(\"BABYLON.InstancedMesh\", InstancedMesh);\r\n };\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"file":"instancedMesh.pure.js","sourceRoot":"","sources":["../../../../dev/core/src/Meshes/instancedMesh.pure.ts"],"names":[],"mappings":"AAAA,6DAA6D;AAG7D,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;AAE/D,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAGxC,OAAO,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAE3D,OAAO,EAAE,IAAI,EAAE,MAAM,qBAAqB,CAAC;AAG3C,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAChD,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAErD,OAAO,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AAItD,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAElD;;GAEG;AACH,MAAM,OAAO,aAAc,SAAQ,YAAY;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YAAY,IAAI,IAAI,CAAC,oBAAoB,CAAC,YAAY,EAAE,CAAC;gBAChE,IAAI,CAAC,oBAAoB,CAAC,YAAY,CAAC,YAAY,CAAC,CAAC,eAAe,EAAE,OAAO,EAAE,CAAC;YACpF,CAAC;YACD,IAAI,CAAC,oBAAoB,CAAC,YAAY,GAAG,EAAE,CAAC;YAC5C,IAAI,CAAC,oBAAoB,CAAC,qBAAqB,EAAE,eAAe,EAAE,OAAO,EAAE,CAAC;YAE5E,OAAO,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,CAAC;gBAC3B,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,OAAO,EAAE,CAAC;YAChC,CAAC;YAED,KAAK,MAAM,IAAI,IAAI,IAAI,CAAC,gBAAgB,EAAE,CAAC;gBACvC,IAAI,IAAI,CAAC,4BAA4B,CAAC,aAAa,CAAC,IAAI,CAAC,EAAE,CAAC;oBACxD,IAAI,CAAC,4BAA4B,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC,OAAO,EAAE,CAAC;gBACpE,CAAC;YACL,CAAC;YAED,IAAI,CAAC,oCAAoC,EAAE,CAAC;YAE5C,IAAI,CAAC,gBAAgB,GAAG,EAAE,CAAC;QAC/B,CAAC,CAAC;QAEF,sBAAsB;QACtB,aAAa,CAAC,uBAAuB,EAAE,aAAa,CAAC,CAAC;IAC1D,CAAC,CAAC;AACN,CAAC","sourcesContent":["/** This file must only contain pure code and pure imports */\r\n\r\nimport { type FloatArray, type IndicesArray, type Nullable } from \"../types\";\r\nimport { Matrix, TmpVectors } from \"../Maths/math.vector.pure\";\r\nimport { type Vector3 } from \"../Maths/math.vector\";\r\nimport { Logger } from \"../Misc/logger\";\r\nimport { type Camera } from \"../Cameras/camera.pure\";\r\nimport { type Node } from \"../node\";\r\nimport { AbstractMesh } from \"../Meshes/abstractMesh.pure\";\r\nimport { type IMeshDataOptions } from \"../Meshes/abstractMesh\";\r\nimport { Mesh } from \"../Meshes/mesh.pure\";\r\nimport { type Material } from \"../Materials/material.pure\";\r\nimport { type Skeleton } from \"../Bones/skeleton\";\r\nimport { DeepCopier } from \"../Misc/deepCopier\";\r\nimport { TransformNode } from \"./transformNode.pure\";\r\nimport { type Light } from \"../Lights/light\";\r\nimport { VertexBuffer } from \"../Buffers/buffer.pure\";\r\nimport { type Geometry } from \"./geometry\";\r\n\r\nimport { type ThinEngine } from \"../Engines/thinEngine.pure\";\r\nimport { RegisterClass } from \"../Misc/typeStore\";\r\n\r\n/**\r\n * Creates an instance based on a source mesh.\r\n */\r\nexport class InstancedMesh extends AbstractMesh {\r\n private _sourceMesh: Mesh;\r\n private _currentLOD: Mesh;\r\n private _billboardWorldMatrix: Matrix;\r\n\r\n /** @internal */\r\n public _indexInSourceMeshInstanceArray = -1;\r\n /** @internal */\r\n public _distanceToCamera: number = 0;\r\n /** @internal */\r\n public _previousWorldMatrix: Nullable<Matrix>;\r\n\r\n /**\r\n * Creates a new InstancedMesh object from the mesh source.\r\n * @param name defines the name of the instance\r\n * @param source the mesh to create the instance from\r\n */\r\n constructor(name: string, source: Mesh) {\r\n super(name, source.getScene());\r\n\r\n source.addInstance(this);\r\n\r\n this._sourceMesh = source;\r\n\r\n this._unIndexed = source._unIndexed;\r\n\r\n this.position.copyFrom(source.position);\r\n this.rotation.copyFrom(source.rotation);\r\n this.scaling.copyFrom(source.scaling);\r\n\r\n if (source.rotationQuaternion) {\r\n this.rotationQuaternion = source.rotationQuaternion.clone();\r\n }\r\n\r\n this.animations = source.animations.slice();\r\n for (const range of source.getAnimationRanges()) {\r\n if (range != null) {\r\n this.createAnimationRange(range.name, range.from, range.to);\r\n }\r\n }\r\n\r\n this.infiniteDistance = source.infiniteDistance;\r\n\r\n this.setPivotMatrix(source.getPivotMatrix());\r\n\r\n if (!source.skeleton && !source.morphTargetManager && source.hasBoundingInfo) {\r\n // without skeleton or morphTargetManager, use bounding info of source mesh directly\r\n const boundingInfo = source.getBoundingInfo();\r\n this.buildBoundingInfo(boundingInfo.minimum, boundingInfo.maximum);\r\n } else {\r\n this.refreshBoundingInfo(true, true);\r\n }\r\n this._syncSubMeshes();\r\n }\r\n\r\n /**\r\n * @returns the string \"InstancedMesh\".\r\n */\r\n public override getClassName(): string {\r\n return \"InstancedMesh\";\r\n }\r\n\r\n /** Gets the list of lights affecting that mesh */\r\n public override get lightSources(): Light[] {\r\n return this._sourceMesh._lightSources;\r\n }\r\n\r\n /** @internal */\r\n public override _resyncLightSources(): void {\r\n // Do nothing as all the work will be done by source mesh\r\n }\r\n\r\n /** @internal */\r\n public override _resyncLightSource(): void {\r\n // Do nothing as all the work will be done by source mesh\r\n }\r\n\r\n /** @internal */\r\n public override _removeLightSource(): void {\r\n // Do nothing as all the work will be done by source mesh\r\n }\r\n\r\n // Methods\r\n /**\r\n * If the source mesh receives shadows\r\n */\r\n public override get receiveShadows(): boolean {\r\n return this._sourceMesh.receiveShadows;\r\n }\r\n\r\n public override set receiveShadows(_value: boolean) {\r\n if (this._sourceMesh?.receiveShadows !== _value) {\r\n Logger.Warn(\"Setting receiveShadows on an instanced mesh has no effect\");\r\n }\r\n }\r\n\r\n /**\r\n * The material of the source mesh\r\n */\r\n public override get material(): Nullable<Material> {\r\n return this._sourceMesh.material;\r\n }\r\n\r\n public override set material(_value: Nullable<Material>) {\r\n if (this._sourceMesh?.material !== _value) {\r\n Logger.Warn(\"Setting material on an instanced mesh has no effect\");\r\n }\r\n }\r\n\r\n /**\r\n * Visibility of the source mesh\r\n */\r\n public override get visibility(): number {\r\n return this._sourceMesh.visibility;\r\n }\r\n\r\n public override set visibility(_value: number) {\r\n if (this._sourceMesh?.visibility !== _value) {\r\n Logger.Warn(\"Setting visibility on an instanced mesh has no effect\");\r\n }\r\n }\r\n\r\n /**\r\n * Skeleton of the source mesh\r\n */\r\n public override get skeleton(): Nullable<Skeleton> {\r\n return this._sourceMesh.skeleton;\r\n }\r\n\r\n public override set skeleton(_value: Nullable<Skeleton>) {\r\n if (this._sourceMesh?.skeleton !== _value) {\r\n Logger.Warn(\"Setting skeleton on an instanced mesh has no effect\");\r\n }\r\n }\r\n\r\n /**\r\n * Rendering ground id of the source mesh\r\n */\r\n public override get renderingGroupId(): number {\r\n return this._sourceMesh.renderingGroupId;\r\n }\r\n\r\n public override set renderingGroupId(value: number) {\r\n if (!this._sourceMesh || value === this._sourceMesh.renderingGroupId) {\r\n return;\r\n }\r\n\r\n //no-op with warning\r\n Logger.Warn(\"Note - setting renderingGroupId of an instanced mesh has no effect on the scene\");\r\n }\r\n\r\n /**\r\n * @returns the total number of vertices (integer).\r\n */\r\n public override getTotalVertices(): number {\r\n return this._sourceMesh ? this._sourceMesh.getTotalVertices() : 0;\r\n }\r\n\r\n /**\r\n * Returns a positive integer : the total number of indices in this mesh geometry.\r\n * @returns the number of indices or zero if the mesh has no geometry.\r\n */\r\n public override getTotalIndices(): number {\r\n return this._sourceMesh.getTotalIndices();\r\n }\r\n\r\n /**\r\n * The source mesh of the instance\r\n */\r\n public get sourceMesh(): Mesh {\r\n return this._sourceMesh;\r\n }\r\n\r\n /**\r\n * Gets the mesh internal Geometry object\r\n */\r\n public override get geometry(): Nullable<Geometry> {\r\n return this._sourceMesh._geometry;\r\n }\r\n\r\n /**\r\n * Creates a new InstancedMesh object from the mesh model.\r\n * @see https://doc.babylonjs.com/features/featuresDeepDive/mesh/copies/instances\r\n * @param name defines the name of the new instance\r\n * @returns a new InstancedMesh\r\n */\r\n public createInstance(name: string): InstancedMesh {\r\n return this._sourceMesh.createInstance(name);\r\n }\r\n\r\n /**\r\n * Is this node ready to be used/rendered\r\n * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)\r\n * @returns is it ready\r\n */\r\n public override isReady(completeCheck = false): boolean {\r\n return this._sourceMesh.isReady(completeCheck, true);\r\n }\r\n\r\n /**\r\n * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.\r\n * @param kind kind of verticies to retrieve (eg. positions, normals, uvs, etc.)\r\n * @param copyWhenShared If true (default false) and and if the mesh geometry is shared among some other meshes, the returned array is a copy of the internal one.\r\n * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is\r\n * @returns a float array or a Float32Array of the requested kind of data : positions, normals, uvs, etc.\r\n */\r\n public override getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray> {\r\n return this._sourceMesh.getVerticesData(kind, copyWhenShared, forceCopy);\r\n }\r\n\r\n /** @internal */\r\n public override copyVerticesData(kind: string, vertexData: { [kind: string]: Float32Array }): void {\r\n this._sourceMesh.copyVerticesData(kind, vertexData);\r\n }\r\n\r\n /** @internal */\r\n public override getVertexBuffer(kind: string, bypassInstanceData?: boolean): Nullable<VertexBuffer> {\r\n return this._sourceMesh.getVertexBuffer(kind, bypassInstanceData);\r\n }\r\n\r\n /**\r\n * Sets the vertex data of the mesh geometry for the requested `kind`.\r\n * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.\r\n * The `data` are either a numeric array either a Float32Array.\r\n * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initially none) or updater.\r\n * The parameter `stride` is an optional positive integer, it is usually automatically deducted from the `kind` (3 for positions or normals, 2 for UV, etc).\r\n * Note that a new underlying VertexBuffer object is created each call.\r\n * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.\r\n *\r\n * Possible `kind` values :\r\n * - VertexBuffer.PositionKind\r\n * - VertexBuffer.UVKind\r\n * - VertexBuffer.UV2Kind\r\n * - VertexBuffer.UV3Kind\r\n * - VertexBuffer.UV4Kind\r\n * - VertexBuffer.UV5Kind\r\n * - VertexBuffer.UV6Kind\r\n * - VertexBuffer.ColorKind\r\n * - VertexBuffer.MatricesIndicesKind\r\n * - VertexBuffer.MatricesIndicesExtraKind\r\n * - VertexBuffer.MatricesWeightsKind\r\n * - VertexBuffer.MatricesWeightsExtraKind\r\n *\r\n * Returns the Mesh.\r\n * @param kind defines vertex data kind\r\n * @param data defines the data source\r\n * @param updatable defines if the data must be flagged as updatable (false as default)\r\n * @param stride defines the vertex stride (optional)\r\n * @returns the current mesh\r\n */\r\n public override setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh {\r\n if (this.sourceMesh) {\r\n this.sourceMesh.setVerticesData(kind, data, updatable, stride);\r\n }\r\n return this.sourceMesh;\r\n }\r\n\r\n /**\r\n * Updates the existing vertex data of the mesh geometry for the requested `kind`.\r\n * If the mesh has no geometry, it is simply returned as it is.\r\n * The `data` are either a numeric array either a Float32Array.\r\n * No new underlying VertexBuffer object is created.\r\n * If the `kind` is the `PositionKind` and if `updateExtends` is true, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.\r\n * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.\r\n *\r\n * Possible `kind` values :\r\n * - VertexBuffer.PositionKind\r\n * - VertexBuffer.UVKind\r\n * - VertexBuffer.UV2Kind\r\n * - VertexBuffer.UV3Kind\r\n * - VertexBuffer.UV4Kind\r\n * - VertexBuffer.UV5Kind\r\n * - VertexBuffer.UV6Kind\r\n * - VertexBuffer.ColorKind\r\n * - VertexBuffer.MatricesIndicesKind\r\n * - VertexBuffer.MatricesIndicesExtraKind\r\n * - VertexBuffer.MatricesWeightsKind\r\n * - VertexBuffer.MatricesWeightsExtraKind\r\n *\r\n * Returns the Mesh.\r\n * @param kind defines vertex data kind\r\n * @param data defines the data source\r\n * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for \"position\" kind\r\n * @param makeItUnique defines it the updated vertex buffer must be flagged as unique (false by default)\r\n * @returns the source mesh\r\n */\r\n public override updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh {\r\n if (this.sourceMesh) {\r\n this.sourceMesh.updateVerticesData(kind, data, updateExtends, makeItUnique);\r\n }\r\n return this.sourceMesh;\r\n }\r\n\r\n /**\r\n * Sets the mesh indices.\r\n * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).\r\n * If the mesh has no geometry, a new Geometry object is created and set to the mesh.\r\n * This method creates a new index buffer each call.\r\n * Returns the Mesh.\r\n * @param indices the source data\r\n * @param totalVertices defines the total number of vertices referenced by indices (could be null)\r\n * @returns source mesh\r\n */\r\n public override setIndices(indices: IndicesArray, totalVertices: Nullable<number> = null): Mesh {\r\n if (this.sourceMesh) {\r\n this.sourceMesh.setIndices(indices, totalVertices);\r\n }\r\n return this.sourceMesh;\r\n }\r\n\r\n /**\r\n * Boolean : True if the mesh owns the requested kind of data.\r\n * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :\r\n * - VertexBuffer.PositionKind\r\n * - VertexBuffer.UVKind\r\n * - VertexBuffer.UV2Kind\r\n * - VertexBuffer.UV3Kind\r\n * - VertexBuffer.UV4Kind\r\n * - VertexBuffer.UV5Kind\r\n * - VertexBuffer.UV6Kind\r\n * - VertexBuffer.ColorKind\r\n * - VertexBuffer.MatricesIndicesKind\r\n * - VertexBuffer.MatricesIndicesExtraKind\r\n * - VertexBuffer.MatricesWeightsKind\r\n * - VertexBuffer.MatricesWeightsExtraKind\r\n * @returns true if data kind is present\r\n */\r\n public override isVerticesDataPresent(kind: string): boolean {\r\n return this._sourceMesh.isVerticesDataPresent(kind);\r\n }\r\n\r\n /**\r\n * @returns an array of indices (IndicesArray).\r\n */\r\n public override getIndices(): Nullable<IndicesArray> {\r\n return this._sourceMesh.getIndices();\r\n }\r\n\r\n /** @internal */\r\n public override get _positions(): Nullable<Vector3[]> {\r\n return this._sourceMesh._positions;\r\n }\r\n\r\n /** @internal */\r\n public override refreshBoundingInfo(applySkeletonOrOptions: boolean | IMeshDataOptions = false, applyMorph: boolean = false): InstancedMesh {\r\n if (this.hasBoundingInfo && this.getBoundingInfo().isLocked) {\r\n return this;\r\n }\r\n\r\n let options: IMeshDataOptions;\r\n if (typeof applySkeletonOrOptions === \"object\") {\r\n options = applySkeletonOrOptions;\r\n } else {\r\n options = {\r\n applySkeleton: applySkeletonOrOptions,\r\n applyMorph: applyMorph,\r\n };\r\n }\r\n\r\n const bias = this._sourceMesh.geometry ? this._sourceMesh.geometry.boundingBias : null;\r\n this._refreshBoundingInfo(this._sourceMesh._getData(options, null, VertexBuffer.PositionKind), bias);\r\n return this;\r\n }\r\n\r\n /** @internal */\r\n public override _preActivate(): InstancedMesh {\r\n if (this._currentLOD) {\r\n this._currentLOD._preActivate();\r\n }\r\n return this;\r\n }\r\n\r\n /**\r\n * @internal\r\n */\r\n public override _activate(renderId: number, intermediateRendering: boolean): boolean {\r\n super._activate(renderId, intermediateRendering);\r\n\r\n if (!this._sourceMesh.subMeshes) {\r\n Logger.Warn(\"Instances should only be created for meshes with geometry.\");\r\n }\r\n\r\n if (this._currentLOD) {\r\n const differentSign = this._currentLOD._getWorldMatrixDeterminant() >= 0 !== this._getWorldMatrixDeterminant() >= 0;\r\n if (differentSign) {\r\n this._internalAbstractMeshDataInfo._actAsRegularMesh = true;\r\n return true;\r\n }\r\n this._internalAbstractMeshDataInfo._actAsRegularMesh = false;\r\n\r\n this._currentLOD._registerInstanceForRenderId(this, renderId);\r\n\r\n if (intermediateRendering) {\r\n if (!this._currentLOD._internalAbstractMeshDataInfo._isActiveIntermediate) {\r\n this._currentLOD._internalAbstractMeshDataInfo._onlyForInstancesIntermediate = true;\r\n return true;\r\n }\r\n } else {\r\n if (!this._currentLOD._internalAbstractMeshDataInfo._isActive) {\r\n this._currentLOD._internalAbstractMeshDataInfo._onlyForInstances = true;\r\n return true;\r\n }\r\n }\r\n }\r\n return false;\r\n }\r\n\r\n /** @internal */\r\n public override _postActivate(): void {\r\n if (this._sourceMesh.edgesShareWithInstances && this._sourceMesh._edgesRenderer && this._sourceMesh._edgesRenderer.isEnabled && this._sourceMesh._renderingGroup) {\r\n // we are using the edge renderer of the source mesh\r\n this._sourceMesh._renderingGroup._edgesRenderers.pushNoDuplicate(this._sourceMesh._edgesRenderer);\r\n this._sourceMesh._edgesRenderer.customInstances.push(this.getWorldMatrix());\r\n } else if (this._edgesRenderer && this._edgesRenderer.isEnabled && this._sourceMesh._renderingGroup) {\r\n // we are using the edge renderer defined for this instance\r\n this._sourceMesh._renderingGroup._edgesRenderers.push(this._edgesRenderer);\r\n }\r\n }\r\n\r\n /** @internal */\r\n public override getWorldMatrix(): Matrix {\r\n if (\r\n this._currentLOD &&\r\n this._currentLOD !== this._sourceMesh &&\r\n this._currentLOD.billboardMode !== TransformNode.BILLBOARDMODE_NONE &&\r\n this._currentLOD._masterMesh !== this\r\n ) {\r\n if (!this._billboardWorldMatrix) {\r\n this._billboardWorldMatrix = new Matrix();\r\n }\r\n const tempMaster = this._currentLOD._masterMesh;\r\n this._currentLOD._masterMesh = this;\r\n TmpVectors.Vector3[7].copyFrom(this._currentLOD.position);\r\n this._currentLOD.position.set(0, 0, 0);\r\n this._billboardWorldMatrix.copyFrom(this._currentLOD.computeWorldMatrix(true));\r\n this._currentLOD.position.copyFrom(TmpVectors.Vector3[7]);\r\n this._currentLOD._masterMesh = tempMaster;\r\n return this._billboardWorldMatrix;\r\n }\r\n\r\n return super.getWorldMatrix();\r\n }\r\n\r\n /** @internal */\r\n public override get isAnInstance(): boolean {\r\n return true;\r\n }\r\n\r\n /**\r\n * Returns the current associated LOD AbstractMesh.\r\n * @param camera defines the camera to use to pick the LOD level\r\n * @returns a Mesh or `null` if no LOD is associated with the AbstractMesh\r\n */\r\n public override getLOD(camera: Camera): AbstractMesh {\r\n if (!camera) {\r\n return this;\r\n }\r\n\r\n const sourceMeshLODLevels = this.sourceMesh.getLODLevels();\r\n if (!sourceMeshLODLevels || sourceMeshLODLevels.length === 0) {\r\n this._currentLOD = this.sourceMesh;\r\n } else {\r\n const boundingInfo = this.getBoundingInfo();\r\n this._currentLOD = <Mesh>this.sourceMesh.getLOD(camera, boundingInfo.boundingSphere);\r\n }\r\n\r\n return this._currentLOD;\r\n }\r\n\r\n /**\r\n * @internal\r\n */\r\n public override _preActivateForIntermediateRendering(renderId: number): Mesh {\r\n return this.sourceMesh._preActivateForIntermediateRendering(renderId);\r\n }\r\n\r\n /** @internal */\r\n public _syncSubMeshes(): InstancedMesh {\r\n this.releaseSubMeshes();\r\n if (this._sourceMesh.subMeshes) {\r\n for (let index = 0; index < this._sourceMesh.subMeshes.length; index++) {\r\n this._sourceMesh.subMeshes[index].clone(this, this._sourceMesh);\r\n }\r\n }\r\n return this;\r\n }\r\n\r\n /** @internal */\r\n public override _generatePointsArray(): boolean {\r\n return this._sourceMesh._generatePointsArray();\r\n }\r\n\r\n /** @internal */\r\n public override _updateBoundingInfo(): AbstractMesh {\r\n if (this.hasBoundingInfo) {\r\n this.getBoundingInfo().update(this.worldMatrixFromCache);\r\n } else {\r\n this.buildBoundingInfo(this.absolutePosition, this.absolutePosition, this.worldMatrixFromCache);\r\n }\r\n this._updateSubMeshesBoundingInfo(this.worldMatrixFromCache);\r\n return this;\r\n }\r\n\r\n /**\r\n * Creates a new InstancedMesh from the current mesh.\r\n *\r\n * Returns the clone.\r\n * @param name the cloned mesh name\r\n * @param newParent the optional Node to parent the clone to.\r\n * @param doNotCloneChildren if `true` the model children aren't cloned.\r\n * @param newSourceMesh if set this mesh will be used as the source mesh instead of ths instance's one\r\n * @returns the clone\r\n */\r\n public override clone(name: string, newParent: Nullable<Node> = null, doNotCloneChildren?: boolean, newSourceMesh?: Mesh): InstancedMesh {\r\n const result = (newSourceMesh || this._sourceMesh).createInstance(name);\r\n\r\n // Deep copy\r\n DeepCopier.DeepCopy(\r\n this,\r\n result,\r\n [\r\n \"name\",\r\n \"subMeshes\",\r\n \"uniqueId\",\r\n \"parent\",\r\n \"lightSources\",\r\n \"receiveShadows\",\r\n \"material\",\r\n \"visibility\",\r\n \"skeleton\",\r\n \"sourceMesh\",\r\n \"isAnInstance\",\r\n \"facetNb\",\r\n \"isFacetDataEnabled\",\r\n \"isBlocked\",\r\n \"useBones\",\r\n \"hasInstances\",\r\n \"collider\",\r\n \"edgesRenderer\",\r\n \"forward\",\r\n \"up\",\r\n \"right\",\r\n \"absolutePosition\",\r\n \"absoluteScaling\",\r\n \"absoluteRotationQuaternion\",\r\n \"isWorldMatrixFrozen\",\r\n \"nonUniformScaling\",\r\n \"behaviors\",\r\n \"worldMatrixFromCache\",\r\n \"hasThinInstances\",\r\n \"hasBoundingInfo\",\r\n \"geometry\",\r\n ],\r\n []\r\n );\r\n\r\n // Parent\r\n if (newParent) {\r\n result.parent = newParent;\r\n }\r\n\r\n if (!doNotCloneChildren) {\r\n // Children\r\n for (let index = 0; index < this.getScene().meshes.length; index++) {\r\n const mesh = this.getScene().meshes[index];\r\n\r\n if (mesh.parent === this) {\r\n mesh.clone(mesh.name, result);\r\n }\r\n }\r\n }\r\n\r\n result.computeWorldMatrix(true);\r\n\r\n this.onClonedObservable.notifyObservers(result);\r\n\r\n return result;\r\n }\r\n\r\n /**\r\n * Disposes the InstancedMesh.\r\n * Returns nothing.\r\n * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)\r\n * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)\r\n */\r\n public override dispose(doNotRecurse?: boolean, disposeMaterialAndTextures = false): void {\r\n // Remove from mesh\r\n this._sourceMesh.removeInstance(this);\r\n super.dispose(doNotRecurse, disposeMaterialAndTextures);\r\n }\r\n\r\n /**\r\n * @internal\r\n */\r\n public override _serializeAsParent(serializationObject: any) {\r\n super._serializeAsParent(serializationObject);\r\n\r\n serializationObject.parentId = this._sourceMesh.uniqueId;\r\n serializationObject.parentInstanceIndex = this._indexInSourceMeshInstanceArray;\r\n }\r\n\r\n /**\r\n * Instantiate (when possible) or clone that node with its hierarchy\r\n * @param newParent defines the new parent to use for the instance (or clone)\r\n * @param options defines options to configure how copy is done\r\n * @param onNewNodeCreated defines an option callback to call when a clone or an instance is created\r\n * @returns an instance (or a clone) of the current node with its hierarchy\r\n */\r\n public override instantiateHierarchy(\r\n newParent: Nullable<TransformNode> = null,\r\n options?: { doNotInstantiate: boolean | ((node: TransformNode) => boolean); newSourcedMesh?: Mesh },\r\n onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void\r\n ): Nullable<TransformNode> {\r\n const clone = this.clone(\"Clone of \" + (this.name || this.id), newParent || this.parent, true, options && options.newSourcedMesh);\r\n\r\n if (clone) {\r\n if (onNewNodeCreated) {\r\n onNewNodeCreated(this, clone);\r\n }\r\n }\r\n\r\n for (const child of this.getChildTransformNodes(true)) {\r\n child.instantiateHierarchy(clone, options, onNewNodeCreated);\r\n }\r\n\r\n return clone;\r\n }\r\n}\r\n\r\nlet _Registered = false;\r\n/**\r\n * Register side effects for instancedMesh.\r\n * Safe to call multiple times; only the first call has an effect.\r\n */\r\nexport function RegisterInstancedMesh(): void {\r\n if (_Registered) {\r\n return;\r\n }\r\n _Registered = true;\r\n\r\n Mesh._instancedMeshFactory = (name: string, mesh: Mesh): InstancedMesh => {\r\n const instance = new InstancedMesh(name, mesh);\r\n\r\n if (mesh.instancedBuffers) {\r\n instance.instancedBuffers = {};\r\n\r\n for (const key in mesh.instancedBuffers) {\r\n instance.instancedBuffers[key] = mesh.instancedBuffers[key];\r\n }\r\n }\r\n\r\n return instance;\r\n };\r\n\r\n Mesh.prototype.registerInstancedBuffer = function (kind: string, stride: number): void {\r\n // Remove existing one (shared VBO)\r\n this._userInstancedBuffersStorage?.vertexBuffers[kind]?.dispose();\r\n\r\n // Remove existing per-pass VBOs (WebGPU)\r\n if (this._userInstancedBuffersStorage?.renderPasses) {\r\n for (const passId in this._userInstancedBuffersStorage.renderPasses) {\r\n const passVBOs = this._userInstancedBuffersStorage.renderPasses[passId];\r\n passVBOs[kind]?.dispose();\r\n delete passVBOs[kind];\r\n }\r\n }\r\n\r\n // Creates the instancedBuffer field if not present\r\n if (!this.instancedBuffers) {\r\n this.instancedBuffers = {};\r\n }\r\n\r\n for (const instance of this.instances) {\r\n if (!instance.instancedBuffers) {\r\n instance.instancedBuffers = {};\r\n }\r\n }\r\n\r\n if (!this._userInstancedBuffersStorage) {\r\n this._userInstancedBuffersStorage = {\r\n data: {},\r\n vertexBuffers: {},\r\n strides: {},\r\n sizes: {},\r\n vertexArrayObjects: this.getEngine().getCaps().vertexArrayObject ? {} : undefined,\r\n };\r\n }\r\n\r\n // Creates an empty property for this kind\r\n this.instancedBuffers[kind] = null;\r\n\r\n this._userInstancedBuffersStorage.strides[kind] = stride;\r\n this._userInstancedBuffersStorage.sizes[kind] = stride * 32; // Initial size\r\n this._userInstancedBuffersStorage.data[kind] = new Float32Array(this._userInstancedBuffersStorage.sizes[kind]);\r\n // In WebGPU, per-pass VBOs are used instead of a shared one (created on demand in _processInstancedBuffers)\r\n this._userInstancedBuffersStorage.vertexBuffers[kind] = this._instanceDataStorage.useMonoDataStorageRenderPass\r\n ? new VertexBuffer(this.getEngine(), this._userInstancedBuffersStorage.data[kind], kind, true, false, stride, true)\r\n : null;\r\n\r\n for (const instance of this.instances) {\r\n instance.instancedBuffers[kind] = null;\r\n }\r\n\r\n this._invalidateInstanceVertexArrayObject();\r\n\r\n this._markSubMeshesAsAttributesDirty();\r\n };\r\n\r\n Mesh.prototype._processInstancedBuffers = function (visibleInstances: Nullable<InstancedMesh[]>, renderSelf: boolean) {\r\n const instanceCount = visibleInstances ? visibleInstances.length : 0;\r\n\r\n // In WebGPU, queue.writeBuffer() writes are all applied before the command buffer executes,\r\n // so a shared VBO written by multiple render passes (e.g. effect layer + main scene) will\r\n // only reflect the last write for ALL passes. Use per-render-pass VBOs instead.\r\n const usePerPassStorage = !this._instanceDataStorage.useMonoDataStorageRenderPass;\r\n let perPassVertexBuffers: { [kind: string]: Nullable<VertexBuffer> } | undefined;\r\n if (usePerPassStorage) {\r\n const currentRenderPassId = this._instanceDataStorage.engine.currentRenderPassId;\r\n if (!this._userInstancedBuffersStorage.renderPasses) {\r\n this._userInstancedBuffersStorage.renderPasses = {};\r\n }\r\n if (!this._userInstancedBuffersStorage.renderPasses[currentRenderPassId]) {\r\n this._userInstancedBuffersStorage.renderPasses[currentRenderPassId] = {};\r\n }\r\n perPassVertexBuffers = this._userInstancedBuffersStorage.renderPasses[currentRenderPassId];\r\n }\r\n\r\n for (const kind in this.instancedBuffers) {\r\n let size = this._userInstancedBuffersStorage.sizes[kind];\r\n const stride = this._userInstancedBuffersStorage.strides[kind];\r\n\r\n // Resize if required\r\n const expectedSize = (instanceCount + 1) * stride;\r\n\r\n while (size < expectedSize) {\r\n size *= 2;\r\n }\r\n\r\n if (!this._userInstancedBuffersStorage.data[kind] || this._userInstancedBuffersStorage.data[kind].length != size) {\r\n this._userInstancedBuffersStorage.data[kind] = new Float32Array(size);\r\n this._userInstancedBuffersStorage.sizes[kind] = size;\r\n if (usePerPassStorage) {\r\n if (perPassVertexBuffers![kind]) {\r\n perPassVertexBuffers![kind]!.dispose();\r\n perPassVertexBuffers![kind] = null;\r\n }\r\n } else if (this._userInstancedBuffersStorage.vertexBuffers[kind]) {\r\n this._userInstancedBuffersStorage.vertexBuffers[kind].dispose();\r\n this._userInstancedBuffersStorage.vertexBuffers[kind] = null;\r\n }\r\n }\r\n\r\n const data = this._userInstancedBuffersStorage.data[kind];\r\n\r\n if (data) {\r\n // Update data buffer\r\n let offset = 0;\r\n if (renderSelf) {\r\n const value = this.instancedBuffers[kind] ?? 0;\r\n\r\n if (value.toArray) {\r\n value.toArray(data, offset);\r\n } else if (value.copyToArray) {\r\n value.copyToArray(data, offset);\r\n } else {\r\n data[offset] = value;\r\n }\r\n\r\n offset += stride;\r\n }\r\n\r\n for (let instanceIndex = 0; instanceIndex < instanceCount; instanceIndex++) {\r\n const instance = visibleInstances![instanceIndex];\r\n\r\n const value = instance.instancedBuffers[kind] ?? 0;\r\n\r\n if (value.toArray) {\r\n value.toArray(data, offset);\r\n } else if (value.copyToArray) {\r\n value.copyToArray(data, offset);\r\n } else {\r\n data[offset] = value;\r\n }\r\n\r\n offset += stride;\r\n }\r\n\r\n // Update vertex buffer (per-pass in WebGPU, shared in WebGL)\r\n if (usePerPassStorage) {\r\n if (!perPassVertexBuffers![kind]) {\r\n perPassVertexBuffers![kind] = new VertexBuffer(this.getEngine(), data, kind, true, false, stride, true);\r\n this._invalidateInstanceVertexArrayObject();\r\n } else {\r\n perPassVertexBuffers![kind]!.updateDirectly(data, 0);\r\n }\r\n } else {\r\n if (!this._userInstancedBuffersStorage.vertexBuffers[kind]) {\r\n this._userInstancedBuffersStorage.vertexBuffers[kind] = new VertexBuffer(this.getEngine(), data, kind, true, false, stride, true);\r\n this._invalidateInstanceVertexArrayObject();\r\n } else {\r\n this._userInstancedBuffersStorage.vertexBuffers[kind].updateDirectly(data, 0);\r\n }\r\n }\r\n }\r\n }\r\n\r\n Mesh.prototype._invalidateInstanceVertexArrayObject = function () {\r\n if (!this._userInstancedBuffersStorage || this._userInstancedBuffersStorage.vertexArrayObjects === undefined) {\r\n return;\r\n }\r\n\r\n for (const kind in this._userInstancedBuffersStorage.vertexArrayObjects) {\r\n (this.getEngine() as ThinEngine).releaseVertexArrayObject(this._userInstancedBuffersStorage.vertexArrayObjects[kind]);\r\n }\r\n\r\n this._userInstancedBuffersStorage.vertexArrayObjects = {};\r\n };\r\n\r\n Mesh.prototype._disposeInstanceSpecificData = function () {\r\n for (const renderPassId in this._instanceDataStorage.renderPasses) {\r\n this._instanceDataStorage.renderPasses[renderPassId].instancesBuffer?.dispose();\r\n }\r\n this._instanceDataStorage.renderPasses = {};\r\n this._instanceDataStorage.dataStorageRenderPass?.instancesBuffer?.dispose();\r\n\r\n while (this.instances.length) {\r\n this.instances[0].dispose();\r\n }\r\n\r\n for (const kind in this.instancedBuffers) {\r\n if (this._userInstancedBuffersStorage.vertexBuffers[kind]) {\r\n this._userInstancedBuffersStorage.vertexBuffers[kind].dispose();\r\n }\r\n }\r\n\r\n this._invalidateInstanceVertexArrayObject();\r\n\r\n this.instancedBuffers = {};\r\n };\r\n\r\n // Register Class Name\r\n RegisterClass(\"BABYLON.InstancedMesh\", InstancedMesh);\r\n };\r\n}\r\n"]}
|
|
@@ -29,28 +29,59 @@ uint partIndex;
|
|
|
29
29
|
#if defined(IS_FOR_VOXELIZATION)
|
|
30
30
|
vec4 rotationA;vec4 rotationB;vec4 rotationScale;
|
|
31
31
|
#endif
|
|
32
|
+
#ifdef USE_SOG
|
|
33
|
+
float splatIndex;
|
|
34
|
+
#endif
|
|
32
35
|
};float getSplatIndex(int localIndex)
|
|
33
36
|
{float splatIndex;switch (localIndex)
|
|
34
37
|
{case 0: splatIndex=splatIndex0.x; break;case 1: splatIndex=splatIndex0.y; break;case 2: splatIndex=splatIndex0.z; break;case 3: splatIndex=splatIndex0.w; break;case 4: splatIndex=splatIndex1.x; break;case 5: splatIndex=splatIndex1.y; break;case 6: splatIndex=splatIndex1.z; break;case 7: splatIndex=splatIndex1.w; break;case 8: splatIndex=splatIndex2.x; break;case 9: splatIndex=splatIndex2.y; break;case 10: splatIndex=splatIndex2.z; break;case 11: splatIndex=splatIndex2.w; break;case 12: splatIndex=splatIndex3.x; break;case 13: splatIndex=splatIndex3.y; break;case 14: splatIndex=splatIndex3.z; break;case 15: splatIndex=splatIndex3.w; break;}
|
|
35
38
|
return splatIndex;}
|
|
36
39
|
Splat readSplat(float splatIndex)
|
|
37
|
-
{Splat splat;vec2 splatUV=getDataUV(splatIndex,dataTextureSize);
|
|
40
|
+
{Splat splat;vec2 splatUV=getDataUV(splatIndex,dataTextureSize);
|
|
41
|
+
#ifdef USE_SOG
|
|
42
|
+
ivec2 sogUVi=ivec2(int(splatUV.x*dataTextureSize.x),int(splatUV.y*dataTextureSize.y));vec4 mL=texelFetch(centersTexture,sogUVi,0);
|
|
43
|
+
vec4 mU=texelFetch(covariancesATexture,sogUVi,0);
|
|
44
|
+
vec4 sRaw=texelFetch(covariancesBTexture,sogUVi,0);
|
|
45
|
+
vec4 qRaw=texelFetch(sogQuatsTexture,sogUVi,0);
|
|
46
|
+
vec4 c0=texelFetch(colorsTexture,sogUVi,0);
|
|
47
|
+
vec3 q16=(mU.xyz*256.0+mL.xyz)*(255.0/65535.0);vec3 nPos=mix(sogMeansMin,sogMeansMax,q16);vec3 center=sign(nPos)*(exp(abs(nPos))-vec3(1.0));splat.center=vec4(center,1.0);
|
|
48
|
+
#ifdef USE_SOG_V2
|
|
49
|
+
vec3 sIdx=floor(sRaw.xyz*255.0+0.5);vec3 splatScale;splatScale.x=exp(texelFetch(sogCodebookTexture,ivec2(int(sIdx.x),0),0).r);splatScale.y=exp(texelFetch(sogCodebookTexture,ivec2(int(sIdx.y),0),0).r);splatScale.z=exp(texelFetch(sogCodebookTexture,ivec2(int(sIdx.z),0),0).r);
|
|
50
|
+
#else
|
|
51
|
+
vec3 splatScale=exp(mix(sogScalesMin,sogScalesMax,sRaw.xyz));
|
|
52
|
+
#endif
|
|
53
|
+
const float invSqrt2=0.70710678118;vec3 qabc=(qRaw.xyz-vec3(0.5))*2.0*invSqrt2;int qMode=int(qRaw.w*255.0+0.5)-252;float qd=sqrt(max(0.0,1.0-dot(qabc,qabc)));vec4 quat;if (qMode==0) quat=vec4(qd,qabc.x,qabc.y,qabc.z);else if (qMode==1) quat=vec4(qabc.x,qd,qabc.y,qabc.z);else if (qMode==2) quat=vec4(qabc.x,qabc.y,qd,qabc.z);else quat=vec4(qabc.x,qabc.y,qabc.z,qd);float qw=quat.x,qx=quat.y,qy=quat.z,qz=quat.w;mat3 R=mat3(
|
|
54
|
+
1.0-2.0*(qy*qy+qz*qz),2.0*(qx*qy+qw*qz), 2.0*(qx*qz-qw*qy),
|
|
55
|
+
2.0*(qx*qy-qw*qz), 1.0-2.0*(qx*qx+qz*qz),2.0*(qy*qz+qw*qx),
|
|
56
|
+
2.0*(qx*qz+qw*qy), 2.0*(qy*qz-qw*qx), 1.0-2.0*(qx*qx+qy*qy)
|
|
57
|
+
);mat3 S2=mat3(4.0*splatScale.x*splatScale.x,0.0,0.0,
|
|
58
|
+
0.0,4.0*splatScale.y*splatScale.y,0.0,
|
|
59
|
+
0.0,0.0,4.0*splatScale.z*splatScale.z);mat3 Sigma=R*S2*transpose(R);splat.covA=vec4(Sigma[0][0],Sigma[0][1],Sigma[0][2],Sigma[1][1]);splat.covB=vec4(Sigma[1][2],Sigma[2][2],0.0,0.0);const float SH_C0=0.28209479177387814;
|
|
60
|
+
#ifdef USE_SOG_V2
|
|
61
|
+
vec3 c3;c3.x=texelFetch(sogCodebookTexture,ivec2(256+int(c0.x*255.0+0.5),0),0).r;c3.y=texelFetch(sogCodebookTexture,ivec2(256+int(c0.y*255.0+0.5),0),0).r;c3.z=texelFetch(sogCodebookTexture,ivec2(256+int(c0.z*255.0+0.5),0),0).r;vec3 colRgb=vec3(0.5)+c3*SH_C0;float colA=c0.w;
|
|
62
|
+
#else
|
|
63
|
+
vec4 cLerp=mix(sogSh0Min,sogSh0Max,c0);vec3 colRgb=vec3(0.5)+cLerp.xyz*SH_C0;float colA=1.0/(1.0+exp(-cLerp.w));
|
|
64
|
+
#endif
|
|
65
|
+
splat.color=vec4(colRgb,colA);splat.splatIndex=splatIndex;
|
|
66
|
+
#else
|
|
67
|
+
splat.center=texture2D(centersTexture,splatUV);splat.color=texture2D(colorsTexture,splatUV);
|
|
38
68
|
#if !defined(IS_FOR_VOXELIZATION)
|
|
39
69
|
splat.covA=texture2D(covariancesATexture,splatUV)*splat.center.w;splat.covB=texture2D(covariancesBTexture,splatUV)*splat.center.w;
|
|
40
70
|
#endif
|
|
71
|
+
#endif
|
|
41
72
|
#if SH_DEGREE>0 || IS_COMPOUND
|
|
42
73
|
ivec2 splatUVint=getDataUVint(splatIndex,dataTextureSize);
|
|
43
74
|
#endif
|
|
44
|
-
#if SH_DEGREE>0
|
|
75
|
+
#if SH_DEGREE>0 && !defined(USE_SOG)
|
|
45
76
|
splat.sh0=texelFetch(shTexture0,splatUVint,0);
|
|
46
77
|
#endif
|
|
47
|
-
#if SH_DEGREE>1
|
|
78
|
+
#if SH_DEGREE>1 && !defined(USE_SOG)
|
|
48
79
|
splat.sh1=texelFetch(shTexture1,splatUVint,0);
|
|
49
80
|
#endif
|
|
50
|
-
#if SH_DEGREE>2
|
|
81
|
+
#if SH_DEGREE>2 && !defined(USE_SOG)
|
|
51
82
|
splat.sh2=texelFetch(shTexture2,splatUVint,0);
|
|
52
83
|
#endif
|
|
53
|
-
#if SH_DEGREE>3
|
|
84
|
+
#if SH_DEGREE>3 && !defined(USE_SOG)
|
|
54
85
|
splat.sh3=texelFetch(shTexture3,splatUVint,0);splat.sh4=texelFetch(shTexture4,splatUVint,0);
|
|
55
86
|
#endif
|
|
56
87
|
#if IS_COMPOUND
|
|
@@ -103,6 +134,23 @@ float((value ) & 255u),
|
|
|
103
134
|
float((value>>uint( 8)) & 255u),
|
|
104
135
|
float((value>>uint(16)) & 255u),
|
|
105
136
|
float((value>>uint(24)) & 255u));return components*vec4(2./255.)-vec4(1.);}
|
|
137
|
+
#ifdef USE_SOG
|
|
138
|
+
vec3 computeSH(Splat splat,vec3 dir)
|
|
139
|
+
{
|
|
140
|
+
#if SH_DEGREE>0
|
|
141
|
+
vec3 sh[25];sh[0]=vec3(0.,0.,0.);ivec2 labelSize=textureSize(sogShNLabelsTexture,0);int idx=int(splat.splatIndex+0.5);int lx=idx-(idx/labelSize.x)*labelSize.x;int ly=idx/labelSize.x;vec4 labelRaw=texelFetch(sogShNLabelsTexture,ivec2(lx,ly),0);int n=int(labelRaw.r*255.0+0.5)+int(labelRaw.g*255.0+0.5)*256;int coeffs=int(sogShCoeffCount+0.5);int u=(n-(n/64)*64)*coeffs;int v=n/64;for (int k=0; k<24; k++) {if (k>=coeffs) break;vec4 centroidRaw=texelFetch(sogShNCentroidsTexture,ivec2(u+k,v),0);vec3 shCoeff;
|
|
142
|
+
#ifdef USE_SOG_V2
|
|
143
|
+
int rIdx=int(centroidRaw.r*255.0+0.5);int gIdx=int(centroidRaw.g*255.0+0.5);int bIdx=int(centroidRaw.b*255.0+0.5);shCoeff.r=texelFetch(sogCodebookTexture,ivec2(512+rIdx,0),0).r;shCoeff.g=texelFetch(sogCodebookTexture,ivec2(512+gIdx,0),0).r;shCoeff.b=texelFetch(sogCodebookTexture,ivec2(512+bIdx,0),0).r;
|
|
144
|
+
#else
|
|
145
|
+
shCoeff=mix(vec3(sogShnMin),vec3(sogShnMax),centroidRaw.rgb);
|
|
146
|
+
#endif
|
|
147
|
+
sh[k+1]=shCoeff;}
|
|
148
|
+
return computeColorFromSHDegree(dir,sh,1.,1.,1.,1.);
|
|
149
|
+
#else
|
|
150
|
+
return vec3(0.,0.,0.);
|
|
151
|
+
#endif
|
|
152
|
+
}
|
|
153
|
+
#else
|
|
106
154
|
vec3 computeSHWeighted(Splat splat,vec3 dir,float _so1,float _so2,float _so3,float _so4)
|
|
107
155
|
{vec3 sh[25];sh[0]=vec3(0.,0.,0.);
|
|
108
156
|
#if SH_DEGREE>0
|
|
@@ -141,6 +189,7 @@ float _w4=1.0;
|
|
|
141
189
|
float _w4=0.0;
|
|
142
190
|
#endif
|
|
143
191
|
return computeSHWeighted(splat,dir,_w1,_w2,_w3,_w4);}
|
|
192
|
+
#endif
|
|
144
193
|
#else
|
|
145
194
|
vec3 computeSH(Splat splat,vec3 dir)
|
|
146
195
|
{return vec3(0.,0.,0.);}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"gaussianSplatting.js","sourceRoot":"","sources":["../../../../../dev/core/src/Shaders/ShadersInclude/gaussianSplatting.ts"],"names":[],"mappings":"AAAA,eAAe;AACf,OAAO,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AACxD,MAAM,IAAI,GAAG,mBAAmB,CAAC;AACjC,MAAM,MAAM,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA4Ld,CAAC;AACF,aAAa;AACb,IAAI,CAAC,WAAW,CAAC,oBAAoB,CAAC,IAAI,CAAC,EAAE,CAAC;IAC1C,WAAW,CAAC,oBAAoB,CAAC,IAAI,CAAC,GAAG,MAAM,CAAC;AACpD,CAAC;AACD,gBAAgB;AAChB,MAAM,CAAC,MAAM,iBAAiB,GAAG,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC","sourcesContent":["// Do not edit.\nimport { ShaderStore } from \"../../Engines/shaderStore\";\nconst name = \"gaussianSplatting\";\nconst shader = `#if !defined(WEBGL2) && !defined(WEBGPU) && !defined(NATIVE)\nmat3 transpose(mat3 matrix) {return mat3(matrix[0][0],matrix[1][0],matrix[2][0],\nmatrix[0][1],matrix[1][1],matrix[2][1],\nmatrix[0][2],matrix[1][2],matrix[2][2]);}\n#endif\nvec2 getDataUV(float index,vec2 textureSize) {float y=floor(index/textureSize.x);float x=index-y*textureSize.x;return vec2((x+0.5)/textureSize.x,(y+0.5)/textureSize.y);}\n#if SH_DEGREE>0 || IS_COMPOUND\nivec2 getDataUVint(float index,vec2 textureSize) {float y=floor(index/textureSize.x);float x=index-y*textureSize.x;return ivec2(uint(x+0.5),uint(y+0.5));}\n#endif\nstruct Splat {vec4 center;vec4 color;vec4 covA;vec4 covB;\n#if SH_DEGREE>0\nuvec4 sh0; \n#endif\n#if SH_DEGREE>1\nuvec4 sh1;\n#endif\n#if SH_DEGREE>2\nuvec4 sh2;\n#endif\n#if SH_DEGREE>3\nuvec4 sh3;uvec4 sh4;\n#endif\n#if IS_COMPOUND\nuint partIndex;\n#endif\n#if defined(IS_FOR_VOXELIZATION)\nvec4 rotationA;vec4 rotationB;vec4 rotationScale;\n#endif\n};float getSplatIndex(int localIndex)\n{float splatIndex;switch (localIndex)\n{case 0: splatIndex=splatIndex0.x; break;case 1: splatIndex=splatIndex0.y; break;case 2: splatIndex=splatIndex0.z; break;case 3: splatIndex=splatIndex0.w; break;case 4: splatIndex=splatIndex1.x; break;case 5: splatIndex=splatIndex1.y; break;case 6: splatIndex=splatIndex1.z; break;case 7: splatIndex=splatIndex1.w; break;case 8: splatIndex=splatIndex2.x; break;case 9: splatIndex=splatIndex2.y; break;case 10: splatIndex=splatIndex2.z; break;case 11: splatIndex=splatIndex2.w; break;case 12: splatIndex=splatIndex3.x; break;case 13: splatIndex=splatIndex3.y; break;case 14: splatIndex=splatIndex3.z; break;case 15: splatIndex=splatIndex3.w; break;}\nreturn splatIndex;}\nSplat readSplat(float splatIndex)\n{Splat splat;vec2 splatUV=getDataUV(splatIndex,dataTextureSize);splat.center=texture2D(centersTexture,splatUV);splat.color=texture2D(colorsTexture,splatUV);\n#if !defined(IS_FOR_VOXELIZATION)\nsplat.covA=texture2D(covariancesATexture,splatUV)*splat.center.w;splat.covB=texture2D(covariancesBTexture,splatUV)*splat.center.w;\n#endif\n#if SH_DEGREE>0 || IS_COMPOUND\nivec2 splatUVint=getDataUVint(splatIndex,dataTextureSize);\n#endif\n#if SH_DEGREE>0\nsplat.sh0=texelFetch(shTexture0,splatUVint,0);\n#endif\n#if SH_DEGREE>1\nsplat.sh1=texelFetch(shTexture1,splatUVint,0);\n#endif\n#if SH_DEGREE>2\nsplat.sh2=texelFetch(shTexture2,splatUVint,0);\n#endif\n#if SH_DEGREE>3\nsplat.sh3=texelFetch(shTexture3,splatUVint,0);splat.sh4=texelFetch(shTexture4,splatUVint,0);\n#endif\n#if IS_COMPOUND\nsplat.partIndex=uint(texture2D(partIndicesTexture,splatUV).r*255.0+0.5);\n#endif\n#if defined(IS_FOR_VOXELIZATION)\nsplat.rotationA=texture2D(rotationsATexture,splatUV);splat.rotationB=texture2D(rotationsBTexture,splatUV);splat.rotationScale=texture2D(rotationScaleTexture,splatUV);\n#endif\nreturn splat;}\n#if defined(WEBGL2) || defined(WEBGPU) || defined(NATIVE)\nvec3 computeColorFromSHDegree(vec3 dir,const vec3 sh[25],float _so1,float _so2,float _so3,float _so4)\n{const float SH_C0=0.28209479;const float SH_C1=0.48860251;float SH_C2[5];SH_C2[0]=1.092548430;SH_C2[1]=-1.09254843;SH_C2[2]=0.315391565;SH_C2[3]=-1.09254843;SH_C2[4]=0.546274215;float SH_C3[7];SH_C3[0]=-0.59004358;SH_C3[1]=2.890611442;SH_C3[2]=-0.45704579;SH_C3[3]=0.373176332;SH_C3[4]=-0.45704579;SH_C3[5]=1.445305721;SH_C3[6]=-0.59004358;float SH_C4[9];SH_C4[0]= 2.5033429418;SH_C4[1]=-1.7701307698;SH_C4[2]= 0.9461746958;SH_C4[3]=-0.6690465436;SH_C4[4]= 0.1057855469;SH_C4[5]=-0.6690465436;SH_C4[6]= 0.4730873479;SH_C4[7]=-1.7701307698;SH_C4[8]= 0.6258357354;vec3 result=/*SH_C0**/sh[0];\n#if SH_DEGREE>0\nfloat x=dir.x;float y=dir.y;float z=dir.z;result+=_so1*(- SH_C1*y*sh[1]+SH_C1*z*sh[2]-SH_C1*x*sh[3]);\n#if SH_DEGREE>1\nfloat xx=x*x,yy=y*y,zz=z*z;float xy=x*y,yz=y*z,xz=x*z;result+=_so2*(\nSH_C2[0]*xy*sh[4] +\nSH_C2[1]*yz*sh[5] +\nSH_C2[2]*(2.0*zz-xx-yy)*sh[6] +\nSH_C2[3]*xz*sh[7] +\nSH_C2[4]*(xx-yy)*sh[8]);\n#if SH_DEGREE>2\nresult+=_so3*(\nSH_C3[0]*y*(3.0*xx-yy)*sh[9] +\nSH_C3[1]*xy*z*sh[10] +\nSH_C3[2]*y*(4.0*zz-xx-yy)*sh[11] +\nSH_C3[3]*z*(2.0*zz-3.0*xx-3.0*yy)*sh[12] +\nSH_C3[4]*x*(4.0*zz-xx-yy)*sh[13] +\nSH_C3[5]*z*(xx-yy)*sh[14] +\nSH_C3[6]*x*(xx-3.0*yy)*sh[15]);\n#if SH_DEGREE>3\nresult+=_so4*(\nSH_C4[0]*x*y*(xx-yy)*sh[16] +\nSH_C4[1]*y*z*(3.0*xx-yy)*sh[17] +\nSH_C4[2]*x*y*(7.0*zz-1.0)*sh[18] +\nSH_C4[3]*y*z*(7.0*zz-3.0)*sh[19] +\nSH_C4[4]*(zz*(35.0*zz-30.0)+3.0)*sh[20] +\nSH_C4[5]*x*z*(7.0*zz-3.0)*sh[21] +\nSH_C4[6]*(xx-yy)*(7.0*zz-1.0)*sh[22] +\nSH_C4[7]*x*z*(xx-3.0*yy)*sh[23] +\nSH_C4[8]*(xx*(xx-3.0*yy)-yy*(3.0*xx-yy))*sh[24]);\n#endif\n#endif\n#endif\n#endif\nreturn result;}\nvec4 decompose(uint value)\n{vec4 components=vec4(\nfloat((value ) & 255u),\nfloat((value>>uint( 8)) & 255u),\nfloat((value>>uint(16)) & 255u),\nfloat((value>>uint(24)) & 255u));return components*vec4(2./255.)-vec4(1.);}\nvec3 computeSHWeighted(Splat splat,vec3 dir,float _so1,float _so2,float _so3,float _so4)\n{vec3 sh[25];sh[0]=vec3(0.,0.,0.);\n#if SH_DEGREE>0\nvec4 sh00=decompose(splat.sh0.x);vec4 sh01=decompose(splat.sh0.y);vec4 sh02=decompose(splat.sh0.z);sh[1]=vec3(sh00.x,sh00.y,sh00.z);sh[2]=vec3(sh00.w,sh01.x,sh01.y);sh[3]=vec3(sh01.z,sh01.w,sh02.x);\n#endif\n#if SH_DEGREE>1\nvec4 sh03=decompose(splat.sh0.w);vec4 sh04=decompose(splat.sh1.x);vec4 sh05=decompose(splat.sh1.y);sh[4]=vec3(sh02.y,sh02.z,sh02.w);sh[5]=vec3(sh03.x,sh03.y,sh03.z);sh[6]=vec3(sh03.w,sh04.x,sh04.y);sh[7]=vec3(sh04.z,sh04.w,sh05.x);sh[8]=vec3(sh05.y,sh05.z,sh05.w);\n#endif\n#if SH_DEGREE>2\nvec4 sh06=decompose(splat.sh1.z);vec4 sh07=decompose(splat.sh1.w);vec4 sh08=decompose(splat.sh2.x);vec4 sh09=decompose(splat.sh2.y);vec4 sh10=decompose(splat.sh2.z);vec4 sh11=decompose(splat.sh2.w);sh[9]=vec3(sh06.x,sh06.y,sh06.z);sh[10]=vec3(sh06.w,sh07.x,sh07.y);sh[11]=vec3(sh07.z,sh07.w,sh08.x);sh[12]=vec3(sh08.y,sh08.z,sh08.w);sh[13]=vec3(sh09.x,sh09.y,sh09.z);sh[14]=vec3(sh09.w,sh10.x,sh10.y);sh[15]=vec3(sh10.z,sh10.w,sh11.x);\n#endif\n#if SH_DEGREE>3\nvec4 sh12=decompose(splat.sh3.x);vec4 sh13=decompose(splat.sh3.y);vec4 sh14=decompose(splat.sh3.z);vec4 sh15=decompose(splat.sh3.w);vec4 sh16=decompose(splat.sh4.x);vec4 sh17=decompose(splat.sh4.y);sh[16]=vec3(sh11.y,sh11.z,sh11.w);sh[17]=vec3(sh12.x,sh12.y,sh12.z);sh[18]=vec3(sh12.w,sh13.x,sh13.y);sh[19]=vec3(sh13.z,sh13.w,sh14.x);sh[20]=vec3(sh14.y,sh14.z,sh14.w);sh[21]=vec3(sh15.x,sh15.y,sh15.z);sh[22]=vec3(sh15.w,sh16.x,sh16.y);sh[23]=vec3(sh16.z,sh16.w,sh17.x);sh[24]=vec3(sh17.y,sh17.z,sh17.w);\n#endif\nreturn computeColorFromSHDegree(dir,sh,_so1,_so2,_so3,_so4);}\nvec3 computeSH(Splat splat,vec3 dir)\n{\n#if !defined(GS_DBG_ENABLED) || GS_DBG_SH_ORDER1==1\nfloat _w1=1.0;\n#else\nfloat _w1=0.0;\n#endif\n#if !defined(GS_DBG_ENABLED) || GS_DBG_SH_ORDER2==1\nfloat _w2=1.0;\n#else\nfloat _w2=0.0;\n#endif\n#if !defined(GS_DBG_ENABLED) || GS_DBG_SH_ORDER3==1\nfloat _w3=1.0;\n#else\nfloat _w3=0.0;\n#endif\n#if !defined(GS_DBG_ENABLED) || GS_DBG_SH_ORDER4==1\nfloat _w4=1.0;\n#else\nfloat _w4=0.0;\n#endif\nreturn computeSHWeighted(splat,dir,_w1,_w2,_w3,_w4);}\n#else\nvec3 computeSH(Splat splat,vec3 dir)\n{return vec3(0.,0.,0.);}\n#endif\n#if !defined(IS_FOR_VOXELIZATION)\nvec4 gaussianSplatting(vec2 meshPos,vec3 worldPos,vec2 scale,vec3 covA,vec3 covB,mat4 worldMatrix,mat4 viewMatrix,mat4 projectionMatrix)\n{mat4 modelView=viewMatrix*worldMatrix;vec4 camspace=viewMatrix*vec4(worldPos,1.);vec4 pos2d=projectionMatrix*camspace;float bounds=1.2*pos2d.w;if (pos2d.z<-pos2d.w || pos2d.x<-bounds || pos2d.x>bounds\n|| pos2d.y<-bounds || pos2d.y>bounds) {return vec4(0.0,0.0,2.0,1.0);}\nmat3 Vrk=mat3(\ncovA.x,covA.y,covA.z,\ncovA.y,covB.x,covB.y,\ncovA.z,covB.y,covB.z\n);bool isOrtho=abs(projectionMatrix[3][3]-1.0)<0.001;mat3 J;if (isOrtho) {J=mat3(\nfocal.x,0.,0.,\n0.,focal.y,0.,\n0.,0.,0.\n);} else {J=mat3(\nfocal.x/camspace.z,0.,-(focal.x*camspace.x)/(camspace.z*camspace.z),\n0.,focal.y/camspace.z,-(focal.y*camspace.y)/(camspace.z*camspace.z),\n0.,0.,0.\n);}\nmat3 T=transpose(mat3(modelView))*J;mat3 cov2d=transpose(T)*Vrk*T;\n#if COMPENSATION\nfloat c00=cov2d[0][0];float c11=cov2d[1][1];float c01=cov2d[0][1];float detOrig=c00*c11-c01*c01;\n#endif\ncov2d[0][0]+=kernelSize;cov2d[1][1]+=kernelSize;\n#if COMPENSATION\nvec3 c2d=vec3(cov2d[0][0],c01,cov2d[1][1]);float detBlur=c2d.x*c2d.z-c2d.y*c2d.y;float compensation=sqrt(max(0.,detOrig/detBlur));vColor.w*=compensation;\n#endif\nfloat mid=(cov2d[0][0]+cov2d[1][1])/2.0;float radius=length(vec2((cov2d[0][0]-cov2d[1][1])/2.0,cov2d[0][1]));float epsilon=0.0001;float lambda1=mid+radius+epsilon,lambda2=mid-radius+epsilon;if (lambda2<0.0)\n{return vec4(0.0,0.0,2.0,1.0);}\nvec2 diagonalVector=normalize(vec2(cov2d[0][1],lambda1-cov2d[0][0]));vec2 majorAxis=min(sqrt(2.0*lambda1),1024.0)*diagonalVector;vec2 minorAxis=min(sqrt(2.0*lambda2),1024.0)*vec2(diagonalVector.y,-diagonalVector.x);vec2 vCenter=vec2(pos2d);float scaleFactor=isOrtho ? 1.0 : pos2d.w;return vec4(\nvCenter \n+ ((meshPos.x*majorAxis\n+ meshPos.y*minorAxis)*invViewport*scaleFactor)*scale,pos2d.zw);}\n#endif\n#if IS_COMPOUND\nmat4 getPartWorld(uint partIndex) {return partWorld[partIndex];}\n#endif\n#if defined(IS_FOR_VOXELIZATION)\nvec4 computeVoxelSplatWorldPos(vec4 rotationA,vec4 rotationB,vec4 rotationScale,vec3 center,mat4 splatWorld,mat4 viewMatrix,mat4 invWorldScale,vec2 quadPos) {mat3 splatRotation=mat3(\nvec3(rotationA.x,rotationA.y,rotationA.z),\nvec3(rotationA.w,rotationB.x,rotationB.y),\nvec3(rotationB.z,rotationB.w,rotationScale.x)\n);vec3 splatScale=vec3(rotationScale.y,rotationScale.z,rotationScale.w);mat3 rotToView=mat3(viewMatrix)*mat3(invWorldScale)*mat3(splatWorld)*splatRotation;vec3 axisLengthInViewZ=abs(vec3(rotToView[0][2],rotToView[1][2],rotToView[2][2]));float gaussianSplatCutoffStddev=1.4142135624/2.0; \nvec3 offsetSplatSpace;if (axisLengthInViewZ.x>axisLengthInViewZ.y && axisLengthInViewZ.x>axisLengthInViewZ.z) {offsetSplatSpace=vec3(0.0,quadPos.x,quadPos.y)*splatScale*gaussianSplatCutoffStddev;} else if (axisLengthInViewZ.y>axisLengthInViewZ.z) {offsetSplatSpace=vec3(quadPos.x,0.0,quadPos.y)*splatScale*gaussianSplatCutoffStddev;} else {offsetSplatSpace=vec3(quadPos.x,quadPos.y,0.0)*splatScale*gaussianSplatCutoffStddev;}\nvec3 vertexObjectSpace=center+splatRotation*offsetSplatSpace;return splatWorld*vec4(vertexObjectSpace,1.0);}\n#endif\n`;\n// Sideeffect\nif (!ShaderStore.IncludesShadersStore[name]) {\n ShaderStore.IncludesShadersStore[name] = shader;\n}\n/** @internal */\nexport const gaussianSplatting = { name, shader };\n"]}
|
|
1
|
+
{"version":3,"file":"gaussianSplatting.js","sourceRoot":"","sources":["../../../../../dev/core/src/Shaders/ShadersInclude/gaussianSplatting.ts"],"names":[],"mappings":"AAAA,eAAe;AACf,OAAO,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AACxD,MAAM,IAAI,GAAG,mBAAmB,CAAC;AACjC,MAAM,MAAM,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA6Od,CAAC;AACF,aAAa;AACb,IAAI,CAAC,WAAW,CAAC,oBAAoB,CAAC,IAAI,CAAC,EAAE,CAAC;IAC1C,WAAW,CAAC,oBAAoB,CAAC,IAAI,CAAC,GAAG,MAAM,CAAC;AACpD,CAAC;AACD,gBAAgB;AAChB,MAAM,CAAC,MAAM,iBAAiB,GAAG,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC","sourcesContent":["// Do not edit.\nimport { ShaderStore } from \"../../Engines/shaderStore\";\nconst name = \"gaussianSplatting\";\nconst shader = `#if !defined(WEBGL2) && !defined(WEBGPU) && !defined(NATIVE)\nmat3 transpose(mat3 matrix) {return mat3(matrix[0][0],matrix[1][0],matrix[2][0],\nmatrix[0][1],matrix[1][1],matrix[2][1],\nmatrix[0][2],matrix[1][2],matrix[2][2]);}\n#endif\nvec2 getDataUV(float index,vec2 textureSize) {float y=floor(index/textureSize.x);float x=index-y*textureSize.x;return vec2((x+0.5)/textureSize.x,(y+0.5)/textureSize.y);}\n#if SH_DEGREE>0 || IS_COMPOUND\nivec2 getDataUVint(float index,vec2 textureSize) {float y=floor(index/textureSize.x);float x=index-y*textureSize.x;return ivec2(uint(x+0.5),uint(y+0.5));}\n#endif\nstruct Splat {vec4 center;vec4 color;vec4 covA;vec4 covB;\n#if SH_DEGREE>0\nuvec4 sh0; \n#endif\n#if SH_DEGREE>1\nuvec4 sh1;\n#endif\n#if SH_DEGREE>2\nuvec4 sh2;\n#endif\n#if SH_DEGREE>3\nuvec4 sh3;uvec4 sh4;\n#endif\n#if IS_COMPOUND\nuint partIndex;\n#endif\n#if defined(IS_FOR_VOXELIZATION)\nvec4 rotationA;vec4 rotationB;vec4 rotationScale;\n#endif\n#ifdef USE_SOG\nfloat splatIndex;\n#endif\n};float getSplatIndex(int localIndex)\n{float splatIndex;switch (localIndex)\n{case 0: splatIndex=splatIndex0.x; break;case 1: splatIndex=splatIndex0.y; break;case 2: splatIndex=splatIndex0.z; break;case 3: splatIndex=splatIndex0.w; break;case 4: splatIndex=splatIndex1.x; break;case 5: splatIndex=splatIndex1.y; break;case 6: splatIndex=splatIndex1.z; break;case 7: splatIndex=splatIndex1.w; break;case 8: splatIndex=splatIndex2.x; break;case 9: splatIndex=splatIndex2.y; break;case 10: splatIndex=splatIndex2.z; break;case 11: splatIndex=splatIndex2.w; break;case 12: splatIndex=splatIndex3.x; break;case 13: splatIndex=splatIndex3.y; break;case 14: splatIndex=splatIndex3.z; break;case 15: splatIndex=splatIndex3.w; break;}\nreturn splatIndex;}\nSplat readSplat(float splatIndex)\n{Splat splat;vec2 splatUV=getDataUV(splatIndex,dataTextureSize);\n#ifdef USE_SOG\nivec2 sogUVi=ivec2(int(splatUV.x*dataTextureSize.x),int(splatUV.y*dataTextureSize.y));vec4 mL=texelFetch(centersTexture,sogUVi,0); \nvec4 mU=texelFetch(covariancesATexture,sogUVi,0); \nvec4 sRaw=texelFetch(covariancesBTexture,sogUVi,0); \nvec4 qRaw=texelFetch(sogQuatsTexture,sogUVi,0); \nvec4 c0=texelFetch(colorsTexture,sogUVi,0); \nvec3 q16=(mU.xyz*256.0+mL.xyz)*(255.0/65535.0);vec3 nPos=mix(sogMeansMin,sogMeansMax,q16);vec3 center=sign(nPos)*(exp(abs(nPos))-vec3(1.0));splat.center=vec4(center,1.0);\n#ifdef USE_SOG_V2\nvec3 sIdx=floor(sRaw.xyz*255.0+0.5);vec3 splatScale;splatScale.x=exp(texelFetch(sogCodebookTexture,ivec2(int(sIdx.x),0),0).r);splatScale.y=exp(texelFetch(sogCodebookTexture,ivec2(int(sIdx.y),0),0).r);splatScale.z=exp(texelFetch(sogCodebookTexture,ivec2(int(sIdx.z),0),0).r);\n#else\nvec3 splatScale=exp(mix(sogScalesMin,sogScalesMax,sRaw.xyz));\n#endif\nconst float invSqrt2=0.70710678118;vec3 qabc=(qRaw.xyz-vec3(0.5))*2.0*invSqrt2;int qMode=int(qRaw.w*255.0+0.5)-252;float qd=sqrt(max(0.0,1.0-dot(qabc,qabc)));vec4 quat;if (qMode==0) quat=vec4(qd,qabc.x,qabc.y,qabc.z);else if (qMode==1) quat=vec4(qabc.x,qd,qabc.y,qabc.z);else if (qMode==2) quat=vec4(qabc.x,qabc.y,qd,qabc.z);else quat=vec4(qabc.x,qabc.y,qabc.z,qd);float qw=quat.x,qx=quat.y,qy=quat.z,qz=quat.w;mat3 R=mat3(\n1.0-2.0*(qy*qy+qz*qz),2.0*(qx*qy+qw*qz), 2.0*(qx*qz-qw*qy),\n2.0*(qx*qy-qw*qz), 1.0-2.0*(qx*qx+qz*qz),2.0*(qy*qz+qw*qx),\n2.0*(qx*qz+qw*qy), 2.0*(qy*qz-qw*qx), 1.0-2.0*(qx*qx+qy*qy)\n);mat3 S2=mat3(4.0*splatScale.x*splatScale.x,0.0,0.0,\n0.0,4.0*splatScale.y*splatScale.y,0.0,\n0.0,0.0,4.0*splatScale.z*splatScale.z);mat3 Sigma=R*S2*transpose(R);splat.covA=vec4(Sigma[0][0],Sigma[0][1],Sigma[0][2],Sigma[1][1]);splat.covB=vec4(Sigma[1][2],Sigma[2][2],0.0,0.0);const float SH_C0=0.28209479177387814;\n#ifdef USE_SOG_V2\nvec3 c3;c3.x=texelFetch(sogCodebookTexture,ivec2(256+int(c0.x*255.0+0.5),0),0).r;c3.y=texelFetch(sogCodebookTexture,ivec2(256+int(c0.y*255.0+0.5),0),0).r;c3.z=texelFetch(sogCodebookTexture,ivec2(256+int(c0.z*255.0+0.5),0),0).r;vec3 colRgb=vec3(0.5)+c3*SH_C0;float colA=c0.w; \n#else\nvec4 cLerp=mix(sogSh0Min,sogSh0Max,c0);vec3 colRgb=vec3(0.5)+cLerp.xyz*SH_C0;float colA=1.0/(1.0+exp(-cLerp.w));\n#endif\nsplat.color=vec4(colRgb,colA);splat.splatIndex=splatIndex;\n#else\nsplat.center=texture2D(centersTexture,splatUV);splat.color=texture2D(colorsTexture,splatUV);\n#if !defined(IS_FOR_VOXELIZATION)\nsplat.covA=texture2D(covariancesATexture,splatUV)*splat.center.w;splat.covB=texture2D(covariancesBTexture,splatUV)*splat.center.w;\n#endif\n#endif\n#if SH_DEGREE>0 || IS_COMPOUND\nivec2 splatUVint=getDataUVint(splatIndex,dataTextureSize);\n#endif\n#if SH_DEGREE>0 && !defined(USE_SOG)\nsplat.sh0=texelFetch(shTexture0,splatUVint,0);\n#endif\n#if SH_DEGREE>1 && !defined(USE_SOG)\nsplat.sh1=texelFetch(shTexture1,splatUVint,0);\n#endif\n#if SH_DEGREE>2 && !defined(USE_SOG)\nsplat.sh2=texelFetch(shTexture2,splatUVint,0);\n#endif\n#if SH_DEGREE>3 && !defined(USE_SOG)\nsplat.sh3=texelFetch(shTexture3,splatUVint,0);splat.sh4=texelFetch(shTexture4,splatUVint,0);\n#endif\n#if IS_COMPOUND\nsplat.partIndex=uint(texture2D(partIndicesTexture,splatUV).r*255.0+0.5);\n#endif\n#if defined(IS_FOR_VOXELIZATION)\nsplat.rotationA=texture2D(rotationsATexture,splatUV);splat.rotationB=texture2D(rotationsBTexture,splatUV);splat.rotationScale=texture2D(rotationScaleTexture,splatUV);\n#endif\nreturn splat;}\n#if defined(WEBGL2) || defined(WEBGPU) || defined(NATIVE)\nvec3 computeColorFromSHDegree(vec3 dir,const vec3 sh[25],float _so1,float _so2,float _so3,float _so4)\n{const float SH_C0=0.28209479;const float SH_C1=0.48860251;float SH_C2[5];SH_C2[0]=1.092548430;SH_C2[1]=-1.09254843;SH_C2[2]=0.315391565;SH_C2[3]=-1.09254843;SH_C2[4]=0.546274215;float SH_C3[7];SH_C3[0]=-0.59004358;SH_C3[1]=2.890611442;SH_C3[2]=-0.45704579;SH_C3[3]=0.373176332;SH_C3[4]=-0.45704579;SH_C3[5]=1.445305721;SH_C3[6]=-0.59004358;float SH_C4[9];SH_C4[0]= 2.5033429418;SH_C4[1]=-1.7701307698;SH_C4[2]= 0.9461746958;SH_C4[3]=-0.6690465436;SH_C4[4]= 0.1057855469;SH_C4[5]=-0.6690465436;SH_C4[6]= 0.4730873479;SH_C4[7]=-1.7701307698;SH_C4[8]= 0.6258357354;vec3 result=/*SH_C0**/sh[0];\n#if SH_DEGREE>0\nfloat x=dir.x;float y=dir.y;float z=dir.z;result+=_so1*(- SH_C1*y*sh[1]+SH_C1*z*sh[2]-SH_C1*x*sh[3]);\n#if SH_DEGREE>1\nfloat xx=x*x,yy=y*y,zz=z*z;float xy=x*y,yz=y*z,xz=x*z;result+=_so2*(\nSH_C2[0]*xy*sh[4] +\nSH_C2[1]*yz*sh[5] +\nSH_C2[2]*(2.0*zz-xx-yy)*sh[6] +\nSH_C2[3]*xz*sh[7] +\nSH_C2[4]*(xx-yy)*sh[8]);\n#if SH_DEGREE>2\nresult+=_so3*(\nSH_C3[0]*y*(3.0*xx-yy)*sh[9] +\nSH_C3[1]*xy*z*sh[10] +\nSH_C3[2]*y*(4.0*zz-xx-yy)*sh[11] +\nSH_C3[3]*z*(2.0*zz-3.0*xx-3.0*yy)*sh[12] +\nSH_C3[4]*x*(4.0*zz-xx-yy)*sh[13] +\nSH_C3[5]*z*(xx-yy)*sh[14] +\nSH_C3[6]*x*(xx-3.0*yy)*sh[15]);\n#if SH_DEGREE>3\nresult+=_so4*(\nSH_C4[0]*x*y*(xx-yy)*sh[16] +\nSH_C4[1]*y*z*(3.0*xx-yy)*sh[17] +\nSH_C4[2]*x*y*(7.0*zz-1.0)*sh[18] +\nSH_C4[3]*y*z*(7.0*zz-3.0)*sh[19] +\nSH_C4[4]*(zz*(35.0*zz-30.0)+3.0)*sh[20] +\nSH_C4[5]*x*z*(7.0*zz-3.0)*sh[21] +\nSH_C4[6]*(xx-yy)*(7.0*zz-1.0)*sh[22] +\nSH_C4[7]*x*z*(xx-3.0*yy)*sh[23] +\nSH_C4[8]*(xx*(xx-3.0*yy)-yy*(3.0*xx-yy))*sh[24]);\n#endif\n#endif\n#endif\n#endif\nreturn result;}\nvec4 decompose(uint value)\n{vec4 components=vec4(\nfloat((value ) & 255u),\nfloat((value>>uint( 8)) & 255u),\nfloat((value>>uint(16)) & 255u),\nfloat((value>>uint(24)) & 255u));return components*vec4(2./255.)-vec4(1.);}\n#ifdef USE_SOG\nvec3 computeSH(Splat splat,vec3 dir)\n{\n#if SH_DEGREE>0\nvec3 sh[25];sh[0]=vec3(0.,0.,0.);ivec2 labelSize=textureSize(sogShNLabelsTexture,0);int idx=int(splat.splatIndex+0.5);int lx=idx-(idx/labelSize.x)*labelSize.x;int ly=idx/labelSize.x;vec4 labelRaw=texelFetch(sogShNLabelsTexture,ivec2(lx,ly),0);int n=int(labelRaw.r*255.0+0.5)+int(labelRaw.g*255.0+0.5)*256;int coeffs=int(sogShCoeffCount+0.5);int u=(n-(n/64)*64)*coeffs;int v=n/64;for (int k=0; k<24; k++) {if (k>=coeffs) break;vec4 centroidRaw=texelFetch(sogShNCentroidsTexture,ivec2(u+k,v),0);vec3 shCoeff;\n#ifdef USE_SOG_V2\nint rIdx=int(centroidRaw.r*255.0+0.5);int gIdx=int(centroidRaw.g*255.0+0.5);int bIdx=int(centroidRaw.b*255.0+0.5);shCoeff.r=texelFetch(sogCodebookTexture,ivec2(512+rIdx,0),0).r;shCoeff.g=texelFetch(sogCodebookTexture,ivec2(512+gIdx,0),0).r;shCoeff.b=texelFetch(sogCodebookTexture,ivec2(512+bIdx,0),0).r;\n#else\nshCoeff=mix(vec3(sogShnMin),vec3(sogShnMax),centroidRaw.rgb);\n#endif\nsh[k+1]=shCoeff;}\nreturn computeColorFromSHDegree(dir,sh,1.,1.,1.,1.);\n#else\nreturn vec3(0.,0.,0.);\n#endif\n}\n#else\nvec3 computeSHWeighted(Splat splat,vec3 dir,float _so1,float _so2,float _so3,float _so4)\n{vec3 sh[25];sh[0]=vec3(0.,0.,0.);\n#if SH_DEGREE>0\nvec4 sh00=decompose(splat.sh0.x);vec4 sh01=decompose(splat.sh0.y);vec4 sh02=decompose(splat.sh0.z);sh[1]=vec3(sh00.x,sh00.y,sh00.z);sh[2]=vec3(sh00.w,sh01.x,sh01.y);sh[3]=vec3(sh01.z,sh01.w,sh02.x);\n#endif\n#if SH_DEGREE>1\nvec4 sh03=decompose(splat.sh0.w);vec4 sh04=decompose(splat.sh1.x);vec4 sh05=decompose(splat.sh1.y);sh[4]=vec3(sh02.y,sh02.z,sh02.w);sh[5]=vec3(sh03.x,sh03.y,sh03.z);sh[6]=vec3(sh03.w,sh04.x,sh04.y);sh[7]=vec3(sh04.z,sh04.w,sh05.x);sh[8]=vec3(sh05.y,sh05.z,sh05.w);\n#endif\n#if SH_DEGREE>2\nvec4 sh06=decompose(splat.sh1.z);vec4 sh07=decompose(splat.sh1.w);vec4 sh08=decompose(splat.sh2.x);vec4 sh09=decompose(splat.sh2.y);vec4 sh10=decompose(splat.sh2.z);vec4 sh11=decompose(splat.sh2.w);sh[9]=vec3(sh06.x,sh06.y,sh06.z);sh[10]=vec3(sh06.w,sh07.x,sh07.y);sh[11]=vec3(sh07.z,sh07.w,sh08.x);sh[12]=vec3(sh08.y,sh08.z,sh08.w);sh[13]=vec3(sh09.x,sh09.y,sh09.z);sh[14]=vec3(sh09.w,sh10.x,sh10.y);sh[15]=vec3(sh10.z,sh10.w,sh11.x);\n#endif\n#if SH_DEGREE>3\nvec4 sh12=decompose(splat.sh3.x);vec4 sh13=decompose(splat.sh3.y);vec4 sh14=decompose(splat.sh3.z);vec4 sh15=decompose(splat.sh3.w);vec4 sh16=decompose(splat.sh4.x);vec4 sh17=decompose(splat.sh4.y);sh[16]=vec3(sh11.y,sh11.z,sh11.w);sh[17]=vec3(sh12.x,sh12.y,sh12.z);sh[18]=vec3(sh12.w,sh13.x,sh13.y);sh[19]=vec3(sh13.z,sh13.w,sh14.x);sh[20]=vec3(sh14.y,sh14.z,sh14.w);sh[21]=vec3(sh15.x,sh15.y,sh15.z);sh[22]=vec3(sh15.w,sh16.x,sh16.y);sh[23]=vec3(sh16.z,sh16.w,sh17.x);sh[24]=vec3(sh17.y,sh17.z,sh17.w);\n#endif\nreturn computeColorFromSHDegree(dir,sh,_so1,_so2,_so3,_so4);}\nvec3 computeSH(Splat splat,vec3 dir)\n{\n#if !defined(GS_DBG_ENABLED) || GS_DBG_SH_ORDER1==1\nfloat _w1=1.0;\n#else\nfloat _w1=0.0;\n#endif\n#if !defined(GS_DBG_ENABLED) || GS_DBG_SH_ORDER2==1\nfloat _w2=1.0;\n#else\nfloat _w2=0.0;\n#endif\n#if !defined(GS_DBG_ENABLED) || GS_DBG_SH_ORDER3==1\nfloat _w3=1.0;\n#else\nfloat _w3=0.0;\n#endif\n#if !defined(GS_DBG_ENABLED) || GS_DBG_SH_ORDER4==1\nfloat _w4=1.0;\n#else\nfloat _w4=0.0;\n#endif\nreturn computeSHWeighted(splat,dir,_w1,_w2,_w3,_w4);}\n#endif\n#else\nvec3 computeSH(Splat splat,vec3 dir)\n{return vec3(0.,0.,0.);}\n#endif\n#if !defined(IS_FOR_VOXELIZATION)\nvec4 gaussianSplatting(vec2 meshPos,vec3 worldPos,vec2 scale,vec3 covA,vec3 covB,mat4 worldMatrix,mat4 viewMatrix,mat4 projectionMatrix)\n{mat4 modelView=viewMatrix*worldMatrix;vec4 camspace=viewMatrix*vec4(worldPos,1.);vec4 pos2d=projectionMatrix*camspace;float bounds=1.2*pos2d.w;if (pos2d.z<-pos2d.w || pos2d.x<-bounds || pos2d.x>bounds\n|| pos2d.y<-bounds || pos2d.y>bounds) {return vec4(0.0,0.0,2.0,1.0);}\nmat3 Vrk=mat3(\ncovA.x,covA.y,covA.z,\ncovA.y,covB.x,covB.y,\ncovA.z,covB.y,covB.z\n);bool isOrtho=abs(projectionMatrix[3][3]-1.0)<0.001;mat3 J;if (isOrtho) {J=mat3(\nfocal.x,0.,0.,\n0.,focal.y,0.,\n0.,0.,0.\n);} else {J=mat3(\nfocal.x/camspace.z,0.,-(focal.x*camspace.x)/(camspace.z*camspace.z),\n0.,focal.y/camspace.z,-(focal.y*camspace.y)/(camspace.z*camspace.z),\n0.,0.,0.\n);}\nmat3 T=transpose(mat3(modelView))*J;mat3 cov2d=transpose(T)*Vrk*T;\n#if COMPENSATION\nfloat c00=cov2d[0][0];float c11=cov2d[1][1];float c01=cov2d[0][1];float detOrig=c00*c11-c01*c01;\n#endif\ncov2d[0][0]+=kernelSize;cov2d[1][1]+=kernelSize;\n#if COMPENSATION\nvec3 c2d=vec3(cov2d[0][0],c01,cov2d[1][1]);float detBlur=c2d.x*c2d.z-c2d.y*c2d.y;float compensation=sqrt(max(0.,detOrig/detBlur));vColor.w*=compensation;\n#endif\nfloat mid=(cov2d[0][0]+cov2d[1][1])/2.0;float radius=length(vec2((cov2d[0][0]-cov2d[1][1])/2.0,cov2d[0][1]));float epsilon=0.0001;float lambda1=mid+radius+epsilon,lambda2=mid-radius+epsilon;if (lambda2<0.0)\n{return vec4(0.0,0.0,2.0,1.0);}\nvec2 diagonalVector=normalize(vec2(cov2d[0][1],lambda1-cov2d[0][0]));vec2 majorAxis=min(sqrt(2.0*lambda1),1024.0)*diagonalVector;vec2 minorAxis=min(sqrt(2.0*lambda2),1024.0)*vec2(diagonalVector.y,-diagonalVector.x);vec2 vCenter=vec2(pos2d);float scaleFactor=isOrtho ? 1.0 : pos2d.w;return vec4(\nvCenter \n+ ((meshPos.x*majorAxis\n+ meshPos.y*minorAxis)*invViewport*scaleFactor)*scale,pos2d.zw);}\n#endif\n#if IS_COMPOUND\nmat4 getPartWorld(uint partIndex) {return partWorld[partIndex];}\n#endif\n#if defined(IS_FOR_VOXELIZATION)\nvec4 computeVoxelSplatWorldPos(vec4 rotationA,vec4 rotationB,vec4 rotationScale,vec3 center,mat4 splatWorld,mat4 viewMatrix,mat4 invWorldScale,vec2 quadPos) {mat3 splatRotation=mat3(\nvec3(rotationA.x,rotationA.y,rotationA.z),\nvec3(rotationA.w,rotationB.x,rotationB.y),\nvec3(rotationB.z,rotationB.w,rotationScale.x)\n);vec3 splatScale=vec3(rotationScale.y,rotationScale.z,rotationScale.w);mat3 rotToView=mat3(viewMatrix)*mat3(invWorldScale)*mat3(splatWorld)*splatRotation;vec3 axisLengthInViewZ=abs(vec3(rotToView[0][2],rotToView[1][2],rotToView[2][2]));float gaussianSplatCutoffStddev=1.4142135624/2.0; \nvec3 offsetSplatSpace;if (axisLengthInViewZ.x>axisLengthInViewZ.y && axisLengthInViewZ.x>axisLengthInViewZ.z) {offsetSplatSpace=vec3(0.0,quadPos.x,quadPos.y)*splatScale*gaussianSplatCutoffStddev;} else if (axisLengthInViewZ.y>axisLengthInViewZ.z) {offsetSplatSpace=vec3(quadPos.x,0.0,quadPos.y)*splatScale*gaussianSplatCutoffStddev;} else {offsetSplatSpace=vec3(quadPos.x,quadPos.y,0.0)*splatScale*gaussianSplatCutoffStddev;}\nvec3 vertexObjectSpace=center+splatRotation*offsetSplatSpace;return splatWorld*vec4(vertexObjectSpace,1.0);}\n#endif\n`;\n// Sideeffect\nif (!ShaderStore.IncludesShadersStore[name]) {\n ShaderStore.IncludesShadersStore[name] = shader;\n}\n/** @internal */\nexport const gaussianSplatting = { name, shader };\n"]}
|
|
@@ -26,16 +26,27 @@ uniform vec2 invViewport;uniform vec2 dataTextureSize;uniform vec2 focal;uniform
|
|
|
26
26
|
uniform mat4 partWorld[MAX_PART_COUNT];uniform float partVisibility[MAX_PART_COUNT];
|
|
27
27
|
#endif
|
|
28
28
|
uniform sampler2D covariancesATexture;uniform sampler2D covariancesBTexture;uniform sampler2D centersTexture;uniform sampler2D colorsTexture;
|
|
29
|
+
#ifdef USE_SOG
|
|
30
|
+
uniform sampler2D sogQuatsTexture;uniform vec3 sogMeansMin;uniform vec3 sogMeansMax;
|
|
31
|
+
#ifdef USE_SOG_V2
|
|
32
|
+
uniform sampler2D sogCodebookTexture;
|
|
33
|
+
#else
|
|
34
|
+
uniform vec3 sogScalesMin;uniform vec3 sogScalesMax;uniform vec4 sogSh0Min;uniform vec4 sogSh0Max;uniform float sogShnMin;uniform float sogShnMax;
|
|
35
|
+
#endif
|
|
29
36
|
#if SH_DEGREE>0
|
|
37
|
+
uniform sampler2D sogShNCentroidsTexture;uniform sampler2D sogShNLabelsTexture;uniform float sogShCoeffCount;
|
|
38
|
+
#endif
|
|
39
|
+
#endif
|
|
40
|
+
#if SH_DEGREE>0 && !defined(USE_SOG)
|
|
30
41
|
uniform highp usampler2D shTexture0;
|
|
31
42
|
#endif
|
|
32
|
-
#if SH_DEGREE>1
|
|
43
|
+
#if SH_DEGREE>1 && !defined(USE_SOG)
|
|
33
44
|
uniform highp usampler2D shTexture1;
|
|
34
45
|
#endif
|
|
35
|
-
#if SH_DEGREE>2
|
|
46
|
+
#if SH_DEGREE>2 && !defined(USE_SOG)
|
|
36
47
|
uniform highp usampler2D shTexture2;
|
|
37
48
|
#endif
|
|
38
|
-
#if SH_DEGREE>3
|
|
49
|
+
#if SH_DEGREE>3 && !defined(USE_SOG)
|
|
39
50
|
uniform highp usampler2D shTexture3;uniform highp usampler2D shTexture4;
|
|
40
51
|
#endif
|
|
41
52
|
#if IS_COMPOUND
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"gaussianSplatting.vertex.js","sourceRoot":"","sources":["../../../../dev/core/src/Shaders/gaussianSplatting.vertex.ts"],"names":[],"mapp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Store\";\nimport { gaussianSplattingVertexDeclaration } from \"./ShadersInclude/gaussianSplattingVertexDeclaration\";\nimport { sceneUboDeclaration } from \"./ShadersInclude/sceneUboDeclaration\";\nimport { meshUboDeclaration } from \"./ShadersInclude/meshUboDeclaration\";\nimport { gaussianSplattingUboDeclaration } from \"./ShadersInclude/gaussianSplattingUboDeclaration\";\nimport { clipPlaneVertexDeclaration } from \"./ShadersInclude/clipPlaneVertexDeclaration\";\nimport { fogVertexDeclaration } from \"./ShadersInclude/fogVertexDeclaration\";\nimport { logDepthDeclaration } from \"./ShadersInclude/logDepthDeclaration\";\nimport { helperFunctions } from \"./ShadersInclude/helperFunctions\";\nimport { gaussianSplatting } from \"./ShadersInclude/gaussianSplatting\";\nimport { clipPlaneVertex } from \"./ShadersInclude/clipPlaneVertex\";\nimport { fogVertex } from \"./ShadersInclude/fogVertex\";\nimport { logDepthVertex } from \"./ShadersInclude/logDepthVertex\";\n\nconst name = \"gaussianSplattingVertexShader\";\nconst shader = `#include<__decl__gaussianSplattingVertex>\n#ifdef LOGARITHMICDEPTH\n#extension GL_EXT_frag_depth : enable\n#endif\n#include<clipPlaneVertexDeclaration>\n#include<fogVertexDeclaration>\n#include<logDepthDeclaration>\n#include<helperFunctions>\nuniform vec2 invViewport;uniform vec2 dataTextureSize;uniform vec2 focal;uniform float kernelSize;uniform vec3 eyePosition;uniform float alpha;\n#if IS_COMPOUND\nuniform mat4 partWorld[MAX_PART_COUNT];uniform float partVisibility[MAX_PART_COUNT];\n#endif\nuniform sampler2D covariancesATexture;uniform sampler2D covariancesBTexture;uniform sampler2D centersTexture;uniform sampler2D colorsTexture;\n#ifdef USE_SOG\nuniform sampler2D sogQuatsTexture;uniform vec3 sogMeansMin;uniform vec3 sogMeansMax;\n#ifdef USE_SOG_V2\nuniform sampler2D sogCodebookTexture; \n#else\nuniform vec3 sogScalesMin;uniform vec3 sogScalesMax;uniform vec4 sogSh0Min;uniform vec4 sogSh0Max;uniform float sogShnMin;uniform float sogShnMax;\n#endif\n#if SH_DEGREE>0\nuniform sampler2D sogShNCentroidsTexture;uniform sampler2D sogShNLabelsTexture;uniform float sogShCoeffCount;\n#endif\n#endif\n#if SH_DEGREE>0 && !defined(USE_SOG)\nuniform highp usampler2D shTexture0;\n#endif\n#if SH_DEGREE>1 && !defined(USE_SOG)\nuniform highp usampler2D shTexture1;\n#endif\n#if SH_DEGREE>2 && !defined(USE_SOG)\nuniform highp usampler2D shTexture2;\n#endif\n#if SH_DEGREE>3 && !defined(USE_SOG)\nuniform highp usampler2D shTexture3;uniform highp usampler2D shTexture4;\n#endif\n#if IS_COMPOUND\nuniform sampler2D partIndicesTexture;\n#endif\nvarying vec4 vColor;varying vec2 vPosition;\n#define CUSTOM_VERTEX_DEFINITIONS\n#include<gaussianSplatting>\nvoid main () {\n#define CUSTOM_VERTEX_MAIN_BEGIN\nfloat splatIndex=getSplatIndex(int(position.z+0.5));Splat splat=readSplat(splatIndex);vec3 covA=splat.covA.xyz;vec3 covB=vec3(splat.covA.w,splat.covB.xy);\n#if IS_COMPOUND\nmat4 splatWorld=getPartWorld(splat.partIndex);\n#else\nmat4 splatWorld=world;\n#endif\nvec4 worldPos=splatWorld*vec4(splat.center.xyz,1.0);vColor=splat.color;vPosition=position.xy;\n#if SH_DEGREE>0\nmat3 worldRot=mat3(splatWorld);mat3 normWorldRot=inverseMat3(worldRot);vec3 eyeToSplatLocalSpace=normalize(normWorldRot*(worldPos.xyz-eyePosition));\n#if defined(GS_DBG_ENABLED) && IS_COMPOUND\n{vec4 _row3=texelFetch(dbgPartData,ivec2(int(splat.partIndex),3),0);\n#if SH_DEGREE>3\nfloat _so4=texelFetch(dbgPartData,ivec2(int(splat.partIndex),4),0).x;\n#else\nfloat _so4=1.0;\n#endif\nvColor.xyz=_row3.x*splat.color.xyz+computeSHWeighted(splat,eyeToSplatLocalSpace,_row3.y,_row3.z,_row3.w,_so4);}\n#elif defined(GS_DBG_ENABLED) && GS_DBG_SH_DC==0\nvColor.xyz=computeSH(splat,eyeToSplatLocalSpace);\n#else\nvColor.xyz=splat.color.xyz+computeSH(splat,eyeToSplatLocalSpace);\n#endif\n#else\n#if defined(GS_DBG_ENABLED) && IS_COMPOUND\n{float _shDc=texelFetch(dbgPartData,ivec2(int(splat.partIndex),3),0).x;vColor.xyz=_shDc*splat.color.xyz;}\n#elif defined(GS_DBG_ENABLED) && GS_DBG_SH_DC==0\nvColor.xyz=vec3(0.0);\n#endif\n#endif\nvColor.w*=alpha;\n#if IS_COMPOUND\nvColor.w*=partVisibility[splat.partIndex];\n#endif\nvec2 scale=vec2(1.,1.);\n#define CUSTOM_VERTEX_UPDATE\ngl_Position=gaussianSplatting(position.xy,worldPos.xyz,scale,covA,covB,splatWorld,view,projection);\n#include<clipPlaneVertex>\n#include<fogVertex>\n#include<logDepthVertex>\n#define CUSTOM_VERTEX_MAIN_END\n}\n`;\n// Sideeffect\nif (!ShaderStore.ShadersStore[name]) {\n ShaderStore.ShadersStore[name] = shader;\n}\nconst includes = [gaussianSplattingVertexDeclaration, sceneUboDeclaration, meshUboDeclaration, gaussianSplattingUboDeclaration, clipPlaneVertexDeclaration, fogVertexDeclaration, logDepthDeclaration, helperFunctions, gaussianSplatting, clipPlaneVertex, fogVertex, logDepthVertex];\nfor (const inc of includes) {\n if (!ShaderStore.IncludesShadersStore[inc.name]) {\n ShaderStore.IncludesShadersStore[inc.name] = inc.shader;\n }\n}\n\n/** @internal */\nexport const gaussianSplattingVertexShader = { name, shader };\n"]}
|
|
@@ -27,6 +27,9 @@ rotationA: vec4f,
|
|
|
27
27
|
rotationB: vec4f,
|
|
28
28
|
rotationScale: vec4f,
|
|
29
29
|
#endif
|
|
30
|
+
#ifdef USE_SOG
|
|
31
|
+
splatIndex: f32,
|
|
32
|
+
#endif
|
|
30
33
|
};fn getSplatIndex(localIndex: i32,splatIndex0: vec4f,splatIndex1: vec4f,splatIndex2: vec4f,splatIndex3: vec4f)->f32 {var splatIndex: f32;switch (localIndex)
|
|
31
34
|
{case 0:
|
|
32
35
|
{splatIndex=splatIndex0.x;break;}
|
|
@@ -61,20 +64,49 @@ case 14:
|
|
|
61
64
|
default:
|
|
62
65
|
{splatIndex=splatIndex3.w;break;}}
|
|
63
66
|
return splatIndex;}
|
|
64
|
-
fn readSplat(splatIndex: f32,dataTextureSize: vec2f)->Splat {var splat: Splat;let splatUV=getDataUV(splatIndex,dataTextureSize);let splatUVi32=vec2<i32>(i32(splatUV.x),i32(splatUV.y));
|
|
67
|
+
fn readSplat(splatIndex: f32,dataTextureSize: vec2f)->Splat {var splat: Splat;let splatUV=getDataUV(splatIndex,dataTextureSize);let splatUVi32=vec2<i32>(i32(splatUV.x),i32(splatUV.y));
|
|
68
|
+
#ifdef USE_SOG
|
|
69
|
+
let mL=textureLoad(centersTexture,splatUVi32,0);let mU=textureLoad(covariancesATexture,splatUVi32,0);let sRaw=textureLoad(covariancesBTexture,splatUVi32,0);let qRaw=textureLoad(sogQuatsTexture,splatUVi32,0);let c0=textureLoad(colorsTexture,splatUVi32,0);let q16=(mU.xyz*256.0+mL.xyz)*(255.0/65535.0);let nPos=mix(uniforms.sogMeansMin,uniforms.sogMeansMax,q16);let center3=sign(nPos)*(exp(abs(nPos))-vec3f(1.0));splat.center=vec4f(center3,1.0);
|
|
70
|
+
#ifdef USE_SOG_V2
|
|
71
|
+
let sIdx=floor(sRaw.xyz*255.0+0.5);var splatScale: vec3f;splatScale.x=exp(textureLoad(sogCodebookTexture,vec2<i32>(i32(sIdx.x),0),0).r);splatScale.y=exp(textureLoad(sogCodebookTexture,vec2<i32>(i32(sIdx.y),0),0).r);splatScale.z=exp(textureLoad(sogCodebookTexture,vec2<i32>(i32(sIdx.z),0),0).r);
|
|
72
|
+
#else
|
|
73
|
+
let splatScale=exp(mix(uniforms.sogScalesMin,uniforms.sogScalesMax,sRaw.xyz));
|
|
74
|
+
#endif
|
|
75
|
+
let invSqrt2: f32=0.70710678118;let qabc=(qRaw.xyz-vec3f(0.5))*2.0*invSqrt2;let qMode=i32(qRaw.w*255.0+0.5)-252;let qd=sqrt(max(0.0,1.0-dot(qabc,qabc)));var quat: vec4f;if (qMode==0) { quat=vec4f(qd,qabc.x,qabc.y,qabc.z); }
|
|
76
|
+
else if (qMode==1) { quat=vec4f(qabc.x,qd,qabc.y,qabc.z); }
|
|
77
|
+
else if (qMode==2) { quat=vec4f(qabc.x,qabc.y,qd,qabc.z); }
|
|
78
|
+
else { quat=vec4f(qabc.x,qabc.y,qabc.z,qd); }
|
|
79
|
+
let qw=quat.x; let qx=quat.y; let qy=quat.z; let qz=quat.w;let R=mat3x3<f32>(
|
|
80
|
+
1.0-2.0*(qy*qy+qz*qz),2.0*(qx*qy+qw*qz), 2.0*(qx*qz-qw*qy),
|
|
81
|
+
2.0*(qx*qy-qw*qz), 1.0-2.0*(qx*qx+qz*qz),2.0*(qy*qz+qw*qx),
|
|
82
|
+
2.0*(qx*qz+qw*qy), 2.0*(qy*qz-qw*qx), 1.0-2.0*(qx*qx+qy*qy)
|
|
83
|
+
);let S2=mat3x3<f32>(
|
|
84
|
+
4.0*splatScale.x*splatScale.x,0.0,0.0,
|
|
85
|
+
0.0,4.0*splatScale.y*splatScale.y,0.0,
|
|
86
|
+
0.0,0.0,4.0*splatScale.z*splatScale.z
|
|
87
|
+
);let Sigma=R*S2*transpose(R);splat.covA=vec4f(Sigma[0][0],Sigma[0][1],Sigma[0][2],Sigma[1][1]);splat.covB=vec4f(Sigma[1][2],Sigma[2][2],0.0,0.0);let SH_C0_SOG: f32=0.28209479177387814;
|
|
88
|
+
#ifdef USE_SOG_V2
|
|
89
|
+
var c3: vec3f;c3.x=textureLoad(sogCodebookTexture,vec2<i32>(256+i32(c0.x*255.0+0.5),0),0).r;c3.y=textureLoad(sogCodebookTexture,vec2<i32>(256+i32(c0.y*255.0+0.5),0),0).r;c3.z=textureLoad(sogCodebookTexture,vec2<i32>(256+i32(c0.z*255.0+0.5),0),0).r;let colRgb=vec3f(0.5)+c3*SH_C0_SOG;let colA=c0.w;
|
|
90
|
+
#else
|
|
91
|
+
let cLerp=mix(uniforms.sogSh0Min,uniforms.sogSh0Max,c0);let colRgb=vec3f(0.5)+cLerp.xyz*SH_C0_SOG;let colA=1.0/(1.0+exp(-cLerp.w));
|
|
92
|
+
#endif
|
|
93
|
+
splat.color=vec4f(colRgb,colA);splat.splatIndex=splatIndex;
|
|
94
|
+
#else
|
|
95
|
+
splat.center=textureLoad(centersTexture,splatUVi32,0);splat.color=textureLoad(colorsTexture,splatUVi32,0);
|
|
65
96
|
#if !defined(IS_FOR_VOXELIZATION)
|
|
66
97
|
splat.covA=textureLoad(covariancesATexture,splatUVi32,0)*splat.center.w;splat.covB=textureLoad(covariancesBTexture,splatUVi32,0)*splat.center.w;
|
|
67
98
|
#endif
|
|
68
|
-
#
|
|
99
|
+
#endif
|
|
100
|
+
#if SH_DEGREE>0 && !defined(USE_SOG)
|
|
69
101
|
splat.sh0=textureLoad(shTexture0,splatUVi32,0);
|
|
70
102
|
#endif
|
|
71
|
-
#if SH_DEGREE>1
|
|
103
|
+
#if SH_DEGREE>1 && !defined(USE_SOG)
|
|
72
104
|
splat.sh1=textureLoad(shTexture1,splatUVi32,0);
|
|
73
105
|
#endif
|
|
74
|
-
#if SH_DEGREE>2
|
|
106
|
+
#if SH_DEGREE>2 && !defined(USE_SOG)
|
|
75
107
|
splat.sh2=textureLoad(shTexture2,splatUVi32,0);
|
|
76
108
|
#endif
|
|
77
|
-
#if SH_DEGREE>3
|
|
109
|
+
#if SH_DEGREE>3 && !defined(USE_SOG)
|
|
78
110
|
splat.sh3=textureLoad(shTexture3,splatUVi32,0);splat.sh4=textureLoad(shTexture4,splatUVi32,0);
|
|
79
111
|
#endif
|
|
80
112
|
#if IS_COMPOUND
|
|
@@ -150,6 +182,24 @@ f32((value ) & 255u),
|
|
|
150
182
|
f32((value>>u32( 8)) & 255u),
|
|
151
183
|
f32((value>>u32(16)) & 255u),
|
|
152
184
|
f32((value>>u32(24)) & 255u));return components*vec4f(2./255.)-vec4f(1.);}
|
|
185
|
+
#ifdef USE_SOG
|
|
186
|
+
fn computeSH(splat: Splat,dir: vec3f)->vec3f
|
|
187
|
+
{
|
|
188
|
+
#if SH_DEGREE>0
|
|
189
|
+
var sh: array<vec3<f32>,25>;sh[0]=vec3f(0.,0.,0.);let labelSize=textureDimensions(sogShNLabelsTexture,0);let idx=i32(splat.splatIndex+0.5);let lw=i32(labelSize.x);let lx=idx-(idx/lw)*lw;let ly=idx/lw;let labelRaw=textureLoad(sogShNLabelsTexture,vec2<i32>(lx,ly),0);let n=i32(labelRaw.r*255.0+0.5)+i32(labelRaw.g*255.0+0.5)*256;let coeffs=i32(uniforms.sogShCoeffCount+0.5);let u=(n-(n/64)*64)*coeffs;let v=n/64;for (var k: i32=0; k<24; k=k+1) {if (k>=coeffs) { break; }
|
|
190
|
+
let centroidRaw=textureLoad(sogShNCentroidsTexture,vec2<i32>(u+k,v),0);var shCoeff: vec3f;
|
|
191
|
+
#ifdef USE_SOG_V2
|
|
192
|
+
let rIdx=i32(centroidRaw.r*255.0+0.5);let gIdx=i32(centroidRaw.g*255.0+0.5);let bIdx=i32(centroidRaw.b*255.0+0.5);shCoeff.r=textureLoad(sogCodebookTexture,vec2<i32>(512+rIdx,0),0).r;shCoeff.g=textureLoad(sogCodebookTexture,vec2<i32>(512+gIdx,0),0).r;shCoeff.b=textureLoad(sogCodebookTexture,vec2<i32>(512+bIdx,0),0).r;
|
|
193
|
+
#else
|
|
194
|
+
shCoeff=mix(vec3f(uniforms.sogShnMin),vec3f(uniforms.sogShnMax),centroidRaw.rgb);
|
|
195
|
+
#endif
|
|
196
|
+
sh[k+1]=shCoeff;}
|
|
197
|
+
return computeColorFromSHDegree(dir,sh,1.,1.,1.,1.);
|
|
198
|
+
#else
|
|
199
|
+
return vec3f(0.,0.,0.);
|
|
200
|
+
#endif
|
|
201
|
+
}
|
|
202
|
+
#else
|
|
153
203
|
fn computeSHWeighted(splat: Splat,dir: vec3f,_so1: f32,_so2: f32,_so3: f32,_so4: f32)->vec3f
|
|
154
204
|
{var sh: array<vec3<f32>,25>;sh[0]=vec3f(0.,0.,0.);
|
|
155
205
|
#if SH_DEGREE>0
|
|
@@ -188,6 +238,7 @@ let _w4: f32=1.0;
|
|
|
188
238
|
let _w4: f32=0.0;
|
|
189
239
|
#endif
|
|
190
240
|
return computeSHWeighted(splat,dir,_w1,_w2,_w3,_w4);}
|
|
241
|
+
#endif
|
|
191
242
|
fn gaussianSplatting(
|
|
192
243
|
meshPos: vec2<f32>,
|
|
193
244
|
worldPos: vec3<f32>,
|