Consider a 3D model for a spider that consists of a body and eight legs. The legs can be transformed (rotated) relative to the body. I am not sure what the common ways of rendering such a scene are, at a low level. Two ways I could think of:

  1. Render the body and legs separately, using different VBOs (or different indices) (one for the body, one for the leg) and separate draw calls.
  2. Encode in each vertex which body part it belongs to, and decide based on this information how to transform the vertex in the vertex shader.

I searched a bit and could find some tutorials on skeletal animation and similar techniques, but they still boil down to this question.

  • \$\begingroup\$ Not really sure what you are asking. Are you referring to animation \$\endgroup\$ – unknownSPY Oct 24 '17 at 17:07
  • \$\begingroup\$ @unknownSPY Not necessarily animation. It seems to me that drawing the whole model in one go is not possible to do in a sane way, but I might be missing something. So the question is: do I have to render the different parts of the model separately? \$\endgroup\$ – rightfold Oct 24 '17 at 17:09

Your second guess is almost correct. Skeletal based animation usually uses a weight map to bind certain vertices to certain bones (a single vertex can have multiple parent bones, there's usually an upper limit though). Then a vertex shader is used to move the vertices based on their parent bones.

Basically, the files include the skinning values for the separate bones, you process them and send them to the shader somehow. I've seen people using a vec4 and 4 matrices to store the transformations to do this, which limited the weights per vertex to 4 (you usually don't have much more), but it's up to the programmer to decide how he does it.

You can still do the same if you don't want to use this for animation, but instead of using bones, just use a pseudo element with a position and an id

  • \$\begingroup\$ It might be good to include a bit more details about how this type of GPU skinning is achieved - eg. how the vertex shader gets access to bone transforms - since it seems like this user is looking for low-level implementation information like VBO setup. \$\endgroup\$ – DMGregory Oct 24 '17 at 17:13
  • \$\begingroup\$ @DMGregory I'll try \$\endgroup\$ – Bálint Oct 24 '17 at 17:17
  • \$\begingroup\$ If I understand this correctly, each vertex would contain along with the position a weight value for each bone. Then it’s a matter of multiplying the position by the weighted sum of the bones given the weights. \$\endgroup\$ – rightfold Oct 24 '17 at 17:20
  • \$\begingroup\$ @DMGregory I gave an example, but it's really up to the programmer to decide \$\endgroup\$ – Bálint Oct 24 '17 at 17:23

I think skeletal animation is only really possible if you have the bones set up and have the animation frames available. If you have all of that, the skeletal is the way to follow.

If you do not, then I would go forward with your first option, but set it up as a scene graph, to learn about scene graphs I would take a look at this info on scene graphs


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.