Hi,
I’m writing a skeletal animation vertex shader. The most simple version -no lighting, just one bone per vertex- of it works fine (well except the model looks all “jaggy” cos theres really 4 bones per vertex). This is the shader:
attribute vec2 TexCoord;
attribute vec3 Normal;
attribute vec4 Indexes;
attribute vec4 Weights;
uniform vec4 BoneMatrix[87];
void main(void)
{
gl_TexCoord[0].xy = TexCoord;
vec3 Temp=Normal;
vec4 RealVertex=gl_Vertex;
vec4 TempVert1,TempVert2,TempVert3,TempVert4;
ivec4 RealIndexes=ivec4(Indexes)*3;
gl_FrontColor=vec4(1.0,1.0,1.0,1.0);
TempVert1.x=dot(RealVertex,BoneMatrix[RealIndexes.x]);
TempVert1.y=dot(RealVertex,BoneMatrix[RealIndexes.x+1]);
TempVert1.z=dot(RealVertex,BoneMatrix[RealIndexes.x+2]);
TempVert1=TempVert1*Weights.x;
TempVert1.w=1.0;
gl_Position = gl_ModelViewProjectionMatrix * TempVert1;
}
But when I add the second vertex, like so:
attribute vec2 TexCoord;
attribute vec3 Normal;
attribute vec4 Indexes;
attribute vec4 Weights;
uniform vec4 BoneMatrix[87];
void main(void)
{
gl_TexCoord[0].xy = TexCoord;
vec3 Temp=Normal;
vec4 RealVertex=gl_Vertex;
vec4 TempVert1,TempVert2,TempVert3,TempVert4;
ivec4 RealIndexes=ivec4(Indexes)*3;
gl_FrontColor=vec4(1.0,1.0,1.0,1.0);
TempVert1.x=dot(RealVertex,BoneMatrix[RealIndexes.x]);
TempVert1.y=dot(RealVertex,BoneMatrix[RealIndexes.x+1]);
TempVert1.z=dot(RealVertex,BoneMatrix[RealIndexes.x+2]);
TempVert2.x=dot(RealVertex,BoneMatrix[RealIndexes.y]);
TempVert2.y=dot(RealVertex,BoneMatrix[RealIndexes.y+1]);
TempVert2.z=dot(RealVertex,BoneMatrix[RealIndexes.y+2]);
TempVert1=TempVert1*Weights.x;
TempVert1=TempVert1+TempVert2*Weights.y;
TempVert1.w=1.0;
gl_Position = gl_ModelViewProjectionMatrix * TempVert1;
}
The model goes all black and the frame rate drops to like a frame every 2-3 seconds. What could be the reason? I was told this could be caused by ogl going into soft ware rendering mode, becouse the shader is too complex. But why? Is that shader really complex? Dont think so, becouse I’ve seen a shader do 4 bones per vertex and 2 bones for the normal, but only it was written in gpu asm. So I was thinking - maybe my drivers are compiling the asm version in some wierd way? I have a R9500 128mb with the latest drivers, or I think its the latest drivers, I updated 2 weeks ago i think. Can I somehow see the assembler version of the shader, after compilation, using some glsl command or some outside tool? Or could there be another reason? Am I using some stuff that glsl really doesnt like in hw mode? Any suggestions would be most welcome!
Thanks!
EDIT: now I know the problem is: going into software becouse availeable number of temporary registers exceeded. But how to solve that?