PDA

View Full Version : ARB_Vertex_program for skeletal animation



Xero-X2
06-24-2003, 11:58 AM
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?

white_cat
06-25-2003, 06:11 AM
did you use a Program Local Parameter?
I think not bad idea.

Xero-X2
06-25-2003, 01:03 PM
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?

jwatte
06-25-2003, 03:09 PM
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.

Xero-X2
06-25-2003, 05:51 PM
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.

jwatte
06-25-2003, 06:54 PM
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.