fresnel_conductive.osl 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. /*
  2. * Copyright 2011-2014 Blender Foundation
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License
  15. */
  16. color fresnel_conductor(float cosi, color eta, color k)
  17. {
  18. color cosi2 = color(cosi * cosi);
  19. color one = color(1, 1, 1);
  20. color tmp_f = eta * eta + k * k;
  21. color tmp = tmp_f * cosi2;
  22. color Rparl2 = (tmp - (2.0 * eta * cosi) + one) /
  23. (tmp + (2.0 * eta * cosi) + one);
  24. color Rperp2 = (tmp_f - (2.0 * eta * cosi) + cosi2) /
  25. (tmp_f + (2.0 * eta * cosi) + cosi2);
  26. return (Rparl2 + Rperp2) * 0.5;
  27. }
  28. shader node_fresnel_conductive(
  29. color n = color(0.084136, 0.410708, 1.472421),
  30. color k = color(4.018579, 2.363371, 1.607574),
  31. normal Normal = N,
  32. output color Color = color(0.8, 0.8, 0.8))
  33. {
  34. float cosi = dot(I, Normal);
  35. Color = fresnel_conductor(cosi, n, k);
  36. }