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

  1. // K-3D
  2. // Copyright (c) 1995-2004, Timothy M. Shead
  3. //
  4. // Contact: tshead@k-3d.com
  5. //
  6. // This program is free software; you can redistribute it and/or
  7. // modify it under the terms of the GNU General Public
  8. // License as published by the Free Software Foundation; either
  9. // version 2 of the License, or (at your option) any later version.
  10. //
  11. // This program is distributed in the hope that it will be useful,
  12. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  14. // General Public License for more details.
  15. //
  16. // You should have received a copy of the GNU General Public
  17. // License along with this program; if not, write to the Free Software
  18. // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  19.  
  20. /** \file
  21.         \author Tim Shead (tshead@k-3d.com)
  22. */
  23.  
  24. surface k3d_projectionmap_plastic(
  25.     float Ka = 1.0;
  26.     float Kd = 0.5;
  27.     float Ks = 0.5;
  28.     float roughness = 0.1;
  29.     color specularcolor = 1.0;
  30.     string texturename = "";
  31.     float s0 = 0.0;
  32.     float s1 = 1.0;
  33.     float t0 = 0.0;
  34.     float t1 = 1.0;
  35.     vector axis = vector(0, 0, 1);
  36.     float xfreq = 1.0;
  37.     float yfreq = 1.0;
  38.     float xoffset = 0.0;
  39.     float yoffset = 0.0;
  40.     )
  41. {
  42.     color Ct = color(1, 1, 1);
  43.     float Ot = 1;
  44.     
  45.     if(texturename != "")
  46.         {
  47.             point Pshad = transform("shader", P);
  48.             
  49.             float x = xfreq * (xcomp(Pshad) - xoffset + 0.5);
  50.             float y = yfreq * (ycomp(Pshad) - yoffset + 0.5);
  51.             
  52.             float ss = mix(s0, s1, x);
  53.             float tt = mix(t1, t0, y);
  54.             
  55.             Ct = color texture(texturename, ss, tt);
  56.             Ot = float texture(texturename[3], ss, tt);
  57.         }
  58.  
  59.     normal Nf = faceforward(normalize(N), I);
  60.     vector V = -normalize(I);
  61.     Oi = Os * Ot;
  62.     Ci = Oi * Cs * Ct * (Ka * ambient() + Kd * diffuse(Nf)) + specularcolor * Ks * specular(Nf, V, roughness);
  63. }
  64.  
  65.  
  66.