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

  1.  
  2. /*
  3.  * threads(): wrap threads around a cylinder 
  4.  */
  5. displacement 
  6. RCThreads ( 
  7.     float   Km        =  .1,
  8.         frequency    = 5.0,
  9.         phase        =  .0,
  10.         offset        =  .0,
  11.         dampzone    =  .05 )
  12. {
  13.     float magnitude;
  14.  
  15.     /* Calculate the undamped displacement */
  16.     magnitude = (sin( PI*2*(t*frequency + s + phase))+offset) * Km;
  17.  
  18.     /* Damp the displacement to 0 at each end */
  19.     if( t > (1-dampzone)) 
  20.         magnitude *= (1.0-t) / dampzone;
  21.     else if( t < dampzone )
  22.         magnitude *= t / dampzone;
  23.  
  24.     /* Do the displacement */
  25.     P += normalize(N) * magnitude;
  26.     N = calculatenormal(P);
  27. }
  28.