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_glow.sl < prev    next >
Encoding:
Text File  |  2008-01-23  |  729 b   |  30 lines

  1. surface k3d_glow(float attenuation = 2.0;
  2.          color centercolor = 1.0;
  3.          color edgecolor = color(1.0, 1.0, 0.0))
  4. {
  5.   float incidence, strength;
  6.   color C;
  7.  
  8.   incidence = I.N;
  9.   if(incidence < 0)        // If this point is on the front face of the sphere
  10.     {
  11.       // Normalize incidence
  12.       incidence = incidence * incidence / (I.I * N.N);
  13.  
  14.       // Calculate a "strength" function based on incidence
  15.       strength = pow(incidence, attenuation);
  16.  
  17.       C = mix(edgecolor, centercolor, strength);
  18.  
  19.       // Calculate final color and opacity - we set Oi near zero
  20.       // and skip pre-multiplication to get an "add" effect ...
  21.       Ci = C * strength * Os;
  22.       Oi = 0.0001;
  23.     }
  24.   else
  25.     {
  26.       Ci = 0;
  27.       Oi = 0;
  28.     }
  29. }
  30.