#version 450 core layout (location = 0) in vec2 pos_min; layout (location = 1) in vec2 pos_max; layout (location = 2) in vec2 tex_min; layout (location = 3) in vec2 tex_max; layout (location = 4) in vec4 color; layout (std140, binding = 0) uniform Camera { mat4 projection; mat4 view; vec2 size; } camera; layout (location = 1) uniform mat4 model; out FragmentData { vec2 tex_coord; vec4 color; } data; void main() { vec2 position = vec2(0.0); vec2 tex_coord = vec2(0.0); switch (gl_VertexID) { case 0: position = vec2(pos_min.x, pos_max.y); tex_coord = vec2(tex_min.x, tex_max.y); break; case 1: position = vec2(pos_min.x, pos_min.y); tex_coord = vec2(tex_min.x, tex_min.y); break; case 2: position = vec2(pos_max.x, pos_max.y); tex_coord = vec2(tex_max.x, tex_max.y); break; case 3: position = vec2(pos_max.x, pos_min.y); tex_coord = vec2(tex_max.x, tex_min.y); break; } mat4 ortho = mat4( vec4(2.0 / camera.size.x, 0.0, 0.0, 0.0), vec4(0.0, -2.0 / camera.size.y, 0.0, 0.0), vec4(0.0, 0.0, 1.0, 0.0), vec4(-1.0, 1.0, 1.0, 1.0) ); gl_Position = ortho * vec4(position, 0.0, 1.0); data.tex_coord = tex_coord; data.color = color; }