instanciedshadow.vert 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. uniform int layer;
  2. #if __VERSION__ >= 330
  3. layout(location = 0) in vec3 Position;
  4. layout(location = 3) in vec2 Texcoord;
  5. layout(location = 7) in vec3 Origin;
  6. layout(location = 8) in vec3 Orientation;
  7. layout(location = 9) in vec3 Scale;
  8. #ifdef Use_Bindless_Texture
  9. layout(location = 10) in uvec2 Handle;
  10. #endif
  11. #else
  12. in vec3 Position;
  13. in vec2 Texcoord;
  14. in vec3 Origin;
  15. in vec3 Orientation;
  16. in vec3 Scale;
  17. #endif
  18. #ifdef VSLayer
  19. out vec2 uv;
  20. #ifdef Use_Bindless_Texture
  21. flat out uvec2 handle;
  22. #endif
  23. #else
  24. out vec2 tc;
  25. out int layerId;
  26. #ifdef Use_Bindless_Texture
  27. flat out uvec2 hdle;
  28. #endif
  29. #endif
  30. mat4 getWorldMatrix(vec3 translation, vec3 rotation, vec3 scale);
  31. mat4 getInverseWorldMatrix(vec3 translation, vec3 rotation, vec3 scale);
  32. void main(void)
  33. {
  34. mat4 ModelMatrix = getWorldMatrix(Origin, Orientation, Scale);
  35. #ifdef VSLayer
  36. gl_Layer = layer;
  37. gl_Position = ShadowViewProjMatrixes[gl_Layer] * ModelMatrix * vec4(Position, 1.);
  38. uv = Texcoord;
  39. #ifdef Use_Bindless_Texture
  40. handle = Handle;
  41. #endif
  42. #else
  43. layerId = layer;
  44. gl_Position = ShadowViewProjMatrixes[layerId] * ModelMatrix * vec4(Position, 1.);
  45. tc = Texcoord;
  46. #ifdef Use_Bindless_Texture
  47. hdle = Handle;
  48. #endif
  49. #endif
  50. }