home *** CD-ROM | disk | FTP | other *** search
/ Chip 2000 August / chip_08_2000.iso / aktualnosci / shareware / Rhinoceros / rh11eval_20000320.exe / %MAINDIR% / RIB / checker.sl < prev    next >
Encoding:
Text File  |  2000-06-08  |  685 b   |  37 lines

  1. /* Copyrighted Pixar 1989 */
  2. /* From the RenderMan Companion p.345 */
  3. /* Listing 16.12  Surface shader providing checkerboard pattern */
  4.  
  5. /*
  6.  * checker(): surface shader for applying a checkerboard pattern.
  7.  */
  8. surface
  9. checker (
  10.     float Kd = .5,
  11.           Ka = .1,
  12.           frequency = 10;
  13.     color blackcolor = color (0, 0, 0) )
  14. {
  15.     float smod = mod (s* frequency, 1),
  16.           tmod = mod (t* frequency, 1);
  17.     
  18.     if (smod < 0.5) {
  19.         if (tmod < 0.5)
  20.             Ci = Cs;
  21.         else
  22.             Ci = blackcolor;
  23.     }
  24.     else {
  25.         if (tmod < 0.5)
  26.             Ci = blackcolor;
  27.         else
  28.             Ci = Cs;
  29.     }
  30.     
  31.     Oi = Os;
  32.     Ci = Oi * Ci *
  33.      (Ka * ambient() +
  34.       Kd * diffuse (faceforward (normalize (N), I) ) );
  35. }
  36.  
  37.