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

  1. /*
  2.  * dented.sl -- displacement shader for dents
  3.  *
  4.  * DESCRIPTION:
  5.  *   Makes a surface appear worn and dented.
  6.  * 
  7.  * PARAMETERS:
  8.  *   Km            the amplitude of the dents
  9.  *   power           controls the fractal dimension of the dents (1 looks
  10.  *                         like previously crumpled paper or cloth, 3 looks
  11.  *                         like worn metal).
  12.  *   frequency      the frequency of the dents
  13.  *
  14.  *
  15.  * AUTHOR: written by Larry Gritz, based on the "dented" shader in
  16.  *         RenderMan Companion, but with more control parameters.
  17.  *
  18.  * HISTORY:
  19.  *      Dec 1992 -- written by lg for "Timbre Trees Examples" (jingle)
  20.  *
  21.  * last modified  12 Jan 1994 by Larry Gritz
  22.  *
  23.  * The RenderMan (R) Interface Procedures and RIB Protocol are:
  24.  *     Copyright 1988, 1989, Pixar.  All rights reserved.
  25.  * RenderMan (R) is a registered trademark of Pixar.
  26.  */
  27.  
  28.  
  29.  
  30. displacement
  31. dented ( float Km = 1, power = 3, frequency = 1, maxoctaves = 6; )
  32. {
  33.   float size;
  34.   float magnitude = 0;
  35.   float i;
  36.   point PP;
  37.  
  38.   PP = transform ("shader", P);
  39.   size = frequency;
  40.   for (i = 0;  i < maxoctaves;  i += 1) {
  41.       magnitude += abs (.5 - noise (PP*size)) / size;
  42.       size *= 2;
  43.     }
  44.   P = P - (Km * pow (magnitude, power)) * normalize (N);
  45.   N = calculatenormal (P);
  46. }
  47.