zPrePass_optimized.vert 896 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. #version 430
  2. #pragma debug(on)
  3. layout(location = 0) in vec3 a_positions;
  4. //layout(location = 1) in vec3 a_normals;
  5. layout(location = 2) in vec2 a_texCoord;
  6. layout(location = 3) in ivec4 a_jointsId;
  7. layout(location = 4) in vec4 a_weights;
  8. uniform mat4 u_transform; //full model view projection
  9. readonly restrict layout(std140) buffer u_jointTransforms
  10. {
  11. mat4 jointTransforms[];
  12. };
  13. uniform int u_hasAnimations;
  14. out vec2 v_texCoord;
  15. void main()
  16. {
  17. vec4 totalLocalPos = vec4(0.f);
  18. if(u_hasAnimations != 0)
  19. //if(false)
  20. {
  21. for(int i=0; i<4; i++)
  22. {
  23. if(a_jointsId[i] < 0){break;}
  24. mat4 jointTransform = jointTransforms[a_jointsId[i]];
  25. vec4 posePosition = jointTransform * vec4(a_positions, 1);
  26. totalLocalPos += posePosition * a_weights[i];
  27. }
  28. }else
  29. {
  30. totalLocalPos = vec4(a_positions, 1.f);
  31. }
  32. gl_Position = u_transform * totalLocalPos;
  33. v_texCoord = a_texCoord;
  34. }