home *** CD-ROM | disk | FTP | other *** search
/ Chip 2000 August / chip_08_2000.iso / aktualnosci / shareware / Rhinoceros / rh11eval_20000320.exe / %MAINDIR% / RIB / rh_shinymetal.sl < prev    next >
Encoding:
Text File  |  2000-06-08  |  1.3 KB  |  49 lines

  1. /* rh_shinymetal.sl - custom shiny shader for Rhino.
  2.  * 
  3.  *
  4.  *
  5.  * shiny.sl -- Shiny metal surface, using ray tracing.
  6.  *
  7.  * DESCRIPTION:
  8.  *   Makes a smoothly polished metal, using ray tracing to calculate
  9.  *   reflections of the environment.
  10.  * 
  11.  * PARAMETERS:
  12.  *    Ka, Kd, Ks, roughness, specularcolor - The usual meaning
  13.  *    Kr - coefficient for mirror-like reflections of environment
  14.  *    blur - how blurry are the reflections? (0 = perfectly sharp)
  15.  *    samples - set to higher than 1 for oversampling of blur
  16.  *
  17.  * AUTHOR: written by Larry Gritz, 1991
  18.  *
  19.  * HISTORY:
  20.  *      Aug 1991 -- written by lg in C
  21.  *      25 Jan 1994 -- recoded by lg in correct shading language.
  22.  *
  23.  * last modified 25 Jan 1994 by Larry Gritz
  24.  */
  25.  
  26.  
  27. #include "rayserver.h"
  28. #include "raytrace.h"
  29.  
  30.  
  31.  
  32. surface
  33. rh_shinymetal ( float Ka = 1, Kd = 0.2, Ks = 1;
  34.     float Kr = 0.8, roughness = 0.05, blur = 0;
  35.     float samples = 1; )
  36. {
  37.     normal Nf = faceforward (normalize(N), I);
  38.     vector IN = normalize (I);
  39.  
  40.     /* Calculate the reflection color */
  41.     color ev;
  42.         vector Rdir = normalize (reflect (IN, Nf));
  43.         ev = Kr * RayTrace (P, Rdir, blur, 1, samples);
  44.  
  45.     Ci = Cs * (Ka*ambient() + Kd*diffuse(Nf) + ev 
  46.                         + Ks*specular(Nf,-IN,roughness));
  47.     Oi = 1;
  48. }
  49.