/*
 * pokadot(): surface shader for applying a pokadot pattern
 */

surface
lab7(
	float Kd	= .5,
	      Ka	= .1,
	      frequency = 1;
	color yellowcolor = color (1,1,0); )
{

	float smod = mod(s*frequency, 1),
	      tmod = mod(t*frequency, 1),
	      xmod = mod(0.5*frequency, 1),
	      ymod = mod(0.5*frequency, 1);

	point center  = point (xmod,ymod,0),
	      current = point (smod,tmod,0);

	color whitecolor = color (1,1,1);

	float dist    = distance(center,current);

	if (dist < 0.25) {
	   Ci = yellowcolor;
	} else {
	   Ci = Cs;
	}


	Oi = Os;
	Ci = Oi*Ci*(Ka*ambient() + Kd*diffuse(faceforward(normalize(N),I)));
}