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_map_pattern_1.sl < prev    next >
Encoding:
Text File  |  2008-01-23  |  1.7 KB  |  74 lines

  1. surface k3d_map_pattern_1 (
  2. string map1=""; 
  3. float channel1=4; 
  4. float swidth1=1; 
  5. float twidth1=1; 
  6. float samples1=1; 
  7. float ss1=1; 
  8. float tt1=1; 
  9. float txtscale=1; 
  10. color lightwood=color(0.69,0.44,0.25); 
  11. color darkwood=color(0.35,0.22,0.08); 
  12. float grainy=1; 
  13. float Ka = 1;
  14. float Kd = .5; 
  15. float Ks = .5; 
  16. float roughness = .1;
  17. color specularcolor = 1;
  18. {
  19. /** Surface main-code start **/
  20.  
  21. /** Texture_Brick_1 **/
  22. color temt_c1;
  23. float temp_ss1;
  24. float temp_tt1;
  25. if (ss1 ==1) {temp_ss1=s;} else {temp_ss1=ss1;}
  26. if (tt1 ==1) {temp_tt1=t;} else {temp_tt1=tt1;}
  27. if ( map1=="" ) 
  28. {
  29. temt_c1=0;
  30. else
  31. {
  32. if (channel1 < 0 || channel1 > 3)
  33. {
  34. temt_c1=texture(map1,temp_ss1,temp_tt1,"swidth",swidth1,"twidth",twidth1,"samples",samples1);
  35. else 
  36. {
  37. temt_c1=texture(map1[channel1],temp_ss1,temp_tt1,"swidth",swidth1,"twidth",twidth1,"samples",samples1);
  38. }
  39. }
  40. /** ColorToFloat_Brick_3 **/
  41. float temp_f_3=(comp(temt_c1,0)+comp(temt_c1,1)+comp(temt_c1,2))/3;
  42. point PP, PQ;
  43. color Ct; 
  44. float r, r2;
  45. float my_t;
  46. color C_temp1;
  47.  
  48. PP = txtscale * transform ("shader", P);
  49.  
  50. my_t = zcomp(PP) / temp_f_3;
  51. PQ = point (xcomp(PP)*8, ycomp(PP)*8, zcomp(PP));
  52. my_t += noise (PQ) / 16;
  53.  
  54. PQ = point (xcomp(PP), my_t, ycomp(PP)+12.93);
  55. r = temp_f_3 * noise (PQ);
  56. r -= floor (r);
  57. r = 0.2 + 0.8 * smoothstep(0.2, 0.55, r) * (1 - smoothstep(0.75, 0.8, r));
  58.  
  59. PQ = point (xcomp(PP)*128+5, zcomp(PP)*8-3, ycomp(PP)*128+1);
  60. r2 = grainy * (1.3 - noise (PQ)) + (1-grainy);
  61.  
  62. Ct = mix (lightwood, darkwood, r*r2*r2);
  63.  
  64. /** Surface main-code end **/
  65. normal Nf = faceforward(normalize(N), I);
  66. C_temp1 = Os * (Cs * (Ka * ambient() + Kd * diffuse(Nf)) + specularcolor * Ks * specular(Nf, -normalize(I), roughness));
  67. Ci = mix (C_temp1, Ct, 0.5);
  68.   Oi = Os;
  69.   Ci *= Oi;
  70. }
  71.