Skip to main content
GameDev.net gamedev.net
🔒 Locked

GLSL bone + light structuring code

Started by dpadam450 Mar 9, 2008 at 7:22 PM 0 replies 600+ views
Original Post
dpadam450
dpadam450
I already have bone and 1 directional light working for animations, heres my question though: vertex_position = boneMatrix0*weight0 +.....boneMatrixN*weightN; It would be faster to do something like this:

//You have an array of matrices per frame
//each vertex has an array of integer indexes
//stating the bone and weight
for(int i = 0; i < vertex.boneIndex;i++)
{
    vertex_position += boneMatrix[vertex.boneIndex]*vertex.weight[vertex.boneIndex];
}

Basically, just getting rid of all the weights of 0 to speed up the shader. I wasted all my time writing the above, my question really is this: mat4 boneMatrix[32]; //32 bones When I sent the matrices as uniforms to the shader, how do I specify locations = GetUniformLocation(..., "boneMatrix[1]")? Do I just say locations+= (sizeof(float)*16 ?
NBA2K, Madden, Maneater, Killing Floor, Sims 
V-man
V-man
You can do
locations = GetUniformLocation(..., "boneMatrix[1]")

or if you prefer
all_locations = GetUniformLocation(..., "boneMatrix")

that will get you location of the first and you can upload all of them at once.

Quote:
locations+= (sizeof(float)*16


No, the actual locations of each matrix is up to the driver.
[0] might be 10
[1] might be 11
[2] might be 12

or maybe
[0] might be 10
[1] might be 12
[2] might be 14

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.