Hi. I’m currently hitting a bottleneck with hardware skinning control. I’m planning to make a large dense forest of animated trees (with bones to simulate wind) and need control over the frame times and bone amounts for each instance. To fix this, I want to put the transform table into a TBO. currently i’m working like this:
uniform samplerBuffer TBO_TransformTable;
uniform int TBO_SkinningFrame;
uniform int TBO_NumJoints;
this will be passed into the shader. However, the TBO needs to store the entirety of the animation so that I can pass any frame number in and it will index the right position in the TBO. However I’m struggling to actually get the animation information extracted from the animated tree. How do I extract the bone data from Character and put it into the TBO?
I was thinking of storing each matrix row side by side in a rgba32 texture and reconstruct the matrix in the shader.
yea that would be overkill. My trees only need one animation at once. And to reduce CPU overhead, it would be good to just put the entire animation in one TBO.
I noticed in your code, you also create another TBO _bone_id_tree_tex. I’m interested how you exactly referenced in uvec4 transform_index; in you shaders. What is you structure exactly?
hmm. Like you said you built your own Character class. How do you extract animation information that is in the correct order for transform_index? Could I potentially use the same method for the default Character class? I think storing the information won’t be too hard. Just need to multiply the frame time with the animation offset for the TBO as an extension to the function you showed.
I’m not actually to sure where to actually get the animation skinning data?
Like you said you built your own Character class. How do you extract animation information that is in the correct order for transform_index?
I built my own Animation class too.
So it all up to me for match the bone index in character and animation. I’m just sorting all the bones by it’s name for simplicity and referencing bones by it’s name in the animation.
This is where I sort the bones by name and generating a new transform_index for each bone:
This is where I write the new transform_index into GeomVertexData during the loading mesh from glTF:
You can use the same methods to get transform_index from the mesh or rewrite it.
I’m not actually to sure where to actually get the animation skinning data?
The animation is basically array of matrices. I don’t know how to parse the panda animaions, but since you want to animate the model by yourself in shader you can use any animation format. I’m using BVH, but I have extended it with quaternions. It’s a simple text-based format where the bone order is defined in HIERARCHY section.
Surely there is a simpler way to store the matrix deform of each bone to the transform index. Maybe since I am using the original panda3d library, somewhere in the source code I could find how the uniform p3d_TransformTable is constructed. It would save me some time re-formatting my Character’s geometry.
looking through the documentation and source code, I might be able to extract animation data from the geometry’s TransformTable. From my understanding of the C++ function:
The transform table object gets filled every frame but I can’t find from where. Looking at the documentation, I can get the TransformTable from a GeomVertexData object. I’m not very familiar of how the data is stored. Is there a new GeomVertexData object per frame of character animation? Does this mean I have to go through the animation frame by frame and extract a TransformTable? I’m just trying to keep my code as simple as possible. I would prefer to avoid making an entire new Character class as all I need is one animation playing at a time.
Or maybe it could be worth investing in what you currently have for future proof reasons. Not sure. Maybe panda3d will eventually add a shader uniform option to store skinning data on a TBO.