這確實是這樣做的常見方式,例如, (這是HLSL,但基本相同 - 請注意全球統一的'boneArray')
float4x3 CalcBoneTransform(float4 blendWeights, float4 boneIndices)
{
// Calculate normalized fourth bone weight2
float4 weights = float4(blendWeights.x, blendWeights.y, blendWeights.z , 1.0f - blendWeights.x - blendWeights.y - blendWeights.z);
// Calculate bone transform
float4x3 boneTransform;
int4 indices = boneIndices;
boneTransform = weights.x * boneArray[indices.x];
boneTransform += weights.y * boneArray[indices.y];
boneTransform += weights.z * boneArray[indices.z];
boneTransform += weights.w * boneArray[indices.w];
return boneTransform;
}
感謝您的迴應!事實證明,事實上,可以爲我的平臺(Playstation Mobile)做到這一點,但是有一個未記錄的怪癖,這意味着一個單一的統一陣列最多隻能有256個字節(這樣一個由4個4×4矩陣組成的陣列) 。一旦我發現了這一點,這是一個簡單的問題,我的骨頭陣列拆分成256個字節的單個塊。 – DAVco