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_grids.sl < prev    next >
Encoding:
Text File  |  2008-01-23  |  2.9 KB  |  98 lines

  1. /** Grid shader copyright 2005 Daniel Scott Matthews dan@3-e.net **/
  2.  
  3. #include "k3d_rmannotes.h"
  4. #include "k3d_noises.h"
  5.  
  6. surface k3d_grids (
  7.  
  8. float K_ambient=0.993; 
  9. float K_diffuse=0.381; 
  10. float K_specular=0.269; 
  11. float roughness=0.0373; 
  12. color specularcolor=color(1, 1, 1); 
  13. color ambientcolor=color(0.5,0.5,0.5); 
  14.  
  15. float G1L1_freq=33.2; 
  16. float G1L1_rotation=46.3; 
  17. float G1L1_fuzz=0.453; 
  18. float G1L1_linewidth=0.579; 
  19. float G1L1_Randomness=0;
  20. color G1L1_SurfaceColor=color(1,1,1); 
  21. color G1L1_GridColor=color(0,0,0); 
  22.  
  23. float G1L2_freq=6.87; 
  24. float G1L2_rotation=42.4; 
  25. float G1L2_fuzz=0.363; 
  26. float G1L2_linewidth=0.209; 
  27. float G1L2_Randomness=0;
  28. color G1L2_SurfaceColor=color(1,1,1); 
  29. color G1L2_GridColor=color(0,0,0); 
  30.  
  31. float G2L1_freq=10.4; 
  32. float G2L1_rotation=0.162; 
  33. float G2L1_fuzz=0.0655; 
  34. float G2L1_linewidth=0.281; 
  35. float G2L1_Randomness=0;
  36. color G2L1_SurfaceColor=color(1,1,1); 
  37. color G2L1_GridColor=color(0,0,0); 
  38.  
  39. float G2L2_freq=16.7; 
  40. float G2L2_rotation=44.2; 
  41. float G2L2_fuzz=0.306; 
  42. float G2L2_linewidth=0.149; 
  43. float G2L2_Randomness=0;
  44. color G2L2_SurfaceColor=color(1,1,1); 
  45. color G2L2_GridColor=color(0,0,0); 
  46. {
  47. /** Surface main-code start **/
  48.  
  49. float G1L1_ss, G1L1_tt;
  50. float G1L2_ss, G1L2_tt;
  51. float G2L1_ss, G2L1_tt;
  52. float G2L2_ss, G2L2_tt;
  53. float blend_val=0.5; 
  54.  
  55. /** Grid 1 Color **/
  56. /** line set 1 **/
  57. rotate2d(s, t, radians(G1L1_rotation), 0.5, 0.5, G1L1_ss, G1L1_tt);
  58. G1L1_ss = repeat(G1L1_ss, G1L1_freq);
  59. G1L1_tt = repeat(G1L1_tt, G1L1_freq);
  60.  
  61. color G1L1_layer_opac = pulse(G1L1_linewidth, 1-G1L1_linewidth, G1L1_fuzz, G1L1_tt);
  62. color G1L1_Ct = blend(G1L1_SurfaceColor, G1L1_GridColor, G1L1_layer_opac);
  63.  
  64. /** line set 2 **/
  65. rotate2d(s, t, radians(G1L2_rotation), 0.5, 0.5, G1L2_ss, G1L2_tt);
  66. G1L2_ss = repeat(G1L2_ss, G1L2_freq);
  67. G1L2_tt = repeat(G1L2_tt, G1L2_freq);
  68.  
  69. color G1L2_layer_opac = pulse(G1L2_linewidth, 1-G1L2_linewidth, G1L2_fuzz, G1L2_tt);
  70. color G1L2_Ct = blend(G1L2_SurfaceColor, G1L2_GridColor, G1L2_layer_opac);
  71. normal G1_Nf = faceforward(normalize(N), I);
  72. vector G1_V = -normalize(I);
  73.  
  74. /** Grid 2 Opacity **/
  75. /** line set 3 **/
  76. rotate2d(s, t, radians(G2L1_rotation), 0.5, 0.5, G2L1_ss, G2L1_tt);
  77. G2L1_ss = repeat(G2L1_ss, G2L1_freq);
  78. G2L1_tt = repeat(G2L1_tt, G2L1_freq);
  79.  
  80. color G2L1_layer_opac = pulse(G2L1_linewidth, 1-G2L1_linewidth, G2L1_fuzz, G2L1_tt);
  81. color G2L1_Ct = blend(G2L1_SurfaceColor, G2L1_GridColor, G2L1_layer_opac);
  82.  
  83. /** line set 4 **/
  84. rotate2d(s, t, radians(G2L2_rotation), 0.5, 0.5, G2L2_ss, G2L2_tt);
  85. G2L2_ss = repeat(G2L2_ss, G2L2_freq);
  86. G2L2_tt = repeat(G2L2_tt, G2L2_freq);
  87.  
  88. color G2L2_layer_opac = pulse(G2L2_linewidth, 1-G2L2_linewidth, G2L2_fuzz, G2L2_tt);
  89. color G2L2_Ct = blend(G2L2_SurfaceColor, G2L2_GridColor, G2L2_layer_opac);
  90.  
  91. /** Surface main-code end **/
  92.  
  93. Ci = (blend_val*G1L1_Ct+(1-blend_val)*G1L2_Ct) * (ambientcolor * K_ambient * ambient() + K_diffuse * diffuse(G1_Nf)) + 
  94. specularcolor * K_specular * phong(G1_Nf, G1_V, 1/roughness);
  95. Oi = (blend_val*G2L1_Ct+(1-blend_val)*G2L2_Ct);
  96. }
  97.