mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-07-13 07:34:45 +00:00
Hardware Skinning Support
- Supports GL, D3D9 & D3D11 - Extends vertex formats & shadergen to support blend indices and weights - Adds basic support for using 4x3 matrices for shader constants - Supports software fallback
This commit is contained in:
parent
507c239a87
commit
3496c549b5
72 changed files with 2533 additions and 1327 deletions
|
|
@ -150,9 +150,11 @@ bool GFXD3D11ConstBufferLayout::set(const ParamDesc& pd, const GFXShaderConstTyp
|
|||
(
|
||||
(pd.constType == GFXSCT_Float2x2 ||
|
||||
pd.constType == GFXSCT_Float3x3 ||
|
||||
pd.constType == GFXSCT_Float4x3 ||
|
||||
pd.constType == GFXSCT_Float4x4) &&
|
||||
(constType == GFXSCT_Float2x2 ||
|
||||
constType == GFXSCT_Float3x3 ||
|
||||
constType == GFXSCT_Float4x3 ||
|
||||
constType == GFXSCT_Float4x4)
|
||||
), "Mismatched const type!");
|
||||
|
||||
|
|
@ -161,6 +163,7 @@ bool GFXD3D11ConstBufferLayout::set(const ParamDesc& pd, const GFXShaderConstTyp
|
|||
{
|
||||
case GFXSCT_Float2x2:
|
||||
case GFXSCT_Float3x3:
|
||||
case GFXSCT_Float4x3:
|
||||
case GFXSCT_Float4x4:
|
||||
return setMatrix(pd, constType, size, data, basePointer);
|
||||
break;
|
||||
|
|
@ -201,6 +204,40 @@ bool GFXD3D11ConstBufferLayout::setMatrix(const ParamDesc& pd, const GFXShaderCo
|
|||
|
||||
return false;
|
||||
}
|
||||
else if (pd.constType == GFXSCT_Float4x3)
|
||||
{
|
||||
F32 buffer[4 * 4];
|
||||
const U32 csize = 48;
|
||||
|
||||
// Loop through and copy
|
||||
bool ret = false;
|
||||
U8* currDestPointer = basePointer + pd.offset;
|
||||
const U8* currSourcePointer = static_cast<const U8*>(data);
|
||||
const U8* endData = currSourcePointer + size;
|
||||
while (currSourcePointer < endData)
|
||||
{
|
||||
#ifdef TORQUE_DOUBLE_CHECK_43MATS
|
||||
Point4F col;
|
||||
((MatrixF*)currSourcePointer)->getRow(3, &col);
|
||||
AssertFatal(col.x == 0.0f && col.y == 0.0f && col.z == 0.0f && col.w == 1.0f, "3rd row used");
|
||||
#endif
|
||||
|
||||
if (dMemcmp(currDestPointer, currSourcePointer, csize) != 0)
|
||||
{
|
||||
dMemcpy(currDestPointer, currSourcePointer, csize);
|
||||
ret = true;
|
||||
}
|
||||
else if (pd.constType == GFXSCT_Float4x3)
|
||||
{
|
||||
ret = true;
|
||||
}
|
||||
|
||||
currDestPointer += csize;
|
||||
currSourcePointer += sizeof(MatrixF);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
else
|
||||
{
|
||||
PROFILE_SCOPE(GFXD3D11ConstBufferLayout_setMatrix_not4x4);
|
||||
|
|
@ -480,8 +517,15 @@ void GFXD3D11ShaderConstBuffer::set(GFXShaderConstHandle* handle, const MatrixF&
|
|||
AssertFatal(!h->isSampler(), "Handle is sampler constant!" );
|
||||
AssertFatal(h->mShader == mShader, "Mismatched shaders!");
|
||||
|
||||
MatrixF transposed;
|
||||
mat.transposeTo(transposed);
|
||||
MatrixF transposed;
|
||||
if (matrixType == GFXSCT_Float4x3)
|
||||
{
|
||||
transposed = mat;
|
||||
}
|
||||
else
|
||||
{
|
||||
mat.transposeTo(transposed);
|
||||
}
|
||||
|
||||
if (h->mInstancingConstant)
|
||||
{
|
||||
|
|
@ -510,9 +554,17 @@ void GFXD3D11ShaderConstBuffer::set(GFXShaderConstHandle* handle, const MatrixF*
|
|||
|
||||
static Vector<MatrixF> transposed;
|
||||
if (arraySize > transposed.size())
|
||||
transposed.setSize(arraySize);
|
||||
for (U32 i = 0; i < arraySize; i++)
|
||||
mat[i].transposeTo(transposed[i]);
|
||||
transposed.setSize(arraySize);
|
||||
|
||||
if (matrixType == GFXSCT_Float4x3)
|
||||
{
|
||||
dMemcpy(transposed.address(), mat, arraySize * sizeof(MatrixF));
|
||||
}
|
||||
else
|
||||
{
|
||||
for (U32 i = 0; i < arraySize; i++)
|
||||
mat[i].transposeTo(transposed[i]);
|
||||
}
|
||||
|
||||
// TODO: Maybe support this in the future?
|
||||
if (h->mInstancingConstant)
|
||||
|
|
@ -1190,19 +1242,13 @@ bool GFXD3D11Shader::_convertShaderVariable(const D3D11_SHADER_TYPE_DESC &typeDe
|
|||
case D3D_SVC_MATRIX_ROWS:
|
||||
case D3D_SVC_MATRIX_COLUMNS:
|
||||
{
|
||||
switch (typeDesc.Columns)
|
||||
switch (typeDesc.Rows)
|
||||
{
|
||||
case 3:
|
||||
if (typeDesc.Rows == 3)
|
||||
{
|
||||
desc.constType = GFXSCT_Float3x3;
|
||||
}
|
||||
desc.constType = typeDesc.Columns == 4 ? GFXSCT_Float3x4 : GFXSCT_Float3x3;
|
||||
break;
|
||||
case 4:
|
||||
if (typeDesc.Rows == 4)
|
||||
{
|
||||
desc.constType = GFXSCT_Float4x4;
|
||||
}
|
||||
desc.constType = typeDesc.Columns == 3 ? GFXSCT_Float4x3 : GFXSCT_Float4x4;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
@ -1513,6 +1559,9 @@ U32 GFXD3D11Shader::getAlignmentValue(const GFXShaderConstType constType) const
|
|||
case GFXSCT_Float3x3 :
|
||||
return mRowSizeF * 3;
|
||||
break;
|
||||
case GFXSCT_Float4x3:
|
||||
return mRowSizeF * 3;
|
||||
break;
|
||||
case GFXSCT_Float4x4 :
|
||||
return mRowSizeF * 4;
|
||||
break;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue