
uniform mat4 projection_matrix;
uniform mat4 view_matrix;

in vec3 attrib_position;
in vec3 attrib_normal;
in vec4 attrib_texture;

flat out float v_atlas;
out vec2 v_offset;
out float v_brightness;
out vec3 v_normal;
out vec3 v_fragpos;
#ifdef selection
    out vec3 v_position;
#endif

void main() {
    gl_Position = (
        projection_matrix
        * view_matrix
        * vec4(attrib_position, 1.0)
    );
    vec4 fpos = view_matrix * vec4(attrib_position, 1.0);
    v_fragpos = fpos.xyz / fpos.w;
    v_atlas = attrib_texture.x;
    v_offset = attrib_texture.yz;
    v_brightness = attrib_texture.w;
    v_normal = vec3(attrib_normal);
    #ifdef selection
    v_position = attrib_position;
    #endif
}
