This topic is 5201 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

I wrote a shader for doing vertex skinning with 4 weights per vertex in a GLSL vertex shader, and it does the right thing, but for some reason it is extremely slow (one frame every 3-4 seconds). Other vertex shaders work fine (normal mapping, for instance). If I comment out some of the shader code for the skinning, it goes back up to speed. I tried writing it a number of ways, but I can't get it to run at speed. If anyone has any ideas on why this is running so slow please let me know. Thanks, Jerec Here is the shader:
// Vertex Skinning GLSL shader
// weights in gl_MultiTexCoord1
// boneIds in gl_MultiTexCoord2

uniform vec4 boneMatrix[72];

void main()
{
vec4 w    = gl_MultiTexCoord1;
ivec4 idx = ivec4(gl_MultiTexCoord2[0],
gl_MultiTexCoord2[1],
gl_MultiTexCoord2[2],
gl_MultiTexCoord2[3]);

vec4 bonePosition;

// weighted sum of x positions
bonePosition.x = w[0] * dot(boneMatrix[idx[0] + 0], gl_Vertex) +
w[1] * dot(boneMatrix[idx[1] + 0], gl_Vertex) +
w[2] * dot(boneMatrix[idx[2] + 0], gl_Vertex) +
w[3] * dot(boneMatrix[idx[3] + 0], gl_Vertex);

// weighted sum of y positions
bonePosition.y = w[0] * dot(boneMatrix[idx[0] + 1], gl_Vertex) +
w[1] * dot(boneMatrix[idx[1] + 1], gl_Vertex) +
w[2] * dot(boneMatrix[idx[2] + 1], gl_Vertex) +
w[3] * dot(boneMatrix[idx[3] + 1], gl_Vertex);

// weighted sum of z positions
bonePosition.z = w[0] * dot(boneMatrix[idx[0] + 2], gl_Vertex) +
w[1] * dot(boneMatrix[idx[1] + 2], gl_Vertex) +
w[2] * dot(boneMatrix[idx[2] + 2], gl_Vertex) +
w[3] * dot(boneMatrix[idx[3] + 2], gl_Vertex);

bonePosition.w = 1.0;

gl_Position = gl_ModelViewProjectionMatrix * bonePosition;
gl_TexCoord[0] = gl_MultiTexCoord0;
gl_FrontColor = vec4(1,1,1,1);
}



##### Share on other sites
Is the vertex shader running in hardware? Tip, glGetInfoLogARB.

##### Share on other sites
ah ha!

I get the following:

"Link Successful. The GLSL shader will run in software - available number of temporary registers exceeded."

I guess I'll have to figure out how to fix that.

Thanks,
Jerec

##### Share on other sites
Is there any way to figure out the number of temporary registers available, and how many a vertex shader is using?

##### Share on other sites
You can probably get rendermonkey to tell you how many regs/alu ops/texture fetches a shader uses.

Quote:
 Original post by JerecIs there any way to figure out the number of temporary registers available, and how many a vertex shader is using?

1. 1
Rutin
32
2. 2
3. 3
4. 4
5. 5

• 13
• 9
• 9
• 9
• 14
• ### Forum Statistics

• Total Topics
633326
• Total Posts
3011373
• ### Who's Online (See full list)

There are no registered users currently online

×

## Important Information

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!