PDA

View Full Version : invisible vertex attributes



Sansus
10-19-2007, 08:28 AM
Hello. I'm trying to write a vertex shader for skinning, so I have to pass some per-vertex attributes to the shader.

This is the shader I'm writing:


varying vec3 normal;
attribute vec4 attr_boneRelPos1;
attribute vec4 attr_boneRelPos0;
attribute vec4 attr_boneIdx;
uniform vec4 in_bonesMat[84];
void main()
{
// first bone weight
int idx = int(attr_boneIdx.x);
vec3 pos1;
pos1.x = dot(in_bonesMat[idx],attr_boneRelPos0);
pos1.y = dot(in_bonesMat[idx+1],attr_boneRelPos0);
pos1.z = dot(in_bonesMat[idx+2],attr_boneRelPos0);
pos1 = pos1 * attr_boneIdx.y;
idx = int(attr_boneIdx.z);
vec3 pos2;
pos2.x = dot(in_bonesMat[idx],attr_boneRelPos1);
pos2.y = dot(in_bonesMat[idx+1],attr_boneRelPos1);
pos2.z = dot(in_bonesMat[idx+2],attr_boneRelPos1);
vec4 vertexBonePosition = vec4((pos2 * attr_boneIdx.w) + pos1,1.0);
gl_Position = ftransform();
normal = gl_Normal;
gl_TexCoord[0] = gl_MultiTexCoord0;
} I'm setting up 3 custom attribute variables to bind them to some buffers where I have the necessary data.

The shader compiles and links perfectly, but unfortunately, I'm not able to retrieve the location of those attributes, since glGetAttribLocation always return -1.

Using glGetActiveAttribARB I can get the active attributes, which are:
gl_Vertex, gl_Normal and gl_MultiTexCoord0.

Why I'm not able to "see" my custom attributes? Is every thing ok? Any ideas are appreciated?

Thanks in advance.

Mazy
10-19-2007, 10:22 AM
since you aren't using the 'vertexBonePosition' variable to anything, the compiler will remove everything you use to calculate that. No need to input parameters that you aren't using.

oc2k1
10-19-2007, 03:31 PM
Bone animations are very easy to implement. Here are some examples: http://lumina.sourceforge.net/?id=27

Sansus
10-22-2007, 12:48 PM
Thank you! that was exactly the problem ;)