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_granite.sl < prev    next >
Encoding:
Text File  |  2008-01-23  |  508 b   |  22 lines

  1. /* Copyrighted Pixar 1989 */
  2. /* From the RenderMan Companion p.352 */
  3. /* Listing 16.18  Surface shader for granite-like surface*/
  4.  
  5. /* 
  6.  * granite(): Provide a diffuse granite-like surface texture. 
  7.  */
  8. surface 
  9. k3d_granite(
  10.     float    Kd    = .8,
  11.         Ka    = .2 )
  12. {
  13.     float sum = 0;
  14.     float i, freq = 1.0; /* Try other values for example, 7.0 */
  15.  
  16.     for (i = 0; i < 6; i = i + 1) {
  17.         sum = sum + abs(.5 - noise( 4 * freq * I))/freq ;
  18.         freq *= 2;
  19.     }
  20.     Ci = Cs * sum * (Ka + Kd * diffuse(faceforward( normalize(N), I )) ) ;
  21. }
  22.