home *** CD-ROM | disk | FTP | other *** search
/ Chip 2000 August / chip_08_2000.iso / aktualnosci / shareware / Rhinoceros / rh11eval_20000320.exe / %MAINDIR% / RIB / locillum.h < prev    next >
Encoding:
C/C++ Source or Header  |  2000-06-08  |  1.2 KB  |  48 lines

  1. #ifdef RCSIDS
  2. static char rcsid[] = "$Id: locillum.h,v 1.3 1998/09/18 02:31:07 lg Exp $";
  3. #endif
  4.  
  5. /*
  6.  * locillum.h - a collection of local illumination functions.
  7.  *
  8.  * Author: written by Larry Gritz (gritzl@acm.org)
  9.  *
  10.  * $Revision: 1.3 $      $Date: 1998/09/18 02:31:07 $
  11.  *
  12.  */
  13.  
  14.  
  15.  
  16.  
  17. /*
  18.  * LocIllumGlossy - a possible replacement for specular(), which has a
  19.  * more uniformly bright core and a sharper falloff.  It's a nice
  20.  * specular function to use for something made of glass or liquid.
  21.  *
  22.  * Suggested parameter values:
  23.  *  Pt = P (surface point)
  24.  *  N = faceforward (normalize(N),I)
  25.  *  V = -normalize(I)
  26.  *  width = 1  (related to the size of the highlight, larger is bigger)
  27.  *  sharpness = .5  (1 is infinitely sharp, 0 is very dull)
  28.  */
  29. color LocIllumGlossy (point Pt; normal Nf; vector V;
  30.                       float width; float sharpness)
  31. {
  32.     color C = 0;
  33.     float w = .18 * (1-sharpness);
  34.     illuminance (Pt, Nf, PI/2) {
  35.     extern color Cl;
  36.     extern vector L;
  37.     float nonspec = 0;
  38.     float r = lightsource ("__nonspecular", nonspec);
  39.     if (nonspec < 1) {
  40.         vector H = normalize(normalize(L)+V);
  41.         C += Cl * ((1-nonspec) * smoothstep (.72-w, .72+w,
  42.                          pow(max(0,Nf.H), 1/width)));
  43.     }
  44.     }
  45.     return C;
  46. }
  47.  
  48.