I want to have a mesh that can be animated. I’m loading mesh from a file, including key frames. I want to put all the frames into VBO and compose two of them on the GPU in a vertex shader. So i want to pass to frames to GPU and some uniform that will allow to create one result frame from these two
Is it possible? If so, how can i do it?
You would just have more vertex attributes. Normally, you might have:
With morph targets, you would need:
The actual model-space position would be a linear interpolation between
position0andposition1. Same goes for the normal (I guess). Once you get them, you pass them through the usual transforms. The color and texture coordinates presumably don’t change, but if they do, then they too need to have0and1versions.The actual rendering is pretty simple. Presumably, you will have all the positions for the morph targets in the same buffer. So it’s a matter of binding
position0‘s attribute to the first morph target, andposition1‘s attribute to the second morph target. Same goes for the normals. Then you render as normal.