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

  1. // rh_spotlight -- a custom spotlight shader for using attenuating spotlights
  2.  * in Rhino. This one uses the light color for determining the light intensity,
  3.  * since Rhino currently does not have a light intensity setting.
  4.  * The intensity varies between 1 and 4.9e8.
  5.  * It is based on spotlight.sl by Pixar.
  6.  *
  7.  * spotlight.sl - Standard spot light source for RenderMan Interface.
  8.  * (c) Copyright 1988, Pixar.
  9.  * The RenderMan (R) Interface Procedures and RIB Protocol are:
  10.  *     Copyright 1988, 1989, Pixar.  All rights reserved.
  11.  * RenderMan (R) is a registered trademark of Pixar.
  12.  */
  13.  
  14. light
  15. rh_spotlight ( 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.   uniform vector A = normalize(to-from);
  24.   float intensity, maxintensity;
  25.   
  26.   maxintensity = max ( comp( lightcolor, 0), comp( lightcolor, 1), comp(lightcolor, 2));
  27.   intensity = exp( maxintensity * 20);  
  28.  
  29.   illuminate (from, A, coneangle) {
  30.       cosangle = (L . A) / length(L);
  31.       atten = pow (cosangle, beamdistribution) / (L . L);
  32.       atten *= smoothstep (cos(coneangle), cos(coneangle-conedeltaangle),
  33.                cosangle);
  34.       Cl = atten * intensity * lightcolor ;
  35.     }
  36. }