home *** CD-ROM | disk | FTP | other *** search
/ Hackers Magazine 57 / CdHackersMagazineNr57.iso / Software / Multimedia / k3d-setup-0.7.11.0.exe / share / k3d / shaders / light / k3d_causticlight.sl < prev    next >
Encoding:
Text File  |  2008-01-23  |  1.2 KB  |  37 lines

  1. light
  2. k3d_causticlight ( float intensity = 1;
  3.            color lightcolor = 1;
  4.            point from = point "shader" (0,0,0);
  5.            point to = point "shader" (0,0,1);
  6.            float coneangle = radians(30);
  7.            float conedeltaangle = radians(5);
  8.            float beamdistribution = 2;
  9.            string shadowname = "";
  10.            float  samples = 16;
  11.            float  blur = 0.01;
  12.            float  bias = 0.01;
  13.                float  threshold = 0.5;
  14.            float  noiseamp = 0, noisefreq = 1, noisepow = 1;
  15.     )
  16. {
  17.     uniform vector axis = normalize(to-from);
  18.  
  19.     illuminate (from, axis, coneangle) {
  20.     float cosangle = (L . axis) / length(L);
  21.     float atten = pow (cosangle, beamdistribution) / (L . L);
  22.     atten *= smoothstep (cos(coneangle), cos(coneangle-conedeltaangle),
  23.                  cosangle);
  24.     Cl = atten * intensity * lightcolor;
  25.         if (shadowname != "") {
  26.             float caustic = shadow (shadowname, Ps, "samples", samples,
  27.                     "blur", blur, "bias", bias);
  28.         caustic = smoothstep (threshold, 1, caustic);
  29.         if (noiseamp != 0) {
  30.         point PL = transform ("shader", Ps);
  31.         caustic *= noiseamp * pow (noise(PL*noisefreq), noisepow);
  32.         }
  33.             Cl *= caustic;
  34.     }
  35.     }
  36. }
  37.