Sign in to follow this  

OpenGL GLSL skinning problem with vertex indexes

Recommended Posts

Hello, I've added GLSL support to my engine, some normal mapping, and want to test if hardware skinning is faster then software (done on the cpu). But I'm doing something wrong the shader below, it compiles without errors/warnnings, but on some vertices maybe all not sure doesn't do the indexing write. The visual result is that there are lots of vertices having the same world coordinates.

uniform vec3	lightInObject;

uniform mat4	boneTransforms[28];

attribute vec4	tangent;
attribute ivec4	weightIndexes;
attribute vec4	weights;

varying vec3	light;

void main()
//	vec4	position = gl_Vertex;
	vec4	position = vec4(0.0);
//	if(weights[0] > 0.0)
		position += (boneTransforms[ weightIndexes[0] ] * gl_Vertex) * weights[0];
//	if(weights[1] > 0.0)
		position += (boneTransforms[ weightIndexes[1] ] * gl_Vertex) * weights[1];
/*/	if(weights[2] > 0.0)
		position += (boneTransforms[ weightIndexes[2] ] * gl_Vertex) * weights[2];
//	if(weights[3] > 0.0)
		position += (boneTransforms[ weightIndexes[3] ] * gl_Vertex) * weights[3];
	gl_Position = gl_ModelViewProjectionMatrix * position ;
	vec3	binormal = cross(gl_Normal, ) * tangent.w;
	mat3	TBNmatrix = mat3(tangent.x, binormal.x, gl_Normal.x,
				 tangent.y, binormal.y, gl_Normal.y,
				 tangent.z, binormal.z, gl_Normal.z

	light = normalize(  TBNmatrix * ( lightInObject - );
	gl_TexCoord[0] = gl_TextureMatrix[0] * gl_MultiTexCoord0;

/// here I store the weight indexes
struct tWeightIndex
	unsigned char		v[4];
	unsigned char&	operator [] (unsigned const ind) { return v[ind]; }

/// and thats how I create the vbo
glGenBuffersARB(1, &m_VBO_id);
glBufferDataARB(GL_ARRAY_BUFFER_ARB, total_size, 0, GL_STATIC_DRAW );

/// here I setup other attributes

if(m_format.getAttr(CMeshFormat::WEIGHT_INDS) )
	glBufferSubDataARB(GL_ARRAY_BUFFER_ARB, offset, sizeof(tWeightIndex) * vert_count,								m_geometry.getWeightIndexes() );			offset+= vert_count * sizeof(tWeightIndex);

///here is the code for sending the mesh to the card

attribIndex = m_format.getWeightLocation();
if( m_format.getAttr(CMeshFormat::WEIGHTS) && attribIndex != -1)
	glVertexAttribPointerARB(attribIndex, 4, GL_FLOAT, GL_FALSE, 0, VBO_OFFSET(offset) );
	offset += vert_count * sizeof(Vector4d);
attribIndex = m_format.getWeightIndexLocation();
if( m_format.getAttr(CMeshFormat::WEIGHT_INDS) && attribIndex != -1)
	glVertexAttribPointerARB(attribIndex, 4, GL_INT, GL_FALSE, 0, VBO_OFFSET(offset) );
	offset += vert_count * sizeof(tWeightIndex);

This is the whole testing vertex shader... I've tried all combinations (uncommenting/commenting lines) that came into my mind but it doesn't help... My card is nvidia gf6600 drivers: linux 76.76, windows 71.84... the result is the same on both OSes... The second problem I have is how to use the openGL 2.0 functions (those without the ARB at the end), I'm using the GLEW library for setuping the extensions, but on windows when I call function without the ending ARB, I get the accesss violation, it compiles fine and the library claims to have the ogl2.0 support, but it doesn't work!!! :( Thanks in advance, sorry for the bad English Greetings, Teodor

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this