/*
 * lab7.sl -- Surface shader for polkadots.
 *
 * DESCRIPTION:
 *   Makes a polkadot wall.  Need more be said?  OK.  It makes a good
 *   looking pseudo retro background. 
 * 
 * PARAMETERS:
 *    polkadot_color		Pretty obvious (default is blue)
 *    back_color                Pretty obvious (default is white)
 *    radius	                Radius of polkadots (in uv space)
 *    dot_freq                  Frequency of dots the higher the frequency, the
 *						closer that the polkadots are together (in 
 *						uv space)
 *
 * AUTHOR: written by Jimmy Agustin, cs184-ci@cory.eecs.berkeley.edu
 *
 * Date: 1998-10-13
 */

surface lab7(color polkadot_color = color "rgb" (0, 0, 1);
				color back_color = color "rgb" (1, 1, 1);
				float radius = .3;
				float freq = 10;
				)
{
  color color_out;
  point midofpolk;
  float d, disk, disku, diskv;

  midofpolk = (0.5, 0.5, 0);
  disku = (mod((u) * (freq), 1.0));
  diskv = (mod((v) * (freq), 1.0));
  d = distance(midofpolk, (disku, diskv, 0));
  disk = ((step(radius, d)) * - 1) + 1;

  color_out = mix(back_color, polkadot_color, disk);

  Ci = color_out;
}