# ARB_Vertex_program for skeletal animation

I have my basic idea for the thing, my problem is how to get the rotation info and such to the vertex program.

I have a matrix for every bone. but how do I get it to the vertexprogram and use it properly?

did you use a Program Local Parameter?
I think not bad idea.

Inside the vertex program how would I use that, I can’t simply just say

DP4 Result.Position, Pos, program.env[Color.x];

I need a way to tell the vereices to use ONE matrix. and only that matrix.

My final goal is to use Vertex Arrays with this. so I can’t use a simpler Inteermeidate mode fix such as speciflying the correct matrix ever vertex. or even when the matrix changed.

Could anyone help me with this?

You need to use the ARL instruction, and put all of your matrices in the indexable register store.

You could read the NV_vertex_program and NV_vertex_program_2 specifications, which specify a slightly different flavor of vertex program, but which have code examples for how to do skinning which easily port to ARB_vertex_program.

I have looked into it, it appears that will certainly help, but I have noticed one more issue, how will I do lighting? I can’t use the Inverse matrix, any ideas on how to compute lighting for my normals.

If your animation contains no non-uniform scale, you can transform your normals using the vertex position matrices, just like a vertex, but setting “w” to 0 (which most easily is done by using DP3 instead of DP4). This will result in normals being rotated, but not translated, by the vertex transform, which works as long as you only use rotation, translation (which gets removed) and uniform scaling. Normalize the output normal, and you’re done.

If you do skinning with 4 bones per vertex or more, it’s more efficient to first calculate the “blended” matrix, and then run the vertex through that once. If that’s the case, you can calculate the inverse transpose of the matrix (again, minus translation) in the shader, as an alternative; this will work even if you use non-uniform scale.