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_saturn.sl < prev    next >
Encoding:
Text File  |  2008-01-23  |  2.4 KB  |  88 lines

  1. /* This was terran.sl from Larry Gritz and Ken Musgrave.  But there isn't much of it left.
  2. */
  3.  
  4. /*
  5.  * TLSaturn.sl - surface for an Saturn-like planet.
  6.  *
  7.  *
  8.  * DESCRIPTION:
  9.  *      When put on a sphere, sets the color to look like relatively
  10.  *   Saturn-like.  The shader works by using a variety of fractal 
  11.  *   turbulence techniques.
  12.  *
  13.  *
  14.  * PARAMETERS:
  15.  *    Ka, Kd - the usual meaning
  16.  *    dist_scale - scaling for multifractal distortion
  17.  *    lat_scale,  map_exp - control scaling of 
  18.  *               terrain type by latitude
  19.  *
  20.  *
  21.  * HINTS:
  22.  *   Assumes being used on a sphere.  Haven't really tried it by using other
  23.  *   than the default arguments.
  24.  *
  25.  * AUTHOR: Ken Musgrave.
  26.  *    Conversion to Shading Language and minor modifications by Larry Gritz.
  27.  *
  28.  *
  29.  * REFERENCES:
  30.  *
  31.  *
  32.  * HISTORY:
  33.  *    This started out as L. Gritz's terran.sl shader.  But I think he may be
  34.  *        the only one that would recognize that it was.
  35.  *    23 May 1995 - Changed name from terran.sl to TLSaturn.sl and
  36.  *        Did major hacking to make it a Saturn-like shader by Tal Lancaster 
  37.  *        tal@SpamSucks_cs.caltech.edu
  38.  *
  39.  * last modified 23 May 1995 by Tal
  40.  */
  41.  
  42. surface
  43. k3d_saturn (float Ka = .5, Kd = .7;
  44.       float dist_scale = .2;
  45.       float offset = 0;
  46.       float lat_scale = 0.95;
  47.       float map_exp = 0;)
  48. {
  49.   point PP;
  50.   point PtN;
  51.   float latitude;
  52.   color Ct;
  53.   point Ptexture;
  54.  
  55.   /* Do all shading in shader space */
  56.   Ptexture = transform ("shader", P);
  57.   PtN = normalize (Ptexture);      /* Version of Ptexture with radius 1 */
  58.  
  59.   /************************************************************************
  60.    * Step 2: Assign a climite type, roughly by latitude.
  61.    ************************************************************************/
  62.  
  63.   /* make climate symmetric about equator */
  64.   latitude = abs (zcomp (PtN));
  65.     
  66.   if (map_exp > 0)
  67.        latitude = lat_scale * pow(latitude,map_exp);
  68.   else latitude *= lat_scale;
  69.  
  70.       /* Color map for Saturn */
  71.       Ct = spline (latitude,
  72.         color (.73, .598, .266),
  73.         color (.73, .598, .266),
  74.         color (1, .63, .332),
  75.         color (.598, .531, .266),
  76.         color (.863, .664, .332),
  77.         color (.797, .598, .332),
  78.         color (.73, .598, .266),
  79.         color (.461, .461, .461),
  80.         color (.332, .199, .266),
  81.         color (.332, .199, .266),
  82.         color (.332, .199, .266));
  83.  
  84.   /* Shade using matte model */
  85.   Oi = 1;
  86.   Ci = Os * Ct * (Ka * ambient() + Kd * diffuse(faceforward(normalize(N),I)));
  87. }
  88.