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

  1. /* 
  2.  * screen(): surface shader for giving "wireframe" appearance. The method is
  3.   *     to render the surface opaque within a small distance of a grid in s,t
  4.   *     space. The grid is derived from a modulus function.
  5.  */
  6. surface 
  7. RCScreen(
  8.      float    Ks        = .5, 
  9.         Kd        = .5, 
  10.         Ka        = .1, 
  11.         roughness    = .1,
  12.         density     = .25,
  13.         frequency    = 20;
  14.     color    specularcolor = color (1,1,1) )
  15. {
  16.     varying point Nf = faceforward( normalize(N), I );
  17.     point V = normalize(-I);
  18.  
  19.     if( mod(s*frequency,1) < density || mod(t*frequency,1) < density)
  20.         Oi = 1.0;
  21.     else 
  22.         Oi = 0.0;
  23.  
  24.     Ci = Oi * ( Cs * ( Ka*ambient() + Kd*diffuse(Nf) ) + 
  25.                specularcolor*Ks*specular(Nf,V,roughness));
  26. }
  27.