help with iqm gpu animation please

Started by
-1 comments, last by MglNewb 8 years, 3 months ago
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.

This topic is closed to new replies.

Advertisement