|
@@ -74,7 +74,7 @@ export class Skeleton implements IAnimatable {
|
|
private _useTextureToStoreBoneMatrices = true;
|
|
private _useTextureToStoreBoneMatrices = true;
|
|
/**
|
|
/**
|
|
* Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
|
|
* Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
|
|
- * Please note that this option is not available when needInitialSkinMatrix === true or if the hardware does not support it
|
|
|
|
|
|
+ * Please note that this option is not available if the hardware does not support it
|
|
*/
|
|
*/
|
|
public get useTextureToStoreBoneMatrices(): boolean {
|
|
public get useTextureToStoreBoneMatrices(): boolean {
|
|
return this._useTextureToStoreBoneMatrices;
|
|
return this._useTextureToStoreBoneMatrices;
|
|
@@ -118,7 +118,7 @@ export class Skeleton implements IAnimatable {
|
|
* Gets a boolean indicating that the skeleton effectively stores matrices into a texture
|
|
* Gets a boolean indicating that the skeleton effectively stores matrices into a texture
|
|
*/
|
|
*/
|
|
public get isUsingTextureForMatrices() {
|
|
public get isUsingTextureForMatrices() {
|
|
- return this.useTextureToStoreBoneMatrices && this._canUseTextureForBones && !this.needInitialSkinMatrix;
|
|
|
|
|
|
+ return this.useTextureToStoreBoneMatrices && this._canUseTextureForBones;
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -191,7 +191,11 @@ export class Skeleton implements IAnimatable {
|
|
* Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
|
|
* Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
|
|
* @returns a raw texture containing the data
|
|
* @returns a raw texture containing the data
|
|
*/
|
|
*/
|
|
- public getTransformMatrixTexture(): Nullable<RawTexture> {
|
|
|
|
|
|
+ public getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture> {
|
|
|
|
+ if (this.needInitialSkinMatrix && mesh._transformMatrixTexture) {
|
|
|
|
+ return mesh._transformMatrixTexture;
|
|
|
|
+ }
|
|
|
|
+
|
|
return this._transformMatrixTexture;
|
|
return this._transformMatrixTexture;
|
|
}
|
|
}
|
|
|
|
|
|
@@ -475,9 +479,25 @@ export class Skeleton implements IAnimatable {
|
|
bone._updateDifferenceMatrix(Tmp.Matrix[1]);
|
|
bone._updateDifferenceMatrix(Tmp.Matrix[1]);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ if (this.isUsingTextureForMatrices) {
|
|
|
|
+ const textureWidth = (this.bones.length + 1) * 4;
|
|
|
|
+ if (!mesh._transformMatrixTexture || mesh._transformMatrixTexture.getSize().width !== textureWidth) {
|
|
|
|
+
|
|
|
|
+ if (mesh._transformMatrixTexture) {
|
|
|
|
+ mesh._transformMatrixTexture.dispose();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ mesh._transformMatrixTexture = RawTexture.CreateRGBATexture(mesh._bonesTransformMatrices, (this.bones.length + 1) * 4, 1, this._scene, false, false, Constants.TEXTURE_NEAREST_SAMPLINGMODE, Constants.TEXTURETYPE_FLOAT);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
|
|
this._computeTransformMatrices(mesh._bonesTransformMatrices, poseMatrix);
|
|
this._computeTransformMatrices(mesh._bonesTransformMatrices, poseMatrix);
|
|
|
|
+
|
|
|
|
+ if (this.isUsingTextureForMatrices && mesh._transformMatrixTexture) {
|
|
|
|
+ mesh._transformMatrixTexture.update(mesh._bonesTransformMatrices);
|
|
|
|
+ }
|
|
}
|
|
}
|
|
} else {
|
|
} else {
|
|
if (!this._transformMatrices || this._transformMatrices.length !== 16 * (this.bones.length + 1)) {
|
|
if (!this._transformMatrices || this._transformMatrices.length !== 16 * (this.bones.length + 1)) {
|