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_gooch.sl < prev    next >
Encoding:
Text File  |  2008-01-23  |  1.7 KB  |  60 lines

  1. /* Renamed to MKgooch.sl for RMR -- tal@SpamSucks_cs.caltech.edu */
  2.  
  3. /* s_gooch.sl - a simple implementation of the Gooch
  4.  *              non-photorealistic lighting model
  5.  *
  6.  * DESCRIPTION   : This model is described in "A Non-Photorealistc
  7.  *                 Lighting Model For Automatic Technical 
  8.  *                 Illustration" in the Siggraph 1998 Proceedings.
  9.  *                 http://www.cs.utah.edu/~gooch/SIG98/abstract.html
  10.  *
  11.  * INPUTS        : 
  12.  *  Ka           : ambient factor
  13.  *  Kd           : diffuse factor
  14.  *  Ks           : specular factor
  15.  *  alpha        : Gooch cool color factor
  16.  *  beta         : Gooch warm color factor
  17.  *  b            : used to construct the cool color
  18.  *  y            : used to construct the warm color
  19.  *  roughness    : specular roughness
  20.  *  specularcolor: specular hilight color
  21.  *
  22.  * AUTHOR: written by Mike King
  23.  *               
  24.  ***************************************************/
  25.  
  26. surface
  27. k3d_gooch (float Ka = 0;
  28.          float Kd = 1;
  29.          float Ks = 0;
  30.          float alpha = .25;
  31.          float beta = .5;
  32.          float b = .55;
  33.          float y = .3;
  34.          float roughness = .1;
  35.          color specularcolor = 1;)
  36. {
  37.     normal Nf = faceforward (normalize(N),I);
  38.     color blue = color(0,0,b);
  39.     color yellow = color(y,y,0);
  40.  
  41.     color Cgooch = color(0,0,0); 
  42.     float ldotn, blendval;
  43.     color kcool,kwarm;
  44.  
  45.     kcool = blue + ( Cs * alpha);
  46.     kwarm = yellow + (Cs * beta);
  47.     illuminance(P,Nf,PI) {
  48.         ldotn = (normalize(L)).Nf;
  49.         blendval = 0.5*(1+ldotn);
  50.         Cgooch += mix(kcool,kwarm,blendval); 
  51.     }
  52.     
  53.     Oi = Os;
  54.     Ci = Os * ((Ka*ambient() + 
  55.                 Kd*Cgooch +
  56.                 specularcolor*Ks*specular(Nf,-normalize(I),roughness)));
  57. }
  58.  
  59.  
  60.