Guest User

vertex shader

a guest
Aug 3rd, 2023
15
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.26 KB | None | 0 0
  1. // **** before instancing **** //
  2. layout(std430, set = 1, binding = 0) readonly buffer JointMatrices {
  3. mat4 finalBonesMatrices[];
  4. };
  5.  
  6. struct PlayerBoneIndex{
  7. int playerIndex;
  8. int playerBoneCount;
  9. };
  10.  
  11. layout(push_constant) uniform Push {
  12. mat4 modelMatrix;
  13. int index_boneCount;
  14. } push;
  15. void main(){
  16. mat4 skinMat = finalBonesMatrices[boneIds[0] + push.index_boneCount] * weights[0]
  17. + finalBonesMatrices[boneIds[1] + push.index_boneCount] * weights[1]
  18. + finalBonesMatrices[boneIds[2] + push.index_boneCount] * weights[2]
  19. + finalBonesMatrices[boneIds[3] + push.index_boneCount] * weights[3];
  20. //modelMatrix = push.modelMatrix
  21.  
  22.  
  23. // **** After instancing **** //
  24. #define DEER_BONE_COUNT 22
  25. layout (set = 1, binding = 0) readonly buffer ModelMatrices {
  26. mat4 modelMatrix[4096];
  27. };
  28.  
  29. layout (set = 1, binding = 1) readonly buffer JointMatrices {
  30. mat4 finalBonesMatrices[];
  31. };
  32.  
  33. void main(){
  34. int boneIndex = gl_InstanceIndex * DEER_BONE_COUNT;
  35. mat4 skinMat = finalBonesMatrices[boneIds[0] + boneIndex] * weights[0]
  36. + finalBonesMatrices[boneIds[1] + boneIndex] * weights[1]
  37. + finalBonesMatrices[boneIds[2] + boneIndex] * weights[2]
  38. + finalBonesMatrices[boneIds[3] + boneIndex] * weights[3];
  39. //modelMatrix = modelMatrix[gl_InstanceIndex]
Add Comment
Please, Sign In to add comment