• Advertisement
Sign in to follow this  

Passing bone matrices to shader

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

If you intended to correct an error in the post then please contact us.

Recommended Posts

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

Share this post


Link to post
Share on other sites
Advertisement
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

Share this post


Link to post
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

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement