2019-01-30 12:11:34 +00:00
|
|
|
#version 330 core
|
|
|
|
|
2019-05-14 06:43:07 +00:00
|
|
|
#include <globals.glsl>
|
|
|
|
|
2019-02-23 02:41:52 +00:00
|
|
|
in vec2 v_pos;
|
2019-01-30 12:11:34 +00:00
|
|
|
in vec2 v_uv;
|
2020-02-06 17:34:32 +00:00
|
|
|
in vec2 v_center;
|
2019-02-23 02:41:52 +00:00
|
|
|
in vec4 v_color;
|
|
|
|
in uint v_mode;
|
2019-01-30 12:11:34 +00:00
|
|
|
|
2019-05-14 06:43:07 +00:00
|
|
|
layout (std140)
|
|
|
|
uniform u_locals {
|
|
|
|
vec4 w_pos;
|
|
|
|
};
|
|
|
|
|
2019-01-30 12:11:34 +00:00
|
|
|
uniform sampler2D u_tex;
|
|
|
|
|
|
|
|
out vec2 f_uv;
|
2019-02-23 02:41:52 +00:00
|
|
|
flat out uint f_mode;
|
|
|
|
out vec4 f_color;
|
2019-01-30 12:11:34 +00:00
|
|
|
|
|
|
|
void main() {
|
2019-05-02 22:42:04 +00:00
|
|
|
f_color = v_color;
|
2019-05-14 06:43:07 +00:00
|
|
|
|
2020-07-02 20:10:22 +00:00
|
|
|
// vec2 v_pos = vec2(-1.0,1.0) * v_pos;
|
|
|
|
/* f_uv = vec2(1.0,1.0) * v_uv; */
|
|
|
|
// vec2 v_uv = vec2(1.0,-1.0) * v_uv;
|
|
|
|
|
2019-05-14 06:43:07 +00:00
|
|
|
if (w_pos.w == 1.0) {
|
2020-02-06 17:34:32 +00:00
|
|
|
f_uv = v_uv;
|
2020-07-02 20:10:22 +00:00
|
|
|
// Fixed scale In-game element
|
|
|
|
vec4 projected_pos = /*proj_mat * view_mat*/all_mat * vec4(w_pos.xyz - focus_off.xyz, 1.0);
|
|
|
|
gl_Position = vec4(projected_pos.xy / projected_pos.w + v_pos/* * projected_pos.w*/, -1.0, /*projected_pos.w*/1.0);
|
2020-02-06 17:34:32 +00:00
|
|
|
} else if (v_mode == uint(3)) {
|
|
|
|
// HACK: North facing source rectangle.
|
|
|
|
vec2 look_at_dir = normalize(vec2(-view_mat[0][2], -view_mat[1][2]));
|
|
|
|
mat2 look_at = mat2(look_at_dir.y, look_at_dir.x, -look_at_dir.x, look_at_dir.y);
|
|
|
|
f_uv = v_center + look_at * (v_uv - v_center);
|
2020-07-02 20:10:22 +00:00
|
|
|
gl_Position = vec4(v_pos, -1.0, 1.0);
|
2020-02-06 17:34:32 +00:00
|
|
|
} else if (v_mode == uint(5)) {
|
|
|
|
// HACK: North facing target rectangle.
|
|
|
|
f_uv = v_uv;
|
|
|
|
float aspect_ratio = screen_res.x / screen_res.y;
|
|
|
|
vec2 look_at_dir = normalize(vec2(-view_mat[0][2], -view_mat[1][2]));
|
|
|
|
mat2 look_at = mat2(look_at_dir.y, -look_at_dir.x, look_at_dir.x, look_at_dir.y);
|
|
|
|
vec2 v_len = v_pos - v_center;
|
|
|
|
vec2 v_proj = look_at * vec2(v_len.x, v_len.y / aspect_ratio);
|
2020-07-02 20:10:22 +00:00
|
|
|
gl_Position = vec4(v_center + vec2(v_proj.x, v_proj.y * aspect_ratio), -1.0, 1.0);
|
2019-05-14 06:43:07 +00:00
|
|
|
} else {
|
|
|
|
// Interface element
|
2020-02-06 17:34:32 +00:00
|
|
|
f_uv = v_uv;
|
2020-07-02 20:10:22 +00:00
|
|
|
gl_Position = vec4(v_pos, -1.0, 1.0);
|
2019-05-14 06:43:07 +00:00
|
|
|
}
|
2019-05-02 22:42:04 +00:00
|
|
|
f_mode = v_mode;
|
2019-01-30 12:11:34 +00:00
|
|
|
}
|