#version 140

in vec3 o_nrm;
in vec2 o_tex;

uniform vec3 u_light;
uniform sampler2D tex;

out vec4 color;

void main() {
  float brightness = dot(normalize(o_nrm), normalize(u_light));
  float factor = 0.5 + (brightness * 0.5);
  vec2 near_tex = (floor(o_tex * 32.0) + 0.5) / 32.0;
  color = texture(tex, near_tex) * factor;
}
