mp_plastic.sl 744 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. /****************************
  2. Plastic Surface Shader
  3. (c) Mad Processor, 2009
  4. Features Color texture mapping
  5. and Opacity texture mapping
  6. *****************************/
  7. surface
  8. mp_plastic(
  9. float Ks = .5;
  10. float Kd = .5;
  11. float Ka = 1;
  12. float roughness = .1;
  13. color specularcolor = 1;
  14. string texturename = "";
  15. string alphamap = "";)
  16. {
  17. normal Nf;
  18. vector V;
  19. color Ct;
  20. float a;
  21. Nf = faceforward(normalize(N), I);
  22. V = normalize(-I);
  23. Ct = ( texturename != "" ) ?
  24. texture( texturename, "filter", "gaussian" ) : 1.0;
  25. a = ( alphamap != "" ) ?
  26. texture( alphamap[3], "filter", "gaussian" ) : 1.0;
  27. Oi = Os*a;
  28. Ci = (Cs * Ct * (Ka * ambient() + Kd * diffuse(Nf)) +
  29. specularcolor * Ks * specular(Nf, V, roughness));
  30. Ci *= Oi;
  31. }