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_imagelayerclouds.sl < prev    next >
Encoding:
Text File  |  2008-01-23  |  950 b   |  37 lines

  1. #include "k3d_noises.h"
  2.  
  3. surface k3d_imagelayerclouds(float txtscale = 1;
  4.                  color skycolor = color(.15, .15, .6);
  5.                  color cloudcolor = color(1, 1, 1);
  6.                  float octaves = 8, omega = 0.5, lambda = 2;
  7.                  float threshold = 0.5;)
  8. {
  9.   float value;
  10.   color Ct;            /* Color of the surface */
  11.   point PP;            /* Surface point in shader space */
  12.   float i, a, l, o;
  13.  
  14. //  PP = txtscale * transform ("shader", P);
  15.   PP = txtscale * point(s, t, s);
  16.  
  17.   /* Use fractional Brownian motion to compute a value for this point */
  18. /*  value = fBm (PP, omega, lambda, octaves); */
  19.   value = 0;
  20.   l = 1;
  21.   o = 1;
  22.   a = 0;
  23.   for(i = 0; i < octaves; i += 1)
  24.     {
  25.       a += o * snoise(PP * l);
  26.       l *= 2;
  27.       o *= omega;
  28.     }
  29.   value = a;
  30.  
  31.   Ct = mix(skycolor, cloudcolor, smoothstep(threshold, 1, value));
  32.  
  33.   /* Shade like matte, but use color Ct */
  34.   Oi = 1;            /* Make it opaque */
  35.   Ci = Ct;            /* This makes the color disregard the lighting */
  36. }
  37.