instanced_object_pass.vert 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. #if __VERSION__ >= 330
  2. layout(location = 0) in vec3 Position;
  3. layout(location = 1) in vec3 Normal;
  4. layout(location = 2) in vec4 Color;
  5. layout(location = 3) in vec2 Texcoord;
  6. layout(location = 4) in vec2 SecondTexcoord;
  7. layout(location = 5) in vec3 Tangent;
  8. layout(location = 6) in vec3 Bitangent;
  9. layout(location = 7) in vec3 Origin;
  10. layout(location = 8) in vec3 Orientation;
  11. layout(location = 9) in vec3 Scale;
  12. #ifdef Use_Bindless_Texture
  13. layout(location = 10) in sampler2D Handle;
  14. layout(location = 11) in sampler2D SecondHandle;
  15. layout(location = 13) in sampler2D ThirdHandle;
  16. #endif
  17. #else
  18. in vec3 Position;
  19. in vec3 Normal;
  20. in vec4 Color;
  21. in vec2 Texcoord;
  22. in vec2 SecondTexcoord;
  23. in vec3 Tangent;
  24. in vec3 Bitangent;
  25. in vec3 Origin;
  26. in vec3 Orientation;
  27. in vec3 Scale;
  28. #endif
  29. out vec3 nor;
  30. out vec3 tangent;
  31. out vec3 bitangent;
  32. out vec2 uv;
  33. out vec2 uv_bis;
  34. out vec4 color;
  35. #ifdef Use_Bindless_Texture
  36. flat out sampler2D handle;
  37. flat out sampler2D secondhandle;
  38. flat out sampler2D thirdhandle;
  39. #endif
  40. mat4 getWorldMatrix(vec3 translation, vec3 rotation, vec3 scale);
  41. mat4 getInverseWorldMatrix(vec3 translation, vec3 rotation, vec3 scale);
  42. void main(void)
  43. {
  44. mat4 ModelMatrix = getWorldMatrix(Origin, Orientation, Scale);
  45. mat4 TransposeInverseModelView = transpose(getInverseWorldMatrix(Origin, Orientation, Scale) * InverseViewMatrix);
  46. gl_Position = ProjectionViewMatrix * ModelMatrix * vec4(Position, 1.);
  47. // Keep orthogonality
  48. nor = (TransposeInverseModelView * vec4(Normal, 0.)).xyz;
  49. // Keep direction
  50. tangent = (ViewMatrix * ModelMatrix * vec4(Tangent, 0.)).xyz;
  51. bitangent = (ViewMatrix * ModelMatrix * vec4(Bitangent, 0.)).xyz;
  52. uv = Texcoord;
  53. uv_bis = SecondTexcoord;
  54. color = Color.zyxw;
  55. #ifdef Use_Bindless_Texture
  56. handle = Handle;
  57. secondhandle = SecondHandle;
  58. thirdhandle = ThirdHandle;
  59. #endif
  60. }