Followers 0

4 posts in this topic

I have couple of different models with varying bones count.
To get away from shaders switch could i just use one for all without consequence?

I tried this and it worked:
MAX_BONES = 35;
...
vector<D3DXMATRIX> vMat; // vMat size varies from 20 - 30 depending on a model
...
effect->SetValue(hMatrices, &vMat[0], MAX_BONES * sizeof(D3DXMATRIX));


...
float4x4 mats[MAX_BONES];
...

Edited by belfegor
1

Share on other sites
Then i always need a vector with size of MAX_BONES ?

Thats why i asked this question, is there a harm if it reads past the end of a vector, even if that data isn't used? Or is it undefined behaviour?

I got shader error if i pass it like this:
effect->SetValue(hMatrices, &vMat[0], vMat.size() * sizeof(D3DXMATRIX));

vMat size is 33, but in shader i have:
float4x4 mats[35];

Edited by belfegor
1

Share on other sites
the bone indicies on verticies should always point to a defined matrix in the uniform array of matricies. So define the array correctly, feeding it matricies that conform to indicies. About that error, though it is unlikely, you may have a limit of 32 in the uniform array, in case you are using realy old pixel shader model. Edited by JohnnyCode
0

Create an account

Register a new account