instanciedgrassshadow.vert 1.3 KB

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