Transform pointer with VBO

Started by Maykin53, May 22, 2011, 01:18:02

Previous topic - Next topic

Maykin53

I've been experimenting with optimisations for my renderer that uses VBOs.
Currently for each model segment that is undergoing skeletal animation, transformation occurs with the deprecated glRotate and glTranslate functions and then the glDrawElements is called (to draw from the VBOs).

Currently this is what happens:

# for each entity (some object that can move and animate)
- glTranslate to the entity's location
   # for each skeletal segment in the entity's model
   - do glRotate and glTranslate based on any animations occurring for that segment
   - bind the texture for that segment
   - call glDrawElements (with offsets and lengths for the location of the data in the VBO for this model segment)

I've read that calling glDrawElements has a significant overhead so it should be called as little as possible. I'd like to trim it down to possibly one call that includes all my transformed model segments and in the process remove the deprecated glTranslate and glRotate functions.

The problem I have is that I cannot find a way to specify transforms per vertex such that I can call drawElements just once. Is this even possible? It would be good if there was a glTransformPointer like glVertexPointer, glNormalPointer, glColorPointer, and glTexCoordPointer. Perhaps I'm going about this all wrong and I've missed the point?

I read somewhere that "OpenGL 3.0 adds the ability to stream the results of vertex transformation into a vertex buffer object" - I'm not sure how to achieve this or how to get glDrawElements to recognise them.

I've read that skeletal animation can be achieved using vertex shading with uniform arrays in the shader. The problem with this approach is that there's an implementation independent maximum amount of uniform registry space which can become a problem when you have a lot of models with a lot of skeletal parts - so it gets pretty messy doing it that way.

Does anyone have any ideas? Feel free to criticise my severe lack of knowledge on the subject.

spasi

Skeletal animation is usually done on the GPU using a technique called "matrix palette skinning". Read this chapter in GPU Gems for a nice explanation and some sample code. Depending on how many bones you have per model, the uniform space could be a limitation, but it can be easily solved by splitting the model in multiple parts.