object_pass.vert 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. uniform mat4 ModelMatrix =
  2. mat4(1., 0., 0., 0.,
  3. 0., 1., 0., 0.,
  4. 0., 0., 1., 0.,
  5. 0., 0., 0., 1.);
  6. uniform mat4 InverseModelMatrix =
  7. mat4(1., 0., 0., 0.,
  8. 0., 1., 0., 0.,
  9. 0., 0., 1., 0.,
  10. 0., 0., 0., 1.);
  11. uniform mat4 TextureMatrix =
  12. mat4(1., 0., 0., 0.,
  13. 0., 1., 0., 0.,
  14. 0., 0., 1., 0.,
  15. 0., 0., 0., 1.);
  16. #if __VERSION__ >= 330
  17. layout(location = 0) in vec3 Position;
  18. layout(location = 1) in vec3 Normal;
  19. layout(location = 2) in vec4 Color;
  20. layout(location = 3) in vec2 Texcoord;
  21. layout(location = 4) in vec2 SecondTexcoord;
  22. layout(location = 5) in vec3 Tangent;
  23. layout(location = 6) in vec3 Bitangent;
  24. #else
  25. in vec3 Position;
  26. in vec3 Normal;
  27. in vec4 Color;
  28. in vec2 Texcoord;
  29. in vec2 SecondTexcoord;
  30. in vec3 Tangent;
  31. in vec3 Bitangent;
  32. #endif
  33. out vec3 nor;
  34. out vec3 tangent;
  35. out vec3 bitangent;
  36. out vec2 uv;
  37. out vec2 uv_bis;
  38. out vec4 color;
  39. void main(void)
  40. {
  41. color = Color.zyxw;
  42. mat4 ModelViewProjectionMatrix = ProjectionMatrix * ViewMatrix * ModelMatrix;
  43. mat4 TransposeInverseModelView = transpose(InverseModelMatrix * InverseViewMatrix);
  44. gl_Position = ModelViewProjectionMatrix * vec4(Position, 1.);
  45. // Keep orthogonality
  46. nor = (TransposeInverseModelView * vec4(Normal, 0.)).xyz;
  47. // Keep direction
  48. tangent = (ViewMatrix * ModelMatrix * vec4(Tangent, 0.)).xyz;
  49. bitangent = (ViewMatrix * ModelMatrix * vec4(Bitangent, 0.)).xyz;
  50. uv = (TextureMatrix * vec4(Texcoord, 1., 1.)).xy;
  51. uv_bis = SecondTexcoord;
  52. }