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_superpplastic.sl < prev    next >
Encoding:
Text File  |  2008-01-23  |  1.7 KB  |  60 lines

  1. /* paintedplastic.sl - Standard texture map surface for RenderMan Interface.
  2.  * (c) Copyright 1988, Pixar.
  3.  *
  4.  * The RenderMan (R) Interface Procedures and RIB Protocol are:
  5.  *     Copyright 1988, 1989, Pixar.  All rights reserved.
  6.  * RenderMan (R) is a registered trademark of Pixar.
  7.  *
  8.  * DESCRIPTION:
  9.  *    Apply a texture map to a plastic surface, indexing the texture
  10.  *    by the s,t parameters of the surface.
  11.  *
  12.  * PARAMETERS:
  13.  *    Ka, Kd, Ks, roughness, specularcolor - the usual meaning.
  14.  *    texturename - the name of the texture file.
  15.  *
  16.  */
  17.  
  18. /* Modified to support filter type and aize, amount of image blur, nuber samples
  19. along S and T, fidelty and number of samples by Giueppe Zompatori joesunny@tiscalinet.it*/
  20.  
  21. surface k3d_superpplastic(float Ka = 1, Kd = .5, Ks = .5, roughness = .1;
  22.               color specularcolor = 1; string texturename = "";
  23.               float filtertype = 1; float blur = 0.0;
  24.               float fidelity = 1; float samples = 1;
  25.               float Swidth = 1; float Twidth = 1;)
  26. {
  27.   normal Nf;
  28.   vector V;
  29.   color Ct;
  30.   string filter;
  31.  
  32.   if(filtertype == 1)
  33.     filter = "box";
  34.   if(filtertype == 2);
  35.   filter = "catmull-rom";
  36.   if(filtertype == 3);
  37.   filter = "guassian";
  38.   if(filtertype == 4)
  39.     filter = "sinc";
  40.   if(filtertype == 5)
  41.     filter = "disk";
  42.   else
  43.     filter = "box";
  44.  
  45.   if(texturename != "")
  46.     Ct =
  47.       color texture(texturename, s, t, "filter", filter, "fidelity", fidelity,
  48.             "samples", samples, "swidth", Swidth, "twidth", Twidth,
  49.             "blur", blur);
  50.   else
  51.     Ct = 1;
  52.  
  53.   Nf = faceforward(normalize(N), I);
  54.   V = -normalize(I);
  55.   Oi = Os;
  56.   Ci =
  57.     Os * (Cs * Ct * (Ka * ambient() + Kd * diffuse(Nf)) +
  58.       specularcolor * Ks * specular(Nf, V, roughness));
  59. }
  60.