You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

54 lines
1.4 KiB

  1. #version 450 core
  2. #pragma include ./shared.glsl
  3. #pragma include ../misc/camera.glsl
  4. layout (location = 0) in vec2 inPosMin;
  5. layout (location = 1) in vec2 inPosMax;
  6. layout (location = 2) in vec2 inTexMin;
  7. layout (location = 3) in vec2 inTexMax;
  8. layout (location = 4) in vec4 inColor;
  9. layout (location = 2) uniform vec2 uOffset;
  10. out FragmentData fragmentData;
  11. void main() {
  12. vec2 position = vec2(0.0);
  13. vec2 texCoords = vec2(0.0);
  14. switch (gl_VertexID) {
  15. case 0:
  16. position = vec2(inPosMin.x, inPosMax.y);
  17. texCoords = vec2(inTexMin.x, inTexMax.y);
  18. break;
  19. case 1:
  20. position = vec2(inPosMin.x, inPosMin.y);
  21. texCoords = vec2(inTexMin.x, inTexMin.y);
  22. break;
  23. case 2:
  24. position = vec2(inPosMax.x, inPosMax.y);
  25. texCoords = vec2(inTexMax.x, inTexMax.y);
  26. break;
  27. case 3:
  28. position = vec2(inPosMax.x, inPosMin.y);
  29. texCoords = vec2(inTexMax.x, inTexMin.y);
  30. break;
  31. }
  32. mat4 ortho = mat4(
  33. vec4(2.0 / uCamera.size.x, 0.0, 0.0, 0.0),
  34. vec4(0.0, -2.0 / uCamera.size.y, 0.0, 0.0),
  35. vec4(0.0, 0.0, 1.0, 0.0),
  36. vec4(-1.0, 1.0, 1.0, 1.0)
  37. );
  38. gl_Position = ortho * vec4(position + uOffset, 0.0, 1.0);
  39. fragmentData.texCoords = texCoords;
  40. fragmentData.color = inColor;
  41. }