opengl_present.vert 1.0 KB

12345678910111213141516171819202122232425262728
  1. // Copyright 2020 yuzu Emulator Project
  2. // Licensed under GPLv2 or any later version
  3. // Refer to the license.txt file included.
  4. #version 430 core
  5. out gl_PerVertex {
  6. vec4 gl_Position;
  7. };
  8. layout (location = 0) in vec2 vert_position;
  9. layout (location = 1) in vec2 vert_tex_coord;
  10. layout (location = 0) out vec2 frag_tex_coord;
  11. // This is a truncated 3x3 matrix for 2D transformations:
  12. // The upper-left 2x2 submatrix performs scaling/rotation/mirroring.
  13. // The third column performs translation.
  14. // The third row could be used for projection, which we don't need in 2D. It hence is assumed to
  15. // implicitly be [0, 0, 1]
  16. layout (location = 0) uniform mat3x2 modelview_matrix;
  17. void main() {
  18. // Multiply input position by the rotscale part of the matrix and then manually translate by
  19. // the last column. This is equivalent to using a full 3x3 matrix and expanding the vector
  20. // to `vec3(vert_position.xy, 1.0)`
  21. gl_Position = vec4(mat2(modelview_matrix) * vert_position + modelview_matrix[2], 0.0, 1.0);
  22. frag_tex_coord = vert_tex_coord;
  23. }