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

  1. /*************************************************************************
  2. *    Copyright (c) 1989-1992 Stone Design Corp.  All rights reserved. 
  3. *    programmer:    Bill Bumgarner
  4. *    File name:    SD_Centered_tx.sl
  5. *    Date:        Jul 21 1992 
  6. *    Purpose:    Map a texture to a surface.
  7. *
  8.     Variables:
  9.         s_frequency:  # of times to repeat texture in the s direction
  10.         t_frequency:  # of times to repeat texture in the t direction
  11.         s_center:      s coordinate of the center of texture mapped area
  12.         t_center:      t coordinate of the center of texture mapped area
  13.         s_width:      width of area to be covered by the texture
  14.         t_height:      height of area to be covered by the texture
  15.  
  16.         txmap:      full path to the texture map file
  17.         
  18. ***************************************************************************/
  19.  
  20. surface SD_Centered_tx(
  21.  
  22.     float     s_frequency     = 1.,
  23.         t_frequency     = 1.;
  24.         
  25.     float    s_center    = .5,
  26.         t_center    = .5,
  27.         s_width        = 1.,
  28.         t_height        = 1.;
  29.  
  30.     string    txmap        = "";
  31.  
  32. )
  33. {
  34.     float     t_min = t_center - (t_height/2.);
  35.     float     s_min = s_center - (s_width/2.);
  36.     
  37.     float    s_max = s_min+s_width;
  38.     float    t_max = t_min+t_height;
  39.     
  40.     float     ss, tt;
  41.     
  42.     ss= smoothstep(s_min, s_max, s) * s_frequency;
  43.     tt= smoothstep(t_min, t_max, t) * t_frequency;
  44.     
  45.     if(txmap != "" && 
  46.         ( (ss != 0) && (ss != 1) && (tt != 0) && (tt != 1)) ){
  47.         Ci = color texture(txmap, ss, tt);
  48.     } else {
  49.         Ci = Cs;
  50.     }
  51.     Oi = Os;
  52. }