I’m trying to do what I believe is called ‘vertex tweening’ on the GPU. Basically, I want to calculate a final vertex position based on a base position, target position, and an interpolation factor, e.g.
vec3 v_f = v_b + (v_t - v_b)*f;
Not sure if this is relevant, but I’m using a NV 8800 GTX. I’m not sure which shader model I will need, but I’d like to keep that as relaxed as possible for now, unless some huge performance benefit is possible. My code is built around the functions of a GL2 context so using any new features in GL3 might not be worth the effort for this (simple) animation feature.
I’ve been brainstorming to figure out the ‘fast path’ for vertex tweening. Here is the process my brain went through:
I am using VBOs to store my vertex data, but I’m not sure how to pack the target position into the VBO because I don’t know what semantic to declare it as. Pretending that the target position is a (3d) texture coordinate might work, but it seems less than ideal because my C code and shader code might be confusing to another developer. Also, I’d like to have several keyframes, so the base position and target position will need to come from different buffers (which means different VBOs) as the keyframe index changes. This makes me realize that there is no benefit of packing the vertex data into an interleaved VBO at all. I’ve thought about sending the target position as an attribute, which seems like a good fit because the code will make sense to other developers, but this seems slower because the attributes are not stored on the hardware.
So, the results from brainstorming tell me that multiple VBOs seem like the way to go. I can have a separate VBO to hold each keyframe position (and normal?). The current (base) keyframe will be assigned with the glVertexPointer function (and glEnableClientState(GL_VERTEX_ARRAY)), allowing my GLSL code to use the reserved attribute name gl_Vertex to reference it…My question is, when I bind the VBO holding the target positions, which gl*Pointer function should I use to assign them and what attribute name will my GLSL code use to reference them?