Advertisement
Guest User

Untitled

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