home *** CD-ROM | disk | FTP | other *** search
/ Hackers Magazine 57 / CdHackersMagazineNr57.iso / Software / Multimedia / k3d-setup-0.7.11.0.exe / share / k3d / shaders / displacemnt / k3d_gouge.sl < prev    next >
Encoding:
Text File  |  2008-01-23  |  841 b   |  27 lines

  1. /* Copyrighted Pixar 1989 */
  2. /* From the RenderMan Companion p.379 */
  3. /* Listing 16.32  Displacement shader for beating up a surface with a texture  */
  4.  
  5. /*
  6.  * gouge(): Use a texture map to displace a surface.
  7.  */
  8. displacement
  9. k3d_gouge(
  10.     float    Km    = 0.03,
  11.         spin    = 0.0;        /* each pin gets its texture spun */
  12.     string    texturename = "")
  13. {
  14.     float    y = ycomp(transform("object",P));    /* convert to object space     */
  15.  
  16.    /* Use the same texture map that the surface shader uses. Spin it a different
  17.     *  amount for each pin so that similarity is not detected.  The texture 
  18.     *  determines the size of the gouge. Multiply by the Km factor, then 
  19.     *  displace the surface point inwards by that amount. 
  20.     */
  21.  
  22.    if( texturename != "") 
  23.    {  P += (-Km * texture(texturename,s+spin,y/15.0)) * normalize(N);
  24.       N = calculatenormal(P);
  25.    }
  26. }
  27.