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

  1. /* rh_spot.sl - a custom spotlight shader similar to the default
  2.  * non-attenuating spotlight in Rhino.
  3.  * It is based on spotlight.sl by Pixar.
  4.  *
  5.  * spotlight.sl - Standard spot light source for RenderMan Interface.
  6.  * (c) Copyright 1988, Pixar.
  7.  *
  8.  * The RenderMan (R) Interface Procedures and RIB Protocol are:
  9.  *     Copyright 1988, 1989, Pixar.  All rights reserved.
  10.  * RenderMan (R) is a registered trademark of Pixar.
  11.  */
  12.  
  13. light
  14. rh_spot ( float intensity = 1;
  15.         color lightcolor = 1;
  16.         point from = point "shader" (0,0,0);
  17.         point to = point "shader" (0,0,1);
  18.         float coneangle = radians(30);
  19.         float conedeltaangle = radians(5);
  20.         float beamdistribution = 2; )
  21. {
  22.   float atten, cosangle;
  23.  
  24.   uniform vector A = normalize(to-from);
  25.  
  26.   illuminate (from, A, coneangle) {
  27.       cosangle = (L . A) / length(L);
  28.       atten = pow (cosangle, beamdistribution);
  29.       atten *= smoothstep (cos(coneangle), cos(coneangle-conedeltaangle),
  30.                cosangle);
  31.       Cl = atten * intensity * lightcolor * 2;
  32.     }
  33. }
  34.  
  35.