home *** CD-ROM | disk | FTP | other *** search
/ Stone Design / Stone Design.iso / Stone_Friends / Wave / WavesWorld / Source / Shaders / RCShaders / RCFilament.sl < prev    next >
Encoding:
Text File  |  1995-03-22  |  521 b   |  24 lines

  1. /* Listing 16.25  Surface shader to make a cylinder look like a filament*/
  2. /*
  3.  * filament(): map a filament-like spiral onto the surface of a cylinder.
  4.  */
  5. surface 
  6. RCFilament ( 
  7.     float    frequency    = 5.0,
  8.         phase         = 0.0, 
  9.         width        = 0.3 )
  10. {
  11.     /* Calculate the distance of (s,t) from a spiral as a fraction [0,1] */
  12.     float offset = mod((t*frequency + s + phase), 1.0);
  13.  
  14.     /* Threshold the fraction against the fractional filament width */
  15.     if (offset < width) {
  16.         Ci = Cs;
  17.         Oi = 1.0;
  18.     } else {
  19.         Ci = 0.0;
  20.         Oi = 0.0;
  21.     }
  22. }
  23.  
  24.