veloren/voxygen/shaders/terrain.vert

48 lines
932 B
GLSL
Raw Normal View History

2019-01-14 23:13:58 +00:00
#version 330 core
#include <globals.glsl>
2019-06-03 21:35:03 +00:00
in uint v_pos_norm;
in uint v_col_light;
2019-01-14 23:13:58 +00:00
layout (std140)
uniform u_locals {
vec3 model_offs;
};
out vec3 f_pos;
out vec3 f_norm;
out vec3 f_col;
2019-05-31 20:37:11 +00:00
out float f_light;
2019-01-14 23:13:58 +00:00
void main() {
f_pos = vec3(
2019-06-03 21:35:03 +00:00
float((v_pos_norm >> 0) & 0x00FFu),
float((v_pos_norm >> 8) & 0x00FFu),
float((v_pos_norm >> 16) & 0x1FFFu)
2019-05-31 20:37:11 +00:00
) + model_offs;
f_col = vec3(
2019-06-03 21:35:03 +00:00
float((v_col_light >> 8) & 0xFFu),
float((v_col_light >> 16) & 0xFFu),
float((v_col_light >> 24) & 0xFFu)
) / 255.0;
2019-01-14 23:13:58 +00:00
2019-06-03 21:35:03 +00:00
uint norm_axis = (v_pos_norm >> 30) & 0x3u;
float norm_dir = float((v_pos_norm >> 29) & 0x1u) * 2.0 - 1.0;
if (norm_axis == 0u) {
f_norm = vec3(1.0, 0.0, 0.0) * norm_dir;
} else if (norm_axis == 1u) {
f_norm = vec3(0.0, 1.0, 0.0) * norm_dir;
} else {
f_norm = vec3(0.0, 0.0, 1.0) * norm_dir;
}
f_light = float(v_col_light & 0xFFu) / 255.0;
2019-05-31 20:37:11 +00:00
2019-01-14 23:13:58 +00:00
gl_Position =
proj_mat *
view_mat *
2019-05-31 20:37:11 +00:00
vec4(f_pos, 1);
2019-01-14 23:13:58 +00:00
}