Advertisement
Guest User

Untitled

a guest
May 13th, 2015
478
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #version 430
  2.  
  3. //bones
  4. uniform mat4 ProjectionMatrix;
  5. uniform mat4 CameraMatrix;
  6. uniform mat4 ModelMatrix;
  7.  
  8. uniform mat4 Bones[64];
  9.  
  10. layout(location = 0) in vec3 vertex;
  11. //layout(location = 1) in vec2 uv;
  12. //layout(location = 2) in vec3 normal;
  13. layout(location = 3) in ivec4 boneIndices;
  14. layout(location = 4) in vec4 vertexWeights;
  15.  
  16. const int NUM_INFLUENCE_BONES = 4;
  17.  
  18. void main()
  19. {
  20.     vec4 final = vec4(0);
  21.  
  22.     if(vertexWeights[0] + vertexWeights[1] + vertexWeights[2] + vertexWeights[3] > 0.9)
  23.         for(int i = 0; i < NUM_INFLUENCE_BONES; i++)
  24.         {
  25.             vec4 v = Bones[boneIndices[i]] * vec4(vertex, 1.0) * vertexWeights[i];
  26.        
  27.             final += v;
  28.         }
  29.     else
  30.         final = vec4(vertex,1.0);
  31.  
  32.     gl_Position = ProjectionMatrix * CameraMatrix * ModelMatrix * final;
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement