skinning effect

Started by
-1 comments, last by 7Days 17 years, 10 months ago
I am currently trying to perform a skinning effect with shader and I have a problem. Here is my shader: /*****************************************************************************/ attribute vec3 vertices_coord; attribute vec4 vertices_color; attribute vec2 weight;//weight of each bones attribute float numbones;//number of bones treated attribute vec2 indice;//indices for the matrix varying vec4 color; void main(void) { float i; mat4 bone[2]; bone[0] = gl_ModelViewMatrix; bone[1] = mat4(1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0); vec4 position = vec4(0.0, 0.0, 0.0, 0.0); vec2 weights = weight; vec2 index = indice; for( i=0.0; i< numbones; i+=1.0) { position = position + weights.x*(bone[int(index.x)]*vec4(vertices_coord, 1.0)); index = index.yx; weights = weights.yx; } gl_Position = position; color = vertices_color; } /*****************************************************************************/ My problem comes from the position calculation. Indeed I cannot do bone[int(index.x)], it does not work, and I could not access the proper matrix... So I have a solution, I do a if in my loop on the index.x value, but I would like to know why I cannot access the proper matrix via this methods.

This topic is closed to new replies.

Advertisement