# Need help in two silly DX question

This topic is 4491 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

1. I have a effect file that has this variable: 'float4x3 Palette[37]' To set the data, i used: pEffect->SetMatrixArray(hParam, pBoneMatrices, NumPaletteEntries); However if i change to use this command: pEffect->SetValue(hParam, pBoneMatrices, sizeof(D3DXMATRIX)*NumPaletteEntries); It doesn't work? how come? am i doing anything wrong? 2. Just asking how do i know how many bones my shader can support in the matrix Palette? Thanks in Advance

##### Share on other sites
Quote:
 Original post by littlekid1. I have a effect file that has this variable: 'float4x3 Palette[37]'To set the data, i used:pEffect->SetMatrixArray(hParam, pBoneMatrices, NumPaletteEntries);However if i change to use this command:pEffect->SetValue(hParam, pBoneMatrices, sizeof(D3DXMATRIX)*NumPaletteEntries);It doesn't work? how come? am i doing anything wrong?
D3DXMATRIX is not the same as a float4x3 - specifically the 4x3 part should be 4x4 if you want them to match up [smile]

Quote:
 Original post by littlekid2. Just asking how do i know how many bones my shader can support in the matrix Palette?
Shader reflection should reveal the information, something along the lines of:

D3DXHANDLE h = pEffect->GetParameterByName( NULL, "Palette" );D3DXPARAMETER_DESC paletteDescription;pEffect->GetParameterDesc( h, &paletteDescription );// examine paletteDescription for info:UINT boneCount = paletteDescription.Elements;

hth
Jack

##### Share on other sites
oops sorry i think my second question was not clear.

What i meant is, when loading a skin mesh into the shader for skinning, is there a maximum number of matrix palette i can load, or can i load a mesh with 500 bones aka palette into the shader. As in if there is a restriction, how am i able to find out what is the maximum value my graphic card can support?

For the 1st question, is there a way i can use SetValue instead of setMatrixArray? i change the sizeof(D3DXMATRIX)*NumPalette to sizeof(float)*12*NumPalette, it still dosen't work.

##### Share on other sites
Shaders, by default, want the matrices in a form that's the transpose of a regular D3D matrix (I can never remember which way is column major vs. row major). If you copy the first 12 floats of each transposed matrix, then you'll be able to set the values at once, but you might as well use SetMatrixArray and let D3DX handle it.

The transposed matrix makes it so the shader is calculating w as a seperate operation, and that we only really care about W when doing projection. We can use a float4x3 to eliminate that extra instruction without losing anything except the W that we don't really care about anyway.

As for the maximum palette size, you need to break up your mesh into sections that require, at most, your matrix palette size number of bones. For 1.1 cards, this is something as low as 20 bones, depending on what else you need stored in constants such as lights, fog, texture transforms, viewproj matrices, etc. Or even a mere 10 bones, if you're going to be correct and do lighting with InverseTranspose matrices... but nobody does that. It may be good to store two versions of the model. One for 1.1 hardware, and one for everything else.

##### Share on other sites
I have this right now:

V_RETURN( pDevice->GetDirect3D(&d3d9) );
D3DCAPS9 pCaps;

if (pCaps.MaxVertexBlendMatrices < 2 ||
pCaps.MaxVertexBlendMatrixIndex == 0)
return E_NOINTERFACE;

For my ATI X800 I get:

pCaps.MaxVertexBlendMatrices = 4;
pCaps.MaxVertexBlendMatrixIndex = 37;

But, I am using shaders to do the work and don't know if these limits apply there. It would seem to be restricted more by the shader constants limitation, which for VS_2_0 is 256, leaving plenty of room for more than 37 matrices. Also, the SDK says to use this:

m_IndexedMatrixMaxSize = (pCaps.MaxVertexBlendMatrixIndex + 1) / 2; // max matrices for bone palette with normals

but it is 19 on my computer and Tiny has normals, 35 bones that are skinned, and works fine.

##### Share on other sites
yup DXNut i agree with you. I was also wondering why is it that if i follow the DX Documentation, my pCaps.MaxVertexBlendMatrixIndex = 37, hence if i do:
(pCaps.MaxVertexBlendMatrixIndex + 1)/2 = 19, yet i am able to do hardware skinning on Tiny, which also hae normals. This i don't understand? Is the documentation inaccurate, or am i getting the max blend matrix the wrong way since Tiny has 35 bones as DXNut said.

##### Share on other sites
They use "ID3DXSkinInfo::ConvertToIndexedBlendedMesh", which takes a matrix palette size. This splits the mesh into bits that use at most the palette size number of matrices.

1. 1
Rutin
29
2. 2
3. 3
4. 4
5. 5

• 13
• 13
• 11
• 10
• 13
• ### Forum Statistics

• Total Topics
632959
• Total Posts
3009458
• ### Who's Online (See full list)

There are no registered users currently online

×