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_glass.sl < prev    next >
Encoding:
Text File  |  2008-01-23  |  1.8 KB  |  49 lines

  1. /****************************************************************************
  2.  * glass.sl -- Shiny reflective & refractive glass, using ray tracing.
  3.  *
  4.  * Description:
  5.  *   Makes semi-transparent glass, using ray tracing to calculate
  6.  *   reflections and refractions of the environment.
  7.  * 
  8.  * Parameters:
  9.  *    Ka, Kd, Ks, roughness, specularcolor - The usual meaning
  10.  *    Kr - coefficient for mirror-like reflections of environment
  11.  *    blur - how blurry are the reflections? (0 = perfectly sharp)
  12.  *    envname, envspace, envrad - controls for using environment maps
  13.  *    rayjitter, raysamples - ray tracing controls for reflection
  14.  *    Kt - coefficient for refracted transmission
  15.  *    transmitcolor - color of the glass
  16.  *    refrblur - how blurry are the refractions? (0 = perfectly sharp)
  17.  *    eta - the coefficient of refraction of the glass
  18.  *    reflrayjitter, refrraysamples - ray tracing controls for refraction
  19.  *
  20.  ***************************************************************************
  21.  *
  22.  * Author: Larry Gritz, 1999  (lg@bmrt.org)
  23.  *
  24.  * Reference:
  25.  *   _Advanced RenderMan: Creating CGI for Motion Picture_, 
  26.  *   by Anthony A. Apodaca and Larry Gritz, Morgan Kaufmann, 1999.
  27.  *
  28.  * $Revision: 1.1 $    $Date: 2006/02/25 20:11:54 $
  29.  *
  30.  ****************************************************************************/
  31.  
  32. #include "k3d_rayserver.h"
  33. #include "k3d_material.h"
  34.  
  35. surface k3d_glass(float Ka = 0.2, Kd = 0, Ks = 0.5, roughness = 0.05;
  36.           color specularcolor = 1;
  37.           float Kr = 1, reflblur = 0;
  38.           DECLARE_DEFAULTED_ENVPARAMS;
  39.           float Kt = 1, refrblur = 0, eta = 1.5;
  40.           color transmitcolor = 1;
  41.           float refrrayjitter = 0, refrraysamples = 1;)
  42. {
  43.   normal Nf = faceforward(normalize(N), I);
  44.   Ci =
  45.     MaterialGlass(Nf, Cs, Ka, Kd, Ks, roughness, Kr, reflblur, Kt, refrblur,
  46.           eta, transmitcolor, refrrayjitter, refrraysamples,
  47.           ENVPARAMS);
  48. }
  49.