Advertisement
Guest User

Untitled

a guest
Mar 30th, 2018
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #version 300 es
  2. layout(location = 0) in vec3 position;
  3. layout(location = 1) in vec3 normal;
  4. layout(location = 2) in vec2 texCoord;
  5. layout(location = 3) in vec3 blinking;
  6. layout(location = 4) in vec3 headLeft;
  7. layout(location = 5) in vec3 blinkingNormals;
  8. layout(location = 6) in vec3 headLeftNormals;
  9. layout(location = 7) in float index;
  10.  
  11.  
  12. out vec3 Normal;
  13. out vec3 FragPos;
  14. out vec4 ModelPos;
  15. out vec2 TexCoord;
  16.  
  17. uniform mat4 model;
  18. uniform mat4 view;
  19. uniform mat4 projection;
  20.  
  21. const int maxcount = 600;
  22.  
  23. uniform int indicesAnimation[maxcount];
  24. uniform vec3 positionsAnimation[maxcount];
  25. uniform vec3 normalsAnimation[maxcount];
  26.  
  27. const int indicesMouth[65] = int[](1086, 1157, 1230, 1373, 2073, 2088, 2090, 2092, 2095, 2106, 2108, 2110, 2113, 2116, 2120, 2130, 2132, 2140, 2144, 2144, 2211, 2216, 2223, 2234, 2271, 2271, 2273, 2276, 2535, 2540, 2547, 2558, 2601, 2606, 3699, 3770, 3843, 3986, 4686, 4699, 4702, 4715, 4718, 4720, 4722, 4722, 4726, 4728, 4732, 4740, 4742, 4752, 4756, 4757, 4824, 4829, 4836, 4847, 4885, 4887, 5148, 5153, 5160, 5171, 5214
  28. );
  29.  
  30.  
  31. uniform float amount[3];
  32.  
  33. uniform bool animationOn;
  34. uniform bool isAvatar;
  35.  
  36. flat out int mouthVertex;
  37.  
  38. vec3 pos, norm;
  39.  
  40. void binSearch()
  41. {
  42.    int low = 0, mid, high = maxcount - 1;
  43.  
  44.    while(low <= high)
  45.    {
  46.        mid = (low + high) / 2;
  47.        if (int(index) < indicesAnimation[mid])
  48.             high = mid - 1;
  49.        else if (int(index) > indicesAnimation[mid])
  50.             low = mid + 1;
  51.        else
  52.        {
  53.            pos += positionsAnimation[mid] * amount[0] * amount[0];
  54.            norm += normalsAnimation[mid] * amount[0] * amount[0];
  55.            break;
  56.        }
  57.    }
  58. }
  59.  
  60. void main()
  61. {
  62.     pos = position;
  63.     norm = normal ;
  64.  
  65.     mouthVertex = 0;
  66.  
  67.     if(animationOn)
  68.     {
  69.         if(isAvatar)
  70.         {
  71.             pos = pos + blinking * amount[1];// + headLeft*amount[2];
  72.             norm = normal  + blinkingNormals * amount[1];
  73.  
  74.             for(int i = 1; i < 65; i += 2)
  75.             {
  76.                 if(gl_VertexID >= (indicesMouth[i - 1]) && gl_VertexID <= (indicesMouth[i]))
  77.                     mouthVertex = 1;
  78.             }
  79.         }
  80.         binSearch();
  81.     }
  82.  
  83.     gl_Position = projection * view * model * vec4(pos, 1.0f);
  84.     ModelPos =  vec4(pos, 1.0f);
  85.     FragPos = position;
  86.     Normal = mat3(transpose(inverse(model))) * norm;
  87.     TexCoord = vec2(texCoord.x, 1.0f - texCoord.y);
  88. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement