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_orange.sl < prev    next >
Encoding:
Text File  |  2008-01-23  |  930 b   |  51 lines

  1. /*
  2.  * Actually it is a condensed version of the mango shader from Sig '92 "Writing RenderMan Shaders"
  3.  */
  4.  
  5. /*
  6.  * TLOrange.sl -- create an orange
  7.  *
  8.  * DESCRIPTION:
  9.  *    Creates an stippled orange surface.
  10.  *
  11.  * PARAMETERS:
  12.  *    Ka, Kd, Ks, roughness - the usual
  13.  *
  14.  * HINTS:
  15.  *
  16.  * AUTHOR: Tal Lancaster
  17.  *    tal@SpamSucks_cs.caltech.edu
  18.  *
  19.  * History:
  20.  *    Created: 9/4/96
  21.  */
  22.  
  23. #define BUMP_AMPLITUDE (1/30)
  24. #define BUMP_FREQUENCY (35)
  25.  
  26. surface k3d_orange (
  27.     float Ka = 1;
  28.     float Kd = .8;
  29.     float Ks = .8;
  30.     float roughness = .2;
  31. )
  32. {
  33.     point Nf, V;
  34.     point turb, p2;
  35.     point newP;
  36.     
  37.     
  38.     setxcomp (p2, sin (2 * PI * s));
  39.     setycomp (p2, 2*t);
  40.     setzcomp (p2, cos (2 * PI * s));
  41.     
  42.  
  43.     turb = noise (BUMP_FREQUENCY * p2) * BUMP_AMPLITUDE;
  44.     newP = calculatenormal (P + turb * normalize (N));
  45.     Nf = faceforward (normalize (newP), I);
  46.     V = -normalize (I);
  47.     
  48.     Oi = 1;
  49.     Ci = Cs * (Ka * ambient() + Kd * diffuse (Nf)) + Ks * specular (Nf, V, roughness);
  50. }
  51.