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

  1. /* Based on 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.  *    Has optional parameters to change texture coordinate bounds.
  12.  *    
  13.  *
  14.  * PARAMETERS:
  15.  *    Ka, Kd, Ks, roughness, specularcolor - the usual meaning.
  16.  *    texturename - the name of the texture file.
  17.  *    s0, s1, t0, t1 - texture coordinate bounds.
  18.  *    Uses alpha channel value to blend texture.
  19.  */
  20.  
  21. surface k3d_paintedplastic_alpha(
  22.     float Ka = 1.0;
  23.     float Kd = 0.5;
  24.     float Ks = 0.5;
  25.     float roughness = 0.1;
  26.     color specularcolor = 1.0;
  27.     string texturename = "";
  28.     float s0 = 0.0;
  29.     float s1 = 1.0;
  30.     float t0 = 0.0;
  31.     float t1 = 1.0;
  32.     )
  33. {
  34.     color Ct = color(1, 1, 1);
  35.     float Ot = 1;
  36.     
  37.     if(texturename != "")
  38.         {
  39.             float ss = mix(s0, s1, s);
  40.             float tt = mix(t0, t1, t);
  41.             
  42.             Ct = color texture(texturename, ss, tt);
  43.             Ot = float texture(texturename[3], ss, tt);
  44.         }
  45.  
  46.     normal Nf = faceforward(normalize(N), I);
  47.     vector V = -normalize(I);
  48.     Oi = Os * Ot;
  49.     Ci = Oi * Cs * Ct * (Ka * ambient() + Kd * diffuse(Nf)) + specularcolor * Ks * specular(Nf, V, roughness);
  50. }
  51.