home *** CD-ROM | disk | FTP | other *** search
/ Hackers Magazine 57 / CdHackersMagazineNr57.iso / Software / Multimedia / k3d-setup-0.7.11.0.exe / share / k3d / shaders / surface / k3d_filament.sl < prev    next >
Encoding:
Text File  |  2008-01-23  |  595 b   |  27 lines

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