• 10
• 9
• 13
• 10
• 18

# [Solved] Struggling at Shader Translation

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

## Recommended Posts

Hello guys, first of all a big hi to everybody since it's my first thread since i joined. I also have a problem i've been trying to solve for several days now. I hope someone can point out something that might help me translate the following. Basicly i try to translate the vertex program that comes with Cal3d to GLSL. I've been throught several books and tutorials, example shaders and other sources but i wasn't able to find something that has enought familiarities so it would help me. I think the basic calculations are correct and it's actually my C++ code that's causing the malfunction. That's what i got as source: The Shader Part looks like:
PARAM matrix[87] = { program.local[0..86] };

... and that's how the stuff is pushed into the shader.
for(boneId = 0; boneId < m_calHardwareModel->getBoneCount(); boneId++)
{
float transformation[12];
... //transformations are calculated
glProgramLocalParameter4fvARB(GL_VERTEX_PROGRAM_ARB,boneId*3,&transformation[0]);
glProgramLocalParameter4fvARB(GL_VERTEX_PROGRAM_ARB,boneId*3+1,&transformation[4]);
glProgramLocalParameter4fvARB(GL_VERTEX_PROGRAM_ARB,boneId*3+2,&transformation[8]);
}

This, of course, is working. Here's how i try to translate the code above. Shader:
uniform vec4 BoneMatrix[87];
and the corresponding C++ code: (which now works)

for(boneId = 0; boneId < m_calHardwareModel->getBoneCount(); boneId++)
{
transformation[...] = ...;
....
char buffer[18];
sprintf (buffer, "BoneMatrix[%i]", boneId*3);
GLint MatrixLoc = glGetUniformLocation(p,buffer);
glUniform4fv(MatrixLoc, 3, &transformation[0]);
}

I´ve got a good feeling about the basic idea but i can´t really tell if the code is totally correct. I'd be so happy if anyone had a nice idea where or what the problem is located. thx in advance Grey [Edited by - GreyHound on May 23, 2007 9:35:36 AM]

Looks correct

##### Share on other sites
glad to hear that, thx, since that´s what i thought too. But that makes it even stranger since i´ve no idea how i get problems then.

I really need to be 100% sure the array BoneMatrix[87] is filled exactly the same as in the original. But i thought i tried all the basic combinations i could think off.

##### Share on other sites
To know the value that something contains, I output as color. It can be a lot of work to debug it.