
uniform mat4 projection_matrix;
uniform mat4 view_matrix;

in vec3 attrib_position;
in vec3 attrib_normal;
in vec2 attrib_uv;
in mat4 attrib_matrix;
in vec4 attrib_tint;
in vec4 attrib_highlight;

out vec3 v_normal;
out vec2 v_uv;
out vec4 v_tint;
out vec4 v_highlight;
out vec3 v_fragpos;
#if defined water
    out vec4 v_position;
#endif

void main() {
    gl_Position = (
        projection_matrix
        * view_matrix * attrib_matrix
        * vec4(attrib_position, 1.0)
    );
    vec4 fpos = view_matrix * attrib_matrix * vec4(attrib_position, 1.0);
    v_fragpos = fpos.xyz / fpos.w;
    #if !defined shadow_pass
        vec4 normal = vec4(attrib_normal, 0.0);
        v_normal = (transpose(inverse(attrib_matrix)) * normal).xyz;
    #endif
    #if defined water
        v_position = attrib_matrix
            * vec4(attrib_position, 1.0);
    #endif
    v_uv = attrib_uv;
    v_highlight = attrib_highlight;
    v_tint = attrib_tint;
}
