Jump to content
  • Advertisement
Sign in to follow this  
EternityZA

Vertex weights

This topic is 2608 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

Hi.

I want to implement vertex wieghts in my engine.

I have a an idea of how i would do it but i dont know if its optimal. I havent done any reseach on this so im just guessing.

My way would limit the amount of parent bones of each vertice to 3.

I would create a vertex atribute that would store 3 parent bone id's.
I would create another vertice atribute that would store 3 weight values (one for each parent)
I would pass an array of matrixes to my vertice shader, one for each parent bone's absolute transformation.

My vertex shader will then use the 3 id's to get the 3 parent matrixes from the array of matrixes and using those together with the weight values to calculate the final matrix.

Is my line of thought more or less correct? anything else i should keep in mind? Thnx in Advance!

Share this post


Link to post
Share on other sites
Advertisement
That's correct, although the traditional method has been to store the matrices in a cbuffer (or uniform array before cbuffers). Using a texture works too, as of DX9c/DX10.

3 is a strange number to choose as a limit though -- why not 2 or 4?

Share this post


Link to post
Share on other sites
I just edited my origanel post from textures to uniforms right before you submitted your post.

but thnx for confirming that both ways would work. Just wondering about using uniforms.

Can the size of the array vary? or does it need to be declared with a fixed size in the shader. And if it has to have a fixed size whats a good amount? What if you have a mesh with alot of bones, wont that cause issues when using uniform arrays? I thought there was a limit with the amount of data you can send through using uniforms.

EDIT: I think i confused it with the limit there is on the amount of varying variables. Wich makes more sense.

Share this post


Link to post
Share on other sites
Yea I dont think there is a limit to uniforms as they are just data, varying means it actually gets computed from vert to pixel shader.

Share this post


Link to post
Share on other sites
Can the size of the array vary? or does it need to be declared with a fixed size in the shader. And if it has to have a fixed size whats a good amount? What if you have a mesh with alot of bones, wont that cause issues when using uniform arrays? I thought there was a limit with the amount of data you can send through using uniforms.
In DX9, you're limited to 256 float4's worth of uniform data (256 is the minimum for SM3 compliance, individual cards may support higher numbers).
In DX10/11, cbuffers can contain 4KB of data each (IIRC), and you can have 14 constant buffers bound at once. Alternatively, tbuffers can hold 128MB of data each ;)

Yes, the maximum size of your array has to be fixed at shader-compile time. In our DX9 renderer, we make an array of 150 float4's, which gives us storage for 50 4x3 bone matrices. If a model requires more than 50 bones, it has to be drawn in multiple draw-calls. This also means we can't use instancing with animated meshes.
In DX11, or on DX9 using the bones-in-a-texture method, you're less limited in this regard.

Share this post


Link to post
Share on other sites
If you use a 4x3 matrix, do you just use x,y,z of the vertex, mutliply it and the do : glPosition = glModelViewProjectionMatrix*vec4(x,y,z,1.0) ?

Share this post


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

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!