2019-08-19 20:09:35 +00:00
|
|
|
#version 330 core
|
|
|
|
|
|
|
|
#include <globals.glsl>
|
|
|
|
#include <srgb.glsl>
|
|
|
|
|
|
|
|
in vec3 v_pos;
|
|
|
|
in vec3 v_norm;
|
|
|
|
in vec3 v_col;
|
2020-04-18 20:26:43 +00:00
|
|
|
in float v_ao;
|
2019-08-21 12:47:29 +00:00
|
|
|
in vec4 inst_mat0;
|
|
|
|
in vec4 inst_mat1;
|
|
|
|
in vec4 inst_mat2;
|
|
|
|
in vec4 inst_mat3;
|
2019-08-19 20:09:35 +00:00
|
|
|
in vec3 inst_col;
|
2019-08-21 12:47:29 +00:00
|
|
|
in float inst_wind_sway;
|
2019-08-19 20:09:35 +00:00
|
|
|
|
|
|
|
out vec3 f_pos;
|
|
|
|
flat out vec3 f_norm;
|
|
|
|
out vec3 f_col;
|
2020-04-18 20:26:43 +00:00
|
|
|
out float f_ao;
|
2019-08-19 20:09:35 +00:00
|
|
|
out float f_light;
|
|
|
|
|
|
|
|
const float SCALE = 1.0 / 11.0;
|
|
|
|
|
|
|
|
void main() {
|
2019-08-21 12:47:29 +00:00
|
|
|
mat4 inst_mat;
|
|
|
|
inst_mat[0] = inst_mat0;
|
|
|
|
inst_mat[1] = inst_mat1;
|
|
|
|
inst_mat[2] = inst_mat2;
|
|
|
|
inst_mat[3] = inst_mat3;
|
|
|
|
|
2019-09-26 10:43:03 +00:00
|
|
|
vec3 sprite_pos = (inst_mat * vec4(0, 0, 0, 1)).xyz;
|
|
|
|
|
2019-08-21 12:47:29 +00:00
|
|
|
f_pos = (inst_mat * vec4(v_pos * SCALE, 1)).xyz;
|
2020-04-25 13:04:30 +00:00
|
|
|
f_pos.z -= 25.0 * pow(distance(focus_pos.xy, f_pos.xy) / view_distance.x, 20.0);
|
2019-08-19 20:09:35 +00:00
|
|
|
|
2019-08-20 09:59:15 +00:00
|
|
|
// Wind waving
|
2019-08-21 12:47:29 +00:00
|
|
|
f_pos += inst_wind_sway * vec3(
|
2019-08-21 16:03:03 +00:00
|
|
|
sin(tick.x * 1.5 + f_pos.y * 0.1) * sin(tick.x * 0.35),
|
|
|
|
sin(tick.x * 1.5 + f_pos.x * 0.1) * sin(tick.x * 0.25),
|
2019-08-21 12:47:29 +00:00
|
|
|
0.0
|
2019-09-01 19:04:03 +00:00
|
|
|
) * pow(abs(v_pos.z) * SCALE, 1.3) * 0.2;
|
2019-08-20 09:59:15 +00:00
|
|
|
|
2019-08-21 15:22:49 +00:00
|
|
|
f_norm = (inst_mat * vec4(v_norm, 0)).xyz;
|
2019-08-19 20:09:35 +00:00
|
|
|
|
2019-09-01 19:04:03 +00:00
|
|
|
f_col = srgb_to_linear(v_col) * srgb_to_linear(inst_col);
|
2020-04-18 20:26:43 +00:00
|
|
|
f_ao = v_ao;
|
2019-08-19 20:09:35 +00:00
|
|
|
|
2019-09-26 10:43:03 +00:00
|
|
|
// Select glowing
|
|
|
|
if (select_pos.w > 0 && select_pos.xyz == floor(sprite_pos)) {
|
|
|
|
f_col *= 4.0;
|
|
|
|
}
|
|
|
|
|
2019-08-19 20:09:35 +00:00
|
|
|
f_light = 1.0;
|
|
|
|
|
|
|
|
gl_Position =
|
2020-01-21 12:57:59 +00:00
|
|
|
all_mat *
|
2019-08-19 20:09:35 +00:00
|
|
|
vec4(f_pos, 1);
|
2020-01-27 14:27:36 +00:00
|
|
|
gl_Position.z = -1000.0 / (gl_Position.z + 10000.0);
|
2019-08-19 20:09:35 +00:00
|
|
|
}
|