/*Evan Pon
  cs184-ej
  Jenny Huang
  cs184-bd
  M 3-4 */

/* This is our surface shader for the blocks. */ 

surface
colorE(	
	float 	Ka = 0.5, 
		Kd = 0.75, 
		Ks = 0.25,
		roughness = 0.1;  
	color 	specularcolor = 1,
	 	border = color (.1, .1, .75),
	      	letter = color (1, 0, 0),
     	      	background = color (0, 1, 0);
)
{
	color currentcolor = background;
	normal Nf;

	if (s < .05 || t < .05 || s > .35 || t > .35) {
		currentcolor = border;
	}
	else if (s > .1 && s < .3) {
		if (t > .1 && t < .14) {
			currentcolor = letter;
		}
		else if (t > .26 && t < .3) {
			currentcolor = letter;
		}
		else if (s < .14 && t > .1 && t < .3) {
			currentcolor = letter;
		}
		else if (s < .25 && t > .18 && t < .22) {
			currentcolor = letter;
		}
	}
	Nf = faceforward (normalize(N),I);
	Oi = Os;
	Ci = Os * (currentcolor * (Ka*ambient() + Kd*diffuse(Nf)) +
	      specularcolor * Ks*specular(Nf,-normalize(I),roughness));
}