Advertisement
Guest User

Untitled

a guest
Nov 6th, 2015
142
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. const int NUM_INFLUENCE_BONES = 4;
  9. uniform mat4 Bones[64];
  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. void main()
  20. {
  21.     fsUvs = uvs;
  22.  
  23.     vec4 final = vec4(0);
  24.  
  25.     if(vertexWeights[0] + vertexWeights[1] + vertexWeights[2] + vertexWeights[3] > 0.5)
  26.         for(int i = 0; i < NUM_INFLUENCE_BONES; i++)
  27.         {
  28.             vec4 v = Bones[boneIndices[i]] * vec4(vertex, 1.0) * vertexWeights[i];
  29.  
  30.             final += v;
  31.         }
  32.     else {
  33.         final = vec4(vertex,1.0);
  34.         final.xyz *= (normal * 0.0001);/////////////
  35.     }
  36.  
  37.     gl_Position = ProjectionMatrix * CameraMatrix * ModelMatrix * final;
  38. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement