Cycles / OSL: Add a conductive fresnel shader template.

This adds a fresnel conductive OSL preset to the Text Editor. Based on a patch by Lukas Stockner.
Differential revision: https://developer.blender.org/D145

See the differential for details.
This commit is contained in:
Thomas Dinges
2014-09-07 18:28:59 +02:00
parent 2633d0fac5
commit aa8d25bf09
3 changed files with 60 additions and 7 deletions

View File

@@ -34,3 +34,16 @@ float fresnel_dielectric_cos(float cosi, float eta)
return result;
}
color fresnel_conductor(float cosi, color eta, color k)
{
color cosi2 = color(cosi*cosi);
color one = color(1, 1, 1);
color tmp_f = eta * eta + k * k;
color tmp = tmp_f * cosi2;
color Rparl2 = (tmp - (2.0 * eta * cosi) + one) /
(tmp + (2.0 * eta * cosi) + one);
color Rperp2 = (tmp_f - (2.0 * eta * cosi) + cosi2) /
(tmp_f + (2.0 * eta * cosi) + cosi2);
return (Rparl2 + Rperp2) * 0.5;
}