home *** CD-ROM | disk | FTP | other *** search
- // rh_spotlight -- a custom spotlight shader for using attenuating spotlights
- * in Rhino. This one uses the light color for determining the light intensity,
- * since Rhino currently does not have a light intensity setting.
- * The intensity varies between 1 and 4.9e8.
- * It is based on spotlight.sl by Pixar.
- *
- * spotlight.sl - Standard spot light source for RenderMan Interface.
- * (c) Copyright 1988, Pixar.
- * The RenderMan (R) Interface Procedures and RIB Protocol are:
- * Copyright 1988, 1989, Pixar. All rights reserved.
- * RenderMan (R) is a registered trademark of Pixar.
- */
-
- light
- rh_spotlight ( color lightcolor = 1;
- point from = point "shader" (0,0,0);
- point to = point "shader" (0,0,1);
- float coneangle = radians(30);
- float conedeltaangle = radians(5);
- float beamdistribution = 2; )
- {
- float atten, cosangle;
- uniform vector A = normalize(to-from);
- float intensity, maxintensity;
-
- maxintensity = max ( comp( lightcolor, 0), comp( lightcolor, 1), comp(lightcolor, 2));
- intensity = exp( maxintensity * 20);
-
- illuminate (from, A, coneangle) {
- cosangle = (L . A) / length(L);
- atten = pow (cosangle, beamdistribution) / (L . L);
- atten *= smoothstep (cos(coneangle), cos(coneangle-conedeltaangle),
- cosangle);
- Cl = atten * intensity * lightcolor ;
- }
- }