Jump to content
  • Advertisement
Sign in to follow this  
MglNewb

OpenGL help with iqm gpu animation please

This topic is 888 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 im new to modern opengl and am trying to get Iqm animation to work on the gpu. I have got the fixed function version of it working no problem, but shaders are new to me. I was would appreciate it if you guys could give me a hand.
here is the code i got so far pastebin.com/XJsTFKeF i put it all in one file so easier for you see all the code. here is the vert shader
#version 330
 
uniform mat4 projectionMatrix;
uniform mat4 modelViewMatrix;
uniform mat3x4 bonemats[80];
layout (location = 0) in vec3 inPosition;
layout (location = 1) in vec3 inColor;
layout (location = 2) in vec4 vweights;
layout (location = 3) in vec4 vbones;
layout (location = 4) in vec4 vtangent;
 
 
 
smooth out vec3 theColor;
 
void main()
{
 mat3x4 m = bonemats[int(vbones.x)] * vweights.x;
  m += bonemats[int(vbones.y)] * vweights.y;
  m += bonemats[int(vbones.z)] * vweights.z;
 m += bonemats[int(vbones.w)] * vweights.w;
  vec4 mpos = vec4(gl_Vertex * m, gl_Vertex.w);
  gl_Position = gl_ModelViewProjectionMatrix * mpos;
   gl_TexCoord[0] = gl_MultiTexCoord0;
   mat3 madjtrans = mat3(cross(m[1].xyz, m[2].xyz), cross(m[2].xyz, m[0].xyz), cross(m[0].xyz, m[1].xyz));
   vec3 mnormal = gl_Normal * madjtrans;
   vec3 mtangent = vtangent.xyz * madjtrans; // tangent not used, just here as an example
  vec3 mbitangent = cross(mnormal, mtangent) * vtangent.w; // bitangent not used, just here as an example
   gl_FrontColor = gl_Color * (clamp(dot(normalize(gl_NormalMatrix * mnormal), gl_LightSource[0].position.xyz), 0.0, 1.0) * gl_LightSource[0].diffuse + gl_LightSource[0].ambient);
gl_Position = projectionMatrix*modelViewMatrix*vec4(inPosition, 1.0);
theColor = inColor;
}
 
 
 
and here is frag shader
#version 330
uniform sampler2D tex;
smooth in vec3 theColor;
out vec4 outputColor;
 
void main()
{
outputColor = vec4(theColor, 1.0);
}
 
any help would be greatly appreciated.
Edited by swiftcoder
Please don't wipe out posts. Instead, if you have found the solution, post it so that others can benefit!

Share this post


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