home *** CD-ROM | disk | FTP | other *** search
/ Stone Design / Stone Design.iso / Stone_Stuff / 3D_Reality / Shaders / Shader_Source / SD_Depth_tx.sl < prev    next >
Encoding:
Text File  |  1992-07-25  |  1.5 KB  |  54 lines

  1. /*************************************************************************
  2. *    Copyright (c) 1989-1992 Stone Design Corp.  All rights reserved. 
  3. *    programmer:    Bill Bumgarner
  4. *    File name:    SD_Depth_tx.sl
  5. *    Date:        Jul 21 1992 
  6. *    Purpose:    Map a texture to a surface with depth cue style
  7.             light response.  Based on txtplastic, but allows
  8.             one to specify the number of times to repeat the
  9.             texture across the surface.  Also used as a base for 
  10.             a series of other texture mapping shaders.
  11. *
  12.     Variables:
  13.         Ka:            percentage of ambient light used
  14.         Kd:            percentage of diffuse light used
  15.         Ks:            specular highlight intensity
  16.         roughness:        the roughness/smoothness (reflectivity) of
  17.                     of the surface-- very noticeable effect on the
  18.                 specular highlight
  19.         specularcolor:    color used in the specular highlight
  20.         
  21.         s_frequency:    # of times to repeat texture in the s direction
  22.         t_frequency:    # of times to repeat texture in the t direction
  23.         
  24.         txmap:        full path to the texture map file
  25. ***************************************************************************/
  26.  
  27. surface SD_Depth_tx(
  28.     float     Ka        =  1,
  29.         Kd        = .5,
  30.         Ks        = .5,
  31.         roughness    = .1;
  32.     color    specularcolor    = 1;
  33.  
  34.     float     s_frequency     = 1.,
  35.         t_frequency     = 1.;
  36.  
  37.     string    txmap        = "";
  38.  
  39. )
  40. {
  41.     point Nf = faceforward(N, I);
  42.     float ss = s_frequency * s;
  43.     float tt = t_frequency * t;
  44.     
  45.  
  46.     if(txmap != ""){
  47.         Ci = color texture(txmap, ss, tt);
  48.     } else {
  49.         Ci = Cs;
  50.     }    
  51.     Oi=Os;
  52.     Ci=Os * (Ci * (Ka*ambient() + Kd*diffuse(Nf)) + 
  53.             specularcolor * Ks * specular(Nf,-I,roughness));
  54. }