home *** CD-ROM | disk | FTP | other *** search
/ Stone Design / Stone Design.iso / Stone_Stuff / 3D_Reality / Shaders / Shader_Source / gouge.sl < prev    next >
Encoding:
Text File  |  1992-07-08  |  639 b   |  20 lines

  1.  
  2. /*
  3.  * gouge(): Use a texture map to displace a surface.
  4.  */
  5. displacement
  6. gouge(
  7.     float    Km    = 0.03,
  8.         spin    = 0.0;        /* each pin gets its texture spun */
  9.     string    texturename = "marks.txt")
  10. {
  11.     float    y = ycomp(transform("object",P));                        /* convert to object space     */
  12.  
  13. /* Use the same texture map that the surface shader uses. Spin it a different
  14.  *  amount for each pin so that similarity is not detected.  The texture 
  15.  *  determines the size of the gouge. Multiply by the Km factor, then 
  16.  *  displace the surface point inwards by that amount. */
  17.     P += (-Km * texture(texturename,s+spin,y/15.0)) * normalize(N);
  18.     N = calculatenormal(P);
  19. }
  20.