Advertisement
Guest User

Untitled

a guest
Aug 24th, 2015
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.84 KB | None | 0 0
  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. uniform bool skeletal_animation;
  10.  
  11. layout(location = 0) in vec3 vertex;
  12. layout(location = 1) in vec2 uvs;
  13. //layout(location = 2) in vec3 normal;
  14. layout(location = 3) in ivec4 boneIndices;
  15. layout(location = 4) in vec4 vertexWeights;
  16.  
  17. out vec2 fsUvs;
  18.  
  19. const int NUM_INFLUENCE_BONES = 4;
  20.  
  21. void main()
  22. {
  23. fsUvs = uvs;
  24.  
  25. vec4 final = vec4(0);
  26.  
  27. if(skeletal_animation && vertexWeights[0] + vertexWeights[1] + vertexWeights[2] + vertexWeights[3] > 0.5)
  28. for(int i = 0; i < NUM_INFLUENCE_BONES; i++)
  29. {
  30. vec4 v = Bones[boneIndices[i]] * vec4(vertex, 1.0) * vertexWeights[i];
  31.  
  32. final += v;
  33. }
  34. else
  35. final = vec4(vertex,1.0);
  36.  
  37. gl_Position = ProjectionMatrix * CameraMatrix * ModelMatrix * final;
  38. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement