home *** CD-ROM | disk | FTP | other *** search
- /*************************************************************************
- * Copyright (c) 1989-1992 Stone Design Corp. All rights reserved.
- * programmer: Bill Bumgarner
- * File name: SD_Centered_tx.sl
- * Date: Jul 21 1992
- * Purpose: Map a texture to a surface.
- *
- Variables:
- s_frequency: # of times to repeat texture in the s direction
- t_frequency: # of times to repeat texture in the t direction
- s_center: s coordinate of the center of texture mapped area
- t_center: t coordinate of the center of texture mapped area
- s_width: width of area to be covered by the texture
- t_height: height of area to be covered by the texture
-
- txmap: full path to the texture map file
-
- ***************************************************************************/
-
- surface SD_Centered_tx(
-
- float s_frequency = 1.,
- t_frequency = 1.;
-
- float s_center = .5,
- t_center = .5,
- s_width = 1.,
- t_height = 1.;
-
- string txmap = "";
-
- )
- {
- float t_min = t_center - (t_height/2.);
- float s_min = s_center - (s_width/2.);
-
- float s_max = s_min+s_width;
- float t_max = t_min+t_height;
-
- float ss, tt;
-
- ss= smoothstep(s_min, s_max, s) * s_frequency;
- tt= smoothstep(t_min, t_max, t) * t_frequency;
-
- if(txmap != "" &&
- ( (ss != 0) && (ss != 1) && (tt != 0) && (tt != 1)) ){
- Ci = color texture(txmap, ss, tt);
- } else {
- Ci = Cs;
- }
- Oi = Os;
- }