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_wallpaper_2stripe.sl < prev    next >
Encoding:
Text File  |  2008-01-23  |  1.4 KB  |  50 lines

  1. /*
  2.  * wallpaper_2stripe.sl -- surface shader for double striped wall paper
  3.  *
  4.  * DESCRIPTION:
  5.  *   Makes a double striped pattern appropriate for wall paper.  Stripes
  6.  *   are shaded in s-t space, and the stripes are parallel to lines of
  7.  *   equal s.  The background color is given by the surface color.
  8.  *
  9.  * 
  10.  * PARAMETERS:
  11.  *   Ka, Kd, Ks, roughness    the usual
  12.  *   specularcolor
  13.  *   bgcolor, stripecolor       color of background and stripes
  14.  *   stripewidth                width of stripes, in s coordinates
  15.  *   stripespacing              dist between sets of stripes, in s coordinates
  16.  *
  17.  *
  18.  * ANTIALIASING:  should analytically antialias itself quite well.
  19.  *
  20.  * AUTHOR: written by Larry Gritz (email: lg@bmrt.org)
  21.  *
  22.  * $Revision: 1.1 $   $Date: 2006/02/25 20:11:54 $
  23.  */
  24.  
  25.  
  26. #include "k3d_patterns.h"
  27. #include "k3d_material.h"
  28.  
  29. surface k3d_wallpaper_2stripe(float Ka = 0.5, Kd = 0.75, Ks = 0.25;
  30.                   float roughness = 0.1;
  31.                   color stripecolor = color "rgb"(1, 0.5, 0.5);
  32.                   float stripewidth = 0.05;
  33.                   float stripespacing = 0.5;)
  34. {
  35.   float ss = s / stripespacing - 0.5;
  36.   float ds = filterwidth(ss);
  37.   float edge = (1 - stripewidth);
  38.  
  39.   float stripe =
  40.     (filteredpulsetrain(edge, 1, ss, ds) +
  41.      filteredpulsetrain(edge, 1, ss + 2 * stripewidth, ds));
  42.  
  43.   color Ct = mix(Cs, stripecolor, stripe);
  44.  
  45.   normal Nf = faceforward(normalize(N), I);
  46.   Ci = MaterialPlastic(Nf, Ct, Ka, Kd, Ks, roughness);
  47.   Oi = Os;
  48.   Ci *= Oi;
  49. }
  50.