Jump to content
  • Advertisement
Sign in to follow this  
GreyHound

[Solved] Struggling at Shader Translation

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

If you intended to correct an error in the post then please contact us.

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]

Share this post


Link to post
Share on other sites
Advertisement
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 this post


Link to post
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.

Share this post


Link to post
Share on other sites
the uniforms work(ed) as we guessed, it´s been a small but crucial error in my translated code that totally messed up the results.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

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!