No Description

instancing.vert 582B

1234567891011121314151617181920212223242526272829
  1. #version 450
  2. #extension GL_ARB_separate_shader_objects : enable
  3. #extension GL_ARB_shading_language_420pack : enable
  4. layout (location = 0) in vec4 inPos;
  5. layout (location = 1) in vec2 inUV;
  6. struct Instance
  7. {
  8. mat4 model;
  9. vec4 arrayIndex;
  10. };
  11. layout (binding = 0) uniform UBO
  12. {
  13. mat4 projection;
  14. mat4 view;
  15. Instance instance[8];
  16. } ubo;
  17. layout (location = 0) out vec3 outUV;
  18. void main()
  19. {
  20. outUV = vec3(inUV, ubo.instance[gl_InstanceIndex].arrayIndex.x);
  21. mat4 modelView = ubo.view * ubo.instance[gl_InstanceIndex].model;
  22. gl_Position = ubo.projection * modelView * inPos;
  23. }