#include "light.glsl"

varying vec2 brick_coord;
varying vec3 eye_space_vertex;
varying vec3 eye_space_normal;

void main()
{
	vec3 normal = normalize(eye_space_normal);
	
	float brick_size = 0.25;
	vec3 brick_color = vec3(0.8, 0.0, 0.0);
	vec3 mortar_color = vec3(0.4, 0.4, 0.4);
	vec2 brick_pct = vec2(0.9, 0.9);

	vec2 interp = brick_coord/brick_size;
	if (fract(interp.y * 0.5) > 0.5)
		interp.x += 0.5;

	interp = step(fract(interp), brick_pct);
	
	vec3 diffuse = mix(mortar_color, brick_color, interp.x*interp.y);
	
	gl_FragColor = vec4(lighting(vec3(0.0, 0.0, 0.0), diffuse, diffuse, diffuse, 1.0, eye_space_vertex, normal), 1.0);
}
