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_urbermap.sl < prev    next >
Encoding:
Text File  |  2008-01-23  |  3.8 KB  |  204 lines

  1.  
  2.  
  3. surface k3d_urbermap (
  4.  
  5. string abColorMap=""; 
  6. float abColorMapBlur=1; 
  7. float abUseColorMapAlpha=0; 
  8. float abDiffuse=0.8; 
  9. string abDiffuseMap=""; 
  10. float abDiffuseMapBlur=1; 
  11. float abSpecular=0.3; 
  12. string abSpecularMap=""; 
  13. float abSpecularMapBlur=1; 
  14. color abSpecularColor=color(1.00,1.00,1.00); 
  15. string abSpecularColorMap=""; 
  16. float abSpecularColorMapBlur=1; 
  17. float abRoughness=0.3; 
  18. string abRoughnessMap=""; 
  19. float abRoughnessMapBlur=1; 
  20. string abTransparencyMap=""; 
  21. float abInvertTransparencyMap=0; 
  22. float abTransparencyMapBlur=1; 
  23. color abIncandescence=color(0.00,0.00,0.00); 
  24. string abIncandescenseMap=""; 
  25. float abIncandescenseMapBlur=1; 
  26. string abReflectionMap=""; 
  27. float abReflectionUp=0; 
  28. float abReflectivity=0.1; 
  29. float abReflectionMapBlur=1; 
  30. string abBumpMap=""; 
  31. float abBumpMapBlur=1; 
  32. float abBumpScale=1; 
  33. float abDoDisplacement=0; 
  34. float abUseNormals=0; 
  35. point STMatrix0=point(1,0,0); 
  36. point STMatrix1=point(0,1,0); ) 
  37. {
  38. /** Surface main-code start **/
  39.  
  40. normal Nf;
  41. vector V, D;
  42. point PP;
  43. color Csurf, Cspec, Copac, Cincand, Crefl;
  44. float ss, tt, roughness, diff, spec, bmp;
  45.  
  46.  
  47. ss = vector(s, t, 1) . vector(transform("shader", STMatrix0));
  48. tt = vector(s, t, 1) . vector(transform("shader", STMatrix1));
  49.  
  50.  
  51. if(abColorMap != "")
  52. {
  53. Csurf = Cs * color texture(abColorMap, ss, tt,
  54. "swidth", abColorMapBlur,
  55. "twidth", abColorMapBlur );
  56. if(abUseColorMapAlpha != 0)
  57. {
  58. Copac = float texture(abColorMap[3], ss, tt,
  59. "swidth", abColorMapBlur,
  60. "twidth", abColorMapBlur );
  61.  
  62. Csurf = Csurf / Copac;
  63. }
  64. else
  65. {
  66. Copac = color(1, 1, 1);
  67. }
  68. }
  69. else
  70. {
  71. Csurf = Cs;
  72. Copac = color(1);
  73. }
  74.  
  75.  
  76. if(abDiffuseMap != "")
  77. {
  78. diff = abDiffuse * float texture(abDiffuseMap, ss, tt,
  79. "swidth", abDiffuseMapBlur,
  80. "twidth", abDiffuseMapBlur );
  81. }
  82. else
  83. {
  84. diff = abDiffuse;
  85. }
  86.  
  87.  
  88. if(abSpecularMap != "")
  89. {
  90. spec = abSpecular * float texture(abSpecularMap, ss, tt,
  91. "swidth", abSpecularMapBlur,
  92. "twidth", abSpecularMapBlur );
  93. }
  94. else
  95. {
  96. spec = abSpecular;
  97. }
  98.  
  99.  
  100. if(abSpecularColorMap != "")
  101. {
  102. Cspec = abSpecularColor * color texture(abSpecularColorMap, ss, tt,
  103. "swidth", abSpecularColorMapBlur,
  104. "twidth", abSpecularColorMapBlur );
  105. }
  106. else
  107. {
  108. Cspec = abSpecularColor;
  109. }
  110.  
  111.  
  112. if(abRoughnessMap != "")
  113. {
  114. roughness = abRoughness * float texture(abRoughnessMap, ss, tt,
  115. "swidth", abRoughnessMapBlur,
  116. "twidth", abRoughnessMapBlur );
  117. }
  118. else
  119. {
  120. roughness = abRoughness;
  121. }
  122.  
  123.  
  124. if(abTransparencyMap != "")
  125. {
  126. if(abInvertTransparencyMap != 0)
  127. {
  128. Copac = Copac * color texture(abTransparencyMap, ss, tt,
  129. "swidth", abTransparencyMapBlur,
  130. "twidth", abTransparencyMapBlur );
  131. }
  132. else
  133. {
  134. Copac = Copac * (color(1) - color texture(abTransparencyMap, ss, tt,
  135. "swidth", abTransparencyMapBlur,
  136. "twidth", abTransparencyMapBlur ));
  137. }
  138. }
  139.  
  140.  
  141. if(abIncandescenseMap != "")
  142. {
  143. Cincand = abIncandescence * color texture(abIncandescenseMap, ss, tt,
  144. "swidth", abIncandescenseMapBlur,
  145. "twidth", abIncandescenseMapBlur );
  146. }
  147. else
  148. {
  149. Cincand = abIncandescence;
  150. }
  151.  
  152.  
  153.  
  154. if( abBumpMap != "" )
  155. {
  156. bmp = abBumpScale * float texture( abBumpMap, ss, tt,
  157. "swidth", abBumpMapBlur,
  158. "twidth", abBumpMapBlur );
  159. PP = transform("shader", P);
  160. Nf = normalize( ntransform("shader", N) );
  161. PP += bmp * Nf;
  162. PP = transform("shader", "current", PP);
  163. Nf = calculatenormal(PP);
  164.  
  165. if (abUseNormals == 1) {
  166. normal deltaN = normalize(N) - normalize(Ng);
  167. Nf = normalize(Nf) + deltaN;
  168. }
  169.  
  170. if( abDoDisplacement == 1.0 )
  171. P = PP;
  172. }
  173. else
  174. {
  175. Nf = N;
  176. }
  177.  
  178.  
  179. Nf = faceforward( normalize(Nf), I );
  180. V = -normalize(I);
  181.  
  182.  
  183. if( abReflectionMap != "" )
  184. {
  185. D = reflect(-V, Nf);
  186. D = vtransform("worldspace", D);
  187. if( abReflectionUp != 0 )
  188. {
  189. D = vector(-zcomp(D), xcomp(D), ycomp(D));
  190. }
  191. Crefl = abReflectivity *
  192. color environment(abReflectionMap, D,
  193. "swidth", abReflectionMapBlur,
  194. "twidth", abReflectionMapBlur );
  195. }
  196. else
  197. Crefl = color(0);
  198.  
  199. /** Surface main-code end **/
  200.  
  201. Ci = Csurf * (Cincand + ambient() + diff * diffuse(Nf)) + (spec * Cspec * (specular(Nf, V, roughness) + Crefl));
  202.  
  203. }
  204.