
[vert.glsl]
#version 130

in vec3 in_position;
in vec3 in_Normal;
in vec4 in_color;

uniform mat4 u_modelview;
uniform mat4 u_view;
uniform mat4 u_projection;
uniform mat3 u_normalmat;

out vec4 pass_vertex; /* View space */
out vec3 pass_tnormal;
out vec4 pass_color;

void main(void)
{
    vec4 vertex = u_modelview * vec4(in_position, 1.0);
    vec3 tnorm = normalize(in_Normal);

    pass_vertex = vertex;
    pass_tnormal = tnorm;
    pass_color = in_color;

    gl_Position = u_projection * vertex;
}

[frag.glsl]
#version 130

#if defined GL_ES
precision highp float;
#endif

in vec4 pass_vertex; /* View space */
in vec3 pass_tnormal;
in vec4 pass_color;

uniform float u_damage;
uniform mat4 u_view;
uniform mat4 u_inv_view;

uniform vec4 u_lights[8 * 2];

void main(void)
{
    vec3 real_color = vec3(0.0, 0.0, 0.0);
    real_color += abs(pass_tnormal.x) * ((pass_tnormal.x < 0.0)?(vec3(0.0, 1.0, 1.0)):(vec3(1.0, 0.0, 0.0)));
    real_color += abs(pass_tnormal.y) * ((pass_tnormal.y < 0.0)?(vec3(1.0, 0.0, 1.0)):(vec3(0.0, 1.0, 0.0)));
    real_color += abs(pass_tnormal.z) * ((pass_tnormal.z < 0.0)?(vec3(1.0, 1.0, 0.0)):(vec3(0.0, 0.0, 1.0)));
    gl_FragColor = vec4(real_color, pass_color.w);
}

