veloren/assets/voxygen/shaders/sprite-vert.glsl

57 lines
1.1 KiB
Plaintext
Raw Normal View History

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;
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;
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;
out float f_light;
const float SCALE = 1.0 / 11.0;
void main() {
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;
f_pos = (inst_mat * vec4(v_pos * SCALE, 1)).xyz;
2019-08-19 20:09:35 +00:00
2019-08-20 09:59:15 +00:00
// Wind waving
f_pos += inst_wind_sway * vec3(
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),
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);
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 =
proj_mat *
view_mat *
vec4(f_pos, 1);
}