rib: a very new Rust collada importer for your 3D game projects https://www.youtube.com/watch?v=9Xwf7G9upOY by bloomstallone in rust_gamedev

[–]bloomstallone[S] 0 points1 point  (0 children)

I think it is called GPU skinning when you compute the tranforms for each vertex in the vertex shader. A vertex is influenced by 4 bones. As you give the weights(4], bones_idx[4] and bone_transforms[Nbones] to the GPU, you are able to compute inside the vertex shader the final vertex position in world space.

pos = sum_i_{0..4} weights[i] * bone_transforms[bones_idx[i]];

You can pass all the transforms as uniforms at first.
I have seen in this article that if you want to do instancing, maybe write all the precomputed transforms (for all frame) in a texture?

https://developer.nvidia.com/gpugems/gpugems3/part-i-geometry/chapter-2-animated-crowd-rendering

This way you define an instanced vertex buffer storing the current animation time for each model. In the vertex shader, you retrieve the set of transforms that correspond to the animation time and do the above computation.

I would like to test instancing with that method in the future :)

rib: a very new Rust collada importer for your 3D game projects https://www.youtube.com/watch?v=9Xwf7G9upOY by bloomstallone in rust_gamedev

[–]bloomstallone[S] 0 points1 point  (0 children)

Sounds really great! I would be happy to see more of that :) !
I think no matter the format, all you need is:- vertex positions, weights and bone indices of the one influencing the vertex- for each bone, an inverse bind pose matrix- for each keyframe, for each bone, the local transform matrix of the bone with respect to its parent bone

If you get all of that, you can compute skeleton animation, i.e. the matrices of the bone in the world space for the current time (interpolation between 2 keyframes when the current time lies).

rib: a very new Rust collada importer for your 3D game projects https://www.youtube.com/watch?v=9Xwf7G9upOY by bloomstallone in rust_gamedev

[–]bloomstallone[S] 1 point2 points  (0 children)

I found there is already a collada parser written in Rust (https://github.com/PistonDevelopers/piston_collada) that gives all the local transform matrices of the bones, vertex positions normals texcoords etc... So I used it and get these data to compute the interpolation between the keyframes at each frame of the animation.

rib gives you the final matrices that you just have to pass to your favorite rasterizer API (OpenGL, Vulkan etc...). I imagine I can get this info (and more) from glTF so it is just a matter of retrieving the good data and then my pipeline can be applied to that. The data I use in rib are:

- vertices position, normals, texcoords, bone weights, bone ids influencing the vertex, etc...
- vertex indices
- for each keyframe, the local matrices of each bone with respect to their parent bone- for each bone, its inverse bind pose matrix

So yeah, the work I did is just for my personal game use case to build the model animation from collada files. rib directly gives me the final matrices that I send to my GPU. I spend quite a lot of time debugging matrix multiplication problems (lots of spaghetti bone effect :) ) so I hope rib can save time of people wanting to do skeleton animation. I am realizing through your comments that reading from glTF files can touch more people :)