home *** CD-ROM | disk | FTP | other *** search
- /* rh_shinymetal.sl - custom shiny shader for Rhino.
- *
- *
- *
- * shiny.sl -- Shiny metal surface, using ray tracing.
- *
- * DESCRIPTION:
- * Makes a smoothly polished metal, using ray tracing to calculate
- * reflections of the environment.
- *
- * PARAMETERS:
- * Ka, Kd, Ks, roughness, specularcolor - The usual meaning
- * Kr - coefficient for mirror-like reflections of environment
- * blur - how blurry are the reflections? (0 = perfectly sharp)
- * samples - set to higher than 1 for oversampling of blur
- *
- * AUTHOR: written by Larry Gritz, 1991
- *
- * HISTORY:
- * Aug 1991 -- written by lg in C
- * 25 Jan 1994 -- recoded by lg in correct shading language.
- *
- * last modified 25 Jan 1994 by Larry Gritz
- */
-
-
- #include "rayserver.h"
- #include "raytrace.h"
-
-
-
- surface
- rh_shinymetal ( float Ka = 1, Kd = 0.2, Ks = 1;
- float Kr = 0.8, roughness = 0.05, blur = 0;
- float samples = 1; )
- {
- normal Nf = faceforward (normalize(N), I);
- vector IN = normalize (I);
-
- /* Calculate the reflection color */
- color ev;
- vector Rdir = normalize (reflect (IN, Nf));
- ev = Kr * RayTrace (P, Rdir, blur, 1, samples);
-
- Ci = Cs * (Ka*ambient() + Kd*diffuse(Nf) + ev
- + Ks*specular(Nf,-IN,roughness));
- Oi = 1;
- }
-