[C++] The IN55 project
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

shader.vs 876B

123456789101112131415161718192021222324252627282930313233
  1. #version 330
  2. layout (location = 0) in vec3 Position;
  3. layout (location = 1) in vec2 TexCoord;
  4. layout (location = 2) in vec3 Normal;
  5. layout (location = 3) in ivec4 BoneIDs;
  6. layout (location = 4) in vec4 Weights;
  7. out vec2 TexCoord0;
  8. out vec3 Normal0;
  9. out vec3 WorldPos0;
  10. const int MAX_BONES = 100;
  11. uniform mat4 gWVP;
  12. uniform mat4 gWorld;
  13. uniform mat4 gBones[MAX_BONES];
  14. void main()
  15. {
  16. mat4 BoneTransform = gBones[BoneIDs[0]] * Weights[0];
  17. BoneTransform += gBones[BoneIDs[1]] * Weights[1];
  18. BoneTransform += gBones[BoneIDs[2]] * Weights[2];
  19. BoneTransform += gBones[BoneIDs[3]] * Weights[3];
  20. vec4 PosL = BoneTransform * vec4(Position, 1.0);
  21. gl_Position = gWVP * PosL;
  22. TexCoord0 = TexCoord;
  23. vec4 NormalL = BoneTransform * vec4(Normal, 0.0);
  24. Normal0 = (gWorld * NormalL).xyz;
  25. WorldPos0 = (gWorld * PosL).xyz;
  26. }