#version 400

in vec3 v2f_pos;
in vec3 v2f_normal;
in vec2 v2f_texcoord;

out vec4 out_color;

uniform sampler2D texture_sampler;

uniform vec3  camera_translation;

void main()
{
    vec2 uv = vec2(v2f_texcoord.x, 1 - v2f_texcoord.y);

    //
    // Debug  code for drawing diffusely lit mesh into input images
    //
    // Both in world space!
    vec3 L = normalize((camera_translation - v2f_pos));
    vec3 N = normalize(v2f_normal);

    vec3 base_color = vec3(0.2, 0.2, 0.4);
    vec3 diffuse_color = vec3(0.55, 0.55, 0.55);

    float diffuse_falloff = max(0, dot(N,L));

    //out_color = vec4(base_color + diffuse_falloff * diffuse_color, 1.0);
    out_color = vec4(texture2D(texture_sampler, uv).rgb, 1.0);
}
