Jump to content
  • Advertisement
Sign in to follow this  

skinning effect

This topic is 4571 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

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.

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!