compacted skinning bone buffer

This commit is contained in:
turanszkij
2017-09-13 19:18:43 +02:00
parent 0176cdb3af
commit 758cfec5ba
4 changed files with 24 additions and 5 deletions
+12 -2
View File
@@ -3,7 +3,9 @@
struct Bone
{
float4x4 pose;
float4 pose0;
float4 pose1;
float4 pose2;
};
STRUCTUREDBUFFER(boneBuffer, Bone, SKINNINGSLOT_IN_BONEBUFFER);
@@ -30,7 +32,15 @@ inline void Skinning(inout float4 pos, inout float4 nor, in float4 inBon, in flo
[loop]
for (uint i = 0; ((i < 4) && (weisum<1.0f)); ++i)
{
m = boneBuffer[(uint)inBon[i]].pose;
float4 pose0 = boneBuffer[(uint)inBon[i]].pose0;
float4 pose1 = boneBuffer[(uint)inBon[i]].pose1;
float4 pose2 = boneBuffer[(uint)inBon[i]].pose2;
m = float4x4(
float4(pose0.x, pose1.x, pose2.x, 0),
float4(pose0.y, pose1.y, pose2.y, 0),
float4(pose0.z, pose1.z, pose2.z, 0),
float4(pose0.w, pose1.w, pose2.w, 1)
);
m3 = (float3x3)m;
p += mul(float4(pos.xyz, 1), m)*inWei[i];
+10 -1
View File
@@ -718,7 +718,16 @@ public:
GFX_STRUCT ShaderBoneType
{
XMMATRIX pose;
XMFLOAT4A pose0;
XMFLOAT4A pose1;
XMFLOAT4A pose2;
void Create(const XMFLOAT4X4& matIn)
{
pose0 = XMFLOAT4A(matIn._11, matIn._21, matIn._31, matIn._41);
pose1 = XMFLOAT4A(matIn._12, matIn._22, matIn._32, matIn._42);
pose2 = XMFLOAT4A(matIn._13, matIn._23, matIn._33, matIn._43);
}
STRUCTUREDBUFFER_SETBINDSLOT(SKINNINGSLOT_IN_BONEBUFFER)
+1 -1
View File
@@ -1827,7 +1827,7 @@ void wiRenderer::UpdateRenderData(GRAPHICSTHREAD threadID)
for (unsigned int k = 0; k < armature->boneCollection.size(); k++)
{
// Note the transpose: we NEED to transpose so that loading from the structured buffer is easier in the shader (avoid the many mov operations)
armature->boneData[k].pose = XMMatrixTranspose(XMLoadFloat4x4(&armature->boneCollection[k]->boneRelativity));
armature->boneData[k].Create(armature->boneCollection[k]->boneRelativity);
}
GetDevice()->UpdateBuffer(&armature->boneBuffer, armature->boneData.data(), threadID, (int)(sizeof(Armature::ShaderBoneType) * armature->boneCollection.size()));
GetDevice()->BindResourceCS(&armature->boneBuffer, STRUCTUREDBUFFER_GETBINDSLOT(Armature::ShaderBoneType), threadID);
+1 -1
View File
@@ -9,7 +9,7 @@ namespace wiVersion
// minor features, major updates
const int minor = 13;
// minor bug fixes, alterations, refactors, updates
const int revision = 13;
const int revision = 14;
long GetVersion()