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_hilltop.sl < prev    next >
Encoding:
Text File  |  2008-01-23  |  1.1 KB  |  55 lines

  1.  
  2.  
  3. surface k3d_hilltop (
  4.  
  5. float Ka=0; 
  6. float Kd=.8; 
  7. color ambientcolor8=1; 
  8. color aColor3=color(0,0,0); 
  9. color aColor6=color(0.45,0.58,0.32); 
  10. float TopDir=1; 
  11. string geospace="shader"; 
  12. float Altitude=0.8; 
  13. float Blend=.7; 
  14. float octaves2=4; 
  15. float freq2=10; ) 
  16. {
  17. /** Surface main-code start **/
  18. matrix ident=1;
  19. point PP2=point(0.0,0.0,0.0); 
  20. /** Turbulence_Brick_2 **/
  21. point temp_PP2;
  22. temp_PP2=transform("shader",P);
  23. uniform float i2;
  24. float size2,sum2;
  25. sum2 = 0;
  26. size2 = 1;
  27. for (i2=0;i2<octaves2;i2+=1)
  28. {
  29. sum2 += noise(temp_PP2*freq2*size2)/size2;
  30. size2 *= 2;
  31. }
  32. float temt_f2=clamp(sum2-0.4,0,1);
  33. float Result;
  34. normal Nn;
  35. Nn = ntransform(geospace, N);
  36. Nn = normalize(Nn);
  37. if (TopDir == 0)
  38. Result = xcomp(Nn) + clamp(temt_f2,0,1);
  39. else
  40. if (TopDir == 1)
  41. Result = ycomp(Nn) + clamp(temt_f2,0,1);
  42. else
  43. if (TopDir == 2)
  44. Result = zcomp(Nn) + clamp(temt_f2,0,1);
  45.  
  46. Result = (Result + 1)/2;
  47. Result = 1 - smoothstep(Altitude, Altitude+(1-Altitude)*Blend, Result);
  48. normal Nf8 = faceforward (normalize(N),I);
  49.  
  50. /** Surface main-code end **/
  51.  
  52. Ci = ambientcolor8 * Ka * ambient() + (Result*aColor3+(1-Result)*aColor6) * Kd * diffuse(Nf8);
  53. Oi = color((1-(Result)));
  54. }
  55.